[PATCH] OpenMP support
Richard Guenther
rguenth at tat.physik.uni-tuebingen.de
Fri Jan 2 15:36:47 UTC 2004
Hi Jeffrey,
would you please look at "[PATCH] OpenMP loop level parallelism" mail I
sent Dec23? Additionally to this patch I propose the following, which
adds a --openmp switch to configure.
Tested with gcc (with and without --openmp, which is the same here) and
Intel icpc (with and without --openmp, which makes a difference here).
Ok?
Thanks,
Richard.
2004Jan02 Richard Guenther <richard.guenther at uni-tuebingen.de>
* config/arch/LINUXICC.conf: don't warn about unused #pragmas.
configure: add --openmp switch.
scripts/configure.ac: add test to detect wether -openmp works.
scripts/configure: regenerated.
diff -Nru a/r2/config/arch/LINUXICC.conf b/r2/config/arch/LINUXICC.conf
--- a/r2/config/arch/LINUXICC.conf Fri Jan 2 16:32:14 2004
+++ b/r2/config/arch/LINUXICC.conf Fri Jan 2 16:32:14 2004
@@ -170,8 +170,8 @@
### debug or optimized build settings for C++ applications
-$cppdbg_app = "-g";
-$cppopt_app = "-DNOPAssert -DNOCTAssert -O2";
+$cppdbg_app = "-g -wd161";
+$cppopt_app = "-DNOPAssert -DNOCTAssert -O2 -wd161";
### debug or optimized build settings for C++ libraries
diff -Nru a/r2/configure b/r2/configure
--- a/r2/configure Fri Jan 2 16:32:14 2004
+++ b/r2/configure Fri Jan 2 16:32:14 2004
@@ -170,6 +170,7 @@
$prefixnm = "--prefix";
$serialnm = "--serial";
$threadsnm = "--threads";
+$openmpnm = "--openmp";
$profilenm = "--profile";
$insurenm = "--insure";
$debugnm = "--debug";
@@ -237,7 +238,8 @@
[$finternm, "", "include fortran support libraries."],
[$nofinternm, "", "do not include the fortran libraries."],
[$serialnm, "", "configure to run serially, no parallelism."],
- [$threadsnm, "", "include threads capability, if available."],
+ [$threadsnm, "", "include threads capability, if available."],
+ [$openmpnm, "", "enable use of OpenMP, if available."],
[$cheetahnm, "", "enable use of CHEETAH communications package."],
[$schednm, "<scheduler>", "use <scheduler> for thread scheduling."],
[$pawsnm, "", "enable PAWS program coupling, if available."],
@@ -434,6 +436,10 @@
$threads_include_makefile = "";
$cpp_threads_arg = "";
+### include OpenMP capability?
+$openmp = 0;
+$openmpargs = "";
+
### if threads is used, what scheduler should be employed?
$scheduler = $schedulerdefault;
@@ -1307,9 +1313,9 @@
sub setthreads
{
# set $threads variable properly
- if (scalar @{$arghash{$threadsnm}} > 1 and scalar @{$arghash{$serialnm}}> 1)
+ if (scalar @{$arghash{$threadsnm}} > 1 and (scalar @{$arghash{$serialnm}} > 1 or scalar @{$arghash{$openmpnm}} > 1))
{
- printerror "$threadsnm and $serialnm both given. Use only one.";
+ printerror "$threadsnm and $serialnm or $openmpnm given. Use only one.";
}
elsif (not $threads_able or scalar @{$arghash{$serialnm}} > 1)
{
@@ -1438,6 +1444,13 @@
$pooma_reorder_iterates = $threads || ($scheduler eq "serialAsync");
add_yesno_define("POOMA_REORDER_ITERATES", $pooma_reorder_iterates);
+
+ # OpenMP support
+ if (scalar @{$arghash{$openmpnm}} > 1)
+ {
+ $openmpargs = "\@openmpargs\@";
+ }
+
}
@@ -1936,20 +1949,20 @@
print FSUITE "LD = $link\n";
print FSUITE "\n";
print FSUITE "### flags for applications\n";
- print FSUITE "CXX_OPT_LIB_ARGS = \@cppargs\@ $cppshare $cppopt_lib\n";
- print FSUITE "CXX_DBG_LIB_ARGS = \@cppargs\@ $cppshare $cppdbg_lib\n";
- print FSUITE "CXX_OPT_APP_ARGS = \@cppargs\@ $cppopt_app\n";
- print FSUITE "CXX_DBG_APP_ARGS = \@cppargs\@ $cppdbg_app\n";
+ print FSUITE "CXX_OPT_LIB_ARGS = \@cppargs\@ $openmpargs $cppshare $cppopt_lib\n";
+ print FSUITE "CXX_DBG_LIB_ARGS = \@cppargs\@ $openmpargs $cppshare $cppdbg_lib\n";
+ print FSUITE "CXX_OPT_APP_ARGS = \@cppargs\@ $openmpargs $cppopt_app\n";
+ print FSUITE "CXX_DBG_APP_ARGS = \@cppargs\@ $openmpargs $cppdbg_app\n";
print FSUITE "\n";
- print FSUITE "C_OPT_LIB_ARGS = \@cargs\@ $cshare $copt_lib\n";
- print FSUITE "C_DBG_LIB_ARGS = \@cargs\@ $cshare $cdbg_lib\n";
- print FSUITE "C_OPT_APP_ARGS = \@cargs\@ $copt_app\n";
- print FSUITE "C_DBG_APP_ARGS = \@cargs\@ $cdbg_app\n";
+ print FSUITE "C_OPT_LIB_ARGS = \@cargs\@ $openmpargs $cshare $copt_lib\n";
+ print FSUITE "C_DBG_LIB_ARGS = \@cargs\@ $openmpargs $cshare $cdbg_lib\n";
+ print FSUITE "C_OPT_APP_ARGS = \@cargs\@ $openmpargs $copt_app\n";
+ print FSUITE "C_DBG_APP_ARGS = \@cargs\@ $openmpargs $cdbg_app\n";
print FSUITE "\n";
- print FSUITE "F77_OPT_LIB_ARGS = $f77args $f77share $f77opt_lib\n";
- print FSUITE "F77_DBG_LIB_ARGS = $f77args $f77share $f77dbg_lib\n";
- print FSUITE "F77_OPT_APP_ARGS = $f77args $f77opt_app\n";
- print FSUITE "F77_DBG_APP_ARGS = $f77args $f77dbg_app\n";
+ print FSUITE "F77_OPT_LIB_ARGS = $f77args $openmpargs $f77share $f77opt_lib\n";
+ print FSUITE "F77_DBG_LIB_ARGS = $f77args $openmpargs $f77share $f77dbg_lib\n";
+ print FSUITE "F77_OPT_APP_ARGS = $f77args $openmpargs $f77opt_app\n";
+ print FSUITE "F77_DBG_APP_ARGS = $f77args $openmpargs $f77dbg_app\n";
print FSUITE "\n";
if ($shared) {
print FSUITE "AR_OPT_ARGS = $arshareopt\n";
diff -Nru a/r2/scripts/configure.ac b/r2/scripts/configure.ac
--- a/r2/scripts/configure.ac Fri Jan 2 16:32:14 2004
+++ b/r2/scripts/configure.ac Fri Jan 2 16:32:14 2004
@@ -352,6 +352,31 @@
dnl
+dnl Check for compiler argument for OpenMP support
+dnl
+
+AC_MSG_CHECKING([for way to enable OpenMP support])
+acx_saved_cxxflags=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS -openmp"
+AC_TRY_LINK([
+#include <omp.h>
+], [
+ double d[128];
+#pragma omp parallel for
+ for (int i=0; i<128; ++i)
+ d[i] = 1.0;
+ omp_get_max_threads();
+], [
+AC_MSG_RESULT([-openmp])
+openmpargs="-openmp"
+], [
+AC_MSG_RESULT([none])
+])
+CXXFLAGS=$acx_saved_cxxflags
+AC_SUBST(openmpargs)
+
+
+dnl
dnl Check on how to get failure on unrecognized pragmas
dnl gcc: -Wunknown-pragmas -Werror
dnl icpc: -we161
More information about the pooma-dev
mailing list