solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit b050d29f63075e5da901ecaad7ecca1c86d03f05
parent 93d500d31334a78f3f2a65e794adf4c386665075
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 12 Jul 2016 12:30:52 +0200

Handle the #threads hint on device creation

Diffstat:
Mcmake/CMakeLists.txt | 8+++++++-
Msrc/ssol_device.c | 6+++++-
Msrc/ssol_device_c.h | 2+-
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -27,6 +27,7 @@ find_package(RCMake 0.2.3 REQUIRED) find_package(RSys 0.3 REQUIRED) find_package(Star3D 0.4 REQUIRED) find_package(StarSP 0.4 REQUIRED) +find_package(OpenMP 1.2 REQUIRED) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) include(rcmake) @@ -93,9 +94,14 @@ endif() set_target_properties(solstice-solver PROPERTIES DEFINE_SYMBOL SSOL_SHARED_BUILD + COMPILE_FLAGS ${OpenMP_C_FLAGS} VERSION ${VERSION} SOVERSION ${VERSION_MAJOR}) +if(CMAKE_COMPILER_IS_GNUCC) + set_target_properties(solstice-solver PROPERTIES LINK_FLAGS ${OpenMP_C_FLAGS}) +endif() + rcmake_setup_devel(solstice-solver SolSolver ${VERSION} solstice/ssol_version.h) ################################################################################ @@ -122,7 +128,7 @@ if(NOT NO_TEST) build_test(${_name} ${ARGN}) register_test(${_name} ${_name}) endfunction() - + new_test(test_ssol_device) new_test(test_ssol_image) new_test(test_ssol_material) diff --git a/src/ssol_device.c b/src/ssol_device.c @@ -19,6 +19,8 @@ #include <rsys/logger.h> #include <rsys/mem_allocator.h> +#include <omp.h> + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -61,7 +63,9 @@ ssol_device_create dev->logger = logger ? logger : LOGGER_DEFAULT; dev->allocator = allocator; dev->verbose = verbose; - + dev->nthreads = MMIN(nthreads_hint, (unsigned)omp_get_num_procs()); + omp_set_num_threads((int)dev->nthreads); + res = s3d_device_create(logger, mem_allocator, verbose, &dev->s3d); if (res != RES_OK) goto error; diff --git a/src/ssol_device_c.h b/src/ssol_device_c.h @@ -22,7 +22,7 @@ struct ssol_device { struct logger* logger; struct mem_allocator* allocator; - const unsigned nthreads_hint; + unsigned nthreads; int verbose; struct s3d_device* s3d;