KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
1.01k stars 244 forks source link

[CLANG] fatal error: 'omp.h' file not found #8146

Closed marandra closed 3 years ago

marandra commented 3 years ago

Description Compilation of Kratos ends with the following error:

In file included from /home/marcelo/Projects/Kratos/kratos/tests/cpp_tests/utilities/test_parallel_utilities.cpp:15:
/home/marcelo/Projects/Kratos/kratos/utilities/parallel_utilities.h:23:9: fatal error: 'omp.h' file not found
#include<omp.h>
        ^~~~~~~
1 error generated.

According to git bisect, the error appears in commit 4b134271182ca02e8c6a63df7f83a3f0aea9fc18

I don't understand what is special about parallel_utilities.h that leads to an error, as there were other include <omp.h> in the code before. Also, I'm not sure if the output of cmake is normal (it is the same en both cases):

-- OpenMP included
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 

(see below for the whole output).

Scope

Expected behavior Until the previous commit, compilation ended normally, with the same configuration scripts. The output of the configuration step is the same in both cases:

-- The C compiler identification is Clang 11.0.1
-- The CXX compiler identification is Clang 11.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - 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/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- No KRATOS_SOURCE_DIR is defined, using: /home/marcelo/Projects/Kratos
-- No KRATOS_BINARY_DIR is defined, using: /home/marcelo/Projects/Kratos/build/Release
-- No KRATOS_BUILD_TESTING is defined. Setting to ON
-- No CMAKE_INSTALL_MESSAGE is defined. Setting to NEVER
-- Found Git: /usr/bin/git (found version "2.30.0") 
-- CMAKE_SYSTEM_NAME = Linux
additional default options were set for clang compiler
CMAKE_CXX_FLAGS =  -msse3 -std=c++11 -fPIC -funroll-loops -Wall -Wno-unused-local-typedef -Wno-unknown-pragmas  
CMAKE_C_FLAGS =  -msse3 -fPIC -funroll-loops -Wall -Wno-unknown-pragmas  
-- Found PythonInterp: /usr/bin/python3 (found version "3.9.1") 
-- Found PythonLibs: /usr/lib/libpython3.9.so
-- Standard install dir /home/marcelo/Projects/Kratos/bin/Release
-- OpenMP included
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
-- Found Boost: /usr/lib64/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0")  
-- Boost Include: /usr/include
-- Boost Linkdir: 
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11") 
-- AMatrix not found. Please define the AMATRIX_DIR pointing to the AMatrix root directory.

CMAKE_BUILD_TYPE ........ Release

WARNING: YOUR GIDPOST IS BEING COMPILED  WITHOUT DEBUG (ALL ASSERTS WILL BE AVOIDED)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- 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  
-- Configuring applications (ENV):

***********************************************************************

        LIST OF APPLICATIONS THAT ARE GOING TO BE COMPILED:

        APPLICATIONS ADDED TO COMPILATION THROUGH DEPENDENCIES:

***********************************************************************

List of upcoming api-breaking changes:
    Making variables non-copiable: https://github.com/KratosMultiphysics/Kratos/pull/6339
    Deprecation of NOT_FLAGS : https://github.com/KratosMultiphysics/Kratos/pull/6233
    Removing long deprecated conditions : https://github.com/KratosMultiphysics/Kratos/pull/6475
    Changing 'FindNodalNeighboursProcess' constructor signature: https://github.com/KratosMultiphysics/Kratos/pull/4947
-- triangle : /home/marcelo/Projects/Kratos/external_libraries/triangle
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    KRATOS_SHARED_MEMORY_PARALLELIZATION
    USE_EIGEN_MKL

-- Build files have been written to: /home/marcelo/Projects/Kratos/build/Release

Environment

philbucher commented 3 years ago

hm this is strange can you post your configure file? what worries me is that KRATOS_SHARED_MEMORY_PARALLELIZATION is unused, which should not be

marandra commented 3 years ago

The original "bad" commit is old, before the introduction of KRATOS_SHARED_MEMORY_PARALLELIZATION, so the configuration still uses KRATOS_EXCLUDE_OPENMP (and I assumed the newer was going to be ignored). In the tests I had to switch between both variables. (The error appears independently of the value True/False or None/OpenMP, though)

