diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-08-13 16:08:45 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-08-13 16:08:45 +0000 |
commit | b25ec20e402c13e11d2c112f857332b663ab5589 (patch) | |
tree | 6101263b55ea15d3e51481f24b39d677c8f3b2b2 /rc2/runtime/test/api/omp_get_num_threads.c | |
parent | 89e9f952c629d9ce8b731d18980f4b98790b1c67 (diff) |
Creating release candidate rc2 from release_900 branch
git-svn-id: https://llvm.org/svn/llvm-project/openmp/tags/RELEASE_900@368708 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'rc2/runtime/test/api/omp_get_num_threads.c')
-rw-r--r-- | rc2/runtime/test/api/omp_get_num_threads.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/rc2/runtime/test/api/omp_get_num_threads.c b/rc2/runtime/test/api/omp_get_num_threads.c new file mode 100644 index 0000000..daf286d --- /dev/null +++ b/rc2/runtime/test/api/omp_get_num_threads.c @@ -0,0 +1,39 @@ +// RUN: %libomp-compile-and-run +#include <stdio.h> +#include "omp_testsuite.h" + +int test_omp_get_num_threads() +{ + /* checks that omp_get_num_threads is equal to the number of + threads */ + int nthreads_lib; + int nthreads = 0; + + nthreads_lib = -1; + + #pragma omp parallel + { + #pragma omp critical + { + nthreads++; + } /* end of critical */ + #pragma omp single + { + nthreads_lib = omp_get_num_threads (); + } /* end of single */ + } /* end of parallel */ + return (nthreads == nthreads_lib); +} + +int main() +{ + int i; + int num_failed=0; + + for(i = 0; i < REPETITIONS; i++) { + if(!test_omp_get_num_threads()) { + num_failed++; + } + } + return num_failed; +} |