Apparent syntax error in file "/src/OPENMP/reaxff_forces_omp.cpp"

Hello Everyone,

I am trying to install the latest stable release of LAMMPS (23 Jun 2022) and get the error shown below during compilation on a Ubuntu 18.04 machine. I am using the downloaded tar ball for the stable release.

I am using the cmake command shown below with custom preset files in cmake.

Build and configuration succeed without any hiccups.

However, during compilation using make I run into an error that appears to be a syntax error in the file ../lammpsDir/src/OPENMP/reaxff_forces_omp.cpp. See below for the full error message.

Can anyone please help? Also, please do let me know if there’s more information needed to understand or resolve this.

Many thanks.

Warm regards,
Vaibhav.

cmake -C ../cmake/presets/vt_all_on.cmake -C ../cmake/presets/vt_nolib.cmake ../cmake -DKokkos_ARCH_PASCAL61=yes -DKokkos_ENABLE_CUDA=yes -DKokkos_ENABLE_OPENMP=yes -DCMAKE_CXX_COMPILER=/home/vthakore/src/gLammps-noonian/lib/kokkos/bin/nvcc_wrapper -DBUILD_SHARED_LIBS=on -DCMAKE_Fortran_COMPILER=/usr/bin/gfortran -DLAMMPS_SIZES=smallbig -DGPU_API=cuda -DLAMMPS_EXCEPTIONS=on -DN2P2_DIR=/home/vthakore/src/gn2p2-noonian -DGPU_ARCH=sm_61
loading initial cache file ../cmake/presets/vt_all_on.cmake
loading initial cache file ../cmake/presets/vt_nolib.cmake
-- Running check for auto-generated files from make-based build system
CMake Warning (dev) at /usr/local/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (MPI).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/local/share/cmake-3.22/Modules/FindPkgConfig.cmake:88 (find_package_handle_standard_args)
  /usr/local/share/cmake-3.22/Modules/FindMPI.cmake:270 (include)
  CMakeLists.txt:338 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/local/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (PkgConfig)
  does not match the name of the calling package (MPI).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  /usr/local/share/cmake-3.22/Modules/FindPkgConfig.cmake:88 (find_package_handle_standard_args)
  /usr/local/share/cmake-3.22/Modules/FindMPI.cmake:270 (include)
  CMakeLists.txt:352 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found Python: /usr/bin/python3.6 (found version "3.6.9") found components: Interpreter Development Development.Module Development.Embed 
-- Found Python: /usr/include/python3.6m (found version "3.6.9") found components: NumPy Interpreter Development.Module 
-- KOKKOS: Enabling CUDA LAMBDA function support
-- Setting default Kokkos CXX standard to 14
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: Kokkos
-- Compiler Version: 11.0.194
-- Using -std=c++14 for C++14 standard as feature
-- Built-in Execution Spaces:
--     Device Parallel: Kokkos::Cuda
--     Host Parallel: Kokkos::OpenMP
--       Host Serial: NONE
-- 
-- Architectures:
--  PASCAL61
-- Kokkos Devices: OPENMP;CUDA, Kokkos Backends: OPENMP;CUDA
CMake Warning at Modules/Packages/INTEL.cmake:46 (message):
  INTEL gives best performance with Intel compilers
Call Stack (most recent call first):
  CMakeLists.txt:675 (include)


-- Pair style dpd/intel will be faster with MKL libraries
-- Generating style headers...
-- Generating package headers...
-- Generating lmpinstalledpkgs.h...
-- Found Python: /usr/bin/python3.6 (found version "3.6.9") found components: Interpreter 
-- Could NOT find ClangFormat (missing: ClangFormat_EXECUTABLE) (Required is at least version "8.0")
-- The following tools and libraries have been found and configured:
 * Git
 * MPI
 * OpenMP
 * LAPACK
 * BLAS
 * JPEG
 * FFTW3
 * Cythonize
 * N2P2
 * ZLIB
 * HDF5
 * CUDAToolkit
 * TPLCUDA
 * TPLLIBDL
 * TBB_MALLOC
 * Threads
 * CUDA
 * Python

