Tag Info

New answers tagged

3

It sounds like multi-armed bandit problem or some variation of it: In probability theory, the multi-armed bandit problem (sometimes called the K- or N-armed bandit problem) is a problem in which a gambler at a row of slot machines (sometimes known as "one-armed bandits") has to decide which machines to play, how many times to play each machine and in ...


3

Auto vectorization doesn't actually work quite the way you think it does. It does not turn your initial set of instructions into a loop: see, for example, the results of GCC compiling your code: http://goo.gl/2Tfd2o In general, auto-vectorization takes an unrolled loop, and transforms it so that the multiple statements you show in your example of an ...


3

I think you are missing the most important step. After the compiler turns your multiple statements into a loop, it then uses vector instructions such as SSE instructions to do multiple iterations of the loop in parallel. If your hardware doesn't have vector instructions, then there would be no point. So instead of unrolling the loop like you showed, it ...


5

Take a look at this neat implementation of sorting six integers. According to sorting networks, 16 comparisons are required to sort 7 integers. Here is the code for seven integers: static int sort7(int *d){ #define SWAP(x,y) if (d[y] < d[x]) { int tmp = d[x]; d[x] = d[y]; d[y] = tmp; } SWAP(1, 2); SWAP(3, 4); SWAP(5, 6); SWAP(0, 2); ...


1

Starting from Winston Ewart's answer, I figured out something that still uses only O(n) type instantiations, but also works when you have duplicate types in your parameter pack // we want to get a different size if the types match template <typename A, typename B> struct Same { char padding[3]; }; template <typename A> struct Same<A,A> { ...


1

My question is this: when it call comes down to machine code, to 1s and 0s, to assembly instructions, should I be at all concerned that my class-separated code with variety of small-to-tiny functions generates too much extra overhead? MY answer is yes, you should. Not because you have lots of little functions (once upon a time the overhead of ...


1

The basic trick here is from a blog post describing an implementation of std::tuple. We are limited in our options for variadic template arguments, but we can use them to define the base classes for a class. template<typename T, typename... Haystack> struct SearchImpl : std::is_same<T, Haystack>... { }; This class inherits from std::true_type ...


0

[computer-time element] Does Refactoring towards Looser Coupling and Smaller Functions affect Speed of Code? Yes, it does. But it is up to interpreters, compilers, and JIT-compilers to strip down this "seam/wiring" code, and some do it better than others, but some don't. Multiple-file concern adds to I/O overhead, so that affects speed quite a bit as ...


0

When the 8087 numerical coprocessor was designed, it was fairly common for languages to perform all floating-point math using the highest-precision type, and only round the result to lower precision when assigning it to a lower-precision variable. In the original C standard, for example, the sequence: float a = 16777216, b = 0.125, c = -16777216; float d = ...



Top 50 recent answers are included