Skip to content

Commit

Permalink
Merge pull request #78 from LLNL/feature/zagaris2/fix-openmp-detection
Browse files Browse the repository at this point in the history
Fix openmp detection + minor build improvements
  • Loading branch information
gzagaris committed Aug 27, 2019
2 parents b88a42a + 416a8bc commit 898c9d2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 65 deletions.
4 changes: 4 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The Axom project release numbers follow [Semantic Versioning](http://semver.org/
### Deprecated

### Changed
- AXOM_USE_OPENMP is now being set at configure time accordingly instead of
auto-detected based on whether "_OPENMP" is passed by the compiler. This
fixes issues where a host code would compile Axom w/out OpenMP, but, use
Axom in parts of the code where OpenMP is enabled.

### Fixed

Expand Down
13 changes: 1 addition & 12 deletions src/axom/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
*/
#cmakedefine USE_C_LOC_WITH_ASSUMED_SHAPE


/*
* Compiler defines for libraries (built-in and third party)
*/
Expand All @@ -58,22 +57,12 @@
#cmakedefine AXOM_USE_MFEM
#cmakedefine AXOM_USE_MPI
#cmakedefine AXOM_USE_MPIF_HEADER
#cmakedefine AXOM_USE_OPENMP
#cmakedefine AXOM_USE_RAJA
#cmakedefine AXOM_USE_SCR
#cmakedefine AXOM_USE_SPARSEHASH
#cmakedefine AXOM_USE_UMPIRE

/*
* OpenMP is a special case since it varies by target and the compiler
* provides its own definition. For consistency, the project exposes
* and uses this through its own AXOM_USE define.
*/
#ifdef _OPENMP
#define AXOM_USE_OPENMP
#else
#undef AXOM_USE_OPENMP
#endif


/*
* We need to explicitly add some definitions on Windows
Expand Down
46 changes: 13 additions & 33 deletions src/axom/core/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(gtest_utils_tests
core_array.cpp
core_memory_management.cpp
core_stack_array.cpp

utils_TaskTimer.cpp
utils_endianness.cpp
utils_fileUtilities.cpp
Expand Down Expand Up @@ -62,27 +62,27 @@ endforeach()
# Add MPI tests if MPI is enabled
#
if ( ENABLE_MPI )

set( core_mpi_tests
core_types.cpp
)

foreach( mpitest ${core_mpi_tests} )

get_filename_component( mpitest_name ${mpitest} NAME_WE )

blt_add_executable( NAME ${mpitest_name}_test
SOURCES ${mpitest}
SOURCES ${mpitest}
OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
DEPENDS_ON ${utils_tests_depends} mpi
DEPENDS_ON ${utils_tests_depends} mpi
FOLDER axom/core/tests )
blt_add_test( NAME ${mpitest_name}
COMMAND ${mpitest_name}_test

blt_add_test( NAME ${mpitest_name}
COMMAND ${mpitest_name}_test
NUM_MPI_TASKS 1 )

endforeach()

endif()

#
Expand All @@ -91,6 +91,7 @@ endif()
set(utils_config_test_depends ${utils_tests_depends})

blt_list_append( TO utils_config_test_depends ELEMENTS mfem IF ${MFEM_FOUND} )
blt_list_append( TO utils_config_test_depends ELEMENTS openmp IF ${ENABLE_OPENMP} )

blt_add_executable( NAME utils_config_test
SOURCES utils_config.cpp
Expand All @@ -111,24 +112,3 @@ if(MFEM_FOUND)
APPEND_STRING PROPERTY COMPILE_FLAGS "${AXOM_DISABLE_UNUSED_PARAMETER_WARNINGS}")
endif()


if(ENABLE_OPENMP)
# Add a config test that uses OpenMP
blt_add_executable( NAME utils_config_openmp_test
SOURCES utils_config.cpp
OUTPUT_DIR ${TEST_OUTPUT_DIRECTORY}
DEPENDS_ON ${utils_config_test_depends} openmp
FOLDER axom/core/tests )

blt_add_test( NAME utils_config_openmp
COMMAND utils_config_openmp_test )

if(MFEM_FOUND)
set_property(TARGET utils_config_openmp_test
APPEND_STRING PROPERTY COMPILE_FLAGS "${AXOM_DISABLE_UNUSED_PARAMETER_WARNINGS}")
endif()

endif()



2 changes: 1 addition & 1 deletion src/cmake/AxomConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ message(STATUS "Configuring Axom version ${AXOM_VERSION_FULL}")
## Add a definition to the generated config file for each library dependency
## (optional and built-in) that we might need to know about in the code. We
## check for vars of the form <DEP>_FOUND or ENABLE_<DEP>
set(TPL_DEPS CONDUIT CUDA FMT HDF5 MFEM MPI RAJA SCR SPARSEHASH UMPIRE )
set(TPL_DEPS CONDUIT CUDA FMT HDF5 MFEM MPI RAJA SCR SPARSEHASH UMPIRE OPENMP )
foreach(dep ${TPL_DEPS})
if( ${dep}_FOUND OR ENABLE_${dep} )
set(AXOM_USE_${dep} TRUE )
Expand Down
36 changes: 18 additions & 18 deletions src/cmake/AxomMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ endmacro(axom_add_code_checks)
## (ON/OFF). This macro also adds an "option" so that the user can control,
## which components to build.
##------------------------------------------------------------------------------
set(AXOM_COMPONENTS_FULL CACHE LIST "List of all components in Axom" FORCE)
set(AXOM_COMPONENTS_ENABLED CACHE LIST "List of all enabled components in Axom" FORCE)
set(AXOM_COMPONENTS_FULL CACHE STRING "List of all components in Axom" FORCE)
set(AXOM_COMPONENTS_ENABLED CACHE STRING "List of all enabled components in Axom" FORCE)
macro(axom_add_component)

set(options)
Expand All @@ -90,11 +90,11 @@ macro(axom_add_component)
${arg_DEFAULT_STATE})

set(AXOM_COMPONENTS_FULL ${AXOM_COMPONENTS_FULL} ${COMPONENT_NAME_LOWERED}
CACHE LIST "List of all components in Axom" FORCE)
CACHE STRING "List of all components in Axom" FORCE)

if ( AXOM_ENABLE_${COMPONENT_NAME_CAPITALIZED} )
set(AXOM_COMPONENTS_ENABLED ${AXOM_COMPONENTS_ENABLED} ${COMPONENT_NAME_LOWERED}
CACHE LIST "List of all enabled components in Axom" FORCE)
CACHE STRING "List of all enabled components in Axom" FORCE)
add_subdirectory( ${arg_COMPONENT_NAME} )
endif()

Expand All @@ -118,13 +118,13 @@ endmacro()

##------------------------------------------------------------------------------
## axom_check_code_compiles
##
##
## This macro checks if a snippet of C++ code compiles.
##
## SOURCE_STRING The source snippet to compile.
## SOURCE_STRING The source snippet to compile.
## Must be a valid C++ program with a main() function.
## Note: This parameter should be passed in as a quoted string variable. Otherwise,
## cmake will convert the string into a list and lose the semicolons.
## Note: This parameter should be passed in as a quoted string variable. Otherwise,
## cmake will convert the string into a list and lose the semicolons.
## E.g. axom_check_code_compiles(SOURCE_STRING "${str_var}" ...)
##
## CODE_COMPILES A boolean variable the contains the compilation result.
Expand All @@ -147,11 +147,11 @@ macro(axom_check_code_compiles)
endif()
if(NOT DEFINED arg_CODE_COMPILES)
message(FATAL_ERROR "[axom_check_code_compiles] 'CODE_COMPILES' is a required parameter")
endif()
endif()

if(NOT DEFINED arg_VERBOSE_OUTPUT)
set(arg_VERBOSE_OUTPUT FALSE)
endif()
endif()

if(${arg_VERBOSE_OUTPUT})
message(STATUS "[axom_check_code_compiles] Attempting to compile source string: \n${arg_SOURCE_STRING}")
Expand All @@ -162,7 +162,7 @@ macro(axom_check_code_compiles)
set(_fname ${CMAKE_CURRENT_BINARY_DIR}/_axomCheckCompiles${_rand}.cpp)
file(WRITE ${_fname} "${arg_SOURCE_STRING}")
try_compile(${arg_CODE_COMPILES}
${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp
${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp
SOURCES ${_fname}
CXX_STANDARD ${CMAKE_CXX_STANDARD}
OUTPUT_VARIABLE _res)
Expand All @@ -171,11 +171,11 @@ macro(axom_check_code_compiles)
if(${arg_VERBOSE_OUTPUT})
message(STATUS "[axom_check_code_compiles] Compiler output: \n${_res}\n")

if(${arg_CODE_COMPILES})
if(${arg_CODE_COMPILES})
message(STATUS "[axom_check_code_compiles] The code snippet successfully compiled")
else()
message(STATUS "[axom_check_code_compiles] The code snippet failed to compile")
endif()
endif()
endif()

# clear the variables set within the macro
Expand All @@ -187,7 +187,7 @@ endmacro(axom_check_code_compiles)

##------------------------------------------------------------------------------
## axom_component_requires
##
##
## This macro checks for the required dependencies of the given component
##
## NAME - The name of the component that we are checking the dependencies of
Expand Down Expand Up @@ -224,7 +224,7 @@ endmacro(axom_component_requires)

##------------------------------------------------------------------------------
## axom_install_component
##
##
## This macro installs libraries, fortran modules, headers, and exports the CMake
## target while preserving the directory stucture. This macro assumes the following:
##
Expand Down Expand Up @@ -264,7 +264,7 @@ endmacro(axom_install_component)

##------------------------------------------------------------------------------
## axom_write_unified_header
##
##
## This macro writes the unified header (axom/<lowered NAME>.hpp) to the build directory for the
## given component NAME with the given HEADERS included inside of it.
##
Expand All @@ -289,7 +289,7 @@ macro(axom_write_unified_header)

file(WRITE ${_header} "\/\/ Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC and
\/\/ other Axom Project Developers. See the top-level COPYRIGHT file for details.
\/\/
\/\/
\/\/ SPDX-License-Identifier: (BSD-3-Clause)
\n
")
Expand All @@ -301,7 +301,7 @@ macro(axom_write_unified_header)

foreach(_file ${arg_HEADERS})
set(_headerPath "axom\/${_lcname}\/${_file}")

if(${_file} IN_LIST arg_EXCLUDE)
continue()
elseif(${_headerPath} MATCHES "(\/detail\/)|(\/internal\/)")
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/blt
Submodule blt updated 91 files
+2 −2 .travis.yml
+31 −4 RELEASE-NOTES.md
+9 −3 SetupBLT.cmake
+49 −10 cmake/BLTMacros.cmake
+17 −0 cmake/BLTPrivateMacros.cmake
+1 −0 cmake/SetupCodeChecks.cmake
+4 −2 cmake/thirdparty/SetupHIP.cmake
+40 −14 cmake/thirdparty/SetupMPI.cmake
+2 −2 docs/conf.py
+9 −8 docs/creating_documentation.rst
+7 −5 docs/creating_execs_and_libs.rst
+42 −26 docs/external_dependencies.rst
+6 −4 docs/index.rst
+26 −11 docs/recommendations.rst
+5 −5 docs/setup_blt.rst
+5 −7 docs/tutorial/blank_project/CMakeLists.txt
+17 −22 docs/tutorial/calc_pi/CMakeLists.txt
+2 −2 docs/tutorial/calc_pi/docs/doxygen/CMakeLists.txt
+3 −3 docs/tutorial/calc_pi/docs/doxygen/Doxyfile.in
+2 −2 docs/tutorial/calc_pi/docs/sphinx/CMakeLists.txt
+1 −1 docs/tutorial/calc_pi/docs/sphinx/conf.py
+1 −1 docs/unit_testing.rst
+4 −1 docs/using_flags.rst
+0 −0 host-configs/darwin/elcapitan-x86_64/naples-clang@7.3.0.cmake
+0 −44 host-configs/llnl-quartz-toss3-gcc@4.9.3.cmake
+0 −0 host-configs/llnl/bgqos_0/clang@4.0.0_xlf.cmake
+19 −15 host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_link_with_nvcc.cmake
+76 −0 host-configs/llnl/blueos_3_ppc64le_ib_p9/clang@upstream_nvcc_xlf.cmake
+0 −0 host-configs/llnl/toss_3_x86_64_ib/clang@4.0.0-libcxx.cmake
+0 −0 host-configs/llnl/toss_3_x86_64_ib/clang@6.0.0-static-analysis.cmake
+46 −0 host-configs/llnl/toss_3_x86_64_ib/gcc@4.9.3.cmake
+0 −0 host-configs/llnl/toss_3_x86_64_ib/pgi@18.5.cmake
+0 −0 host-configs/llnl/windows/sqa-uno-msvc@15.cmake
+0 −0 host-configs/other/hcc.cmake
+0 −0 host-configs/other/hip.cmake
+10 −10 host-configs/other/llnl-surface-chaos_5_x86_64_ib-gcc@4.9.3.cmake
+116 −26 tests/internal/CMakeLists.txt
+13 −0 tests/internal/astyle.cfg
+5 −6 tests/internal/src/Example.cpp
+6 −6 tests/internal/src/Example.hpp
+22 −22 tests/internal/src/Example_Exports.h
+6 −4 tests/internal/src/HeaderOnly.hpp
+1 −1 tests/internal/src/combine_static_library_test/Foo1.cpp
+2 −2 tests/internal/src/combine_static_library_test/Foo1.hpp
+1 −1 tests/internal/src/combine_static_library_test/Foo2.cpp
+2 −2 tests/internal/src/combine_static_library_test/Foo2.hpp
+1 −1 tests/internal/src/combine_static_library_test/Foo3.cpp
+1 −1 tests/internal/src/combine_static_library_test/Foo3.hpp
+1 −1 tests/internal/src/combine_static_library_test/blt_combine_static_libraries_shared_smoke.cpp
+1 −1 tests/internal/src/combine_static_library_test/blt_combine_static_libraries_static_smoke.cpp
+1 −1 tests/internal/src/combine_static_library_test/dummy.cpp
+2 −2 tests/internal/src/combine_static_library_test/main.cpp
+7 −7 tests/internal/src/object_library_test/base_object.cpp
+1 −1 tests/internal/src/object_library_test/base_object.hpp
+2 −2 tests/internal/src/object_library_test/inherited_base/inherited_base.cpp
+1 −1 tests/internal/src/object_library_test/inherited_base/inherited_base.hpp
+41 −34 tests/internal/src/object_library_test/main.cpp
+2 −2 tests/internal/src/object_library_test/object.cpp
+1 −1 tests/internal/src/object_library_test/object.hpp
+7 −6 tests/internal/src/static_analysis/well_analyzed_source.cpp
+11 −11 tests/internal/src/t_example_compile_definitions.cpp
+3 −3 tests/internal/src/t_example_smoke.cpp
+2 −2 tests/internal/src/t_header_only_smoke.cpp
+10 −12 tests/internal/src/test_cuda_device_call_from_kernel/CMakeLists.txt
+51 −0 tests/internal/src/test_cuda_device_call_from_kernel/Child.cpp
+0 −47 tests/internal/src/test_cuda_device_call_from_kernel/Child.cxx
+0 −25 tests/internal/src/test_cuda_device_call_from_kernel/Child.h
+30 −0 tests/internal/src/test_cuda_device_call_from_kernel/Child.hpp
+38 −0 tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cpp
+0 −35 tests/internal/src/test_cuda_device_call_from_kernel/CudaTests.cxx
+4 −5 tests/internal/src/test_cuda_device_call_from_kernel/Parent.cpp
+8 −7 tests/internal/src/test_cuda_device_call_from_kernel/Parent.hpp
+418 −0 tests/internal/src/test_cuda_mpi.cpp
+12 −1 tests/smoke/CMakeLists.txt
+68 −0 tests/smoke/blt_cuda_mpi_smoke.cpp
+27 −25 tests/smoke/blt_cuda_openmp_smoke.cpp
+21 −21 tests/smoke/blt_cuda_runtime_smoke.cpp
+11 −11 tests/smoke/blt_cuda_smoke.cpp
+24 −16 tests/smoke/blt_gbenchmark_smoke.cpp
+30 −30 tests/smoke/blt_gmock_smoke.cpp
+6 −6 tests/smoke/blt_gtest_smoke.cpp
+28 −27 tests/smoke/blt_hcc_runtime_smoke.cpp
+9 −8 tests/smoke/blt_hcc_smoke.cpp
+20 −20 tests/smoke/blt_hip_runtime_smoke.cpp
+11 −11 tests/smoke/blt_hip_smoke.cpp
+28 −26 tests/smoke/blt_mpi_smoke.cpp
+14 −14 tests/smoke/blt_openmp_smoke.cpp
+1 −1 tests/smoke/fortran_driver.cpp
+5 −3 thirdparty_builtin/googletest-master-2018-02-01/googletest/CMakeLists.txt
+4 −0 thirdparty_builtin/googletest-master-2018-02-01/googletest/include/gtest/gtest-printers.h
+15 −0 thirdparty_builtin/patches/gtest-2018-02-01-fix-msvc-c++17.patch

0 comments on commit 898c9d2

Please sign in to comment.