Cimple: Instruction and Memory Level Parallelism
arxiv.org
arxiv.org
I created a huge array of 32 bit ints - a few gigabytes in size. Then timed this code:
uint32_t checksum = 0;
for (int i = 0; i < 1000000; i++) {
unsigned offset = rand32() & (TABLE_SIZE - 1);
checksum += table_ints[offset];
}
I was surprised to see it only took about 10 ns per iteration, which is 5 to 10 times faster than a DRAM access. Because the table was large and the access pattern was random, each iteration has to do a DRAM access (there is low probability of getting a cache hit).The processor was able to execute 5 to 10 iterations of that loop in parallel in a single thread. Quite amazing.
The random number generator looked like this:
uint32_t g_seed = 12345;
uint32_t rand32() {
g_seed = 214013 * g_seed + 2531011;
return g_seed;
}I spent months also learning a few things about how the virtual memory page table, memory controller and DRAM subsystem work. I suspect this will be useful to other people and it would be nice to have a forum where this research could be discussed.
Not sure it would make sense to look for publication in a non-academic technical platform (somewhere like drDobbs.com) but I suppose it's an option.
uint32_t checksum = 0; uint32_t prevRes = 0; for (int i = 0; i < 1000000; i++) { unsigned offset = (rand32() ^ prevRes )& (TABLE_SIZE - 1); prevRes = table_ints[offset]; checksum += prevRes ; }
I'd very much enjoy reading a blog post about your findings, if you are interested in writing one. Thanks for sharing, modern CPUs really are quite incredible.
For anyone curious, I'm not affiliated with the authors of the paper. It's scheduled to appear at PACT'19. AFAIK the code is not publicly available yet.
The conclusion includes "We offer an optimization methodology for experts, and a tool usable by end-users today." but doesn't provide any pointers on where to find them.
The study cites a govt. grant but I couldn't find much using the grant number either.