commit 323f0953ec36f4d849cbf3435ae83a0c9482e4fb
parent f585dfd7514f7f271b9390a7f915588ee44e09c7
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 12 Apr 2018 13:57:38 +0200
BugFix: thread count was not set at the correct time.
Need to reset it at the specified count everytime it is used.
Diffstat:
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/senc2d_device.c b/src/senc2d_device.c
@@ -88,7 +88,6 @@ senc2d_device_create
struct senc2d_device* dev = NULL;
struct mem_allocator* allocator = NULL;
res_T res = RES_OK;
- (void)nthreads_hint; /* Unused */
if(nthreads_hint == 0 || !out_dev) return RES_BAD_ARG;
log = logger ? logger : LOGGER_DEFAULT;
@@ -106,8 +105,8 @@ senc2d_device_create
dev->logger = log;
dev->allocator = allocator;
dev->verbose = verbose;
- dev->nthreads = MMIN(nthreads_hint, (unsigned)omp_get_num_procs());
- omp_set_num_threads((int)dev->nthreads);
+ /* Cannot use int args for MMIN here as default is -1 */
+ dev->nthreads = (int)MMIN(nthreads_hint, (unsigned)omp_get_num_procs());
ref_init(&dev->ref);
exit:
diff --git a/src/senc2d_device_c.h b/src/senc2d_device_c.h
@@ -27,7 +27,7 @@ struct senc2d_device {
struct logger* logger;
struct mem_allocator* allocator;
int verbose;
- unsigned nthreads;
+ int nthreads;
ref_T ref;
};
diff --git a/src/senc2d_scene_analyze.c b/src/senc2d_scene_analyze.c
@@ -1114,7 +1114,8 @@ senc2d_scene_analyze
OK(darray_neighbourhood_resize(&neighbourhood_by_vertex, scn->nuverts));
/* The end of the analyze is multithreaded */
- #pragma omp parallel
+ ASSERT(scn->dev->nthreads > 0);
+ #pragma omp parallel num_threads(scn->dev->nthreads)
{
/* Step 1: build neighbourhoods */
collect_and_link_neighbours(scn, segsides, &segments_tmp,