diff options
Diffstat (limited to 'final/libomptarget/deviceRTLs/nvptx/test/parallel/tripcount.c')
-rw-r--r-- | final/libomptarget/deviceRTLs/nvptx/test/parallel/tripcount.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/final/libomptarget/deviceRTLs/nvptx/test/parallel/tripcount.c b/final/libomptarget/deviceRTLs/nvptx/test/parallel/tripcount.c new file mode 100644 index 0000000..b3f8768 --- /dev/null +++ b/final/libomptarget/deviceRTLs/nvptx/test/parallel/tripcount.c @@ -0,0 +1,22 @@ +// RUN: %compile-run-and-check + +#include <omp.h> +#include <stdio.h> + +int main() { + int res = 0; + +#pragma omp parallel num_threads(2) reduction(+:res) + { + int tid = omp_get_thread_num(); +#pragma omp target teams distribute reduction(+:res) + for (int i = tid; i < 2; i++) + ++res; + } + // The first thread makes 2 iterations, the second - 1. Expected result of the + // reduction res is 3. + + // CHECK: res = 3. + printf("res = %d.\n", res); + return 0; +} |