Here you have the whole config script, let me know if there's something else that I can try.


#!/bin/bash
# Please do not modify this script

# You can use your interpreter of choice (bash, sh, zsh, ...)

# For any question please contact with us in:
#   - https://github.com/KratosMultiphysics/Kratos

# Optional parameters:
# You can find a list will all the compiation options in INSTALL.md or here:
#   - https://github.com/KratosMultiphysics/Kratos/wiki/Compilation-options

# Function to add apps
add_app () {
    export KRATOS_APPLICATIONS="${KRATOS_APPLICATIONS}$1;"
}

# Set compiler
export CC=clang
export CXX=clang++

# Set variables
export KRATOS_SOURCE="${KRATOS_SOURCE:-"$( cd "$(dirname "$0")" ; pwd -P )"/..}"
export KRATOS_BUILD="${KRATOS_SOURCE}/build"
export KRATOS_APP_DIR="${KRATOS_SOURCE}/applications"
export KRATOS_INSTALL_PYTHON_USING_LINKS=ON

# Set basic configuration
export KRATOS_BUILD_TYPE=${KRATOS_BUILD_TYPE:-"Release"}
export PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"/usr/bin/python3"}

# Set applications to compile
export KRATOS_APPLICATIONS=
#add_app ${KRATOS_APP_DIR}/LinearSolversApplication
#add_app ${KRATOS_APP_DIR}/ExternalSolversApplication
#add_app ${KRATOS_APP_DIR}/StructuralMechanicsApplication
#add_app ${KRATOS_APP_DIR}/MultiscaleROMApplication

# Clean
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/cmake_install.cmake"
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeCache.txt"
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeFiles"

# Configure
cmake -H"${KRATOS_SOURCE}" -B"${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" \
-D CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11" \
-D CMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 " \
-D USE_MPI=OFF \
-D KRATOS_EXCLUDE_OPENMP=True \
-D KRATOS_SHARED_MEMORY_PARALLELIZATION="None" \
-D USE_EIGEN_MKL=OFF \
-D INSTALL_RUNKRATOS=OFF \
-D USE_COTIRE=OFF \
-D KRATOS_COLORED_OUTPUT=ON \

#-D KRATOS_SHARED_MEMORY_PARALLELIZATION="None" \
#-D CMAKE_INSTALL_MESSAGE=NEVER \
#-D KRATOS_BUILD_TESTING=ON \

# Buid
cmake --build "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" --target install -- -j10

# Buid whit COTIRE
#cmake --build "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" --target all_unity -- -j5
#cmake --build "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" --target install/fast -- -j5
philbucher commented 3 years ago

ok now things get clearer actually using KRATOS_EXCLUDE_OPENMP should give an error https://github.com/KratosMultiphysics/Kratos/blob/74ca63383d1341c849e89554202582b4326d02fb/CMakeLists.txt#L292-L295

can you try without (only using KRATOS_SHARED_MEMORY_PARALLELIZATION)?

marandra commented 3 years ago

I checked out the last version from master and recompiled with KRATOS_SHARED_MEMORY_PARALLELIZATION="OpenMP" (same results as with "None")

I noticed that the problem is with any include <omp.h>, not just parallel utilities, which makes much more sense now.

For what I found, when compiling with clang, one must use "-fopenmp" and pass the include and library locations. I'd expect that cmake takes care of that, but from its output, it is not finding the library:

Using OpenMP for shared memory parallelization -- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) -- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) -- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)

I don't know why it was compiling fine before the last pull, as I didn't change my system...

Here is the script and the output below:

#!/bin/bash

# Function to add apps
add_app () {
    export KRATOS_APPLICATIONS="${KRATOS_APPLICATIONS}$1;"
}

# Set compiler
export CC=clang
export CXX=clang++

# Set variables
export KRATOS_SOURCE="${KRATOS_SOURCE:-"$( cd "$(dirname "$0")" ; pwd -P )"/..}"
export KRATOS_BUILD="${KRATOS_SOURCE}/build"
export KRATOS_APP_DIR="${KRATOS_SOURCE}/applications"
export KRATOS_INSTALL_PYTHON_USING_LINKS=ON

# Set basic configuration
export KRATOS_BUILD_TYPE=${KRATOS_BUILD_TYPE:-"Release"}
export PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"/usr/bin/python3"}

