LLVM OpenMP
omp_num_threads_all_set_defaults.c
Go to the documentation of this file.
1// RUN: %libomp-compile-and-run
2//
3// kmp_set_defaults("OMP_NUM_THREADS_ALL=N") must propagate to live threads,
4// and an unrelated kmp_set_defaults call must not wipe registry state.
5
6#include <omp.h>
7#include <stdio.h>
8
9extern void kmp_set_defaults(const char *);
10extern const char *__kmpc_get_device_env(const char *name, int device_id);
11
12int main(void) {
13 int rc = 0;
15
16 kmp_set_defaults("OMP_NUM_THREADS_ALL=16");
17 if (omp_get_max_threads() != 16) {
18 fprintf(stderr, "FAIL: after _ALL=16 expected 16 got %d\n",
20 rc = 1;
21 }
22
23 kmp_set_defaults("KMP_BLOCKTIME=200");
24 const char *q = __kmpc_get_device_env("OMP_NUM_THREADS", 0);
25 if (q == NULL || q[0] != '1' || q[1] != '6' || q[2] != '\0') {
26 fprintf(stderr,
27 "FAIL: registry wiped by unrelated kmp_set_defaults; got %s\n",
28 q ? q : "(null)");
29 rc = 1;
30 }
31 return rc;
32}
__itt_string_handle * name
Definition ittnotify.h:3305
void
Definition ittnotify.h:3324
#define kmp_set_defaults
Definition kmp_stub.cpp:46
const char * __kmpc_get_device_env(const char *name, int device_id)
int omp_get_max_threads()