stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

commit e0092c4cd828b776869c4f3d9ffe4373e7afda22
parent 42b9a159c2519f8b9bbea1ed47fef0f0afeaced7
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 25 Feb 2022 10:32:37 +0100

Add the rng_type as an input argument of the solve functions

It defines the type of the RNG to use if no initial RNG state is
defined.

Diffstat:
Msrc/sdis.c | 3++-
Msrc/sdis.h | 36+++++++++++++++++++++++++++---------
Msrc/sdis_c.h | 4+++-
Msrc/sdis_solve_boundary_Xd.h | 14++++++++++++--
Msrc/sdis_solve_camera.c | 7++++++-
Msrc/sdis_solve_medium_Xd.h | 14++++++++++++--
Msrc/sdis_solve_probe_Xd.h | 7++++++-
Msrc/sdis_solve_probe_boundary_Xd.h | 14++++++++++++--
8 files changed, 80 insertions(+), 19 deletions(-)

diff --git a/src/sdis.c b/src/sdis.c @@ -293,6 +293,7 @@ res_T create_per_thread_rng (struct sdis_device* dev, struct ssp_rng* rng_state, + const enum ssp_rng_type rng_type, struct ssp_rng_proxy** out_proxy, struct ssp_rng** out_rngs[]) { @@ -312,7 +313,7 @@ create_per_thread_rng /* Create the RNG proxy */ proxy_args.rng= rng_state; - proxy_args.type = SSP_RNG_MT19937_64; + proxy_args.type = rng_type; proxy_args.nbuckets = dev->nthreads; #ifdef SDIS_ENABLE_MPI if(dev->use_mpi) { diff --git a/src/sdis.h b/src/sdis.h @@ -16,6 +16,8 @@ #ifndef SDIS_H #define SDIS_H +#include <star/ssp.h> + #include <rsys/rsys.h> #include <float.h> @@ -50,7 +52,6 @@ struct logger; struct mem_allocator; struct senc2d_scene; struct senc3d_scene; -struct ssp_rng; /* Forward declaration of the Stardis opaque data types. These data types are * ref counted. Once created the caller implicitly owns the created data, i.e. @@ -442,6 +443,7 @@ struct sdis_solve_probe_args { int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ + enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ }; #define SDIS_SOLVE_PROBE_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -449,7 +451,8 @@ struct sdis_solve_probe_args { {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* Picard order */ \ SDIS_HEAT_PATH_NONE, /* Register paths mask */ \ - NULL /* RNG state */ \ + NULL, /* RNG state */ \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_solve_probe_args SDIS_SOLVE_PROBE_ARGS_DEFAULT = SDIS_SOLVE_PROBE_ARGS_DEFAULT__; @@ -469,6 +472,7 @@ struct sdis_solve_probe_boundary_args { enum sdis_side side; /* Side of iprim on which the probe lies */ int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ + enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ }; #define SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -478,7 +482,8 @@ struct sdis_solve_probe_boundary_args { 1, /* Picard order */ \ SDIS_SIDE_NULL__, \ SDIS_HEAT_PATH_NONE, \ - NULL /* RNG state */ \ + NULL, /* RNG state */ \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_solve_probe_boundary_args SDIS_SOLVE_PROBE_BOUNDARY_ARGS_DEFAULT = @@ -498,6 +503,7 @@ struct sdis_solve_boundary_args { int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ + enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ }; #define SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -507,7 +513,8 @@ struct sdis_solve_boundary_args { {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* Picard order */ \ SDIS_HEAT_PATH_NONE, \ - NULL /* RNG state */ \ + NULL, /* RNG state */ \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_solve_boundary_args SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT = SDIS_SOLVE_BOUNDARY_ARGS_DEFAULT__; @@ -524,6 +531,7 @@ struct sdis_solve_medium_args { int register_paths; /* Combination of enum sdis_heat_path_flag */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ + enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ }; #define SDIS_SOLVE_MEDIUM_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -531,7 +539,8 @@ struct sdis_solve_medium_args { {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* Picard order */ \ SDIS_HEAT_PATH_NONE, \ - NULL /* RNG state */ \ + NULL, /* RNG state */ \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_solve_medium_args SDIS_SOLVE_MEDIUM_ARGS_DEFAULT = SDIS_SOLVE_MEDIUM_ARGS_DEFAULT__; @@ -548,6 +557,7 @@ struct sdis_solve_probe_boundary_flux_args { size_t picard_order; struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ + enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ }; #define SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -555,7 +565,8 @@ struct sdis_solve_probe_boundary_flux_args { {0,0}, /* UV */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* Picard order */ \ - NULL /* RNG state */ \ + NULL, /* RNG state */ \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_solve_probe_boundary_flux_args SDIS_SOLVE_PROBE_BOUNDARY_FLUX_ARGS_DEFAULT = @@ -573,6 +584,7 @@ struct sdis_solve_boundary_flux_args { size_t picard_order; struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ + enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ }; #define SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ @@ -580,7 +592,8 @@ struct sdis_solve_boundary_flux_args { 0, /* #primitives */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ 1, /* Picard order */ \ - NULL /* RNG state */ \ + NULL, /* RNG state */ \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_solve_boundary_flux_args SDIS_SOLVE_BOUNDARY_FLUX_ARGS_DEFAULT = @@ -598,6 +611,8 @@ struct sdis_solve_camera_args { size_t image_definition[2]; /* Image definition */ size_t spp; /* #samples per pixel */ int register_paths; /* Combination of enum sdis_heat_path_flag */ + + enum ssp_rng_type rng_type; /* RNG type to use */ }; #define SDIS_SOLVE_CAMERA_ARGS_DEFAULT__ { \ NULL, /* Camera */ \ @@ -605,7 +620,8 @@ struct sdis_solve_camera_args { 1, /* Picard order */ \ {512,512}, /* Image resolution */ \ 256, /* #realisations per pixel */ \ - SDIS_HEAT_PATH_NONE \ + SDIS_HEAT_PATH_NONE, \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_solve_camera_args SDIS_SOLVE_CAMERA_ARGS_DEFAULT = SDIS_SOLVE_CAMERA_ARGS_DEFAULT__; @@ -615,12 +631,14 @@ struct sdis_compute_power_args { struct sdis_medium* medium; /* Medium to solve */ double time_range[2]; /* Observation time */ struct ssp_rng* rng_state; /* Initial RNG state. May be NULL */ + enum ssp_rng_type rng_type; /* RNG type to use if `rng_state' is NULL */ }; #define SDIS_COMPUTE_POWER_ARGS_DEFAULT__ { \ 10000, /* #realisations */ \ NULL, /* Medium */ \ {DBL_MAX,DBL_MAX}, /* Time range */ \ - NULL /* RNG state */ \ + NULL, /* RNG state */ \ + SSP_RNG_THREEFRY /* RNG type */ \ } static const struct sdis_compute_power_args SDIS_COMPUTE_POWER_ARGS_DEFAULT = SDIS_COMPUTE_POWER_ARGS_DEFAULT__; diff --git a/src/sdis_c.h b/src/sdis_c.h @@ -16,6 +16,7 @@ #ifndef SDIS_C_H #define SDIS_C_H +#include <star/ssp.h> #include <rsys/rsys.h> /* Id of the messages sent between processes */ @@ -47,7 +48,8 @@ struct ssp_rng_proxy; extern LOCAL_SYM res_T create_per_thread_rng (struct sdis_device* dev, - struct ssp_rng* rng_state, + struct ssp_rng* rng_state, /* May be NULL */ + const enum ssp_rng_type rng_type, /* RNG type when `rng_state' is NULL */ struct ssp_rng_proxy** rng_proxy, struct ssp_rng** rngs[]); diff --git a/src/sdis_solve_boundary_Xd.h b/src/sdis_solve_boundary_Xd.h @@ -73,6 +73,11 @@ check_solve_boundary_args(const struct sdis_solve_boundary_args* args) return RES_BAD_ARG; } + /* Check RNG type */ + if(!args->rng_state && args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -105,6 +110,11 @@ check_solve_boundary_flux_args(const struct sdis_solve_boundary_flux_args* args) return RES_BAD_ARG; } + /* Check RNG type */ + if(!args->rng_state && args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -267,7 +277,7 @@ XD(solve_boundary) /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, args->rng_state, &rng_proxy, &per_thread_rng); + (scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */ @@ -634,7 +644,7 @@ XD(solve_boundary_flux) /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, args->rng_state, &rng_proxy, &per_thread_rng); + (scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */ diff --git a/src/sdis_solve_camera.c b/src/sdis_solve_camera.c @@ -67,6 +67,11 @@ check_solve_camera_args(const struct sdis_solve_camera_args* args) return RES_BAD_ARG; } + /* Check RNG type */ + if(args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -529,7 +534,7 @@ sdis_solve_camera /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, NULL, &rng_proxy, &per_thread_rng); + (scn->dev, NULL, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */ diff --git a/src/sdis_solve_medium_Xd.h b/src/sdis_solve_medium_Xd.h @@ -167,6 +167,11 @@ check_solve_medium_args(const struct sdis_solve_medium_args* args) return RES_BAD_ARG; } + /* Check the RNG type */ + if(!args->rng_state && args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -192,6 +197,11 @@ check_compute_power_args(const struct sdis_compute_power_args* args) return RES_BAD_ARG; } + /* Check the RNG type */ + if(!args->rng_state && args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -319,7 +329,7 @@ XD(solve_medium) /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, args->rng_state, &rng_proxy, &per_thread_rng); + (scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */ @@ -612,7 +622,7 @@ XD(compute_power) /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, args->rng_state, &rng_proxy, &per_thread_rng); + (scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */ diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h @@ -58,6 +58,11 @@ check_solve_probe_args(const struct sdis_solve_probe_args* args) return RES_BAD_ARG; } + /* Check the RNG type */ + if(!args->rng_state && args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -127,7 +132,7 @@ XD(solve_probe) /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, args->rng_state, &rng_proxy, &per_thread_rng); + (scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */ diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h @@ -66,6 +66,11 @@ check_solve_probe_boundary_args return RES_BAD_ARG; } + /* Check the RNG type */ + if(!args->rng_state && args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -94,6 +99,11 @@ check_solve_probe_boundary_flux_args return RES_BAD_ARG; } + /* Check the RNG type */ + if(!args->rng_state && args->rng_type >= SSP_RNG_TYPES_COUNT__) { + return RES_BAD_ARG; + } + return RES_OK; } @@ -166,7 +176,7 @@ XD(solve_probe_boundary) /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, args->rng_state, &rng_proxy, &per_thread_rng); + (scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */ @@ -473,7 +483,7 @@ XD(solve_probe_boundary_flux) /* Create the per thread RNGs */ res = create_per_thread_rng - (scn->dev, args->rng_state, &rng_proxy, &per_thread_rng); + (scn->dev, args->rng_state, args->rng_type, &rng_proxy, &per_thread_rng); if(res != RES_OK) goto error; /* Allocate the per process progress status */