LLVM OpenMP
omp_num_threads_all_demo.c
Go to the documentation of this file.
1// RUN: %libomp-compile
2// RUN: env OMP_NUM_THREADS_ALL=8 OMP_NUM_THREADS_DEV_0=128 %libomp-run \
3// RUN: | FileCheck %s
4//
5// Demo: host=8 (_ALL), device 0=128 (_DEV_0), other devices=8 (_ALL fallback).
6
7#include <omp.h>
8#include <stdio.h>
9
10extern const char *__kmpc_get_device_env(const char *name, int device_id);
11
12int main(void) {
13 int host_max = omp_get_max_threads();
14 printf("host omp_get_max_threads() = %d\n", host_max);
15 for (int d = 0; d < 3; ++d) {
16 const char *v = __kmpc_get_device_env("OMP_NUM_THREADS", d);
17 printf("device %d resolved OMP_NUM_THREADS = %s\n", d, v ? v : "(default)");
18 }
19 return 0;
20}
21
22// CHECK: host omp_get_max_threads() = 8
23// CHECK: device 0 resolved OMP_NUM_THREADS = 128
24// CHECK: device 1 resolved OMP_NUM_THREADS = 8
25// CHECK: device 2 resolved OMP_NUM_THREADS = 8
__itt_string_handle * name
Definition ittnotify.h:3305
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
int main(void)
const char * __kmpc_get_device_env(const char *name, int device_id)
int omp_get_max_threads()