AMDGPU: Allow f16/bf16 for DS_READ_TR16_B64 gfx950 builtins (#118297)
[llvm-project.git] / openmp / runtime / test / env / omp_thread_limit.c
blob800edc44767fc0ba9707b40a6f38551d8efa0258
1 // RUN: %libomp-compile && env OMP_THREAD_LIMIT=4 %libomp-run 4
2 // RUN: %libomp-compile && env OMP_THREAD_LIMIT=7 %libomp-run 7
3 //
4 // OMP_THREAD_LIMIT=N should imply that no more than N threads are active in
5 // a contention group
6 #include <stdio.h>
7 #include <string.h>
8 #include <limits.h>
9 #include "omp_testsuite.h"
11 int failed = 0;
13 void usage() {
14 fprintf(stderr, "usage: omp_thread_limit <n>\n");
17 void verify(const char* file_name, int line_number, int team_size) {
18 int num_threads = omp_get_num_threads();
19 if (team_size != num_threads) {
20 #pragma omp critical(A)
22 char label[256];
23 snprintf(label, sizeof(label), "%s:%d", file_name, line_number);
24 failed = 1;
25 printf("failed: %s: team_size(%d) != omp_get_num_threads(%d)\n",
26 label, team_size, num_threads);
31 int main(int argc, char** argv)
33 int cl_thread_limit;
35 if (argc != 2) {
36 usage();
37 return 1;
39 cl_thread_limit = atoi(argv[1]);
41 omp_set_dynamic(0);
42 if (omp_get_thread_limit() != cl_thread_limit) {
43 fprintf(stderr, "omp_get_thread_limit failed with %d, should be%d\n",
44 omp_get_thread_limit(), cl_thread_limit);
45 return 1;
47 else if (omp_get_max_threads() > cl_thread_limit) {
48 #if _OPENMP
49 int team_size = cl_thread_limit;
50 #else
51 int team_size = 1;
52 #endif
53 omp_set_num_threads(19);
54 verify(__FILE__, __LINE__, 1);
55 #pragma omp parallel
57 verify(__FILE__, __LINE__, team_size);
58 verify(__FILE__, __LINE__, team_size);
60 verify(__FILE__, __LINE__, 1);
62 omp_set_nested(1);
63 #pragma omp parallel num_threads(3)
65 verify(__FILE__, __LINE__, 3);
66 #pragma omp master
67 #pragma omp parallel num_threads(21)
69 verify(__FILE__, __LINE__, team_size-2);
70 verify(__FILE__, __LINE__, team_size-2);
73 verify(__FILE__, __LINE__, 1);
75 return failed;
76 } else {
77 fprintf(stderr, "This test is not applicable for max num_threads='%d'\n",
78 omp_get_max_threads());
79 return 0;