diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-05-02 14:52:52 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-05-02 14:52:52 +0000 |
commit | 4ad6dbc5fd490c6403cbae48b0b218c68ca22ffe (patch) | |
tree | f84963fda43cb269d5538b8f161134ea5588e845 /openmp/libomptarget/deviceRTLs/nvptx/test/api/max_threads.c | |
parent | 284472be6da3353d81dfd25b1ac4218e852d1e5f (diff) | |
download | bcm5719-llvm-4ad6dbc5fd490c6403cbae48b0b218c68ca22ffe.tar.gz bcm5719-llvm-4ad6dbc5fd490c6403cbae48b0b218c68ca22ffe.zip |
[OPENMP][NVPTX]Improve omp_get_max_threads() function.
Summary:
Function omp_get_max_threads() can always return 1 if current execution
mode is SPMD.
Reviewers: grokos, gtbercea, kkwli0
Subscribers: guansong, jdoerfert, caomhin, openmp-commits
Tags: #openmp
Differential Revision: https://reviews.llvm.org/D61379
llvm-svn: 359792
Diffstat (limited to 'openmp/libomptarget/deviceRTLs/nvptx/test/api/max_threads.c')
-rw-r--r-- | openmp/libomptarget/deviceRTLs/nvptx/test/api/max_threads.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/openmp/libomptarget/deviceRTLs/nvptx/test/api/max_threads.c b/openmp/libomptarget/deviceRTLs/nvptx/test/api/max_threads.c new file mode 100644 index 00000000000..d0d9f315106 --- /dev/null +++ b/openmp/libomptarget/deviceRTLs/nvptx/test/api/max_threads.c @@ -0,0 +1,46 @@ +// RUN: %compile-run-and-check + +#include <omp.h> +#include <stdio.h> + +int main(int argc, char *argv[]) { + int MaxThreadsL1 = -1, MaxThreadsL2 = -1; + +#pragma omp declare reduction(unique:int \ + : omp_out = (omp_in == 1 ? omp_in : omp_out)) \ + initializer(omp_priv = -1) + + // Non-SPMD mode. +#pragma omp target teams map(MaxThreadsL1, MaxThreadsL2) thread_limit(32) \ + num_teams(1) + { + MaxThreadsL1 = omp_get_max_threads(); +#pragma omp parallel reduction(unique : MaxThreadsL2) + { MaxThreadsL2 = omp_get_max_threads(); } + } + + // CHECK: Non-SPMD MaxThreadsL1 = 32 + printf("Non-SPMD MaxThreadsL1 = %d\n", MaxThreadsL1); + // CHECK: Non-SPMD MaxThreadsL2 = 1 + printf("Non-SPMD MaxThreadsL2 = %d\n", MaxThreadsL2); + + // SPMD mode with full runtime + MaxThreadsL2 = -1; +#pragma omp target parallel reduction(unique : MaxThreadsL2) + { MaxThreadsL2 = omp_get_max_threads(); } + + // CHECK: SPMD with full runtime MaxThreadsL2 = 1 + printf("SPMD with full runtime MaxThreadsL2 = %d\n", MaxThreadsL2); + + // SPMD mode without runtime + MaxThreadsL2 = -1; +#pragma omp target parallel for reduction(unique : MaxThreadsL2) + for (int I = 0; I < 2; ++I) { + MaxThreadsL2 = omp_get_max_threads(); + } + + // CHECK: SPMD without runtime MaxThreadsL2 = 1 + printf("SPMD without runtime MaxThreadsL2 = %d\n", MaxThreadsL2); + + return 0; +} |