You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
libcxx
libcxxabi
libunwind
lld
lldb
llvm
openmp
cmake
libomptarget
offload
runtime
cmake
doc
src
test
api
atomic
barrier
critical
env
kmp_aff_disable_hwloc.c
kmp_set_dispatch_buf.c
omp_thread_limit.c
omp_wait_policy.c
flush
lock
master
misc_bugs
ompt
parallel
tasking
threadprivate
worksharing
CMakeLists.txt
lit.cfg
lit.site.cfg.in
omp_my_sleep.h
omp_testsuite.h
tools
.clang-format
CMakeLists.txt
README.txt
www
.arcconfig
.gitignore
CMakeLists.txt
CREDITS.txt
LICENSE.txt
README.rst
polly
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
83 lines
2.0 KiB
C
83 lines
2.0 KiB
C
![]() |
// RUN: %libomp-compile && env OMP_THREAD_LIMIT=4 %libomp-run 4
|
||
|
// RUN: %libomp-compile && env OMP_THREAD_LIMIT=7 %libomp-run 7
|
||
|
//
|
||
|
// OMP_THREAD_LIMIT=N should imply that no more than N threads are active in
|
||
|
// a contention group
|
||
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include <limits.h>
|
||
|
#include "omp_testsuite.h"
|
||
|
|
||
|
int failed = 0;
|
||
|
|
||
|
void usage() {
|
||
|
fprintf(stderr, "usage: omp_thread_limit <n>\n");
|
||
|
}
|
||
|
|
||
|
void verify(const char* file_name, int line_number, int team_size) {
|
||
|
int num_threads = omp_get_num_threads();
|
||
|
if (team_size != num_threads) {
|
||
|
#pragma omp critical(A)
|
||
|
{
|
||
|
char label[256];
|
||
|
snprintf(label, sizeof(label), "%s:%d", file_name, line_number);
|
||
|
failed = 1;
|
||
|
printf("failed: %s: team_size(%d) != omp_get_num_threads(%d)\n",
|
||
|
label, team_size, num_threads);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(int argc, char** argv)
|
||
|
{
|
||
|
int cl_thread_limit;
|
||
|
|
||
|
if (argc != 2) {
|
||
|
usage();
|
||
|
return 1;
|
||
|
}
|
||
|
cl_thread_limit = atoi(argv[1]);
|
||
|
|
||
|
omp_set_dynamic(0);
|
||
|
if (omp_get_thread_limit() != cl_thread_limit) {
|
||
|
fprintf(stderr, "omp_get_thread_limit failed with %d, should be%d\n",
|
||
|
omp_get_thread_limit(), cl_thread_limit);
|
||
|
return 1;
|
||
|
}
|
||
|
else if (omp_get_max_threads() > cl_thread_limit) {
|
||
|
#if _OPENMP
|
||
|
int team_size = cl_thread_limit;
|
||
|
#else
|
||
|
int team_size = 1;
|
||
|
#endif
|
||
|
omp_set_num_threads(19);
|
||
|
verify(__FILE__, __LINE__, 1);
|
||
|
#pragma omp parallel
|
||
|
{
|
||
|
verify(__FILE__, __LINE__, team_size);
|
||
|
verify(__FILE__, __LINE__, team_size);
|
||
|
}
|
||
|
verify(__FILE__, __LINE__, 1);
|
||
|
|
||
|
omp_set_nested(1);
|
||
|
#pragma omp parallel num_threads(3)
|
||
|
{
|
||
|
verify(__FILE__, __LINE__, 3);
|
||
|
#pragma omp master
|
||
|
#pragma omp parallel num_threads(21)
|
||
|
{
|
||
|
verify(__FILE__, __LINE__, team_size-2);
|
||
|
verify(__FILE__, __LINE__, team_size-2);
|
||
|
}
|
||
|
}
|
||
|
verify(__FILE__, __LINE__, 1);
|
||
|
|
||
|
return failed;
|
||
|
} else {
|
||
|
fprintf(stderr, "This test is not applicable for max num_threads='%d'\n",
|
||
|
omp_get_max_threads());
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
}
|