[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / tasking / omp_taskloop_num_tasks.c
blob1999cb57d28217a52bbc05885c8bc495f6560406
1 // This test is known to be fragile on NetBSD kernel at the moment.
2 // UNSUPPORTED: netbsd
3 // RUN: %libomp-compile-and-run
4 // RUN: %libomp-compile && env KMP_TASKLOOP_MIN_TASKS=1 %libomp-run
6 // These compilers don't support the taskloop construct
7 // UNSUPPORTED: gcc-4, gcc-5, icc-16
9 // This test is known to be fragile on NetBSD kernel at the moment,
10 // https://bugs.llvm.org/show_bug.cgi?id=42020.
11 // UNSUPPORTED: netbsd
14 * Test for taskloop
15 * Method: calculate how many times the iteration space is dispatched
16 * and judge if each dispatch has the requested grainsize
17 * It is possible for two adjacent chunks are executed by the same thread
19 #include <stdio.h>
20 #include <omp.h>
21 #include <stdlib.h>
22 #include "omp_testsuite.h"
24 #define CFDMAX_SIZE 1120
26 int test_omp_taskloop_num_tasks()
28 int i;
29 int *tids;
30 int *tidsArray;
31 int count;
32 int result = 0;
33 int num_tasks;
35 for (num_tasks = 1; num_tasks < 120; ++num_tasks) {
36 count = 0;
37 tidsArray = (int *)malloc(sizeof(int) * CFDMAX_SIZE);
38 tids = tidsArray;
40 #pragma omp parallel shared(tids)
42 int i;
43 #pragma omp master
44 #pragma omp taskloop num_tasks(num_tasks)
45 for (i = 0; i < CFDMAX_SIZE; i++) {
46 tids[i] = omp_get_thread_num();
50 for (i = 0; i < CFDMAX_SIZE - 1; ++i) {
51 if (tids[i] != tids[i + 1]) {
52 count++;
56 if (count > num_tasks) {
57 fprintf(stderr, "counted too many tasks: (wanted %d, got %d)\n",
58 num_tasks, count);
59 result++;
63 return (result==0);
66 int main()
68 int i;
69 int num_failed=0;
71 for (i = 0; i < REPETITIONS; i++) {
72 if (!test_omp_taskloop_num_tasks()) {
73 num_failed++;
76 return num_failed;