summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoreschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2011-04-22 22:40:24 +0000
committereschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2011-04-22 22:40:24 +0000
commit75edfc7e5b26ac5f07ce456035c1ff68a9541915 (patch)
tree9efefca0cb8c925a2954cd275a9a55e214e35322 /lib
parentcafed2018c1d03097e30d758ab77c20101e34632 (diff)
Reorder CUDA makefile rules
The rules to build CUDA source files are very similar to those for C and C++, and different from those for the Fortran. Reorder reorder these makefile rules to make the code easier to understand. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4700 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib')
-rw-r--r--lib/make/configure.in63
-rw-r--r--lib/make/make.config.rules.in66
2 files changed, 66 insertions, 63 deletions
diff --git a/lib/make/configure.in b/lib/make/configure.in
index 4705df39..eee68c61 100644
--- a/lib/make/configure.in
+++ b/lib/make/configure.in
@@ -177,6 +177,10 @@ if test "x$CXX" != 'xnone' ; then
AC_PROG_CXX_GNU
fi
+if test -z "$CUCC" ; then
+ AC_CHECK_PROGS(CUCC, nvcc)
+fi
+
if test -z "$RANLIB" ; then
AC_PROG_RANLIB
fi
@@ -193,10 +197,6 @@ if test -z "$FPP" ; then
AC_PATH_PROGS(FPP, cpp, echo, /lib:/usr/lib:/usr/local/lib:$PATH)
fi
-if test -z "$CUCC" ; then
- AC_CHECK_PROGS(CUCC, nvcc)
-fi
-
if test -z "$PERL" ; then
AC_CHECK_PROGS(PERL, perl)
fi
@@ -313,6 +313,10 @@ else
: ${CXX_WARN_FLAGS=''}
fi
+# nvcc itself doesn't have warning flags. warnings will be given by C compilers.
+AC_SUBST(CUCC_WARN_FLAGS)
+ : ${CUCC_WARN_FLAGS=''}
+
AC_SUBST(F77_WARN_FLAGS)
if test "$F77" = 'g77' ; then
: ${F77_WARN_FLAGS='-Wall'}
@@ -327,10 +331,6 @@ else
: ${F90_WARN_FLAGS=''}
fi
-# nvcc itself doesn't have warning flags. warnings will be given by C compilers.
-AC_SUBST(CUCC_WARN_FLAGS)
- : ${CUCC_WARN_FLAGS=''}
-
AC_SUBST(DEBUG_MODE)
DEBUG_MODE='no'
if test -n "$DEBUG_FLAGS"; then
@@ -351,15 +351,15 @@ AC_SUBST(C_DEBUG_FLAGS)
AC_SUBST(CXX_DEBUG_FLAGS)
: ${CXX_DEBUG_FLAGS='-g'}
+AC_SUBST(CUCC_DEBUG_FLAGS)
+: ${CUCC_DEBUG_FLAGS='-g'}
+
AC_SUBST(F77_DEBUG_FLAGS)
: ${F77_DEBUG_FLAGS='-g'}
AC_SUBST(F90_DEBUG_FLAGS)
: ${F90_DEBUG_FLAGS='-g'}
-AC_SUBST(CUCC_DEBUG_FLAGS)
-: ${CUCC_DEBUG_FLAGS='-g'}
-
# Set the optimization flags if they've not been set by now
# (using '-O2' as a reasonable default)
AC_SUBST(OPTIMISE_MODE)
@@ -376,6 +376,9 @@ AC_SUBST(C_OPTIMISE_FLAGS)
AC_SUBST(CXX_OPTIMISE_FLAGS)
: ${CXX_OPTIMISE_FLAGS='-O2'}
+AC_SUBST(CUCC_OPTIMISE_FLAGS)
+: ${CUCC_OPTIMISE_FLAGS='-O2'}
+
AC_SUBST(F77_OPTIMISE_FLAGS)
if test -z "$F77_OPTIMISE_FLAGS" -a "$F77" = 'g77' ; then
F77_OPTIMISE_FLAGS='-O2'
@@ -384,7 +387,10 @@ else
fi
AC_SUBST(F90_OPTIMISE_FLAGS)
-: ${F90_OPTIMISE_FLAGS=''}
+: ${F90_OPTIMISE_FLAGS='-O2'}
+
+# Set the no-optimization flags if they've not been set by now
+# (using '-O0' as a reasonable default)
AC_SUBST(C_NO_OPTIMISE_FLAGS)
: ${C_NO_OPTIMISE_FLAGS='-O0'}
@@ -392,15 +398,15 @@ AC_SUBST(C_NO_OPTIMISE_FLAGS)
AC_SUBST(CXX_NO_OPTIMISE_FLAGS)
: ${CXX_NO_OPTIMISE_FLAGS='-O0'}
+AC_SUBST(CUCC_NO_OPTIMISE_FLAGS)
+: ${CUCC_NO_OPTIMISE_FLAGS='-O0'}
+
AC_SUBST(F77_NO_OPTIMISE_FLAGS)
: ${F77_NO_OPTIMISE_FLAGS='-O0'}
AC_SUBST(F90_NO_OPTIMISE_FLAGS)
: ${F90_NO_OPTIMISE_FLAGS='-O0'}
-AC_SUBST(CUCC_OPTIMISE_FLAGS)
-: ${CUCC_OPTIMISE_FLAGS='-O2'}
-
# Set the profiling flags if they've not been set by now
# (using '-pg' as a reasonable default)
AC_SUBST(PROFILE_MODE)
@@ -417,15 +423,15 @@ AC_SUBST(C_PROFILE_FLAGS)
AC_SUBST(CXX_PROFILE_FLAGS)
: ${CXX_PROFILE_FLAGS='-pg'}
+AC_SUBST(CUCC_PROFILE_FLAGS)
+: ${CUCC_PROFILE_FLAGS=''}
+
AC_SUBST(F77_PROFILE_FLAGS)
: ${F77_PROFILE_FLAGS='-pg'}
AC_SUBST(F90_PROFILE_FLAGS)
: ${F90_PROFILE_FLAGS='-pg'}
-AC_SUBST(CUCC_PROFILE_FLAGS)
-: ${CUCC_PROFILE_FLAGS='-pg'}
-
# Set the OpenMP flags if they've not been set by now
AC_SUBST(OPENMP_MODE)
@@ -433,9 +439,9 @@ AC_SUBST(CPP_OPENMP_FLAGS)
AC_SUBST(FPP_OPENMP_FLAGS)
AC_SUBST(C_OPENMP_FLAGS)
AC_SUBST(CXX_OPENMP_FLAGS)
+AC_SUBST(CUCC_OPENMP_FLAGS)
AC_SUBST(F77_OPENMP_FLAGS)
AC_SUBST(F90_OPENMP_FLAGS)
-AC_SUBST(CUCC_OPENMP_FLAGS)
##########################################################################
@@ -589,9 +595,9 @@ AC_SUBST(USE_RANLIB)
AC_SUBST(RANLIBFLAGS)
: ${RANLIBFLAGS=-cs}
+AC_SUBST(CUCCFLAGS)
AC_SUBST(F90FLAGS)
AC_SUBST(F77FLAGS)
-AC_SUBST(CUCCFLAGS)
#: ${F90FLAGS="$CFLAGS"}
#: ${F77FLAGS="$CFLAGS"}
@@ -599,10 +605,10 @@ AC_SUBST(CUCCFLAGS)
AC_SUBST(CPP_VERSION)
AC_SUBST(CC_VERSION)
AC_SUBST(CXX_VERSION)
+AC_SUBST(CUCC_VERSION)
AC_SUBST(FPP_VERSION)
AC_SUBST(F77_VERSION)
AC_SUBST(F90_VERSION)
-AC_SUBST(CUCC_VERSION)
dnl Checks for library functions.
@@ -1195,6 +1201,11 @@ AC_SUBST(CXX_DEPEND)
AC_SUBST(CXX_DEPEND_OUT)
: ${CXX_DEPEND_OUT=' > $@'}
+AC_SUBST(CU_DEPEND)
+: ${CU_DEPEND='$(CUCC) -M'}
+AC_SUBST(CU_DEPEND_OUT)
+: ${CU_DEPEND_OUT=' > $@'}
+
AC_SUBST(F77_DEPEND)
: ${F77_DEPEND='$(FPP) -M $(FPPFLAGS)'}
AC_SUBST(F77_DEPEND_OUT)
@@ -1205,12 +1216,6 @@ AC_SUBST(F_DEPEND)
AC_SUBST(F_DEPEND_OUT)
: ${F_DEPEND_OUT=' > $@'}
-AC_SUBST(CU_DEPEND)
-: ${CU_DEPEND='$(CUCC) -M'}
-AC_SUBST(CU_DEPEND_OUT)
-: ${CU_DEPEND_OUT=' > $@'}
-
-
# How to generate F90 dependency info for modules
AC_SUBST(F_DEPEND_MODULES)
: ${F_DEPEND_MODULES='$(CCTK_HOME)/lib/sbin/f_depend_modules.pl'}
@@ -1222,14 +1227,14 @@ AC_SUBST(C_POSTPROCESSING)
: ${C_POSTPROCESSING=''}
AC_SUBST(CXX_POSTPROCESSING)
: ${CXX_POSTPROCESSING=''}
+AC_SUBST(CUCC_POSTPROCESSING)
+: ${CUCC_POSTPROCESSING=''}
AC_SUBST(F77_POSTPROCESSING)
: ${F77_POSTPROCESSING=''}
AC_SUBST(F_POSTPROCESSING)
: ${F_POSTPROCESSING=''}
AC_SUBST(F90_POSTPROCESSING)
: ${F90_POSTPROCESSING=''}
-AC_SUBST(CUCC_POSTPROCESSING)
-: ${CUCC_POSTPROCESSING=''}
# How to generate an intermediate C++ name (some compilers are very picky).
AC_SUBST(CXX_WORKING_NAME)
diff --git a/lib/make/make.config.rules.in b/lib/make/make.config.rules.in
index a909e367..4140696b 100644
--- a/lib/make/make.config.rules.in
+++ b/lib/make/make.config.rules.in
@@ -53,6 +53,11 @@ define CXX_DEPENDENCIES
$(DEPENDENCY_FIXER)
endef
+define CU_DEPENDENCIES
+ $(CU_DEPEND) $< $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE $(CU_DEPEND_OUT)
+ $(DEPENDENCY_FIXER)
+endef
+
define F77_DEPENDENCIES
$(F77_DEPEND) $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DFCODE $< $(F77_DEPEND_OUT)
$(DEPENDENCY_FIXER)
@@ -70,11 +75,6 @@ define F90_DEPENDENCIES
current_wd=`$(GET_WD)` ; { if test $(F_LINE_DIRECTIVES) = 'yes'; then echo '#line 1 "'$<'"'; fi; cat $<; } | $(PERL) -p -e 's.//.CCTK_AUTOMATICALLY_GENERATED_CONCATENATION_PROTECTION.g' | $(FPP) $(FPPFLAGS) $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DFCODE -DF90CODE | $(PERL) -p -e 's.CCTK_AUTOMATICALLY_GENERATED_CONCATENATION_PROTECTION.//.g' | $(PERL) $(F_DEPEND_MODULES) $< $(basename $(notdir $<)).F90.o $(SRCDIR) $(USESTHORNS:%=$$current_wd/../%) $(F_DEPEND_MODULES_OUT) || { rm $@; exit 1; }
endef
-define CU_DEPENDENCIES
- $(CU_DEPEND) $< $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE $(CU_DEPEND_OUT)
- $(DEPENDENCY_FIXER)
-endef
-
# No preprocessing, just create empty dependency file
define f77_DEPENDENCIES
echo "" > $@
@@ -91,21 +91,7 @@ define f90_DEPENDENCIES
current_wd=`$(GET_WD)` ; cat $< | $(PERL) $(F_DEPEND_MODULES) $< $(basename $(notdir $<)).f90.o $(SRCDIR) $(USESTHORNS:%=$$current_wd/../%) $(F_DEPEND_MODULES_OUT) || { rm $@; exit 1; }
endef
-#####################################################################
-# Define how to do a CUDA compilation
-# preporcess and postprocess are currently set the same as C.
-define PREPROCESS_CU
-{ if test $(C_LINE_DIRECTIVES) = 'yes'; then echo '#line 1 "'$<'"'; fi; cat $<; } | $(PERL) -s $(C_FILE_PROCESSOR) -line_directives=$(C_LINE_DIRECTIVES) -source_file_name=$< $(CONFIG) > $(notdir $<)
-#{ if test $(C_LINE_DIRECTIVES) = 'yes'; then echo '#line 1 "'$<'"'; fi; cat $<; } | $(CUCC) -E $< $(INCLUDE_LINE) > $(notdir $<)
-endef
-
-define COMPILE_CU
-current_wd=`$(GET_WD)` ; cd $(SCRATCH_BUILD) ; $(CUCC) $(CUCCFLAGS) $(CCOMPILEONLY)$(OPTIONSEP)$$current_wd$(DIRSEP)$@ $$current_wd$(DIRSEP)$(notdir $<) $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE
-endef
-define POSTPROCESS_CU
-$(CU_POSTPROCESSING)
-endef
# Define how to do a C compilation
define PREPROCESS_C
@@ -133,6 +119,19 @@ define POSTPROCESS_CXX
$(CXX_POSTPROCESSING)
endef
+# Define how to do a CUDA compilation
+define PREPROCESS_CU
+{ if test $(C_LINE_DIRECTIVES) = 'yes'; then echo '#line 1 "'$<'"'; fi; cat $<; } | $(PERL) -s $(C_FILE_PROCESSOR) -line_directives=$(C_LINE_DIRECTIVES) -source_file_name=$< $(CONFIG) > $(notdir $<)
+endef
+
+define COMPILE_CU
+current_wd=`$(GET_WD)` ; cd $(SCRATCH_BUILD) ; $(CUCC) $(CUCCFLAGS) $(CCOMPILEONLY)$(OPTIONSEP)$$current_wd$(DIRSEP)$@ $$current_wd$(DIRSEP)$(notdir $<) $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE
+endef
+
+define POSTPROCESS_CU
+$(CU_POSTPROCESSING)
+endef
+
# Define how to do a F77 compilation
define PREPROCESS_F77
{ if test $(F_LINE_DIRECTIVES) = 'yes'; then echo '#line 1 "'$<'"'; fi; cat $<; } | $(PERL) -p -e 's.//.CCTK_AUTOMATICALLY_GENERATED_CONCATENATION_PROTECTION.g' | $(FPP) $(FPPFLAGS) $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DFCODE | $(PERL) -p -e 's.CCTK_AUTOMATICALLY_GENERATED_CONCATENATION_PROTECTION.//.g' | $(PERL) -p -e 's/__FORTRANFILE__/\"$(basename $(notdir $<)).F77\"/g' | $(PERL) -s $(F_FILE_PROCESSOR) -line_directives=$(F_LINE_DIRECTIVES) -source_file_name=$< > $(basename $(notdir $<)).f
@@ -172,7 +171,6 @@ define POSTPROCESS_F90
$(F90_POSTPROCESSING)
endef
-
# Define how to do a f77 compilation
define PREPROCESS_f77
cat $< > $(basename $(notdir $<)).f
@@ -188,19 +186,7 @@ define PREPROCESS_f90
cat $< > $(basename $(notdir $<)).$(F90_SUFFIX)
endef
-# Build rules for CUDA
-
-%.cu.o: $(SRCDIR)/%.cu
- @echo Preprocessing $<
- $(PREPROCESS_CU)
- @echo Compiling $<
- $(COMPILE_CU)
- @echo Postprocessing $<
- $(POSTPROCESS_CU)
- @echo $(DIVIDER)
-%.cu.d: $(SRCDIR)/%.cu
- $(CU_DEPENDENCIES)
# Build rules for C
@@ -239,7 +225,6 @@ endef
$(POSTPROCESS_CXX)
@echo $(DIVIDER)
-
%.C.d: $(SRCDIR)/%.C
$(CXX_DEPENDENCIES)
@@ -265,10 +250,23 @@ endef
$(POSTPROCESS_CXX)
@echo $(DIVIDER)
-
%.cxx.d: $(SRCDIR)/%.cxx
$(CXX_DEPENDENCIES)
+# Build rules for CUDA
+
+%.cu.o: $(SRCDIR)/%.cu
+ @echo Preprocessing $<
+ $(PREPROCESS_CU)
+ @echo Compiling $<
+ $(COMPILE_CU)
+ @echo Postprocessing $<
+ $(POSTPROCESS_CU)
+ @echo $(DIVIDER)
+
+%.cu.d: $(SRCDIR)/%.cu
+ $(CU_DEPENDENCIES)
+
# Build rules for F77
%.F77.o: $(SRCDIR)/%.F77