star-schiff

Library for estimating radiative properties
git clone git://git.meso-star.com/star-schiff.git
Log | Files | Refs | README | LICENSE

commit ad1c938d1ea34cc38d2c30fae15519642f1de6cd
parent 5f8741118ad1e023829dd03defdfa571a6f051fe
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 19 May 2016 10:02:38 +0200

Implement and test the sschiff_device_get_threads_count function

Diffstat:
Msrc/sschiff.h | 6++++++
Msrc/sschiff_device.c | 8++++++++
Msrc/sschiff_estimator.c | 2+-
Msrc/test_sschiff_device.c | 9+++++++++
4 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/sschiff.h b/src/sschiff.h @@ -123,6 +123,12 @@ sschiff_device_create struct s3d_device* s3d, /* May be NULL <=> internally create a S3D device */ struct sschiff_device** dev); +/* Return the number of threads effectively used by the Star-Schiff device */ +SSCHIFF_API res_T +sschiff_device_get_threads_count + (struct sschiff_device* dev, + unsigned* nthreads); + SSCHIFF_API res_T sschiff_device_ref_get (struct sschiff_device* dev); diff --git a/src/sschiff_device.c b/src/sschiff_device.c @@ -155,6 +155,14 @@ error: } res_T +sschiff_device_get_threads_count(struct sschiff_device* dev, unsigned* nthreads) +{ + if(!dev || !nthreads) return RES_BAD_ARG; + *nthreads = dev->nthreads; + return RES_OK; +} + +res_T sschiff_device_ref_get(struct sschiff_device* dev) { if(!dev) return RES_BAD_ARG; diff --git a/src/sschiff_estimator.c b/src/sschiff_estimator.c @@ -368,7 +368,7 @@ accum_differential_cross_section /* Compute and accumulate the MC weights of the differential cross section * and its cumulative. Note that ctx->limit_angles store the index of the - * first scattering angle whos phase function is not estimated by + * first scattering angle whose phase function is not estimated by * Monte-Carlo */ FOR_EACH(iangle, 0, ctx->estimator->limit_angles[iwlen]) { double bessel_j0, bessel_j1; diff --git a/src/test_sschiff_device.c b/src/test_sschiff_device.c @@ -38,6 +38,8 @@ main(int argc, char** argv) struct mem_allocator allocator; struct sschiff_device* dev; struct s3d_device* s3d; + unsigned nthreads; + (void)argc, (void)argv; CHECK(sschiff_device_create(NULL, NULL, N, 0, NULL, NULL), RES_BAD_ARG); @@ -79,6 +81,13 @@ main(int argc, char** argv) CHECK(sschiff_device_create(NULL, NULL, 0, 0, NULL, &dev), RES_BAD_ARG); CHECK(sschiff_device_create(NULL, NULL, 1, 0, NULL, &dev), RES_OK); + + CHECK(sschiff_device_get_threads_count(NULL, NULL), RES_BAD_ARG); + CHECK(sschiff_device_get_threads_count(dev, NULL), RES_BAD_ARG); + CHECK(sschiff_device_get_threads_count(NULL, &nthreads), RES_BAD_ARG); + CHECK(sschiff_device_get_threads_count(dev, &nthreads), RES_OK); + CHECK(nthreads, 1); + CHECK(sschiff_device_ref_put(dev), RES_OK); logger_release(&logger);