omp_options
Sets various OpenMP options.
Synopsis
#include <imsls.h>
void imsls_omp_options(…, 0)
Return Value
The return value for this function is void.
Synopsis with Optional Arguments
#include <imsls.h>
void imsls_omp_options
(IMSLS_SET_FUNCTIONS_THREAD_SAFE, int setting, (Input)
IMSLS_GET_FUNCTIONS_THREAD_SAFE, int *psetting, (Output)
0)
Optional Arguments
IMSLS_SET_FUNCTIONS_THREAD_SAFE, int setting (Input)
If nonzero, user supplied functions are assumed to be thread-safe. This allows user functions to be evaluated in parallel with different arguments.
Default: User supplied functions are not assumed to be thread-safe and will not be evaluated in parallel by IMSL C Stat Library functions.
IMSLS_GET_FUNCTIONS_THREAD_SAFE, int *psetting (Output)
Sets the integer pointed to by psetting to zero if user functions are not assumed to be thread-safe and to one if they are assumed to be thread-safe.
Description
The performance of some IMSL C Stat Library functions can be improved if they evaluate user supplied functions in parallel. Unfortunately, incorrect results can occur if the user supplied functions are not thread-safe. By default, the IMSL C Stat Library assumes user supplied functions are not thread-safe and thus will not evaluate them in parallel. To change this assumption, use the optional argument IMSLS_SET_FUNCTIONS_THREAD_SAFE with its argument equal to one.
This function can be used multiple times in an application to change the thread-safe assumption.
Example
This example performs a chi-squared test on a randomly generated sample. A call to the function imsls_omp_options is used to indicate that function cdf is thread-safe and so can be safely evaluated by multiple, simultaneous threads.
#include <imsls.h>
static float cdf(float x);
#define SEED 123457
#define N_CATEGORIES 10
#define N_OBSERVATIONS 1000
int main()
{
float *x, p_value;
imsls_omp_options(IMSLS_SET_FUNCTIONS_THREAD_SAFE, 1, 0);
imsls_random_seed_set(SEED);
x = imsls_f_random_normal (N_OBSERVATIONS, 0);
p_value = imsls_f_chi_squared_test (cdf, N_OBSERVATIONS,
N_CATEGORIES, x, 0);
printf ("p-value = %7.4f\n", p_value);
}
static float cdf(float x)
{
return imsls_f_normal_cdf(x);
}
Output
p-value = 0.1546