Hacker News new | ask | show | jobs
by chacham15 14 days ago
I think you're thinking about this the wrong way. This isnt about surpassing theoretical parallelism limits. Its about gaining parallelism without having to be explicit about it. If you look at the solve function from the page, its doing a brute force search of the 5 queens problem. In the naieve implementation, this is done serially. But with the different approach to compiling the implementation, we can essentially "automatically parallelize" it. Thats the difference between the animation on the left and right. The thing is that in order to handle fine grained parallelism like this you need better/different hardware primitives so that you can split computation at a more fine grain, which is why they needed a new hardware model/isa. This is how they achieved the 4-5x speed up: by automatically parallizing a serially implemented function. If you were to compare a parallelized function to their parallelized function, I would expect to see a smaller speedup. Or at least as I understand it. Correct me if I'm wrong.
3 comments

I think parent comment does raise a lot of good points. It's very easy to introduce a long critical path in code, and it's not impossible that in certain cases, the critical path is impossible to reduce, or can be only reduced at the cost of a lot more computation.

But even when it's possible to reduce, you often need the compiler to do it for you. For example the simple C loop:

    for (int i = 0;i<LEN;i++){
      b += a[i];
    }
The naive implementation of this loop is serial - every iteration of i relies on the previous one. In this case, the compiler can trivially infer that this is not the case, and can produce the nth value of i without doing all the previous computation, and thus enable parallelism. But if we were to feed the 'naive' version into an inet cpu, we'd still get serial performance.

If a computation's dependencies are not so trivial to determine, this simple parallelization might be beyond the compiler's ability, or may be straight up impossible. The latter seems to be the case for more general software.

Tbh, I'm not criticizing inets, and as GP has pointed out, out-of-order computation already does dependency tracking, but that ends at the scope of a single logical CPU thread, and what comes beyond that is user-managed-threading, a very difficult and bug-prone approach.

So there needs to be a better primitive for hardware parallelism, I agree, but imo inets. are not the whole solution in of themselves.

While the intent behind what you're saying is correct: i.e. that data dependencies are ultimately what constrain parallelism and modern compilers try to handle that in various ways for the hardware, your example is actually a good case showing the opposite.

First, an inet is a general concept with various implementations, but a loop of addition is an inet chain of addition, but since addition is associative, this chain can be processed in any order. You can have up to LEN/2 threads doing an addition at the same time and still yield the correct result. This is a case where the naieve implementation is actually slower than the inet version because threading primitives (and threading overhead) dont outweigh the benefits of parallelism here in most cases. Furthermore, as I said earlier, modern compilers will unroll loops where it can reason about to to similarly reduce the data dependency graph to gain a similar benefit.

Also modern CPUs compute using dependency graphs between instructions. This model has some weaknesses; chiefly how it interacts with memory - which can lead to CPUs having to linearize their works and wait on memory.

Curiously, the nqueens algorithm as presented has no memory accesses, so we have no idea how this tackles that.

This should be the top comment on this article.