Skip to content
Open
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
49 changes: 42 additions & 7 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,10 @@ X_PRE_LIBS
X_CFLAGS
CPP
XMKMF
falcon_OPENMP_LINKFLAGS
falcon_OPENMP_CXXFLAGS
OPENMP_LINKFLAGS
OPENMP_CXXFLAGS
falcon_OPENMP
STDFLAG
MAKEDIRS
Expand Down Expand Up @@ -1492,7 +1496,7 @@ Optional Packages:
--with-ccmalloc use CCMALLOC for malloc
--with-dso use DSO linking
--with-opt use opt for essentials
--with-openmp use OMP directives
--with-openmp use OMP directives; mac/clang only: path to libomp
--with-std use this -std=
--with-x use the X Window System
--with-pgplot-prefix=DIR Directory where PGPLOT was installed, aka PGPLOT_DIR
Expand Down Expand Up @@ -6763,16 +6767,47 @@ else
fi


if test $with_openmp = "yes"; then
CFLAGS="$CFLAGS -fopenmp"
CXXFLAGS="$CXXFLAGS -fopenmp"
FFLAGS="$CFLAGS -fopenmp"
OPENMP_CXXFLAGS=""
OPENMP_LINKFLAGS=""
falcon_OPENMP="noOPENMP"
if test $with_openmp != "no"; then
falcon_OPENMP="OPENMP"
else
falcon_OPENMP="noOPENMP"
if ${CC} --version | grep -q "clang"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we have a valid libomp path" >&5
printf %s "checking whether we have a valid libomp path... " >&6; }
if ! (test -d "$with_openmp/lib" && test -d "$with_openmp/include"); then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: No libomp path" >&5
printf "%s\n" "$as_me: WARNING: No libomp path" >&2;}
echo "*********************************************************************************"
echo " You are compiling on clang (either directly or because you're on OS X)"
echo " and included a --with-openmp option, but did not provide a path to a "
echo " valid libomp install. Unlike other c compilers, clang does not include"
echo " libomp. You'll need to install libomp yourself with something like brew."
echo " Note also that brew will not symlink libomp from within /usr/*/lib, citing"
echo " possible damage to the OS. You'll need to know the path to the parent"
echo " dir of include/libomp.h and lib/libomp.* and provide it with the --with-openmp"
echo " option, e.g.:"
echo " /.configure ... --with-openmp=~/mybrew/Cellar/libomp/18.0.1"
echo "*********************************************************************************"
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
OPENMP_CXXFLAGS="-Xclang -fopenmp -I$with_openmp/include "
OPENMP_LINKFLAGS="-L$with_openmp/lib -lomp "
fi
else
OPENMP_CXXFLAGS="-fopenmp"
fi
fi



falcon_OPENMP_CXXFLAGS="$OPENMP_CXXFLAGS"
falcon_OPENMP_LINKFLAGS="$OPENMP_LINKFLAGS"




ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
Expand Down
42 changes: 35 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ AC_ARG_WITH(dso,
AC_ARG_WITH(opt,
[ --with-opt use opt for essentials], with_opt=$withval, with_opt=no)
AC_ARG_WITH(openmp,
[ --with-openmp use OMP directives], with_openmp=$withval, with_openmp=no)
[ --with-openmp use OMP directives; mac/clang only: path to libomp ], with_openmp=$withval, with_openmp=no)

AC_ARG_WITH(std,
[ --with-std use this -std=], with_std=$withval, with_std=c99)
Expand All @@ -258,15 +258,43 @@ else
fi
AC_SUBST(STDFLAG)

