Skip to content
Merged
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
94 changes: 76 additions & 18 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ CPPFLAGS
LDFLAGS
CXXFLAGS
CXX
PLUMED_ACC_GPU
PLUMED_ACC_TYPE
MPIEXEC
BASH_COMPLETION_DIR
PYTHON_BIN
Expand Down Expand Up @@ -764,6 +766,8 @@ LDSHARED
PYTHON_BIN
BASH_COMPLETION_DIR
MPIEXEC
PLUMED_ACC_TYPE
PLUMED_ACC_GPU
CXX
CXXFLAGS
LDFLAGS
Expand Down Expand Up @@ -1455,7 +1459,9 @@ Optional Features:
--enable-af_cpu enable search for arrayfire_cpu, default: no
--enable-libtorch enable search for libtorch, default: no
--enable-libmetatomic enable search for libmetatomic, default: no
--enable-openacc enable search for openacc, default: no
--enable-openacc enable search for openacc (use PLUMED_ACC_TYPE and
PLUMED_ACC_GPU for controlling the settings),
default: no
--disable-openmp do not use OpenMP

Some influential environment variables:
Expand All @@ -1472,6 +1478,12 @@ Some influential environment variables:
MPIEXEC command to run mpi programs in tests - default not specified,
which means use PLUMED_MPIRUN env var at runtime for backward
compatibility
PLUMED_ACC_TYPE
with --enable-openacc this is the setting ('host' or 'gpu') for
determining the target of the OPENACC pragmas - default: 'gpu'
PLUMED_ACC_GPU
if PLUMED_ACC_TYPE is 'gpu', this is read as a space separated
list of '-gpu' options for openacc (example "cc75 managed")
CXX C++ compiler command
CXXFLAGS C++ compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
Expand Down Expand Up @@ -3267,6 +3279,7 @@ fi




# by default use -O flag
# we override the autoconf default (-g) because in release build we do not want to
# include symbol information (obj files are huge)
Expand Down Expand Up @@ -10169,7 +10182,9 @@ fi

acc_found=ko
if test $openacc = true; then
acc_found=ko
if test -z "$PLUMED_ACC_TYPE"; then
PLUMED_ACC_TYPE=gpu
fi
# optional libraries follow

found=ko
Expand Down Expand Up @@ -10358,9 +10373,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext


save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -acc=gpu"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -acc=gpu" >&5
$as_echo_n "checking whether $CXX accepts -acc=gpu... " >&6; }
CXXFLAGS="$CXXFLAGS -acc=$PLUMED_ACC_TYPE"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -acc=$PLUMED_ACC_TYPE" >&5
$as_echo_n "checking whether $CXX accepts -acc=$PLUMED_ACC_TYPE... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

Expand Down Expand Up @@ -10402,18 +10417,61 @@ $as_echo "no" >&6; }; CXXFLAGS="$save_CXXFLAGS"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

#the cc must be an user input!!!!!!!!!!!!!!!!!!!!!
#use CXXFLAGS="-O3 -gpu=cc80" at configure time
#PLUMED_CHECK_CXXFLAG([-gpu=cc75])
#PLUMED_CHECK_CXXFLAG([-gpu=ccall])
#PLUMED_CHECK_CXXFLAG([-gpu=rdc])
#PLUMED_CHECK_CXXFLAG([-stdpar])
#PLUMED_CHECK_CXXFLAG([-gpu=managed])
#PLUMED_CHECK_LDFLAGS([-static-nvidia])
#PLUMED_CHECK_LDFLAGS([-acc])
if test "$PLUMED_ACC_TYPE" = "gpu"; then
if test -n "$PLUMED_ACC_GPU"; then
for flag in $PLUMED_ACC_GPU; do

save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -gpu=$flag"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -gpu=$flag" >&5
$as_echo_n "checking whether $CXX accepts -gpu=$flag... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not linking" >&5
$as_echo "not linking" >&6; }; CXXFLAGS="$save_CXXFLAGS"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext

else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }; CXXFLAGS="$save_CXXFLAGS"

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

