time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

commit 1d5e0a6a7fc9c84ada20e9e9a15f97eac447da4e
parent 1bc7c90fcfe0d61ce5f0e84c7e8e1a9127f497b0
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sat, 18 Nov 2023 22:59:48 +0000

Revert "tweak: savepoint; test hypothesis over previous stuff."

This reverts commit 1bc7c90fcfe0d61ce5f0e84c7e8e1a9127f497b0.

Diffstat:
MC/alt/05-refactor-split-array/samples.c | 15++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/C/alt/05-refactor-split-array/samples.c b/C/alt/05-refactor-split-array/samples.c @@ -180,26 +180,19 @@ float mixture(float (*samplers[])(uint32_t*), float* weights, int n_dists, uint3 // Parallization function void paralellize(float (*sampler)(uint32_t* seed), float* results, int n_threads, int n_samples){ - if((N_SAMPLES % n_threads) != 0){ fprintf(stderr, "Number of samples isn't divisible by number of threads, aborting\n"); exit(1); } - int n_samples_per_thread = N_SAMPLES / n_threads; - - float** split_results = malloc(n_threads * sizeof(float*)); - for(int i=0; i<n_threads; i++){ - split_results[i] = malloc(n_samples_per_thread * sizeof(float)); - } - + // int n_samples_per_thread = N_SAMPLES / n_thread; + int sample_index, i, split_array_length; uint32_t** seeds = malloc(n_threads * sizeof(uint32_t*)); for (uint32_t i = 0; i < n_threads; i++) { seeds[i] = malloc(sizeof(uint32_t)); *seeds[i] = i + 1; // xorshift can't start with 0 } - - int i; - #pragma omp parallel private(i) + + #pragma omp parallelz private(i, sample_index, split_array_length) { #pragma omp for for (i = 0; i < n_threads; i++) {