# Set applications to compile
export KRATOS_APPLICATIONS=
#add_app ${KRATOS_APP_DIR}/LinearSolversApplication
#add_app ${KRATOS_APP_DIR}/ExternalSolversApplication
#add_app ${KRATOS_APP_DIR}/StructuralMechanicsApplication
#add_app ${KRATOS_APP_DIR}/MultiscaleROMApplication

# Clean
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/cmake_install.cmake"
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeCache.txt"
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeFiles"

# Configure
cmake -H"${KRATOS_SOURCE}" -B"${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" \
-D CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11" \
-D CMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 " \
-D USE_MPI=OFF \
-D KRATOS_SHARED_MEMORY_PARALLELIZATION="None" \
-D INSTALL_RUNKRATOS=OFF \
-D USE_COTIRE=OFF \
-D KRATOS_COLORED_OUTPUT=ON \

#-D KRATOS_EXCLUDE_OPENMP=True \
#-D KRATOS_BUILD_TESTING=ON \

# Buid
cmake --build "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" --target install -- -j10
-- The C compiler identification is Clang 11.0.1
-- The CXX compiler identification is Clang 11.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - 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/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- No KRATOS_SOURCE_DIR is defined, using: /home/marcelo/Projects/Kratos
-- No KRATOS_BINARY_DIR is defined, using: /home/marcelo/Projects/Kratos/build/Release
-- No KRATOS_BUILD_TESTING is defined. Setting to ON
-- No CMAKE_INSTALL_MESSAGE is defined. Setting to NEVER
-- Found Git: /usr/bin/git (found version "2.30.0") 
-- CMAKE_SYSTEM_NAME = Linux
additional default options were set for clang compiler
CMAKE_CXX_FLAGS =  -msse3 -std=c++11 -fPIC -funroll-loops -Wall -Wno-unused-local-typedef -Wno-unknown-pragmas  
CMAKE_C_FLAGS =  -msse3 -fPIC -funroll-loops -Wall -Wno-unknown-pragmas  
-- Found PythonInterp: /usr/bin/python3 (found version "3.9.1") 
-- Found PythonLibs: /usr/lib/libpython3.9.so
-- Standard install dir /home/marcelo/Projects/Kratos/bin/Release
Using OpenMP for shared memory parallelization
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
-- Found Boost: /usr/lib64/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0")  
-- Boost Include: /usr/include
-- Boost Linkdir: 
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11") 
-- AMatrix not found. Please define the AMATRIX_DIR pointing to the AMatrix root directory.

CMAKE_BUILD_TYPE ........ Release

WARNING: YOUR GIDPOST IS BEING COMPILED  WITHOUT DEBUG (ALL ASSERTS WILL BE AVOIDED)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- 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  
-- Configuring applications (ENV):

***********************************************************************

        LIST OF APPLICATIONS THAT ARE GOING TO BE COMPILED:

        APPLICATIONS ADDED TO COMPILATION THROUGH DEPENDENCIES:

***********************************************************************

List of upcoming api-breaking changes:
    Making variables non-copiable: https://github.com/KratosMultiphysics/Kratos/pull/6339
    Deprecation of NOT_FLAGS : https://github.com/KratosMultiphysics/Kratos/pull/6233
    Removing long deprecated conditions : https://github.com/KratosMultiphysics/Kratos/pull/6475
    Changing 'FindNodalNeighboursProcess' constructor signature: https://github.com/KratosMultiphysics/Kratos/pull/4947
    Minor update of import mechanism for applications: https://github.com/KratosMultiphysics/Kratos/pull/6556
    Update of Element, Condition and Scheme Interface: https://github.com/KratosMultiphysics/Kratos/issues/7381
    VariableComponent and VectorComponentAdaptor are no longer used: https://github.com/KratosMultiphysics/Kratos/pull/6686
