LLVM OpenMP
omp_num_threads_dev_all_fallback.c
Go to the documentation of this file.
1// RUN: %libomp-compile && env OMP_NUM_THREADS_ALL=8 %libomp-run
2//
3// OpenMP 6.0: every non-host device falls through to `_ALL` when no
4// `_DEV[_d]` is set.
5
6#include <omp.h>
7#include <stdio.h>
8#include <string.h>
9
10extern const char *__kmpc_get_device_env(const char *name, int device_id);
11
12static int check(int device_id, const char *got, const char *expect) {
13 if (!got || strcmp(got, expect) != 0) {
14 fprintf(stderr, "FAIL: device_id=%d got '%s' expected '%s'\n", device_id,
15 got ? got : "(null)", expect);
16 return 1;
17 }
18 return 0;
19}
20
21int main(void) {
22 int rc = 0;
23 if (omp_get_max_threads() != 8) {
24 fprintf(stderr, "FAIL: host omp_get_max_threads()=%d, expected 8\n",
26 return 1;
27 }
28 rc |= check(0, __kmpc_get_device_env("OMP_NUM_THREADS", 0), "8");
29 rc |= check(1, __kmpc_get_device_env("OMP_NUM_THREADS", 1), "8");
30 rc |= check(2, __kmpc_get_device_env("OMP_NUM_THREADS", 2), "8");
31 return rc;
32}
#define check(condition)
__itt_string_handle * name
Definition ittnotify.h:3305
const char * __kmpc_get_device_env(const char *name, int device_id)
int omp_get_max_threads()