Skip to content

Commit aa97a05

Browse files
authored
Merge pull request #345 from CFD-GO/develop
Version 6.5.1
2 parents 756d304 + e162aac commit aa97a05

10 files changed

+105
-9
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ env:
4545
- MODEL=d3q27
4646
- MODEL=d3q27_cumulant
4747
- MODEL=d3q27_cumulant_AVG_IB_SMAG
48+
- MODEL=d2q9_adj
4849

4950
before_install:
5051
- tools/install.sh rdep
5152
- tools/install.sh rinside
5253
- sudo tools/install.sh python-dev
5354
- tools/install.sh submodules
55+
- "[[ ! $MODEL =~ _adj$ ]] || tools/install.sh tapenade"
5456

5557
install:
5658
- nvcc --version

src/Handlers/cbStop.cpp.Rt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ int cbStop::Init () {
2222
for (g in rows(Globals)) { ?>
2323
attr = node.attribute("<?%s g$name ?>Change");
2424
if (attr) AddStop(<?%s g$Index ?>, STOP_CHANGE, attr.as_double());
25+
attr = node.attribute("<?%s g$name ?>PercentChange");
26+
if (attr) AddStop(<?%s g$Index ?>, STOP_PERCENTCHANGE, attr.as_double());
2527
attr = node.attribute("<?%s g$name ?>Above");
2628
if (attr) AddStop(<?%s g$Index ?>, STOP_ABOVE, attr.as_double());
2729
attr = node.attribute("<?%s g$name ?>Below");
@@ -63,6 +65,10 @@ int cbStop::DoIt () {
6365
if (fabs(old[i] - v) > limit[i]) any++;
6466
if (D_MPI_RANK == 0) output(" change: %4lg < %4lg", fabs(old[i] - v), limit[i]);
6567
break;
68+
case STOP_PERCENTCHANGE:
69+
if (fabs((old[i] - v)/v) > limit[i]) any++;
70+
if (D_MPI_RANK == 0) output(" change: %4lg%% < %4lg%%", 100.0 * fabs((old[i] - v)/v), 100.0 * limit[i]);
71+
break;
6672
case STOP_ABOVE:
6773
if (v < limit[i]) any++;
6874
if (D_MPI_RANK == 0) output(" limit: %4lg > %4lg", v, limit[i]);

src/Handlers/cbStop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#define STOP_CHANGE 0x01
1010
#define STOP_ABOVE 0x02
1111
#define STOP_BELOW 0x03
12+
#define STOP_PERCENTCHANGE 0x04
1213

1314
class cbStop : public Callback {
1415
std::vector< int > what;

src/LatticeContainer.inc.cpp.Rt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ template <class N> CudaGlobalFunction void RunKernel()
268268
now.x_ = CudaThread.x + CudaBlock.z*CudaNumberOfThreads.x + constContainer.dx;
269269
now.y_ = CudaThread.y + CudaBlock.x*CudaNumberOfThreads.y + constContainer.dy;
270270
now.z_ = CudaBlock.y+constContainer.dz;
271-
#ifndef GRID_3D
271+
#ifndef GRID3D
272272
for (; now.x_ < constContainer.nx; now.x_ += CudaNumberOfThreads.x) {
273273
#endif
274274
now.Pre();
@@ -278,7 +278,7 @@ template <class N> CudaGlobalFunction void RunKernel()
278278
now.OutOfDomain();
279279
}
280280
now.Glob();
281-
#ifndef GRID_3D
281+
#ifndef GRID3D
282282
}
283283
#endif
284284
}
@@ -445,7 +445,7 @@ template <class N> inline void LatticeContainer::RunInteriorT(CudaStream_t inter
445445
int nnz;
446446
ky = ThreadNumber< N >::getKY();
447447
nnz = fz - dz;
448-
#ifdef GRID_3D
448+
#ifdef GRID3D
449449
CudaKernelRunNoWait( RunKernel<N> , dim3(ky, nnz, kx) , dim3(X_BLOCK,ThreadNumber< N >::getSY()),(),interiorStream);
450450
#else
451451
CudaKernelRunNoWait( RunKernel<N> , dim3(ky, nnz, 1) , dim3(X_BLOCK,ThreadNumber< N >::getSY()),(),interiorStream);

src/Makefile.in.Rt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ LIBS := @R_LIB@ @LIBS@ @RCPP_LD@ -Xlinker -rpath -Xlinker $(MPI_LIBS) -L$(MPI_LI
2525

2626
TARGETS := CLB.so
2727

28-
NVCC := @CUDA_HOME@/bin/nvcc -gencode arch=compute_10,code=sm_10 -gencode arch=compute_11,code=sm_11 -gencode arch=compute_12,code=sm_12 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_60,code=sm_60
28+
NVCC := @CUDA_HOME@/bin/nvcc -gencode arch=compute_10,code=sm_10 -gencode arch=compute_11,code=sm_11 -gencode arch=compute_12,code=sm_12 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_60,code=sm_60, -gencode arch=compute_75,code=sm_75
2929

3030
all: $(TARGETS)
3131

src/config.main.mk.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ TOOLS = tools
99
RT = $(TOOLS)/RT -b
1010
MKPATH = $(TOOLS)/mkpath
1111
RS = R --slave --quiet --vanilla -f
12+
TAPENADE = @TAPENADE@
1213
ADMOD = tools/ADmod.R
1314

1415
RTOPT=@RTOPT@

src/configure.ac

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ AC_ARG_ENABLE([cpp11],
5151

5252
AC_ARG_WITH([cuda-arch],
5353
AC_HELP_STRING([--with-cuda-arch=arch],
54-
[specify the desired CUDA architecture (sm_11/sm_13/sm_20/sm_30/sm_60)]))
54+
[specify the desired CUDA architecture (sm_11/sm_13/sm_20/sm_30/sm_60/sm_75)]))
5555

5656
AC_ARG_WITH([nlopt],
5757
AC_HELP_STRING([--with-nlopt=nlopt],
@@ -76,6 +76,10 @@ AC_ARG_WITH([lammps],
7676
AC_ARG_WITH([lammps-lib],
7777
AC_HELP_STRING([--with-lammps-lib=libfile],
7878
[specify the name of the lammps/liggghts library (.so/.a)]))
79+
80+
AC_ARG_WITH([tapenade],
81+
AC_HELP_STRING([--with-tapenade=path],
82+
[use tapenade for code differentiation for adjoint]))
7983

8084

8185
AC_ARG_WITH([verbosity_level],
@@ -281,7 +285,14 @@ then
281285
AC_MSG_RESULT([${CUDA_ARCH}])
282286
AC_DEFINE([GRID3D], [1], [Using 3D block grid in CUDA])
283287

284-
CUDA_SUFF="60"
288+
CUDA_SUFF="60"
289+
290+
elif test "$CUDA_ARCH" == "sm_75"
291+
then
292+
AC_MSG_RESULT([${CUDA_ARCH}])
293+
AC_DEFINE([GRID3D], [1], [Using 3D block grid in CUDA])
294+
295+
CUDA_SUFF="75"
285296
else
286297
AC_MSG_ERROR([unknown arch ${CUDA_ARCH}])
287298
fi
@@ -655,6 +666,44 @@ then
655666
fi
656667
fi
657668

669+
if test "x${with_tapenade}" != "xno"
670+
then
671+
if test "x${with_tapenade}" == "xyes" || test "x${with_tapenade}" == "x"
672+
then
673+
if test -f "tapenade/bin/tapenade"
674+
then
675+
TAPENADE="$PWD/tapenade/bin/tapenade"
676+
else
677+
TAPENADE="tapenade"
678+
fi
679+
else
680+
if test -d "${with_tapenade}"
681+
then
682+
TAPENADE="$(cd ${with_tapenade}; pwd)/bin/tapenade"
683+
else
684+
AC_MSG_ERROR([Path '${with_tapenade}' is not a directory])
685+
fi
686+
fi
687+
688+
689+
AC_MSG_CHECKING([for tapenade])
690+
if command -v "${TAPENADE}" >/dev/null 2>&1
691+
then
692+
AC_MSG_RESULT([yes])
693+
TAPENADE="$(command -v "${TAPENADE}")"
694+
else
695+
AC_MSG_RESULT([no])
696+
TAPENADE=""
697+
if test "x${with_tapenade}" != "x"
698+
then
699+
AC_MSG_ERROR([Tapenade '$TAPENADE' is not a valid executable])
700+
fi
701+
fi
702+
fi
703+
704+
705+
706+
658707
if test "x${enable_debug}" == "xyes"
659708
then
660709
if test "x${with_verbosity_level}" == "x"
@@ -779,6 +828,7 @@ AC_SUBST(CROSS_CPU)
779828
AC_SUBST(WITH_CATALYST)
780829
AC_SUBST(WITH_LAMMPS)
781830
AC_SUBST(WITH_R)
831+
AC_SUBST(TAPENADE)
782832
AC_SUBST(PV_VERSION)
783833
AC_SUBST(RTOPT)
784834
AC_SUBST(CPP_OPT)

src/makefile.main.Rt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ wiki/schema/<?%s m ?>.xsd:$(SRC)/schema.xsd.Rt $(SRC)/conf.R doc/elements.yaml <
211211

212212
<?%s d ?>/<?%s m ?>/tapenade.run : tools/makeAD <?%s d ?>/<?%s m ?>/Dynamics.c <?%s d ?>/<?%s m ?>/ADpre.h <?%s d ?>/<?%s m ?>/ADpre_b.h <?%s d ?>/<?%s m ?>/Dynamics.h <?%s d ?>/<?%s m ?>/Consts.h <?%s d ?>/<?%s m ?>/types.h <?%s d ?>/<?%s m ?>/ADset.sh <?%s d ?>/<?%s m ?>/ADpost.sed
213213
@echo " TAPENADE $<"
214-
@(cd <?%s d ?>/<?%s m ?>; ../../tools/makeAD)
214+
@(cd <?%s d ?>/<?%s m ?>; ../../tools/makeAD "$(TAPENADE)")
215215

216216
<?%s d ?>/<?%s m ?>/dep.mk:tools/dep.R <?%s src ?>
217217
@echo " AUTO-DEP $@"

tools/install.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,29 @@ do
393393
try "Leaving module directory" cd ..
394394
try "Remember to restart terminal" . ~/.bashrc
395395
;;
396+
tapenade)
397+
if echo "$2" | grep -Eq '^[0-9]*[.][0-9]*$'
398+
then
399+
shift
400+
VER="$1"
401+
else
402+
VER="3.16"
403+
fi
404+
if test -d ../tapenade
405+
then
406+
echo "Looks like tapenade already is installed at '$(cd ../tapenadel; pwd))'"
407+
exit -1
408+
fi
409+
try "Downloading Tapenade ($VER)" wget $WGETOPT http://www-sop.inria.fr/ecuador/tapenade/distrib/tapenade_$VER.tar
410+
try "Unpacking Tapenade" tar xf tapenade_$VER.tar
411+
if test -d tapenade_$VER
412+
then
413+
mv tapenade_$VER ../tapenade
414+
echo "Installed Tapenade at '$(cd ../tapenade; pwd)'"
415+
else
416+
echo "Tapenade installation failed"
417+
fi
418+
;;
396419
-*)
397420
echo "Unknown option $1" ; usage ;;
398421
*)

tools/makeAD

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
path_to_script=$(dirname $0)
44
#cd package/src
5+
6+
if test -z "$1"
7+
then
8+
TAPENADE="tapenade"
9+
else
10+
TAPENADE="$1"
11+
fi
12+
if ! command -v "$TAPENADE"
13+
then
14+
echo "Tapenade not found ('$TAPENADE')" >&2
15+
exit -1
16+
fi
17+
518
. ADset.sh
619
rm Dynamics_tmp.c Dynamics_b.c* ADpre_.h types_b.h tmp 2>/dev/null
720
echo "#define CudaDeviceFunction" > Dynamics_tmp.c
@@ -16,11 +29,11 @@ cat Dynamics.c | sed 's/pow(\([^,]*\),3)/((\1)*(\1)*(\1))/g' >> Dynamics_tmp.c
1629
echo Variables for differentiation: $VARIABLES
1730
echo Additional variables for differentiation: $SETTINGS
1831
echo tapenade -html -msglevel 12 -b Dynamics_tmp.c -root $MAIN_FUN -o DynamicsS -vars "$VARIABLES $SETTINGS" -outvars "$VARIABLES $SETTINGS"
19-
tapenade -msglevel 12 -b Dynamics_tmp.c -root $MAIN_FUN -o DynamicsS -vars "$VARIABLES $SETTINGS" -outvars "$VARIABLES $SETTINGS"
32+
$TAPENADE -msglevel 12 -b Dynamics_tmp.c -root $MAIN_FUN -o DynamicsS -vars "$VARIABLES $SETTINGS" -outvars "$VARIABLES $SETTINGS"
2033
echo "#define CONST_SETTINGS" > ADpre_.h
2134
cat ADpre.h >> ADpre_.h
2235
echo tapenade -html -msglevel 12 -b Dynamics_tmp.c -root $MAIN_FUN -o DynamicsS -vars "$VARIABLES $SETTINGS" -outvars "$VARIABLES $SETTINGS"
23-
tapenade -msglevel 12 -b Dynamics_tmp.c -root $MAIN_FUN -o Dynamics -vars "$VARIABLES" -outvars "$VARIABLES"
36+
$TAPENADE -msglevel 12 -b Dynamics_tmp.c -root $MAIN_FUN -o Dynamics -vars "$VARIABLES" -outvars "$VARIABLES"
2437
for f in Dynamics_b.c DynamicsS_b.c
2538
do
2639
test -f $f || { echo "Tapenade failed"; exit -1; }

0 commit comments

Comments
 (0)