-- <<< Build configuration >>>
   LAMMPS Version:   20220623
   Operating System: Linux Ubuntu 18.04
   CMake Version:    3.22.0-rc2
   Build type:       RelWithDebInfo
   Install path:     /home/vthakore/.local
   Generator:        Unix Makefiles using /usr/bin/make
-- Enabled packages: ASPHERE;ATC;BOCS;BODY;BPM;BROWNIAN;CG-DNA;CG-SDK;CLASS2;COLLOID;COLVARS;COMPRESS;CORESHELL;DIELECTRIC;DIFFRACTION;DIPOLE;DPD-BASIC;DPD-MESO;DPD-REACT;DPD-SMOOTH;DRUDE;EFF;ELECTRODE;EXTRA-COMPUTE;EXTRA-DUMP;EXTRA-FIX;EXTRA-MOLECULE;EXTRA-PAIR;FEP;GPU;GRANULAR;H5MD;INTEL;INTERLAYER;KOKKOS;KSPACE;LATBOLTZ;MANIFOLD;MANYBODY;MC;MEAM;MGPT;MISC;ML-HDNNP;ML-IAP;ML-RANN;ML-SNAP;MOFFF;MOLECULE;MOLFILE;MPIIO;OPENMP;OPT;ORIENT;PERI;PHONON;PLUGIN;POEMS;PTM;PYTHON;QEQ;QTB;REACTION;REAXFF;REPLICA;RIGID;SHOCK;SMTBQ;SPH;SPIN;SRD;TALLY;UEF;YAFF
-- <<< Compilers and Flags: >>>
-- C++ Compiler:     /home/vthakore/src/gLammps-noonian/lib/kokkos/bin/nvcc_wrapper
      Type:          GNU
      Version:       7.5.0
      C++ Flags:     -O2 -g -DNDEBUG
      Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_EXCEPTIONS;LAMMPS_OMP_COMPAT=3;LAMMPS_JPEG;LAMMPS_GZIP;LAMMPS_FFMPEG;FFT_FFTW3;FFT_FFTW_THREADS;LMP_PYTHON;MLIAP_PYTHON;LAMMPS_ZSTD;LMP_MPIIO;LMP_OPENMP;$<BUILD_INTERFACE:LMP_KOKKOS>;FFT_CUFFT;LMP_INTEL;LMP_INTEL_USELRT;LMP_GPU;LMP_PLUGIN
      Options:       -Xcudafe;--diag_suppress=unrecognized_pragma
-- C compiler:       /usr/bin/cc
      Type:          GNU
      Version:       7.5.0
      C Flags:       -O2 -g -DNDEBUG
-- <<< Linker flags: >>>
-- Executable name:  lmp
-- Shared library flags:    
-- <<< MPI flags >>>
-- MPI_defines:      MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes:     /usr/lib/x86_64-linux-gnu/openmpi/include/openmpi;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include;/usr/lib/x86_64-linux-gnu/openmpi/include
-- MPI libraries:    /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so;/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so;
-- <<< GPU package settings >>>
-- GPU API:                  CUDA
-- CUDA Compiler:            /usr/local/cuda-11.0/bin/nvcc
-- GPU default architecture: sm_61
-- GPU binning with CUDPP:   OFF
-- CUDA MPS support:         OFF
-- GPU precision:            MIXED
-- Kokkos Devices: CUDA;CUDA_LAMBDA;OPENMP
-- Kokkos Architecture: PASCAL61
-- <<< FFT settings >>>
-- Primary FFT lib:  FFTW3
-- Using double precision FFTs
-- Using threaded FFTs
-- Kokkos FFT: cuFFT
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vthakore/src/lammps-23Jun2022/build

ERROR:

[ 88%] Building CXX object CMakeFiles/lammps.dir/home/vthakore/src/lammps-23Jun2022/src/KOKKOS/comm_kokkos.cpp.o
/home/vthakore/src/lammps-23Jun2022/src/OPENMP/reaxff_forces_omp.cpp: In function ‘void ReaxFF::Init_Forces_noQEq_OMP(ReaxFF::reax_system*, ReaxFF::control_params*, ReaxFF::simulation_data*, ReaxFF::storage*, ReaxFF::reax_list**)’:
/home/vthakore/src/lammps-23Jun2022/src/OPENMP/reaxff_forces_omp.cpp:361:1: error: for statement expected before ‘}’ token
 #endif
 ^
