NVIDIA / AMGX

Distributed multigrid linear solver library on GPU
487 stars 141 forks source link

Build error: undefined reference to `omp_get_num_threads' #214

Open YuNkOnG2022 opened 2 years ago

YuNkOnG2022 commented 2 years ago

When I build my project, cmake throw three errors. I had installed openmp for my envionment.

/usr/bin/ld: /home/Software/AMGX-main/build/libamgxsh.so: undefined reference to omp_get_num_threads' /usr/bin/ld: /home/Software/AMGX-main/build/libamgxsh.so: undefined reference to 'GOMP_parallel' /usr/bin/ld: /home/Software/AMGX-main/build/libamgxsh.so: undefined reference to 'omp_get_thread_num' collect2: error: ld returned 1 exit status make[2]: [src/MPS/src/CMakeFiles/MPS.dir/build.make:229: src/MPS/src/MPS] Error 1 make[1]: [CMakeFiles/Makefile2:259: src/MPS/src/CMakeFiles/MPS.dir/all] Error 2 make: *** [Makefile:91: all] Error 2

How to solve this problem? Is there any error in CMakeList.txt? I had downloaded latest zip file AMGX-main.zip on 17th Oct.

marsaev commented 2 years ago

Hi @YuNkOnG2022 Can you provide your cmake command output and also show output of make VERBOSE=1 regarding final linking?

Thanks,

YuNkOnG2022 commented 2 years ago

cmake output:

-- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- This is BINARY dir/home/Public/MPS/Sovler/ZJUGMPS/build -- This is SOURCE dir/home/Public/MPS/Sovler/ZJUGMPS -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - found -- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "11.1") -- Found MPI_C: /usr/local/lib/libmpi.so (found version "3.1") -- Found MPI_CXX: /usr/local/lib/libmpi.so (found version "3.1") -- Found MPI: TRUE (found version "3.1")
-- This is AMGX dir/home/Software/AMGX-main/include -- This is AMGX dir/home/Software/AMGX-main/build -- Configuring done -- Generating done -- Build files have been written to: /home/Public/MPS/Sovler/ZJUGMPS/build

YuNkOnG2022 commented 2 years ago

output of make VERBOSE=1 regarding final linking:

cd /home/Public/MPS/Sovler/ZJUGMPS/build/src/MPS/src && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/MPS.dir/link.txt --verbose=1 /usr/bin/c++ -rdynamic CMakeFiles/MPS.dir/GPUMPS.cpp.o CMakeFiles/MPS.dir/GPUwork.cpp.o CMakeFiles/MPS.dir/Main.cpp.o CMakeFiles/MPS.dir/Params.cpp.o CMakeFiles/MPS.dir/Particle.cpp.o CMakeFiles/MPS.dir/Point.cpp.o CMakeFiles/MPS.dir/SimParams.cpp.o CMakeFiles/MPS.dir/MPI/Network.cpp.o CMakeFiles/MPS.dir/MPI/myMpi.cpp.o -o MPS -L/home/Software/AMGX-main/build -L/usr/local/cuda-11.1/lib64 -L/home/amax/Public/Software/openmp/lib -L/home/Public/MPS/Sovler/ZJUGMPS/src/MPS/src/../lib/INIReader -Wl,-rpath,/home/Software/AMGX-main/build:/usr/local/cuda-11.1/lib64:/home/amax/Public/Software/openmp/lib:/home/Public/MPS/Sovler/ZJUGMPS/src/MPS/src/../lib/INIReader:/home/Public/MPS/Sovler/ZJUGMPS/build/lib/INIReader -lmpi libcuMPS.a ../../../lib/INIReader/libinput.so -lamgxsh -lcudart /usr/local/cuda/lib64/libcudart_static.a -lpthread -ldl -lrt /usr/bin/ld: /home/Software/AMGX-main/build/libamgxsh.so: undefined reference to 'omp_get_num_threads' /usr/bin/ld: /home/Software/AMGX-main/build/libamgxsh.so: undefined reference to 'GOMP_parallel' /usr/bin/ld: /home/Software/AMGX-main/build/libamgxsh.so: undefined reference to 'omp_get_thread_num' collect2: error: ld returned 1 exit status make[2]: [src/MPS/src/CMakeFiles/MPS.dir/build.make:229: src/MPS/src/MPS] Error 1 make[2]: Leaving directory '/home/Public/MPS/Sovler/ZJUGMPS/build' make[1]: [CMakeFiles/Makefile2:259: src/MPS/src/CMakeFiles/MPS.dir/all] Error 2 make[1]: Leaving directory '/home/Public/MPS/Sovler/ZJUGMPS/build' make: *** [Makefile:91: all] Error 2

marsaev commented 1 year ago

@YuNkOnG2022 hmm, weird. I'm using nvidia/cuda:11.1.1-devel-ubuntu20.04 container with libopenmpi3 and libopenmpi-dev installed and cmake-3.25-rc, and it works just fine. Here is my CMake output:

# ../../cmake-3.25.0-rc2-linux-x86_64/bin/cmake ../
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- The CUDA compiler identification is NVIDIA 11.1.105
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found MPI_C: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so (found version "3.1")
-- Found MPI_CXX: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so (found version "3.1")
-- Found MPI: TRUE (found version "3.1")
-- Found CUDAToolkit: /usr/local/cuda/include (found suitable version "11.1.105", minimum required is "10.0")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
This is a MPI build:TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /root/AMGX/build

after that build finishes without errors. My code is from Oct 17:

# git rev-parse HEAD
62796ec7221ce135cc0c84fce285fa6847163bb6

Do you see any other suspects of different build outcome?