commit bbe0116381f797bb29b92d3f2b1429583f4bcf0f
parent 2b5b496c25177b070c247e977d338bb0eea20704
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Fri, 12 Jan 2024 00:33:46 +0100
add code comment about cache sharing
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/squiggle_more.c b/squiggle_more.c
@@ -14,7 +14,10 @@ typedef struct seed_cache_box_t {
uint64_t* seed;
char padding[CACHE_LINE_SIZE - sizeof(uint64_t*)];
} seed_cache_box;
-// This avoid false sharing. Dealing with this shaves ~2ms.
+// This avoids "false sharing", i.e., different threads competing for the same cache line
+// It's possible dealing with this shaves ~2ms
+// However, it's possible it doesn't, since pointers aren't changed, just their contents (and the location of their contents doesn't necessarily have to be close, since they are malloc'ed sepately)
+// Still, I thought it was interesting
void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_threads, int n_samples)
{