SST/macro
uq.h
Go to the documentation of this file.
1 #ifndef sstmac_libraries_uq_uq_h
2 #define sstmac_libraries_uq_uq_h
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 typedef enum {
17 
18 typedef enum {
22 
23 typedef struct
24 {
25  double value;
26  const char* units;
27  const char* cstr;
28  uq_param_type_t type;
29 } uq_param_t;
30 /**
31  Allocate a 2D double array
32  @param njobs
33  @param nresults
34 */
35 double** allocate_results(void* queue, int njobs, int nresults);
36 
37 /**
38  Allocate a 2D double array
39  @param njobs
40  @param nparams
41 */
42 double** allocate_values(void* queue, int njobs, int nparams);
43 
44 /**
45  Allocate a 2D array of param structs
46  @param njobs
47  @param nparams
48 */
49 uq_param_t** allocate_params(int njobs, int nparams);
50 
51 int sstmac_uq_int_param(void* queue, const char* param);
52 
53 int sstmac_uq_double_param(void* queue, const char* param);
54 
55 int sstmac_uq_sim_nproc(void* queue);
56 
57 int sstmac_uq_max_nproc(void* queue);
58 
59 /**
60  Free a 2D array allocated by allocate_results function
61  @param results
62 */
63 void free_results(double** results);
64 
65 /**
66  Free a 2D array allocated by allocate_values function
67  @param values
68 */
69 void free_values(double** values);
70 
71 /**
72  Free a 2D array allocated by allocate_params function
73  @param params
74 */
75 void free_params(uq_param_t** params);
76 
77 /**
78  @param argc The argc that would be used by a standalone SST/macro simulation
79  @param argv The argv that would be used by a standalone SST/macro simulation
80  @param workerID The ID of this worker in a parallel group. 0 return means master.
81  Workers who receiver other than zero should immediately go into
82  sstmac_uq_busy_loop and do nothing else.
83  @return A void* pointer to the simulation queue object. This pointer
84  should NOT be freed. Value is void* for C compatibility.
85 */
86 void* sstmac_uq_init(int argc, char** argv, int* workerID);
87 
88 void sstmac_uq_stop(void* queue);
89 
90 void sstmac_uq_busy_loop(void* queue);
91 
92 /**
93  Run a set of jobs with particular parameters, forking new procs for parallelism
94  @param queue A pointer to a queue object created by sstmac_uq_init
95  @param njobs The number of jobs (simulations) to run
96  @param nparams The number of parameters to set for each job
97  @param nresults The number of results returned by each job
98  @param max_nthread The maximum number of threads or, i.e.
99  the max number of jobs that can run simultaneously
100  @param param_names An array of size nparams. The name of each parameter
101  to configure for each job
102  @param param_values A 2D array of size njobs X nparams
103  The value corresponding to each paramter for all jobs
104  Indexed as p[jobID][paramID]
105  @param results A 2D array of size njobs X nresults
106  Will hold the result values for each job
107  Indexed as p[jobID][resultID]
108  @param ty The type of run to perform. Fork new procs or MPI scan.
109 */
110 void sstmac_uq_run(void* queue,
111  int njobs, int nparams, int nresults, int max_nthread,
112  const char* param_names[], uq_param_t* param_values[],
113  double* results[], uq_spawn_type_t ty);
114 
115 /**
116  Run a set of jobs with particular parameters
117  @param queue A pointer to a queue object created by sstmac_uq_init
118  @param njobs The number of jobs (simulations) to run
119  @param nparams The number of parameters to set for each job
120  @param nresults The number of results returned by each job
121  @param max_nthread The maximum number of threads or, i.e.
122  the max number of jobs that can run simultaneously
123  @param param_names An array of size nparams. The name of each parameter
124  to configure for each job
125  @param param_values A 2D array of size njobs X nparams
126  The value corresponding to each paramter for all jobs
127  Indexed as p[jobID][paramID]
128  @param results A 2D array of size njobs X nresults
129  Will hold the result values for each job
130  Indexed as p[jobID][resultID]
131 */
132 void sstmac_uq_run_units(void* queue,
133  int njobs, int nparams, int nresults, int max_nthread,
134  const char* param_names[], double* param_values[], const char* units[],
135  double* results[], uq_spawn_type_t spwan_ty);
136 
137 /**
138  @param queue A pointer to a queue object created by sstmac_uq_init
139  After finalize, the queue is no longer usable and all
140  resources used by the queue are freed
141 */
142 void sstmac_uq_finalize(void* queue);
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif
Definition: uq.h:9
int sstmac_uq_int_param(void *queue, const char *param)
void sstmac_uq_finalize(void *queue)
uq_param_type_t type
Definition: uq.h:28
uq_spawn_type_t
Definition: uq.h:18
Definition: uq.h:10
void sstmac_uq_busy_loop(void *queue)
void free_values(double **values)
Free a 2D array allocated by allocate_values function.
int sstmac_uq_max_nproc(void *queue)
Definition: uq.h:14
double ** allocate_values(void *queue, int njobs, int nparams)
Allocate a 2D double array.
const char * units
Definition: uq.h:26
void free_results(double **results)
Free a 2D array allocated by allocate_results function.
Definition: uq.h:13
void * sstmac_uq_init(int argc, char **argv, int *workerID)
Definition: uq.h:11
double value
Definition: uq.h:25
void sstmac_uq_stop(void *queue)
int sstmac_uq_sim_nproc(void *queue)
void free_params(uq_param_t **params)
Free a 2D array allocated by allocate_params function.
void sstmac_uq_run_units(void *queue, int njobs, int nparams, int nresults, int max_nthread, const char *param_names[], double *param_values[], const char *units[], double *results[], uq_spawn_type_t spwan_ty)
Run a set of jobs with particular parameters.
void sstmac_uq_run(void *queue, int njobs, int nparams, int nresults, int max_nthread, const char *param_names[], uq_param_t *param_values[], double *results[], uq_spawn_type_t ty)
Run a set of jobs with particular parameters, forking new procs for parallelism.
int sstmac_uq_double_param(void *queue, const char *param)
double ** allocate_results(void *queue, int njobs, int nresults)
Allocate a 2D double array.
Definition: uq.h:23
Definition: uq.h:12
const char * cstr
Definition: uq.h:27
Definition: uq.h:20
Definition: uq.h:19
uq_param_type_t
Definition: uq.h:8
uq_param_t ** allocate_params(int njobs, int nparams)
Allocate a 2D array of param structs.