commit 1eccd33c71ede9d0af001fc46f8b0a59423d94d0
parent 14a18276c01a650893383457712cbb83189da3b6
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Fri, 12 Jan 2024 16:58:45 +0100
try adding quotient as private variable
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/squiggle_more.c b/squiggle_more.c
@@ -56,14 +56,16 @@ void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_
}
int i;
-#pragma omp parallel private(i)
+#pragma omp parallel private(i, quotient)
{
#pragma omp for
for (i = 0; i < n_threads; i++) {
+ int quotient = n_samples / n_threads;
int lower_bound_inclusive = i * quotient;
int upper_bound_not_inclusive = ((i + 1) * quotient); // note the < in the for loop below,
for (int j = lower_bound_inclusive; j < upper_bound_not_inclusive; j++) {
results[j] = sampler(&(cache_box[i].seed));
+ // Could also result in inefficient cache stuff, but hopefully not too often
}
}
}