formatting pass.

This commit is contained in:
NunoSempere 2024-01-12 23:55:09 +01:00
parent dd6bb53f1b
commit eb1c592610

View File

@ -43,7 +43,7 @@ void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_
int divisor_multiple = quotient * n_threads;
// uint64_t** seeds = malloc((size_t)n_threads * sizeof(uint64_t*));
seed_cache_box* cache_box = (seed_cache_box*) malloc(sizeof(seed_cache_box) * (size_t)n_threads);
seed_cache_box* cache_box = (seed_cache_box*)malloc(sizeof(seed_cache_box) * (size_t)n_threads);
// seed_cache_box cache_box[n_threads]; // we could use the C stack. On normal linux machines, it's 8MB ($ ulimit -s). However, it doesn't quite feel right.
srand(1);
for (int i = 0; i < n_threads; i++) {
@ -72,9 +72,9 @@ void sampler_parallel(double (*sampler)(uint64_t* seed), double* results, int n_
// In principle, these results[j] could also result in two threads competing for the same cache line.
// In practice, though,
// a) this would happen infrequently
// b)
// b) trying to unroll loops actually makes the code slower
// c) 8 results[j] are 8 doubles, which fit a cache line. If n_samples/n_threads
}
}
}
for (int j = divisor_multiple; j < n_samples; j++) {
@ -124,7 +124,7 @@ static double quickselect(int k, double xs[], int n)
{
// https://en.wikipedia.org/wiki/Quickselect
double *ys = malloc((size_t)n * sizeof(double));
double* ys = malloc((size_t)n * sizeof(double));
memcpy(ys, xs, (size_t)n * sizeof(double));
// ^: don't rearrange item order in the original array