Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release OpenMP resources in blas_thread_shutdown #4080

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions c_check
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ fi

[ "$USE_OPENMP" != 1 ] && openmp=''

have_omp_pause_resource_all=0
if [ "$USE_OPENMP" = 1 ]; then
if $compiler_name $flags $openmp -o ctest3 ctest3.c; then
have_omp_pause_resource_all=1
fi
rm -f ctest3.o ctest3 ctest3.exe
fi

linker_L=""
linker_l=""
linker_a=""
Expand Down Expand Up @@ -501,6 +509,7 @@ done
[ "$oldgcc" -eq 1 ] && printf "OLDGCC=1\n"
[ "$no_lsx" -eq 1 ] && printf "NO_LSX=1\n"
[ "$no_lasx" -eq 1 ] && printf "NO_LASX=1\n"
[ "$have_omp_pause_resource_all" -eq 1 ] && printf "HAVE_OMP_PAUSE_RESOURCE_ALL=1\n"
} >> "$makefile"

os=`echo "$os" | tr '[[:lower:]]' '[[:upper:]]'/ `
Expand All @@ -518,6 +527,7 @@ compiler=`echo "$compiler" | tr '[[:lower:]]' '[[:upper:]]' `
[ "$c11_atomics" -eq 1 ] && printf "#define HAVE_C11\t1\n"
[ "$no_lsx" -eq 1 ] && printf "#define NO_LSX\t1\n"
[ "$no_lasx" -eq 1 ] && printf "#define NO_LASX\t1\n"
[ "$have_omp_pause_resource_all" -eq 1 ] && printf "#define HAVE_OMP_PAUSE_RESOURCE_ALL\t1\n"
} >> "$config"


Expand Down
10 changes: 10 additions & 0 deletions c_check.pl
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@

$openmp = "" if $ENV{USE_OPENMP} != 1;

$have_omp_pause_resource_all=0;
if ($ENV{USE_OPENMP} == 1) {
if (system("$compiler_name $flags $openmp -o ctest3 ctest3.c") == 0) {
$have_omp_pause_resource_all=1;
}
unlink "ctest3.o", "ctest3", "ctest3.exe";
}

$linker_L = "";
$linker_l = "";
$linker_a = "";
Expand Down Expand Up @@ -472,6 +480,7 @@
print MAKEFILE "OLDGCC=1\n" if $oldgcc eq 1;
print MAKEFILE "NO_LSX=1\n" if $no_lsx eq 1;
print MAKEFILE "NO_LASX=1\n" if $no_lasx eq 1;
print MAKEFILE "HAVE_OMP_PAUSE_RESOURCE_ALL=1\n" if $have_omp_pause_resource_all eq 1;

$os =~ tr/[a-z]/[A-Z]/;
$architecture =~ tr/[a-z]/[A-Z]/;
Expand All @@ -487,6 +496,7 @@
print CONFFILE "#define HAVE_C11\t1\n" if $c11_atomics eq 1;
print CONFFILE "#define NO_LSX\t1\n" if $no_lsx eq 1;
print CONFFILE "#define NO_LASX\t1\n" if $no_lasx eq 1;
print CONFFILE "#define HAVE_OMP_PAUSE_RESOURCE_ALL\t1\n" if $have_omp_pause_resource_all eq 1;


if ($os eq "LINUX") {
Expand Down
2 changes: 2 additions & 0 deletions ctest3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <omp.h>
int main(void) { return omp_pause_resource_all(omp_pause_hard); }
4 changes: 4 additions & 0 deletions driver/others/blas_server_omp.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#else

#include <omp.h>
#ifndef likely
#ifdef __GNUC__
#define likely(x) __builtin_expect(!!(x), 1)
Expand Down Expand Up @@ -172,6 +173,9 @@ int BLASFUNC(blas_thread_shutdown)(void){
}
}
}
#if HAVE_OMP_PAUSE_RESOURCE_ALL
omp_pause_resource_all(omp_pause_hard);
#endif

return 0;
}
Expand Down
10 changes: 7 additions & 3 deletions utest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ endif
#this does not work with OpenMP nor with native Windows or Android threads
# FIXME TBD if this works on OSX, SunOS, POWER and zarch
ifeq ($(OSNAME), $(filter $(OSNAME),Linux CYGWIN_NT))
ifneq ($(USE_OPENMP), 1)
OBJS += test_fork.o
ifeq ($(USE_OPENMP), 1)
ifeq ($(HAVE_OMP_PAUSE_RESOURCE_ALL), 1)
OBJS += test_fork.o
endif
OBJS += test_post_fork.o
else
OBJS += test_fork.o
endif
OBJS += test_post_fork.o
endif

ifeq ($(C_COMPILER), PGI)
Expand Down
Loading