Skip to content

Commit

Permalink
Ignore invalid OpenMP nthreads values (tardis-sn#537)
Browse files Browse the repository at this point in the history
If nthreads is not a positive integer omp_set_num_threads won't be
called. The result is that the default number of threads, or if set
OMP_NUM_THREADS is used.
This enables setting nthreads=0 for example to control the number of
threads through the environment (useful for use on clusters)
  • Loading branch information
yeganer authored and lukeshingles committed Apr 19, 2016
1 parent 3c0d3f5 commit bf143b6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tardis/montecarlo/src/cmontecarlo.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,10 @@ montecarlo_main_loop(storage_model_t * storage, int64_t virtual_packet_flag, int
#endif // WITH_VPACKET_LOGGING
#ifdef WITHOPENMP
omp_set_dynamic(0);
omp_set_num_threads(nthreads);
if (nthreads > 0)
{
omp_set_num_threads(nthreads);
}

#pragma omp parallel firstprivate(finished_packets)
{
Expand Down

0 comments on commit bf143b6

Please sign in to comment.