if test $with_openmp = "yes"; then
CFLAGS="$CFLAGS -fopenmp"
CXXFLAGS="$CXXFLAGS -fopenmp"
FFLAGS="$CFLAGS -fopenmp"
OPENMP_CXXFLAGS=""
OPENMP_LINKFLAGS=""
falcon_OPENMP="noOPENMP"
if test $with_openmp != "no"; then
falcon_OPENMP="OPENMP"
else
falcon_OPENMP="noOPENMP"
if ${CC} --version | grep -q "clang"; then
AC_MSG_CHECKING([whether we have a valid libomp path])
if ! (test -d "$with_openmp/lib" && test -d "$with_openmp/include"); then
AC_MSG_WARN([No libomp path])
echo "*********************************************************************************"
echo " You are compiling on clang (either directly or because you're on OS X)"
echo " and included a --with-openmp option, but did not provide a path to a "
echo " valid libomp install. Unlike other c compilers, clang does not include"
echo " libomp. You'll need to install libomp yourself with something like brew."
echo " Note also that brew will not symlink libomp from within /usr/*/lib, citing"
echo " possible damage to the OS. You'll need to know the path to the parent"
echo " dir of include/libomp.h and lib/libomp.* and provide it with the --with-openmp"
echo " option, e.g.:"
echo " /.configure [...] --with-openmp=~/mybrew/Cellar/libomp/18.0.1"
echo "*********************************************************************************"
else
AC_MSG_RESULT([yes])
OPENMP_CXXFLAGS="-Xclang -fopenmp -I$with_openmp/include "
OPENMP_LINKFLAGS="-L$with_openmp/lib -lomp "
fi
else
OPENMP_CXXFLAGS="-fopenmp"
fi
fi
AC_SUBST(falcon_OPENMP)
AC_SUBST(OPENMP_CXXFLAGS)
AC_SUBST(OPENMP_LINKFLAGS)
falcon_OPENMP_CXXFLAGS="$OPENMP_CXXFLAGS"
falcon_OPENMP_LINKFLAGS="$OPENMP_LINKFLAGS"
AC_SUBST(falcon_OPENMP_CXXFLAGS)
AC_SUBST(falcon_OPENMP_LINKFLAGS)


dnl ---------------------------------------------------------------------
dnl Check for basic X windows stuff : AC_PATH_XTRA -> X_CFLAGS and X_LIBS
Expand Down
11 changes: 8 additions & 3 deletions makedefs.in
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ GSL_LIB =
PLPLOT_INC = @PLPLOT_CFLAGS@
PLPLOT_LIB = @PLPLOT_LIBS@

# OPENMP
OPENMP_CXXFLAGS=@OPENMP_CXXFLAGS@
OPENMP_LINKFLAGS=@OPENMP_LINKFLAGS@


# FFTW
# -lfftw3, or -lfftw3f or -lfftw3l (depending on precision library, for float or long double)
# [actually still not used yet]
Expand Down Expand Up @@ -149,10 +154,10 @@ LOPT = @LDFLAGS@
# for shared libaries
CCSHARED = @CCSHARED@
# everything
CFLAGS = $(COPT) $(CCSHARED) $(NEMO_CFLAGS) $(PFLAGS) @STDFLAG@
CXXFLAGS = $(COPT) $(CCSHARED) $(NEMO_CFLAGS)
CFLAGS = $(COPT) $(CCSHARED) $(NEMO_CFLAGS) $(PFLAGS) $(OPENMP_CXXFLAGS) @STDFLAG@
CXXFLAGS = $(COPT) $(CCSHARED) $(NEMO_CFLAGS) $(OPENMP_CXXFLAGS)
FFLAGS = $(FOPT) $(CCSHARED) $(NEMO_FFLAGS)
LDFLAGS = $(LOPT) $(NEMO_LDFLAGS)
LDFLAGS = $(LOPT) $(NEMO_LDFLAGS) $(OPENMP_LIBFLAGS)
CPPFLAGS = @CPPFLAGS@

RANLIB = @RANLIB@
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/io/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ endian: endian.c
$(CC) $(CFLAGS) -DTOOLBOX -o endian endian.c $(NEMO_LIBS)

getpartest: getparam.c
$(CC) $(CFLAGS) -o getpartest -DTESTBED getparam.c $(NEMO_LIBS)
$(CC) $(CFLAGS) $(OPENMP_CXXFLAGS) -o getpartest -DTESTBED getparam.c $(NEMO_LIBS) $(OPENMP_LINKFLAGS)

stropentest: stropen.c
$(CC) $(CFLAGS) -o stropentest -DTESTBED stropen.c $(NEMO_LIBS)
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/io/getparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@


