4 ms·
A better solution, if you don't need to synchronize writes to said variable across cores, is just to let the compiler figure it out. Dumping the contents of the
by ceeplusplus 4y ago
A better solution, if you don't need to synchronize writes to said variable across cores, is just to let the compiler figure it out. Dumping the contents of the variable into a register is much faster than accessing L1. If you label the variable as const the compiler should be able to figure out that it's safe to concurrently read it into a register from multiple cores. Unless you are writing highly optimized assembly it's a good bet the compiler will do a better job than whatever you do.
- ncmncm 4y agoTrue, even L1 cache is slow nowadays -- you can retire a dozen instructions in the time it takes to get a word of L1 cache into a register, if you're clever and lucky.