summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/UsersGuide.pdfbin875651 -> 790896 bytes
-rw-r--r--doc/UsersGuide/ApplicationThorns.tex27
-rwxr-xr-xlib/make/configure35
-rw-r--r--lib/make/configure.in18
-rw-r--r--lib/make/force-reconfigure1
-rw-r--r--lib/make/make.config.defn.in3
-rw-r--r--lib/make/make.config.rules.in40
7 files changed, 110 insertions, 14 deletions
diff --git a/doc/UsersGuide.pdf b/doc/UsersGuide.pdf
index a3db342c..c4b90484 100644
--- a/doc/UsersGuide.pdf
+++ b/doc/UsersGuide.pdf
Binary files differ
diff --git a/doc/UsersGuide/ApplicationThorns.tex b/doc/UsersGuide/ApplicationThorns.tex
index c7fe58ab..a1f18da8 100644
--- a/doc/UsersGuide/ApplicationThorns.tex
+++ b/doc/UsersGuide/ApplicationThorns.tex
@@ -744,15 +744,16 @@ The following extensions are understood:
\hline
Extension & Language & Format & Preprocess \\
\hline
-{\t .F} & Fortran 90 & fixed & yes \\
-{\t .f} & Fortran 90 & fixed & no \\
+{\t .c} & C & - & yes \\
+{\t .cc} or {\t .C} & C++ & - & yes \\
+{\t .cl} & OpenCL & - & yes \\
+{\t .cu} & CUDA & - & yes \\
{\t .F90} & Fortran 90 & free & yes \\
{\t .f90} & Fortran 90 & free & no \\
+{\t .F} & Fortran 90 & fixed & yes \\
+{\t .f} & Fortran 90 & fixed & no \\
{\t .F77} & Fortran 77 & fixed & yes \\
{\t .f77} & Fortran 77 & fixed & no \\
-{\t .c} & C & - & yes \\
-{\t .cc} or {\t .C} & C++ & - & yes \\
-{\t .cu} & CUDA & - & yes \\
\hline
\end{tabular}
\end{center}
@@ -858,15 +859,15 @@ and has a working directory of
\texttt{CC}, and to \texttt{CXX}
\item \texttt{FPPFLAGS}: Flags which are passed to \texttt{FPP}
\item \texttt{CC}: The C compiler
-\item \texttt{CUDA}: The CUDA compiler
\item \texttt{CXX}: The C++ compiler
+\item \texttt{CUCC}: The CUDA compiler
\item \texttt{F77}: The Fortran 77 compiler. This is only used if
there is no Fortran 90 compiler
\item \texttt{F90}: The Fortran 90 compiler. If this variable is
set, it is also used to compile Fortran 77 files
\item \texttt{CFLAGS}: Flags which are passed to \texttt{CC}
-\item \texttt{CUDAFLAGS}: Flags which are passed to \texttt{CUDA}
\item \texttt{CXXFLAGS}: Flags which are passed to \texttt{CXX}
+\item \texttt{CUCCFLAGS}: Flags which are passed to \texttt{CUDA}
\item \texttt{F77FLAGS}: Flags which are passed to \texttt{F77}
\item \texttt{F90FLAGS}: Flags which are passed to \texttt{F90}
\item \texttt{LD}: The binder. This should not be directly
@@ -875,6 +876,18 @@ and has a working directory of
\item \texttt{LDFLAGS}: Flags which are passed to \texttt{LD}
\end{itemize}
+Note that there are no makefile variables to specify an OpenCL
+compiler or its flags. OpenCL is implemented as a library, and code is
+compiled at run time via library functions to which the source code is
+passed as a string. OpenCL source code (files with the extension
+\texttt{.cl}) are thus not compiled when a Cactus configuration is
+built. Instead, the content of \texttt{.cl} files is converted into a
+string and placed into the executable. These strings have the type
+\texttt{char~const~*} in C, and can be accessed at run time under a
+(globally visible) name \texttt{OpenCL\_source\_THORN\_FILE}, where
+\texttt{THORN} and \texttt{FILE} and are the thorn name and file name,
+respectively.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/lib/make/configure b/lib/make/configure
index c7da6753..858bf2ae 100755
--- a/lib/make/configure
+++ b/lib/make/configure
@@ -6865,10 +6865,10 @@ cat > conftest.$ac_ext <<EOF
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char bAuCWJ;
+char a88VAc;
int main() {
-ondO02
+rLztEw
; return 0; }
EOF
if { (eval echo configure:6875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
@@ -7353,6 +7353,14 @@ if test "$host_os" = 'cygwin' ; then
PERL_CONFIGURE_SCRIPT=`echo $PERL_CONFIGURE_SCRIPT | sed 's,^/cygdrive/\(.\)/,\1:/,' | sed 's,^//\(.\)/,\1:/,'`
fi
+# An OpenCL source file has no external dependencies
+
+# This command will not output a correct dependency by itself (it
+# does not output a target), but the Cactus dependency fixer will
+# overwrite the target anyway with the correct information.
+: ${CL_DEPEND='echo :'}
+
+: ${CL_DEPEND_OUT=' > $@'}
BUILD_ACTIVETHORNS='$(CCTK_HOME)/lib/sbin/BuildActiveThorns.pl'
@@ -7375,6 +7383,14 @@ LDFLAGS="$LDFLAGS $KNOWN_LDFLAGS"
: ${CCOMPILEONLY='-c -o'}
: ${FCOMPILEONLY='-c -o'}
+# An OpenCL source file has no external dependencies
+
+# This command will not output a correct dependency by itself (it
+# does not output a target), but the Cactus dependency fixer will
+# overwrite the target anyway with the correct information.
+: ${CL_DEPEND='echo :'}
+
+: ${CL_DEPEND_OUT=' > $@'}
# Set the createexe flag if it's not been set by now
@@ -7436,6 +7452,8 @@ LDFLAGS="$LDFLAGS $KNOWN_LDFLAGS"
: ${CXX_POSTPROCESSING=''}
+: ${CL_POSTPROCESSING=''}
+
: ${CU_POSTPROCESSING=''}
: ${F77_POSTPROCESSING=''}
@@ -7527,7 +7545,7 @@ if test "x$CCTK_NEED_X" = 'xyes' ; then
# Uses ac_ vars as temps to allow command line to override cache and checks.
# --without-x overrides everything else, but does not touch the cache.
echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:7531: checking for X" >&5
+echo "configure:7549: checking for X" >&5
# Check whether --with-x or --without-x was given.
if test "${with_x+set}" = set; then
@@ -7589,12 +7607,12 @@ if test "$ac_x_includes" = NO; then
# First, try using that file with no special directory specified.
cat > conftest.$ac_ext <<EOF
-#line 7593 "configure"
+#line 7611 "configure"
#include "confdefs.h"
#include <$x_direct_test_include>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7598: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7616: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -7663,14 +7681,14 @@ if test "$ac_x_libraries" = NO; then
ac_save_LIBS="$LIBS"
LIBS="-l$x_direct_test_library $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 7667 "configure"
+#line 7685 "configure"
#include "confdefs.h"
int main() {
${x_direct_test_function}()
; return 0; }
EOF
-if { (eval echo configure:7674: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7692: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
LIBS="$ac_save_LIBS"
# We can link X programs with no special library path.
@@ -7998,6 +8016,8 @@ s%@EXE@%$EXE%g
s%@C_LINE_DIRECTIVES@%$C_LINE_DIRECTIVES%g
s%@F_LINE_DIRECTIVES@%$F_LINE_DIRECTIVES%g
s%@MKDIRFLAGS@%$MKDIRFLAGS%g
+s%@CL_DEPEND@%$CL_DEPEND%g
+s%@CL_DEPEND_OUT@%$CL_DEPEND_OUT%g
s%@BUILD_ACTIVETHORNS@%$BUILD_ACTIVETHORNS%g
s%@CST@%$CST%g
s%@F_FILE_PROCESSOR@%$F_FILE_PROCESSOR%g
@@ -8024,6 +8044,7 @@ s%@F_DEPEND_MODULES@%$F_DEPEND_MODULES%g
s%@F_DEPEND_MODULES_OUT@%$F_DEPEND_MODULES_OUT%g
s%@C_POSTPROCESSING@%$C_POSTPROCESSING%g
s%@CXX_POSTPROCESSING@%$CXX_POSTPROCESSING%g
+s%@CL_POSTPROCESSING@%$CL_POSTPROCESSING%g
s%@CU_POSTPROCESSING@%$CU_POSTPROCESSING%g
s%@F77_POSTPROCESSING@%$F77_POSTPROCESSING%g
s%@F_POSTPROCESSING@%$F_POSTPROCESSING%g
diff --git a/lib/make/configure.in b/lib/make/configure.in
index df2dc0ca..b673cbd3 100644
--- a/lib/make/configure.in
+++ b/lib/make/configure.in
@@ -1186,6 +1186,14 @@ if test "$host_os" = 'cygwin' ; then
PERL_CONFIGURE_SCRIPT=`echo $PERL_CONFIGURE_SCRIPT | sed 's,^/cygdrive/\(.\)/,\1:/,' | sed 's,^//\(.\)/,\1:/,'`
fi
+# An OpenCL source file has no external dependencies
+AC_SUBST(CL_DEPEND)
+# This command will not output a correct dependency by itself (it
+# does not output a target), but the Cactus dependency fixer will
+# overwrite the target anyway with the correct information.
+: ${CL_DEPEND='echo :'}
+AC_SUBST(CL_DEPEND_OUT)
+: ${CL_DEPEND_OUT=' > $@'}
AC_SUBST(BUILD_ACTIVETHORNS)
BUILD_ACTIVETHORNS='$(CCTK_HOME)/lib/sbin/BuildActiveThorns.pl'
@@ -1208,6 +1216,14 @@ AC_SUBST(FCOMPILEONLY)
: ${CCOMPILEONLY='-c -o'}
: ${FCOMPILEONLY='-c -o'}
+# An OpenCL source file has no external dependencies
+AC_SUBST(CL_DEPEND)
+# This command will not output a correct dependency by itself (it
+# does not output a target), but the Cactus dependency fixer will
+# overwrite the target anyway with the correct information.
+: ${CL_DEPEND='echo :'}
+AC_SUBST(CL_DEPEND_OUT)
+: ${CL_DEPEND_OUT=' > $@'}
# Set the createexe flag if it's not been set by now
AC_SUBST(CREATEEXE)
@@ -1268,6 +1284,8 @@ AC_SUBST(C_POSTPROCESSING)
: ${C_POSTPROCESSING=''}
AC_SUBST(CXX_POSTPROCESSING)
: ${CXX_POSTPROCESSING=''}
+AC_SUBST(CL_POSTPROCESSING)
+: ${CL_POSTPROCESSING=''}
AC_SUBST(CU_POSTPROCESSING)
: ${CU_POSTPROCESSING=''}
AC_SUBST(F77_POSTPROCESSING)
diff --git a/lib/make/force-reconfigure b/lib/make/force-reconfigure
index 53750b59..dbac1c08 100644
--- a/lib/make/force-reconfigure
+++ b/lib/make/force-reconfigure
@@ -30,3 +30,4 @@
30 Mar 2011: Add variables MAKE, TAR, GZIP_CMD, PATCH, GIT
26 Apr 2011: Add CCTK_BUILTIN_EXPECT
27 Jun 2011: Add HAVE_SCHED_H
+01 May 2012: Add OpenCL support
diff --git a/lib/make/make.config.defn.in b/lib/make/make.config.defn.in
index f894820c..b8739498 100644
--- a/lib/make/make.config.defn.in
+++ b/lib/make/make.config.defn.in
@@ -146,6 +146,7 @@ export CACTUSLIBLINKLINE = @CACTUSLIBLINKLINE@
# Dependency file generation
export C_DEPEND = @C_DEPEND@
export CXX_DEPEND = @CXX_DEPEND@
+export CL_DEPEND = @CL_DEPEND@
export F77_DEPEND = @F77_DEPEND@
export F_DEPEND = @F_DEPEND@
export F_DEPEND_MODULES = @F_DEPEND_MODULES@
@@ -153,6 +154,7 @@ export CU_DEPEND = @CU_DEPEND@
export C_DEPEND_OUT = @C_DEPEND_OUT@
export CXX_DEPEND_OUT = @CXX_DEPEND_OUT@
+export CL_DEPEND_OUT = @CL_DEPEND_OUT@
export F77_DEPEND_OUT = @F77_DEPEND_OUT@
export F_DEPEND_OUT = @F_DEPEND_OUT@
export F_DEPEND_MODULES_OUT = @F_DEPEND_MODULES_OUT@
@@ -167,6 +169,7 @@ export F90_SUFFIX = @F90_SUFFIX@
# How to postprocess object files
export C_POSTPROCESSING = @C_POSTPROCESSING@
export CXX_POSTPROCESSING = @CXX_POSTPROCESSING@
+export CL_POSTPROCESSING = @CL_POSTPROCESSING@
export F77_POSTPROCESSING = @F77_POSTPROCESSING@
export F_POSTPROCESSING = @F_POSTPROCESSING@
export F90_POSTPROCESSING = @F90_POSTPROCESSING@
diff --git a/lib/make/make.config.rules.in b/lib/make/make.config.rules.in
index cec72a91..caef245d 100644
--- a/lib/make/make.config.rules.in
+++ b/lib/make/make.config.rules.in
@@ -83,6 +83,12 @@ define CXX_DEPENDENCIES
$(DEPENDENCY_FIXER)
endef
+define CL_DEPENDENCIES
+# An OpenCL source file has no external dependencies
+ $(CL_DEPEND) $< $(CL_DEPEND_OUT)
+ $(DEPENDENCY_FIXER)
+endef
+
define CU_DEPENDENCIES
$(CU_DEPEND) $< $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE $(CU_DEPEND_OUT)
$(DEPENDENCY_FIXER)
@@ -149,6 +155,26 @@ define POSTPROCESS_CXX
$(CXX_POSTPROCESSING)
endef
+# Define how to do an OpenCL compilation
+define PREPROCESS_CL
+# Wrap the OpenCL source code into a string, using the thorn name and
+# file name to create a variable name, and create a C file
+{ \
+ echo 'char const *const OpenCL_source_$(THORN)_$* ='; \
+ sed -e 's/\\/\\\\/g;s/"/\\"/g;s/\(.*\)/"\1\\n"/g'; \
+ echo ';'; \
+} < $^ > $(notdir $<).c
+endef
+
+define COMPILE_CL
+# Basically a C compile, but with a different source file name
+current_wd=`$(GET_WD)` ; cd $(SCRATCH_BUILD) ; $(CC) $(CPPFLAGS) $(CFLAGS) $(CCOMPILEONLY)$(OPTIONSEP)$$current_wd$(DIRSEP)$@ $$current_wd$(DIRSEP)$(notdir $<).c $(INCLUDE_LINE) $(EXTRA_DEFINES:%=-D%) -DCCODE
+endef
+
+define POSTPROCESS_CL
+$(CL_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 $<)
@@ -283,6 +309,20 @@ endef
%.cxx.d: $(SRCDIR)/%.cxx
$(CXX_DEPENDENCIES)
+# Build rules for OpenCL
+
+%.cl.o: $(SRCDIR)/%.cl
+ $(NOTIFY_PREPROCESSING)
+ $(PREPROCESS_CL)
+ $(NOTIFY_COMPILING)
+ $(COMPILE_CL)
+ $(NOTIFY_POSTPROCESSING)
+ $(POSTPROCESS_CL)
+ $(NOTIFY_DIVIDER)
+
+%.cl.d: $(SRCDIR)/%.cl
+ $(CL_DEPENDENCIES)
+
# Build rules for CUDA
%.cu.o: $(SRCDIR)/%.cu