Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit 5a6ca80

Browse files
authored
Merge pull request #13 from Alpine-DAV/task/2021_09_pthread_fun
adjust threads and openmp logic for new cmake
2 parents 2da84d7 + 8adabf0 commit 5a6ca80

File tree

9 files changed

+136
-74
lines changed

9 files changed

+136
-74
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,9 @@ endif()
6363
cmake_minimum_required(VERSION 3.9)
6464

6565
################################
66-
# Set BLT Options
66+
# Init BLT w/ our options
6767
################################
68-
69-
# don't use BLT's all warnings feature
70-
set(ENABLE_ALL_WARNINGS OFF CACHE INTERNAL "")
71-
72-
################################
73-
# Init BLT
74-
################################
75-
if (NOT BLT_CXX_STD)
76-
set(BLT_CXX_STD "c++11" CACHE STRING "")
77-
endif()
78-
79-
# if BLT_SOURCE_DIR is not set - use "blt" as default
80-
if(NOT BLT_SOURCE_DIR)
81-
set(BLT_SOURCE_DIR "blt")
82-
endif()
83-
84-
# init blt using BLT_SOURCE_DIR
85-
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
68+
include(cmake/SetupBLT.cmake)
8669

8770
################################
8871
# Basic CMake Setup

src/apcomp/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if (ENABLE_SERIAL)
3939
set(apcomp_deps )
4040

4141
if(ENABLE_OPENMP)
42-
list(APPEND apcomp_deps openmp)
42+
list(APPEND apcomp_deps ${apcomp_blt_openmp_deps})
4343
endif()
4444

