1 // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
2 // RUN: %libomp-compile -DNOWAIT && %libomp-run | %sort-threads | FileCheck %s
3 // REQUIRES: ompt
4 // UNSUPPORTED: gcc
5 #include "callback.h"
6 #include <omp.h>
7
8 #ifdef NOWAIT
9 #define FOR_CLAUSE nowait
10 #else
11 #define FOR_CLAUSE
12 #endif
13
main()14 int main() {
15 int sum = 0, a = 0, b = 0;
16 int i;
17 #pragma omp parallel num_threads(5)
18 // for 32-bit architecture we need at least 3 variables to trigger tree
19 #pragma omp for reduction(+ : sum, a, b) FOR_CLAUSE
20 for (i = 0; i < 10000; i++) {
21 a = b = sum += i;
22 }
23
24
25 printf("%i\n", sum);
26 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
27
28 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin:
29 // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]]
30 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin:
31 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID:[0-9]+]]
32
33 // order and distribution to threads not determined
34 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
35 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
36 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
37 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
38 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
39 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
40 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
41 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
42 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
43 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
44 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
45 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
46 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_begin:
47 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
48 // CHECK: {{^}}{{[0-f]+}}: ompt_event_reduction_end:
49 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}}
50
51 return 0;
52 }
53