done
fi
fi
LDSHARED="$LDSHARED -acc -static-nvidia"
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Please remember to add \"CXXFLAGS\" the compute capability flag of your device, for example \"-gpu=cc80\"" >&5
$as_echo "$as_me: WARNING: Please remember to add \"CXXFLAGS\" the compute capability flag of your device, for example \"-gpu=cc80\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Please remember to personalize the openacc settings with \"PLUMED_ACC_GPU\"" >&5
$as_echo "$as_me: WARNING: Please remember to personalize the openacc settings with \"PLUMED_ACC_GPU\"" >&2;}
fi
else
acc_found=ko
Expand Down Expand Up @@ -11313,8 +11371,8 @@ if test $openacc = true; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: **** PLUMED will be compiled using OPENACC" >&5
$as_echo "$as_me: **** PLUMED will be compiled using OPENACC" >&6;}
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: **** PLUMED will NOT be compiled using MPI because OPENACC have not been found!" >&5
$as_echo "$as_me: WARNING: **** PLUMED will NOT be compiled using MPI because OPENACC have not been found!" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: **** PLUMED will NOT be compiled using OPENACC because OPENACC have not been found!" >&5
$as_echo "$as_me: WARNING: **** PLUMED will NOT be compiled using OPENACC because OPENACC have not been found!" >&2;}
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: **** PLUMED will be compiled without OPENACC" >&5
Expand Down
31 changes: 16 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,16 @@ PLUMED_CONFIG_ENABLE([af_cuda],[search for arrayfire_cuda],[no])
PLUMED_CONFIG_ENABLE([af_cpu],[search for arrayfire_cpu],[no])
PLUMED_CONFIG_ENABLE([libtorch],[search for libtorch],[no]) #added by luigibonati
PLUMED_CONFIG_ENABLE([libmetatomic],[search for libmetatomic],[no])
PLUMED_CONFIG_ENABLE([openacc],[search for openacc],[no])
PLUMED_CONFIG_ENABLE([openacc],[search for openacc (use PLUMED_ACC_TYPE and PLUMED_ACC_GPU for controlling the settings)],[no])

AC_ARG_VAR(SOEXT,[extension of dynamic libraries (so/dylib)])
AC_ARG_VAR(STATIC_LIBS,[variables that should be linked statically directly to MD code - configure will add here -ldl if necessary ])
AC_ARG_VAR(LDSHARED,[command for linking shared library - configure will use CXX plus the proper flags ])
AC_ARG_VAR(PYTHON_BIN,[python executable (e.g. python2.7 or /opt/local/bin/python2.7) - default: search for a python executable])
AC_ARG_VAR(BASH_COMPLETION_DIR,[path where bash completion will be installed - default: search with pkg-config])
AC_ARG_VAR(MPIEXEC,[command to run mpi programs in tests - default not specified, which means use PLUMED_MPIRUN env var at runtime for backward compatibility])

AC_ARG_VAR(PLUMED_ACC_TYPE,[with --enable-openacc this is the setting ('host' or 'gpu') for determining the target of the OPENACC pragmas - default: 'gpu'])
AC_ARG_VAR(PLUMED_ACC_GPU,[if PLUMED_ACC_TYPE is 'gpu', this is read as a space separated list of '-gpu' options for openacc (example "cc75 managed")])
# by default use -O flag
# we override the autoconf default (-g) because in release build we do not want to
# include symbol information (obj files are huge)
Expand Down Expand Up @@ -1004,25 +1005,25 @@ fi

