freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] OpenMP support


From: Richard Guenther
Subject: [PATCH] OpenMP support
Date: Fri, 2 Jan 2004 16:36:47 +0100 (CET)

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 <address@hidden>

        * 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 = "address@hidden@";
+    }
+
 }


@@ -1936,20 +1949,20 @@
   print FSUITE "LD                  = $link\n";
   print FSUITE "\n";
   print FSUITE "### flags for applications\n";
-  print FSUITE "CXX_OPT_LIB_ARGS    = address@hidden@ $cppshare $cppopt_lib\n";
-  print FSUITE "CXX_DBG_LIB_ARGS    = address@hidden@ $cppshare $cppdbg_lib\n";
-  print FSUITE "CXX_OPT_APP_ARGS    = address@hidden@ $cppopt_app\n";
-  print FSUITE "CXX_DBG_APP_ARGS    = address@hidden@ $cppdbg_app\n";
+  print FSUITE "CXX_OPT_LIB_ARGS    = address@hidden@ $openmpargs $cppshare 
$cppopt_lib\n";
+  print FSUITE "CXX_DBG_LIB_ARGS    = address@hidden@ $openmpargs $cppshare 
$cppdbg_lib\n";
+  print FSUITE "CXX_OPT_APP_ARGS    = address@hidden@ $openmpargs 
$cppopt_app\n";
+  print FSUITE "CXX_DBG_APP_ARGS    = address@hidden@ $openmpargs 
$cppdbg_app\n";
   print FSUITE "\n";
-  print FSUITE "C_OPT_LIB_ARGS      = address@hidden@ $cshare $copt_lib\n";
-  print FSUITE "C_DBG_LIB_ARGS      = address@hidden@ $cshare $cdbg_lib\n";
-  print FSUITE "C_OPT_APP_ARGS      = address@hidden@ $copt_app\n";
-  print FSUITE "C_DBG_APP_ARGS      = address@hidden@ $cdbg_app\n";
+  print FSUITE "C_OPT_LIB_ARGS      = address@hidden@ $openmpargs $cshare 
$copt_lib\n";
+  print FSUITE "C_DBG_LIB_ARGS      = address@hidden@ $openmpargs $cshare 
$cdbg_lib\n";
+  print FSUITE "C_OPT_APP_ARGS      = address@hidden@ $openmpargs $copt_app\n";
+  print FSUITE "C_DBG_APP_ARGS      = address@hidden@ $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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]