How to write the same value to sequential locations in x86
I need to do the following code very efficiently with an x86 internal machine. Can anyone suggest a solution?
uint64_t array[8];
array[0] = SOME_VALUE;
array[1] = SOME_VALUE;
array[2] = SOME_VALUE;
array[3] = SOME_VALUE;
array[4] = SOME_VALUE;
array[5] = SOME_VALUE;
array[6] = SOME_VALUE;
array[7] = SOME_VALUE;
Since the same value is written to sequential locations, if the eigenvector / SSE can do this efficiently, I would like to try this.
+3
source to share
2 answers
Use memset
. glibc will take care of the optimization for you. If you think you can do better, you should submit the patch to the mailing list.
Also, "command speed" is hardly a bottleneck here. This is probably the memory bandwidth. Unfortunately, there is no magic bullet to reduce it other than "reading and writing less memory".
0
source to share