/home/vthakore/src/lammps-23Jun2022/src/OPENMP/reaxff_forces_omp.cpp:356:20: error: barrier region may not be closely nested inside of work-sharing, ‘critical’, ‘ordered’, ‘master’, explicit ‘task’ or ‘taskloop’ region
 #pragma omp barrier
                    ^
[ 88%] Building CXX object CMakeFiles/lammps.dir/home/vthakore/src/lammps-23Jun2022/src/KOKKOS/comm_tiled_kokkos.cpp.o
CMakeFiles/lammps.dir/build.make:19193: recipe for target 'CMakeFiles/lammps.dir/home/vthakore/src/lammps-23Jun2022/src/OPENMP/reaxff_forces_omp.cpp.o' failed
make[2]: *** [CMakeFiles/lammps.dir/home/vthakore/src/lammps-23Jun2022/src/OPENMP/reaxff_forces_omp.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:351: recipe for target 'CMakeFiles/lammps.dir/all' failed
make[1]: *** [CMakeFiles/lammps.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

First of all, you have to run configuration and compilation without any customization. Only enable REAXFF and OPENMP and then try again. Once there is anything custom involved that we cannot reproduce, you are on your own.

Thank for your response Axel.
I haven’t really played around with the source code or anything. :slight_smile:

I am using the all_on.cmake preset (copy of it → vt_all_on.cmake) and excluding certain packages with external dependencies in the vt_nolib.cmake. This is the only “customization” that I have. Please see below for details.

I will test the compile with just the REAXFF and the OPENMP packages as well.
Thank you for your suggestion.

Warm regards,
Vaibhav.

File: vt_nolib.cmake

# preset that turns off all packages that require some form of external
# library or special compiler (fortran or cuda) or equivalent.

set(PACKAGES_WITH_LIB
  ADIOS
#   ATC
  AWPMD
#   COMPRESS
#   ELECTRODE
#   GPU
#   H5MD
  KIM
#   KOKKOS
#   LATBOLTZ
  LATTE
  MACHDYN
  MDI
  MESONT
#   ML-HDNNP
  ML-PACE
  ML-QUIP
#   MOLFILE
#   MPIIO
  MSCG
  NETCDF
  PLUMED
#   PYTHON
  QMMM
  SCAFACOS
  VORONOI
  VTK)

foreach(PKG ${PACKAGES_WITH_LIB})
  set(PKG_${PKG} OFF CACHE BOOL "" FORCE)
endforeach()

Hi Axel,

I was able to reproduce the error using the following modified version of /cmake/presets/basic.cmake:

File: checkReaxffOpenmp.cmake

# preset that turns on just a few, frequently used packages
# this will be compiled quickly and handle a lot of common inputs.

set(ALL_PACKAGES KSPACE MANYBODY MOLECULE RIGID REAXFF OPENMP KOKKOS)

foreach(PKG ${ALL_PACKAGES})
  set(PKG_${PKG} ON CACHE BOOL "" FORCE)
endforeach()

I got the same error as before, please see the message below.
I further isolated the problem to the KOKKOS package since the compilation shows no error without the Kokkos package i.e. when the following preset is used:

File: checkReaxffOpenmp.cmake

# preset that turns on just a few, frequently used packages
# this will be compiled quickly and handle a lot of common inputs.

set(ALL_PACKAGES KSPACE MANYBODY MOLECULE RIGID REAXFF OPENMP)

foreach(PKG ${ALL_PACKAGES})
  set(PKG_${PKG} ON CACHE BOOL "" FORCE)
endforeach()

As earlier, the configuration and build operations completed without any hiccups in both the cases.

The cmake command that I used was:
cmake -C ../cmake/presets/checkReaxffOpenmp.cmake ../cmake -DKokkos_ARCH_PASCAL61=yes -DKokkos_ENABLE_CUDA=yes -DKokkos_ENABLE_OPENMP=yes -DCMAKE_CXX_COMPILER=/home/vthakore/src/gLammps-noonian/lib/kokkos/bin/nvcc_wrapper -DBUILD_SHARED_LIBS=on -DCMAKE_Fortran_COMPILER=/usr/bin/gfortran -DLAMMPS_SIZES=smallbig -DLAMMPS_EXCEPTIONS=on

Please do let me know if there’s anything else that you would like me to check out.

Thanks for your time and consideration.

Warm regards,
Vaibhav.


ERROR:

/home/vthakore/src/gLammps-noonian/src/OPENMP/reaxff_forces_omp.cpp: In function ‘void ReaxFF::Init_Forces_noQEq_OMP(ReaxFF::reax_system*, ReaxFF::control_params*, ReaxFF::simulation_data*, ReaxFF::storage*, ReaxFF::reax_list**)’:
/home/vthakore/src/gLammps-noonian/src/OPENMP/reaxff_forces_omp.cpp:361:1: error: for statement expected before ‘}’ token
 #endif
 ^
/home/vthakore/src/gLammps-noonian/src/OPENMP/reaxff_forces_omp.cpp:356:20: error: barrier region may not be closely nested inside of work-sharing, ‘critical’, ‘ordered’, ‘master’, explicit ‘task’ or ‘taskloop’ region
 #pragma omp barrier
                    ^
CMakeFiles/lammps.dir/build.make:9805: recipe for target 'CMakeFiles/lammps.dir/home/vthakore/src/gLammps-noonian/src/OPENMP/reaxff_forces_omp.cpp.o' failed
make[2]: *** [CMakeFiles/lammps.dir/home/vthakore/src/gLammps-noonian/src/OPENMP/reaxff_forces_omp.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:331: recipe for target 'CMakeFiles/lammps.dir/all' failed
make[1]: *** [CMakeFiles/lammps.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

Please try compiling without this. Kokkos doesn’t need to specify the nvcc wrapper explicitly anymore since April 2022. This should also speed up compilation significantly.

As per your suggestion, I tried without specifying the nvcc wrapper (with all other things exactly the same as before) but the error remains the same as earlier.
cmake -C ../cmake/presets/checkReaxffOpenmp.cmake ../cmake -DKokkos_ARCH_PASCAL61=yes -DKokkos_ENABLE_CUDA=yes -DKokkos_ENABLE_OPENMP=yes -DBUILD_SHARED_LIBS=on -DCMAKE_Fortran_COMPILER=/usr/bin/gfortran -DLAMMPS_SIZES=smallbig -DLAMMPS_EXCEPTIONS=on

I also tried compiling the original full version (as specified in my first post) also by excluding the OPENMP package and the compilation worked.

So, it appears that the error occurs when both KOKKOS and OPENMP packages are installed together.

Again, please do let me know if there’s anything else you would want me to try out.
Thanks a ton!

Warm regards,
Vaibhav.

I suspect that there is some header file that is included by accident because it has the same name as a header from a different library/package/software and that defines some macro/string that modifies the code in src/OPENMP/reaxff_forces_omp.cpp. I’ve seen similar things before. The error indication from the compiler is not reliable in these cases.

Can you please do one more check: compile KOKKOS only for OpenMP and not for CUDA. If it still fails, I have a chance to test and reproduce it locally. Otherwise, it will take me a couple of days before I have time to access the machine where I can test with CUDA properly.

If I exclude CUDA i.e. remove -DKokkos_ENABLE_CUDA=yes, the compilation works!
This is the command I used:
cmake -C ../cmake/presets/checkReaxffOpenmp.cmake ../cmake -DKokkos_ARCH_PASCAL61=yes -DKokkos_ENABLE_OPENMP=yes -DBUILD_SHARED_LIBS=on -DCMAKE_Fortran_COMPILER=/usr/bin/gfortran -DLAMMPS_SIZES=smallbig -DLAMMPS_EXCEPTIONS=on

Warm regards,
Vaibhav.

Then I suggest you just compile two executables: one with KOKKOS included but not OPENMP and one with OPENMP but not KOKKOS. You cannot use both packages at the same time, anyway.

The issue may go away with a future version of CUDA. This would not be the first time that something goes wrong with nvcc. It is a bit of a chimera and pretends to be GNU gcc, when it is not and actually based on LLVM.

Cool!
Thanks for guiding me through the process of resolving this error.
I will take your suggestion and run with it… :slight_smile:

You have a great rest of the evening.

Warm regards,
Vaibhav.