acc_found=ko
if test $openacc = true; then
acc_found=ko
if test -z "$PLUMED_ACC_TYPE"; then
PLUMED_ACC_TYPE=gpu
fi
# optional libraries follow
PLUMED_CHECK_PACKAGE([openacc.h],[acc_get_device_type],[__PLUMED_HAS_OPENACC])
if test "$__PLUMED_HAS_OPENACC" = yes; then
acc_found=ok
#test if we can compile with openacc
PLUMED_CHECK_CXXFLAG([-acc])
PLUMED_CHECK_CXXFLAG([-acc=gpu])
#the cc must be an user input!!!!!!!!!!!!!!!!!!!!!
#use CXXFLAGS="-O3 -gpu=cc80" at configure time
#PLUMED_CHECK_CXXFLAG([-gpu=cc75])
#PLUMED_CHECK_CXXFLAG([-gpu=ccall])
#PLUMED_CHECK_CXXFLAG([-gpu=rdc])
#PLUMED_CHECK_CXXFLAG([-stdpar])
#PLUMED_CHECK_CXXFLAG([-gpu=managed])
#PLUMED_CHECK_LDFLAGS([-static-nvidia])
#PLUMED_CHECK_LDFLAGS([-acc])
PLUMED_CHECK_CXXFLAG([-acc=$PLUMED_ACC_TYPE])
if test "$PLUMED_ACC_TYPE" = "gpu"; then
if test -n "$PLUMED_ACC_GPU"; then
for flag in $PLUMED_ACC_GPU; do
PLUMED_CHECK_CXXFLAG([-gpu=$flag])
done
fi
fi
LDSHARED="$LDSHARED -acc -static-nvidia"
AC_MSG_WARN([Please remember to add "CXXFLAGS" the compute capability flag of your device, for example "-gpu=cc80"])
AC_MSG_WARN([Please remember to personalize the openacc settings with "PLUMED_ACC_GPU"])
fi
else
acc_found=ko
Expand Down Expand Up @@ -1584,7 +1585,7 @@ if test $openacc = true; then
if test $acc_found = ok; then
AC_MSG_NOTICE([**** PLUMED will be compiled using OPENACC])
else
AC_MSG_WARN([**** PLUMED will NOT be compiled using MPI because OPENACC have not been found!])
AC_MSG_WARN([**** PLUMED will NOT be compiled using OPENACC because OPENACC have not been found!])
fi
else
AC_MSG_NOTICE([**** PLUMED will be compiled without OPENACC])
Expand Down
45 changes: 45 additions & 0 deletions new-manual/gpu.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,48 @@ command. GPU parallelism in PLUMED has been implemented using [openACC](https://
on these features at the moment. __There is thus no guarantee that the GPU accelerated versions of actions are any faster than
the CPU versions.__ If you have experimented with these features on your own calculations we would love to hear from you (even
if your experience was negative.)

## [Experimental] Compiling plumed with openacc

_This section will likely be moved in the proper installation page_

To compile PLUMED with openacc enabled you will need to have the [NVIDIA HPC SDK](https://developer.nvidia.com/hpc-sdk) avaiable on your path.

Plumed is tested with the [24.3](https://developer.nvidia.com/nvidia-hpc-sdk-243-downloads) version.

To prepare the compilation add `--enable-opeacc` to the `./configure` options.
It is also possible to pass some extra options by exporting or specifying the the following variables:
- **PLUMED_ACC_TYPE**: if omitted defaults to `gpu`, can be changed to `host` or `multicore` to try a compilation that targets the CPU also for the openacc accellerate part of the code.
- **PLUMED_ACC_GPU**: if `PLUMED_ACC_TYPE` is set to `gpu`, it can be used to specify a range of `-gpu` optios to pass to the nvhpc compiler (for example the target gpu, see the [compiler manual](https://docs.nvidia.com/hpc-sdk/compilers/hpc-compilers-user-guide/index.html) for the options) options can be comma separated or space separated


!!! warning
(Currently) modules that use a custom openmp reduction can be compiled with nvhpc.
Currently `membranefusion` is not compatible and should be excluded from the compilation


## List of actions that can be called with the USEGPU option:

- module:
- ACTION

- colvar:
- [ANGLE](ANGLE.md)
- [DIPOLE](DIPOLE.md)
- [DISTANCE](DISTANCE.md)
- [PLANE](PLANE.md)
- [POSITION](POSITION.md)
- [TORSION](TORSION.md)
- crystdistrib:
- ~~[QUATERNION_BOND_PRODUCT_MATRIX](QUATERNION_BOND_PRODUCT_MATRIX.md)~~ setup, but deactivated
- secondarystructure:
- [SECONDARY_STRUCTURE_DRMSD](SECONDARY_STRUCTURE_DRMSD.md), and in particular:
- [ALPHARMSD](ALPHARMSD.md) only with **TYPE=DRMSD**
- [ANTIBETARMSD](ANTIBETARMSD.md) only with **TYPE=DRMSD**
- [PARABETARMSD](PARABETARMSD.md) only with **TYPE=DRMSD**
- volumes:
- [AROUND](AROUND.md)
- [INCYLINDER](INCYLINDER.md)
- [INSPHERE](INSPHERE.md)
- adjmat
- [CONTACT_MATRIX](CONTACT_MATRIX.md)