Problem with Intel installation with CMake

Hello–
We are installing LAMMPS using Intel compilers with the following cmake command:

cmake -C …/cmake/presets/all_on.cmake -C …/cmake/presets/nolib.cmake -D BUILD_SHARED_LIBS=yes -D PKG_KIM=on -D PKG_PYTHON=on -D PKG_GPU=on -D GPU_API=cuda -D PKG_INTEL=on -D PKG_OPENMP=on -D PKG_ML-IAP=off …/cmake -DCMAKE_CXX_COMPILER=mpiicpc -DCMAKE_C_COMPILER=mpiicc -DCMAKE_Fortran_COMPILER=mpiifort

The final link step to create the executable fails due to inability to locate routines in SNAIntel, e.g.

undefined reference to `LAMMPS_NS::SNAIntel::compute_deidrj(int, ip_simd::SIMD256_int const&, ip_simd::SIMD_double*)’

This appears to be because sna_intel.cpp from the INTEL package is not getting linked into liblammps.a. We were able to resolve this issue by adding “sna_intel.cpp” to lammps/cmake/Modules/Packages/INTEL.cmake in the “collect sources” section, i.e.:

set(INTEL_SOURCES ${INTEL_SOURCES_DIR}/fix_intel.cpp
                       ${INTEL_SOURCES_DIR}/fix_nh_intel.cpp
                       ${INTEL_SOURCES_DIR}/intel_buffers.cpp
                       ${INTEL_SOURCES_DIR}/nbin_intel.cpp 
                       ${INTEL_SOURCES_DIR}/sna_intel.cpp
                       ${INTEL_SOURCES_DIR}/npair_intel.cpp)

With this change the executable builds. We’re not sure if this is an error in the LAMMPS build system, or something specific to our system.

–Ellad Tadmor

Which version of LAMMPS is this with?
Which version of CMake is used?

I cannot reproduce this with the current release version.

This should not be necessary, since the sna_intel.cpp file will be automatically included when also the ML-SNAP package is included which provides the sna.cpp file and with the INTEL package all files of the kind xxxx_intel.cpp will be included if there is a xxxx.cpp file in the list of sources.

When building with -D BUILD_SHARED_LIBS=yes there should be no liblammps.a, but only liblammps.so.0 and liblammps.so as a symlink to it. Perhaps you need to completely wipe out the build folder before configuring and building.

LAMMPS version 7 Feb 2024 - Update 1
cmake version 3.17.0

I meant liblammps.so not liblammps.a

This was built from scratch from a fresh clones copy of lammps.

What is the OS/platform?
What is the hardware? If this is a Linux machine, please provide the output of:

grep avx /proc/cpuinfo | uniq

It looks like the snap/intel pair style is only available under very specific circumstances: Intel compiler and compiler optimization for AVX512 enabled (which requires compatible hardware with the default settings of optimizing for the local hardware). Thus for most people there will be just an empty object created and thus no reference to the undefined class/function in the sna_intel.cpp file and the omission of the file from the list of objects would have no effect. This would explain why this has not created any error reports so far and that all integration tests have succeeded. Since in very many cases one of the two requirements is not given.

The change in commit: include missing source file when compiling INTEL package · akohlmey/lammps@ae39eb6 · GitHub
should address this issue correctly.

Intel(R) Xeon(R) Platinum 8168 CPU @ 2.70GHz
OpenSUSE v15.3

% grep avx /proc/cpuinfo | uniq
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts pku ospke md_clear flush_l1d arch_capabilities

Thanks for looking into this and for the fix. One question: The fix checks for PKG_ML-SNAP, but in our case we’re not installing it and also have PKG_ML-IAP=off. So would the fix resolve the issue for us?

Yup, that is one of the limited number of CPUs that has the instruction that is required for snap/intel

You are using the all_on.cmake preset followed by nolib.cmake (that will enable ML-SNAP and a whole lot more). I would recommend to use most.cmake instead as that is safer.

If you run cmake . in your build folder, you should see all installed packages in the line starting with:
-- Enabled packages:

Absolutely. There would be no error if ML-SNAP is not installed.

Great. Thanks.