//#if defined(ENABLE_OPENMP)
#if _OPENMP
//#if _OPENMP
#include <omp.h>
local double omp_t1, omp_t2;
#else
typedef int omp_int_t;
inline omp_int_t omp_get_thread_num() { return 0;}
inline omp_int_t omp_get_max_threads() { return 1;}
#endif
//#endif

#if defined(TCL7)
# include <tcl.h>
Expand Down
10 changes: 5 additions & 5 deletions src/tutor/mp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
CC = gcc
MPICC = mpicc

TIME = /usr/bin/time -f "%U %S %e %P"
TIME = /usr/bin/time

include $(NEMOLIB)/makedefs

Expand All @@ -16,7 +16,7 @@ clean:
rm -f $(BINS)

hello1:
$(CC) -fopenmp -O3 -o hello1 hellomp.c -lm
$(CC) $(OPENMP_CXXFLAGS) -O3 -o hello1 hellomp.c -lm $(OPENMP_LINKFLAGS)

hello2:
$(CC) -O3 -o hello2 hellomp.c -lm
Expand All @@ -27,7 +27,7 @@ bench: $(BINS)


heated_plate_openmp:
$(CC) $(CFLAGS) -fopenmp -o heated_plate_openmp heated_plate_openmp.c $(NEMO_LIBS)
$(CC) $(CFLAGS) $(OPENMP_CXXFLAGS) -o heated_plate_openmp heated_plate_openmp.c $(NEMO_LIBS) $(OPENMP_LINKFLAGS)

bench2: heated_plate_openmp
$(TIME) ./heated_plate_openmp nprocs=4
Expand All @@ -48,7 +48,7 @@ bench4:
# scaling from https://stackoverflow.com/questions/19780554/what-limits-scaling-in-this-simple-openmp-program

scaling: scaling.c
$(CC) scaling.c -std=c99 -fopenmp -O3 -o scaling -lm
$(CC) scaling.c -std=c99 $(OPENMP_CXXFLAGS) -O3 -o scaling -lm $(OPENMP_LINKFLAGS)

ONT=1 2 4 8 16
bench5: scaling
Expand All @@ -58,7 +58,7 @@ bench5: scaling


quad_openmp: quad_openmp.c
gcc -fopenmp quad_openmp.c -o quad_openmp
gcc $(OPENMP_CXXFLAGS) quad_openmp.c -o quad_openmp $(OPENMP_LINKFLAGS)

bench6: quad_openmp
@echo OMP_NUM_THREADS ONT=$(ONT)
Expand Down
27 changes: 17 additions & 10 deletions usr/dehnen/falcON/src/public/lib/bodyfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <limits>