4545
blt_add_library(
@@ -92,10 +92,10 @@ list(APPEND apcomp_mpi_sources ${apcomp_sources})
9292

9393
if (MPI_FOUND)
9494

95-
set(apcomp_mpi_deps mpi)
95+
set(apcomp_mpi_deps ${apcomp_blt_mpi_deps})
9696

9797
if(ENABLE_OPENMP)
98-
list(APPEND apcomp_mpi_deps openmp)
98+
list(APPEND apcomp_mpi_deps ${apcomp_blt_openmp_deps})
9999
endif()
100100

101101

src/cmake/SetupBLT.cmake

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Copyright (c) Lawrence Livermore National Security, LLC and other APComp
2+
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
3+
# other details. No copyright assignment is required to contribute to APComp.
4+
5+
################################################################
6+
# if BLT_SOURCE_DIR is not set - use "blt" as default
7+
################################################################
8+
if(NOT BLT_SOURCE_DIR)
9+
set(BLT_SOURCE_DIR "blt")
10+
endif()
11+
12+
################################################################
13+
# if not set, prefer c++11 lang standard
14+
################################################################
15+
if(NOT BLT_CXX_STD)
16+
set(BLT_CXX_STD "c++11" CACHE STRING "")
17+
endif()
18+
19+
################################################################
20+
# if not set, prefer folder grouped targets
21+
################################################################
22+
if(NOT ENABLE_FOLDERS)
23+
set(ENABLE_FOLDERS TRUE CACHE STRING "")
24+
endif()
25+
26+
27+
################################################################
28+
# init blt using BLT_SOURCE_DIR
29+
################################################################
30+
include(${BLT_SOURCE_DIR}/SetupBLT.cmake)
31+
32+
if(ENABLE_MPI)
33+
# on some platforms (mostly cray systems) folks skip mpi
34+
# detection in BLT by setting ENABLE_FIND_MPI = OFF
35+
# in these cases, we need to set FOUND_MPI = TRUE,
36+
# since the rest of our cmake logic to include MPI uses FOUND_MPI
37+
if(NOT ENABLE_FIND_MPI)
38+
set(FOUND_MPI ON CACHE BOOL "")
39+
endif()
40+
41+
# adjust MPI from BLT
42+
if( ${CMAKE_VERSION} VERSION_LESS "3.15.0" )
43+
# older cmake, we use BLT's mpi support, it uses
44+
# the name mpi
45+
set(apcomp_blt_mpi_deps mpi CACHE STRING "")
46+
else()
47+
if(TARGET MPI::MPI_CXX)
48+
message(STATUS "Using MPI CMake imported target: MPI::MPI_CXX")
49+
# newer cmake we use find mpi targets directly
50+
set(apcomp_blt_mpi_deps MPI::MPI_CXX CACHE STRING "")
51+
else()
52+
message(FATAL_ERROR "Cannot use CMake imported targets for MPI."
53+
"(CMake > 3.15, ENABLE_MPI == ON, but "
54+
"MPI::MPI_CXX CMake target is missing.)")
55+
endif()
56+
endif()
57+
endif()
58+
59+
60+
if(ENABLE_OPENMP)
61+
# adjust OpenMP from BLT
62+
if( ${CMAKE_VERSION} VERSION_LESS "3.9.0" )
63+
# older cmake, we use BLT's openmp support, it uses
64+
# the name openmp
65+
set(apcomp_blt_openmp_deps openmp CACHE STRING "")
66+
else()
67+
if(TARGET OpenMP::OpenMP_CXX)
68+
message(STATUS "Using OpenMP CMake imported target: OpenMP::OpenMP_CXX")
69+
# newer cmake we openmp targets directly
70+
set(apcomp_blt_openmp_deps OpenMP::OpenMP_CXX CACHE STRING "")
71+
else()
72+
message(FATAL_ERROR "Cannot use CMake imported targets for OpenMP."
73+
"(CMake > 3.9, ENABLE_OPENMP == ON, but "
74+
"OpenMP::OpenMP_CXX CMake target is missing.)")
75+
endif()
76+
endif()
77+
endif()
78+
79+
80+
################################################################
81+
# apply folders to a few ungrouped blt targets
82+
################################################################
83+
84+
###############################################
85+
# group main blt docs targets into docs folder
86+
###############################################
87+
blt_set_target_folder( TARGET docs FOLDER docs)
88+
89+
if(TARGET sphinx_docs)
90+
blt_set_target_folder( TARGET sphinx_docs FOLDER docs)
91+
endif()
92+
93+
if(TARGET doxygen_docs)
94+
blt_set_target_folder( TARGET doxygen_docs FOLDER docs)
95+
endif()
96+
97+
####################################################
98+
# group top level blt health checks into blt folder
99+
####################################################
100+
if(TARGET check)
101+
blt_set_target_folder( TARGET check FOLDER blt)
102+
endif()
103+
104+
if(TARGET style)
105+
blt_set_target_folder( TARGET style FOLDER blt)
106+
endif()

src/cmake/VTKhConfig.cmake.in

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/config/APCompConfig.cmake.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ if(NOT APCOMP_FOUND)
5757
set(APCOMP_VERSION "@PROJECT_VERSION@")
5858
set(APCOMP_INSTALL_PREFIX "@ASCENT_INSTALL_PREFIX@")
5959

60+
set(APCOMP_OPENMP_ENABLED "@ENABLE_OPENMP@")
61+
set(APCOMP_MPI_ENABLED "@ENABLE_MPI@")
62+
6063
# pull in vars with details about configured paths
6164
get_filename_component(APCOMP_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
6265

63-
include(${APCOMP_CMAKE_CONFIG_DIR}/APCompTargets.cmake)
66+
# setup dependent pkgs
67+
include(${APCOMP_CMAKE_CONFIG_DIR}/apcomp_setup_deps.cmake)
6468

69+
include(${APCOMP_CMAKE_CONFIG_DIR}/APCompTargets.cmake)
70+
6571
set(APCOMP_FOUND TRUE)
6672

6773
endif()

src/config/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@ configure_package_config_file(
9494
install(FILES
9595
${CMAKE_CURRENT_BINARY_DIR}/APCompConfig.cmake
9696
${CMAKE_CURRENT_BINARY_DIR}/APCompConfigVersion.cmake
97+
apcomp_setup_deps.cmake
9798
DESTINATION ${APComp_INSTALL_CMAKE_MODULE_DIR})
9899

src/config/apcomp_setup_deps.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) Lawrence Livermore National Security, LLC and other APComp
2+
# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
3+
# other details. No copyright assignment is required to contribute to APComp.
4+
5+
6+
if(APCOMP_OPENMP_ENABLED)
7+
# config openmp if not already found
8+
if(NOT TARGET OpenMP::OpenMP_CXX)
9+
find_package(OpenMP REQUIRED)
10+
endif()
11+
endif()
12+

src/tests/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ set(MPI_TESTS t_apcomp_mpi_smoke
6060
t_apcomp_c_order_mpi
6161
t_apcomp_volume_partials_mpi)
6262

63+
# note: this should come in automatically
64+
# but not going to temp fate
6365
if(ENABLE_OPENMP)
64-
set(apcomp_deps openmp)
66+
set(apcomp_deps ${apcomp_blt_openmp_deps})
6567
endif()
68+
6669
################################
6770
# Add main tests
6871
################################

0 commit comments

Comments
 (0)