by chacham15 · 1w ago · 0 comments
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.
No comments yet.