2 ms·
My thought about hand rolling is that any loop is hand-rolled if I tell the compiler how to do things (ie not declarative). Writing out a for loop with an s+=*p
by goalieca 8y ago
My thought about hand rolling is that any loop is hand-rolled if I tell the compiler how to do things (ie not declarative). Writing out a for loop with an s+=*p++ for summing the elements in a vector is hand rolling a “reduce”. You can add all the tricks you want like changing the stride, doing simd, prefetching, but I’ve learned to let the compiler or the math/data library do its job.
For small data (MB) the compiler or library can parallelize things nicely. Bigger data (TB+) can be chewed threw by using MPI aware libraries that optimize and schedule and everything. Database work is already declarative because SQL is just so awesome. C# and java now handle fusion and streams more nicely and c++ can in-line and r-value a lot of overhead away.
- deleted 8y ago[deleted]
- jstimpfle 8y agoYeah you need to be careful what kind of iteration you do. Modifying pointers is likely problematic. Iterating over a range of integers on the other hand should be easy to optimize. In most cases, it shouldn't matter and it's much more important to think about the data accesses, due to the relative slowness of memory.