-- triangle : /home/marcelo/Projects/Kratos/external_libraries/triangle
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marcelo/Projects/Kratos/build/Release
[  1%] Built target KratosVersion
[  2%] Built target triangle
[  3%] Built target gidpost
[  4%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/communicator.cpp.o
[  5%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/dem_variables.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/bounding_volume_tree.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/cfd_variables.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/connectivity_preserve_modeler.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/constitutive_law.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/deprecated_variables.cpp.o
[  7%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/fsi_variables.cpp.o
[  7%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/global_pointer_variables.cpp.o
[  7%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/gid_io.cpp.o
In file included from /home/marcelo/Projects/Kratos/kratos/sources/communicator.cpp:15:
In file included from /home/marcelo/Projects/Kratos/kratos/includes/communicator.h:33:
In file included from /home/marcelo/Projects/Kratos/kratos/includes/condition.h:21:
In file included from /home/marcelo/Projects/Kratos/kratos/includes/properties.h:28:
In file included from /home/marcelo/Projects/Kratos/kratos/includes/node.h:31:
/home/marcelo/Projects/Kratos/kratos/includes/lock_object.h:21:10: fatal error: 'omp.h' file not found
#include <omp.h>
         ^~~~~~~
philbucher commented 3 years ago

hm not sure why this is happening / why CMake cannot find OpenMP

as shown here when I updated the CMakeLists in #7262 I didn't change the mechanism with which OpenMP is detected

@roigcarlo do you know sth?

roigcarlo commented 3 years ago

Looking into it

roigcarlo commented 3 years ago

Well there is indeed a problem in the parallel_utilities.h. All instances of #include "omp.h and #include <omp.h> should be warded by #ifdef _OPENMP, otherwise it will try to include it even if there is no support for such back-ends.

I will prepare a commit to fix this instance of the problem and others I've seen.

roigcarlo commented 3 years ago

@philbucher Maybe it could be usefull to run a weekly ci with less common configurations like this one to catch problems, we can discuss it in the next meeting.

philbucher commented 3 years ago

Well there is indeed a problem in the parallel_utilities.h. All instances of #include "omp.h and #include <omp.h> should be warded by #ifdef _OPENMP, otherwise it will try to include it even if there is no support for such back-ends.

I will prepare a commit to fix this instance of the problem and others I've seen.

Ok this is on my todo list

BTW please use KRATOS_SMP_OMP ;)

still that doesn't answer the question why cmake doesn't find openMP :/

roigcarlo commented 3 years ago

Wait it is indeed in #7474 sorry for the noise. then what is the problem? I thought @marandra wanted to compile without openmp.

roigcarlo commented 3 years ago

Ok I misunderstood the problem. Since you are using arch and they updated to OpenMP 5.0 in clang 11 maybe what is missing is the openmp update.

Try making a pacman -Syu or try to add -fopenmp-version=45 to the compilation

philbucher commented 3 years ago

~yes he does (and I do sometimes too and never had a problem)~ EDIT he wants to use OpenMP Now one thing at a time:

philbucher commented 3 years ago

Ok I misunderstood the problem. Since you are using arch and they updated to OpenMP 5.0 in clang 11 maybe what is missing is the openmp update.

Try making a pacman -Syu or try to add -fopenmp-version=45 to the compilation

that sounds like it could be a solution

roigcarlo commented 3 years ago

Also probably we should move add_definitions( -DKRATOS_SMP_OPENMP ) to inside the if (OPENMP_FOUND), i think this is the case why he was getting the errors.

philbucher commented 3 years ago

Also probably we should move add_definitions( -DKRATOS_SMP_OPENMP ) to inside the if (OPENMP_FOUND), i think this is the case why he was getting the errors.

so probably we should throw an error if OpenMP is not found?

roigcarlo commented 3 years ago

so probably we should throw an error if OpenMP is not found?

Yep

philbucher commented 3 years ago

so probably we should throw an error if OpenMP is not found?

Yep

see #8150

marandra commented 3 years ago

Thanks for looking into it.

Ok I misunderstood the problem. Since you are using arch and they updated to OpenMP 5.0 in clang 11 maybe what is missing is the openmp update.

Try making a pacman -Syu or try to add -fopenmp-version=45 to the compilation

I tried with -fopenmp-version=45 and it doesn't help (the system is already up to date)

To clarify, if I checkout Kratos v8.0.1 (my "production" version), it compiles without problem. Then I checkout master, it fails. Switch back to v8.0.1, compiles.

I normally exclude OpenMP, but the error appears with or without it.

I tried compiling with #8150 , but it keeps failing. Below is the script used (I removed the line defining KRATOS_SHARED_MEMORY_PARALLELIZATION), and below it the output of CMake, now with the error for not finding OpenMP


#!/bin/bash

# Function to add apps
add_app () {
    export KRATOS_APPLICATIONS="${KRATOS_APPLICATIONS}$1;"
}

# Set compiler
export CC=clang
export CXX=clang++

# Set variables
export KRATOS_SOURCE="${KRATOS_SOURCE:-"$( cd "$(dirname "$0")" ; pwd -P )"/..}"
export KRATOS_BUILD="${KRATOS_SOURCE}/build"
export KRATOS_APP_DIR="${KRATOS_SOURCE}/applications"
export KRATOS_INSTALL_PYTHON_USING_LINKS=ON

# Set basic configuration
export KRATOS_BUILD_TYPE=${KRATOS_BUILD_TYPE:-"Release"}
export PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE:-"/usr/bin/python3"}

# Set applications to compile
export KRATOS_APPLICATIONS=

# Clean
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/cmake_install.cmake"
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeCache.txt"
rm -rf "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}/CMakeFiles"

# Configure
cmake -H"${KRATOS_SOURCE}" -B"${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" \
-D CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -msse3 -std=c++11" \
-D CMAKE_C_FLAGS="${CMAKE_C_FLAGS} -msse3 " \
-D USE_MPI=OFF \
-D INSTALL_RUNKRATOS=OFF \

#-D KRATOS_SHARED_MEMORY_PARALLELIZATION="OpenMP" \
#-D KRATOS_EXCLUDE_OPENMP=True \

# Buid
cmake --build "${KRATOS_BUILD}/${KRATOS_BUILD_TYPE}" --target install -- -j10
-- The C compiler identification is Clang 11.0.1
-- The CXX compiler identification is Clang 11.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - 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/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- No KRATOS_SOURCE_DIR is defined, using: /home/marcelo/Projects/Kratos
-- No KRATOS_BINARY_DIR is defined, using: /home/marcelo/Projects/Kratos/build/Release
-- No KRATOS_BUILD_TESTING is defined. Setting to ON
-- No CMAKE_INSTALL_MESSAGE is defined. Setting to NEVER
-- Found Git: /usr/bin/git (found version "2.30.0") 
-- CMAKE_SYSTEM_NAME = Linux
additional default options were set for clang compiler
CMAKE_CXX_FLAGS =  -msse3 -std=c++11 -fPIC -funroll-loops -Wall -Wno-unused-local-typedef -Wno-unknown-pragmas  
CMAKE_C_FLAGS =  -msse3 -fPIC -funroll-loops -Wall -Wno-unknown-pragmas  
-- Found PythonInterp: /usr/bin/python3 (found version "3.9.1") 
-- Found PythonLibs: /usr/lib/libpython3.9.so
-- Standard install dir /home/marcelo/Projects/Kratos/bin/Release
"KRATOS_SHARED_MEMORY_PARALLELIZATION" not defined, defaulting to "OpenMP"
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
CMake Error at CMakeLists.txt:312 (message):
  OpenMP could not be found!

-- Configuring incomplete, errors occurred!
See also "/home/marcelo/Projects/Kratos/build/Release/CMakeFiles/CMakeOutput.log".
See also "/home/marcelo/Projects/Kratos/build/Release/CMakeFiles/CMakeError.log".
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- No KRATOS_SOURCE_DIR is defined, using: /home/marcelo/Projects/Kratos
-- No KRATOS_BINARY_DIR is defined, using: /home/marcelo/Projects/Kratos/build/Release
-- No KRATOS_BUILD_TESTING is defined. Setting to ON
-- No CMAKE_INSTALL_MESSAGE is defined. Setting to NEVER
-- CMAKE_SYSTEM_NAME = Linux
additional default options were set for clang compiler
CMAKE_CXX_FLAGS =  -msse3 -std=c++11 -fPIC -funroll-loops -Wall -Wno-unused-local-typedef -Wno-unknown-pragmas  
CMAKE_C_FLAGS =  -msse3 -fPIC -funroll-loops -Wall -Wno-unknown-pragmas  
-- User defined install dir /home/marcelo/Projects/Kratos/bin/Release
"KRATOS_SHARED_MEMORY_PARALLELIZATION" not defined, defaulting to "OpenMP"
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
CMake Error at CMakeLists.txt:312 (message):
  OpenMP could not be found!

-- Configuring incomplete, errors occurred!
See also "/home/marcelo/Projects/Kratos/build/Release/CMakeFiles/CMakeOutput.log".
See also "/home/marcelo/Projects/Kratos/build/Release/CMakeFiles/CMakeError.log".
make: *** [Makefile:271: cmake_check_build_system] Error 1
marandra commented 3 years ago

Trying #8150 again with KRATOS_SHARED_MEMORY_PARALLELIZATION="None" it skips OpenMP detection, and fails at the first #include <omp.h>.

-- The C compiler identification is Clang 11.0.1
-- The CXX compiler identification is Clang 11.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang - 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/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- No KRATOS_SOURCE_DIR is defined, using: /home/marcelo/Projects/Kratos
-- No KRATOS_BINARY_DIR is defined, using: /home/marcelo/Projects/Kratos/build/Release
-- No KRATOS_BUILD_TESTING is defined. Setting to ON
-- No CMAKE_INSTALL_MESSAGE is defined. Setting to NEVER
-- Found Git: /usr/bin/git (found version "2.30.0") 
-- CMAKE_SYSTEM_NAME = Linux
additional default options were set for clang compiler
CMAKE_CXX_FLAGS =  -msse3 -std=c++11 -fPIC -funroll-loops -Wall -Wno-unused-local-typedef -Wno-unknown-pragmas  
CMAKE_C_FLAGS =  -msse3 -fPIC -funroll-loops -Wall -Wno-unknown-pragmas  
-- Found PythonInterp: /usr/bin/python3 (found version "3.9.1") 
-- Found PythonLibs: /usr/lib/libpython3.9.so
-- Standard install dir /home/marcelo/Projects/Kratos/bin/Release
Shared memory parallelization is disabled!
-- Found Boost: /usr/lib64/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0")  
-- Boost Include: /usr/include
-- Boost Linkdir: 
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11") 
-- AMatrix not found. Please define the AMATRIX_DIR pointing to the AMatrix root directory.

CMAKE_BUILD_TYPE ........ Release

WARNING: YOUR GIDPOST IS BEING COMPILED  WITHOUT DEBUG (ALL ASSERTS WILL BE AVOIDED)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- 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  
-- Configuring applications (ENV):

***********************************************************************

        LIST OF APPLICATIONS THAT ARE GOING TO BE COMPILED:

        APPLICATIONS ADDED TO COMPILATION THROUGH DEPENDENCIES:

***********************************************************************

List of upcoming api-breaking changes:
    Making variables non-copiable: https://github.com/KratosMultiphysics/Kratos/pull/6339
    Deprecation of NOT_FLAGS : https://github.com/KratosMultiphysics/Kratos/pull/6233
    Removing long deprecated conditions : https://github.com/KratosMultiphysics/Kratos/pull/6475
    Changing 'FindNodalNeighboursProcess' constructor signature: https://github.com/KratosMultiphysics/Kratos/pull/4947
    Minor update of import mechanism for applications: https://github.com/KratosMultiphysics/Kratos/pull/6556
    Update of Element, Condition and Scheme Interface: https://github.com/KratosMultiphysics/Kratos/issues/7381
    VariableComponent and VectorComponentAdaptor are no longer used: https://github.com/KratosMultiphysics/Kratos/pull/6686
-- triangle : /home/marcelo/Projects/Kratos/external_libraries/triangle
-- Configuring done
-- Generating done
-- Build files have been written to: /home/marcelo/Projects/Kratos/build/Release
Scanning dependencies of target triangle
Scanning dependencies of target gidpost
Scanning dependencies of target KratosVersion
[  1%] Building CXX object kratos/CMakeFiles/KratosVersion.dir/sources/kratos_version.cpp.o
[  1%] Building C object external_libraries/gidpost/CMakeFiles/gidpost.dir/source/gidpostHash.c.o
[  1%] Building C object external_libraries/gidpost/CMakeFiles/gidpost.dir/source/hashtab.c.o
[  1%] Building C object external_libraries/gidpost/CMakeFiles/gidpost.dir/source/gidpost.c.o
[  1%] Building C object external_libraries/gidpost/CMakeFiles/gidpost.dir/source/gidpostInt.c.o
[  1%] Building C object external_libraries/triangle/CMakeFiles/triangle.dir/triangle.c.o
[  2%] Building C object external_libraries/gidpost/CMakeFiles/gidpost.dir/source/lookupa.c.o
[  2%] Building C object external_libraries/gidpost/CMakeFiles/gidpost.dir/source/recycle.c.o
[  2%] Built target KratosVersion
[  3%] Linking C static library libtriangle.a
[  3%] Built target triangle
[  3%] Linking C static library libgidpost.a
[  3%] Built target gidpost
Scanning dependencies of target KratosCore
[  3%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/cfd_variables.cpp.o
[  3%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/constitutive_law.cpp.o
[  4%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/bounding_volume_tree.cpp.o
[  4%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/code_location.cpp.o
[  5%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/communicator.cpp.o
[  5%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/connectivity_preserve_modeler.cpp.o
[  5%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/data_communicator.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/dem_variables.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/deprecated_variables.cpp.o
[  6%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/exception.cpp.o
[  7%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/fsi_variables.cpp.o
[  7%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/gid_io.cpp.o
[  7%] Building CXX object kratos/CMakeFiles/KratosCore.dir/sources/global_pointer_variables.cpp.o
In file included from /home/marcelo/Projects/Kratos/kratos/sources/connectivity_preserve_modeler.cpp:15:
In file included from /home/marcelo/Projects/Kratos/kratos/utilities/variable_utils.h:27:
In file included from /home/marcelo/Projects/Kratos/kratos/utilities/parallel_utilities.h:36:
/home/marcelo/Projects/Kratos/kratos/utilities/reduction_utilities.h:25:9: fatal error: 'omp.h' file not found
#include<omp.h>
        ^~~~~~~
1 error generated.
make[2]: *** [kratos/CMakeFiles/KratosCore.dir/build.make:134: kratos/CMakeFiles/KratosCore.dir/sources/connectivity_preserve_modeler.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:217: kratos/CMakeFiles/KratosCore.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
marandra commented 3 years ago

One more thing, when switching to v8.0.1 (with or without OpenMP), CMake still doesn't find OpenMP, but compiles with no errors

...
-- OpenMP included
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
...
philbucher commented 3 years ago

One more thing, when switching to v8.0.1 (with or without OpenMP), CMake still doesn't find OpenMP, but compiles with no errors

you mean Clang version 8.0.1?

If so then I think the following happens: Clang 11 seems to be stricter with missing omp.h. Other compilers (such as Clang 8) seem to still allow the compilation even if omp is not included.

There was a missing include guard, I fixed it, can you try to compile again the branch from #8150 ?

philbucher commented 3 years ago

sorry I somehow didn't read that you are referring to an older version of Kratos and not a different version of the compiler

I have one question, did it find OpenMP with the older version of Kratos?

philbucher commented 3 years ago

One more thing, when switching to v8.0.1 (with or without OpenMP), CMake still doesn't find OpenMP, but compiles with no errors

...
-- OpenMP included
-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES) 
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND) 
...

I meant this, it doesn't find OpenMP here either with the old version?

marandra commented 3 years ago

Got it. I found a LLVM-OpenMP package in the package repository, installed, and CMake found it immediately:

...
-- Standard install dir /home/marcelo/Projects/Kratos/bin/Release
Using OpenMP for shared memory parallelization
-- Found OpenMP_C: -fopenmp=libomp (found version "5.0") 
-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.0") 
-- Found OpenMP: TRUE (found version "5.0")  
-- Found Boost: /usr/lib64/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0")  
...

If I disable OpenMP:

...
-- Standard install dir /home/marcelo/Projects/Kratos/bin/Release
Shared memory parallelization is disabled!
-- Found Boost: /usr/lib64/cmake/Boost-1.75.0/BoostConfig.cmake (found version "1.75.0")  
...

I still don't understand why was it working before though, even with CMake saying that OpenMP was not found...

Anyways, I am closing the issue as the problem is solved. Feel free to open it in case you need to investigate it further. Thanks for your help.

philbucher commented 3 years ago

cool, glad it works now Ultimately I think the issue was caused by a non-warded include of omp.h which fails if omp cannot be found Should be solved with #8150