using namespace falcON;
////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -154,8 +155,8 @@ namespace {
// compiles a falcON C++ program in fname using compiler flags
const char* falcON_path = falcON::directory();
if(falcON_path == 0) throw BfErr("cannot locate falcON directory");
char cmmd[512];
SNprintf(cmmd,512,"cd /tmp; %s %s.cc -o %s.so"
char cmmd[PATH_MAX];
SNprintf(cmmd,PATH_MAX,"cd /tmp; %s %s.cc -o %s.so"
" %s -shared -fPIC -I%s/inc -I%s/inc/utils -O2"
#if __cplusplus >= 201103L
" -std=c++0x"
Expand All @@ -172,14 +173,20 @@ namespace {
" -DfalcON_SINGLE"
#endif
#if defined(__INTEL_COMPILER)
" -ip -xHost -fpic -falign-functions -openmp -g -Wall"

" -ip -xHost -fpic -falign-functions -g -Wall"
# if "x$OPENMP" != "x"
" -openmp"
# endif
// " -march=native -mfpmath=sse -mpreferred-stack-boundary=4 -ggdb3"
#elif defined(__clang__)
" -mfpmath=sse -ggdb3"
" -Wall -Wextra -Winit-self -Wshadow -Woverloaded-virtual -fPIC"
" -std=c++11 -funroll-loops -fforce-addr $OPENMP_CXXFLAGS $OPENMP_LINKFLAGS"
#elif defined(__GNUC__)
" -mfpmath=sse -mpreferred-stack-boundary=4 -ggdb3"
" -Wall -Wextra -Winit-self -Wshadow -Woverloaded-virtual -fPIC"
" -std=c++11"
" -fopenmp -funroll-loops -fforce-addr"
" $OPENMP_CXXFLAGS -funroll-loops -fforce-addr $OPENMP_LINKFLAGS"
#else
" -fpic -openmp -g"
#endif
Expand All @@ -193,8 +200,8 @@ namespace {
if(system(cmmd)) {
if(debug(debug_depth)) {
std::cerr<<"could not compile temporary file /tmp/"<<fname<<".cc:\n";
char show[512];
SNprintf(show,512,"more /tmp/%s.cc > /dev/stderr",fname);
char show[PATH_MAX];
SNprintf(show,PATH_MAX,"more /tmp/%s.cc > /dev/stderr",fname);
int rr;
rr=system(show);
std::cerr<<"\nwith the command\n\""<<cmmd<<"\".\n"
Expand All @@ -211,8 +218,8 @@ namespace {
inline void delete_files(const char*fname) {
// delete files /tmp/fname.* UNLESS debug(debug_depth)
if(delete_f && !debug(debug_depth) && fname && fname[0]) {
char cmmd[512];
SNprintf(cmmd,512,"rm -f /tmp/%s.* > /dev/null 2>&1",fname);
char cmmd[PATH_MAX];
SNprintf(cmmd,PATH_MAX,"rm -f /tmp/%s.* > /dev/null 2>&1",fname);
DebugInfo(4,"executing \"%s\"\n",cmmd);
int rr=system(cmmd);
}
Expand Down Expand Up @@ -510,7 +517,7 @@ namespace {
"#define BD_TEST\n"
"#define body_func\n"
"#include <public/bodyfuncdefs.h>\n\n"
"real _P[10]={RNG()};\n\n"
"real _P[10]={static_cast<real>(RNG())};\n\n"
"extern \"C\" {\n"
" fieldset "<<ftype<<"(char&_type)\n"
" {\n"
Expand Down
6 changes: 3 additions & 3 deletions usr/dehnen/utils/make.clang
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ CXXFLAGS := $(STDAPI) $(OPTFLAGS)
endif

ifdef OPENMP
CXXFLAGS += -fopenmp
CFLAGS += -fopenmp
LDFLAGS := -shared -fopenmp $(PROFLAGS)
CXXFLAGS += $(OPENMP_CXXFLAGS)
CFLAGS += $(OPENMP_CXXFLAGS)
LDFLAGS := -shared -$(OPENMP_LINKFLAGS) $(PROFLAGS)
else
LDFLAGS := -shared $(PROFLAGS)
endif
Expand Down
6 changes: 3 additions & 3 deletions usr/dehnen/utils/make.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ CXXFLAGS := $(STDAPI) $(OPTFLAGS)
endif

ifdef OPENMP
CXXFLAGS += -fopenmp
CFLAGS += -fopenmp
LDFLAGS := -shared -fopenmp $(PROFLAGS)
CXXFLAGS += $(OPENMP_CXXFLAGS)
CFLAGS += $(OPENMP_CXXFLAGS)
LDFLAGS := -shared $(OPENMP_CXXFLAGS) $(PROFLAGS)
else
LDFLAGS := -shared $(PROFLAGS)
endif
Expand Down
2 changes: 2 additions & 0 deletions usr/dehnen/utils/make.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ NO_ARCH_NATIVE=@falcon_NO_NATIVE@

# if you want --fopenmp it should say "OPENMP=1"
@falcon_OPENMP@=1
OPENMP_CXXFLAGS=@falcon_OPENMP_CXXFLAGS@
OPENMP_LINKFLAGS=@falcon_OPENMP_LINKFLAGS@

# do or don't do shared libs. by default no, because of SIP on mac
NO_SHARED_LIBS=@NO_SHARED_LIBS@
Expand Down
2 changes: 1 addition & 1 deletion usr/dehnen/utils/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $(LIBT) :
# ---------

INCLUDE := -I$(INC)
LINKLIBS += $(CXXLIBS)
LINKLIBS += $(CXXLIBS) $(OPENMP_LINKFLAGS)

# math lib
ifndef MATHLIB
Expand Down