schiff

Estimate the radiative properties of soft particless
git clone git://git.meso-star.com/schiff.git
Log | Files | Refs | README | LICENSE

commit b60802d96b0a5acb97622a128bfaab34b9e2eda9
parent bb602b656fff49e02245027368b967020be316f7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 25 Nov 2015 14:42:37 +0100

Use the new Star-Schiff API that handle multi-threading

Add the "-n NTHREADS" option that defines an hint on the number of
threads to use by the Schiff integration.

Diffstat:
Msrc/schiff.c | 2+-
Msrc/schiff_args.c | 10+++++++++-
Msrc/schiff_args.h | 3+++
3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/schiff.c b/src/schiff.c @@ -128,7 +128,7 @@ run_integration res_T res = RES_OK; ASSERT(args && sa_size(args->wavelengths) && rng && stream); - res = sschiff_device_create(NULL, NULL, 0, NULL, &sschiff); + res = sschiff_device_create(NULL, NULL, args->nthreads, 0, NULL, &sschiff); if(res != RES_OK) { fprintf(stderr, "Couldn't create the Star Schiff device.\n"); goto error; diff --git a/src/schiff_args.c b/src/schiff_args.c @@ -126,6 +126,9 @@ print_help(const char* binary) printf( " -h display this help and exit.\n"); printf( +" -n NTHREADS hint on the number of threads to use during the integration.\n" +" By default use as many threads as CPU cores.\n"); + printf( " -o OUTPUT write results to OUTPUT. If not defined, write results to\n" " standard output.\n"); printf( @@ -531,7 +534,7 @@ schiff_args_init ASSERT(argc && argv && args); *args = SCHIFF_ARGS_NULL; - while((opt = getopt(argc, argv, "c:C:d:g:G:ho:qs:u:w:")) != -1) { + while((opt = getopt(argc, argv, "c:C:d:g:G:hn:o:qs:u:w:")) != -1) { switch(opt) { case 'c': res = parse_cylinder_distribution(optarg, args); break; case 'C': res = parse_cylinder_as_sphere_distribution(optarg, args); break; @@ -542,6 +545,11 @@ schiff_args_init print_help(argv[0]); schiff_args_release(args); return RES_OK; + case 'n': + res = cstr_to_uint(optarg, &args->nthreads); + if(res == RES_OK && args->nthreads == 0) + res = RES_BAD_ARG; + break; case 'o': args->output_filename = optarg; break; case 'q': quiet = 1; break; case 's': res = parse_sphere_distribution(optarg, args); break; diff --git a/src/schiff_args.h b/src/schiff_args.h @@ -31,6 +31,7 @@ #include "schiff_geometry.h" #include <rsys/rsys.h> +#include <star/sschiff.h> struct schiff_args { const char* output_filename; @@ -40,6 +41,7 @@ struct schiff_args { unsigned ngeoms_dump; unsigned ngeoms; unsigned ndirs; + unsigned nthreads; }; static const struct schiff_args SCHIFF_ARGS_NULL = { @@ -50,6 +52,7 @@ static const struct schiff_args SCHIFF_ARGS_NULL = { 0, /* # Dumped geometries */ 1000, /* # Sampled geometries */ 100, /* # Sampled directions per gemetry */ + SSCHIFF_NTHREADS_DEFAULT }; extern LOCAL_SYM res_T