diff --git a/configure b/configure index 8b631ccd7d..9e34dc28e5 100755 --- a/configure +++ b/configure @@ -660,6 +660,8 @@ CPPFLAGS LDFLAGS CXXFLAGS CXX +PLUMED_ACC_GPU +PLUMED_ACC_TYPE MPIEXEC BASH_COMPLETION_DIR PYTHON_BIN @@ -764,6 +766,8 @@ LDSHARED PYTHON_BIN BASH_COMPLETION_DIR MPIEXEC +PLUMED_ACC_TYPE +PLUMED_ACC_GPU CXX CXXFLAGS LDFLAGS @@ -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: @@ -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 if you have libraries in a @@ -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) @@ -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 @@ -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. */ @@ -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 @@ -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 diff --git a/configure.ac b/configure.ac index ac1a0c8709..dec1f4171b 100644 --- a/configure.ac +++ b/configure.ac @@ -324,7 +324,7 @@ 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 ]) @@ -332,7 +332,8 @@ AC_ARG_VAR(LDSHARED,[command for linking shared library - configure will use CXX 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) @@ -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 @@ -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]) diff --git a/new-manual/gpu.md b/new-manual/gpu.md index 14ce6a057e..70ef96f707 100644 --- a/new-manual/gpu.md +++ b/new-manual/gpu.md @@ -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)