tweak: savepoint; test hypothesis over previous stuff.

This commit is contained in:
NunoSempere 2023-11-18 22:59:03 +00:00
parent 3d3a3f0045
commit 1bc7c90fcf

View File

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