Skip to content
Snippets Groups Projects
Commit 4f16e375 authored by Andreas Gattringer's avatar Andreas Gattringer
Browse files

threading: add temporary variables and more random number generators

parent 7a31d237
No related branches found
No related tags found
No related merge requests found
......@@ -50,10 +50,21 @@ initialize_thread(struct cats_thread_info *thread, struct cats_grid *grid, struc
zero_statistics_stats(&thread->stats[i]);
}
thread->temp = 0;
thread->temp1 = 0;
thread->temp2 = 0;
thread->seed = get_random_seed(false);
for (int i = 0; i < 4; i++) {
thread->seed4[i] = get_random_seed64(false);
}
thread->id = id;
thread->grid = grid;
thread->conf = conf;
thread->rng_buf_size = 32;
thread->rng_state_buffer = calloc_or_die(1, thread->rng_buf_size);
thread->rng_state = calloc_or_die(1, sizeof(struct random_data));
initstate_r(get_random_seed(false), thread->rng_state_buffer, thread->rng_buf_size, thread->rng_state);
}
......@@ -65,8 +76,12 @@ int32_t get_dispersal_radius(const struct cats_configuration *conf, int32_t id)
void cleanup_threads(struct cats_thread_info *threads, int32_t num_threads)
{
for (int32_t i = 0; i < num_threads; i++) {
gsl_rng_free(threads[i].rng);
free(threads[i].rng_state);
free(threads[i].rng_state_buffer);
}
for (int32_t i = 0; i < num_threads; i++) {
......@@ -75,6 +90,8 @@ void cleanup_threads(struct cats_thread_info *threads, int32_t num_threads)
}
}
free(threads);
}
......
......@@ -94,6 +94,8 @@ setup_threads(struct cats_configuration *conf, struct cats_grid *grid, int32_t m
}
switch (t->strategy) {
case TS_UNKNOWN:
log_message(LOG_ERROR, "undefined threading strategy");
......
......@@ -53,6 +53,11 @@ struct cats_thread_info {
int64_t temp;
int64_t temp1;
int64_t temp2;
char *rng_state_buffer;
int32_t rng_buf_size;
struct random_data *rng_state;
unsigned int seed;
uint64_t seed4[4];
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment