marian-nmt / marian

Fast Neural Machine Translation in C++
https://marian-nmt.github.io
Other
1.22k stars 228 forks source link

Compile error: immintrin.h: No such file or directory #351

Open MickHardins opened 3 years ago

MickHardins commented 3 years ago

Hello, I'm trying to compile marian on a node with an IBM POWER9 AC922 CPU. I was able to overcome some errors of g++ complaining about -march flag, changing -march to -mcpu however now the compilation halts because of a fatal error:

/m100/home/userexternal/home/marian/src/common/types.h:20:10: fatal error: immintrin.h: No such file or directory

the output of CMake is this:

-- Project version: v1.9.0+ba94c5b
CMake Warning at CMakeLists.txt:55 (message):
  CMAKE_BUILD_TYPE not set; setting to Release

-- Checking support for CPU intrinsics
-- Could not find hardware support for SSE2 on this machine.
-- Could not find hardware support for SSE3 on this machine.
-- Could not find hardware support for SSSE3 on this machine.
-- Could not find hardware support for SSE4.1 on this machine.
-- Could not find hardware support for AVX on this machine.
-- Could not find hardware support for AVX2 on this machine.
-- Could not find hardware support for AVX512 on this machine.
-- Found CUDA libraries: /cineca/prod/opt/compilers/cuda/10.2/none/lib64/libcurand.so /cineca/prod/opt/compilers/cuda/10.2/none/lib64/libcusparse.so /cineca/prod/opt/compilers/cuda/10.2/none/lib64/libcublas.so
-- Found Tcmalloc: /m100_work/IscrC_EVNT_0/userID/spack-0.14/install/linux-rhel7-power9le/gcc-8.4.0/gperftools-2.7-5wwsc5mvb3caqciy4yjjjkmrqwsk5boz/lib/libtcmalloc_minimal.so
-- Could NOT find MKL (missing: MKL_LIBRARIES MKL_INCLUDE_DIRS MKL_INTERFACE_LIBRARY MKL_SEQUENTIAL_LAYER_LIBRARY MKL_CORE_LIBRARY) 
-- Checking for [openblas]
-- Checking for [openblas] -- includes found
-- Checking for [openblas] -- libraries found
-- CBLAS library found: /m100_work/PROJECTS/spack/spack-0.14/install/linux-rhel7-power9le/gcc-8.4.0/openblas-0.3.9-mzixnx72oqnsksa6cmu67enaetbjw4hl/lib/libopenblas.so
-- cblas.h include directory: /m100_work/PROJECTS/spack/spack-0.14/install/linux-rhel7-power9le/gcc-8.4.0/openblas-0.3.9-mzixnx72oqnsksa6cmu67enaetbjw4hl/include
-- VERSION: 0.1.6
-- Found TCMalloc: /m100_work/IscrC_EVNT_0/useriID/spack-0.14/install/linux-rhel7-power9le/gcc-8.4.0/gperftools-2.7-5wwsc5mvb3caqciy4yjjjkmrqwsk5boz/lib/libtcmalloc_minimal.so
-- Configuring done
-- Generating done
-- Build files have been written to: /m100/home/userexternal/userID/home/marian/build

After a bit of research I found out that this error should be related to the missing support of SIMD instruction. I also tried to set intrinsic in CMakeList.txt to an empty string to avoid passing the flags to compiler but nothing changed.

Is there a way to compile marian on this architechture?

Thanks in advance for the help

kpu commented 3 years ago

There's a few CPU kernels that are only coded in x86 intrinstics but not too many. It looks like you're planning to use GPUs based on the CUDA library presence so presumably you don't care if the CPU backend works. We should add some macros to detect non-x86 and just disable the CPU backend in the short term so it will compile for you. There is an ARM CPU port in progress.

MickHardins commented 3 years ago

We should add some macros to detect non-x86 and just disable the CPU backend in the short term so it will compile for you.

Thanks, that would be awesome.

In the meantime I've found this document: https://developer.ibm.com/technologies/linux/tutorials/migrate-app-on-lop/ it seems that using -DNO_WARN_X86_INTRINSICS flag should enable the conversion to specific SIMD instruction.

If you have some suggestions on how to modify the build flags I can try to compile and report back problems.

EDIT: I just read again your answer, I will try to compile without CPU support and see if everything works!

kpu commented 3 years ago

Find everything that doesn't compile and wrap ?

#if defined(__x86_64__)
// Original code
#else
// Abort unimplemented
#endif
MickHardins commented 3 years ago

Compiling with cmake .. -DCOMPILE_CPU=off -DUSE_SENTENCEPIECE=on -DCOMPILE_SERVER=on is still failing. Even with a modified CMakeLists.txt with $INTRINSIC set to "" the error is the same. The error refers to marian/src/common/types.h:20:10 file

I'm surely doing something wrong here but I'm not very much familiar with CMake.

if defined(__x86_64__)

// Original code

else

// Abort unimplemented

endif

which files should I modify like this?

frankseide commented 3 years ago

Can we fake the intrinsics? How many different intrinsics are actually used? Maybe we can just emulate those that are used.