Skip to content

Commit c41573d

Browse files
authored
Merge pull request #425 from SCOREC/apw/nompi
PCU: Add nompi stub
2 parents 67759a7 + 42c4d6a commit c41573d

File tree

201 files changed

+1329
-782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+1329
-782
lines changed

.github/workflows/cmake.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- { name: GNU, CC: gcc-10, CXX: g++-10 }
1616
- { name: LLVM, CC: clang, CXX: clang++ }
1717
build_type: [Debug, Release]
18+
no_mpi: [OFF, ON]
1819

1920
steps:
2021
- uses: actions/checkout@v4
@@ -30,7 +31,7 @@ jobs:
3031
env:
3132
MPICH_CXX: ${{matrix.compiler.CXX}}
3233
MPICH_CC: ${{matrix.compiler.CC}}
33-
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_C_COMPILER=mpicc -DCMAKE_VERBOSE_MAKEFILE=ON -DMESHES=${{github.workspace}}/pumi-meshes -DIS_TESTING=ON -DSCOREC_CXX_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install
34+
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_C_COMPILER=mpicc -DCMAKE_VERBOSE_MAKEFILE=ON -DMESHES=${{github.workspace}}/pumi-meshes -DIS_TESTING=ON -DSCOREC_CXX_WARNINGS=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install -DSCOREC_NO_MPI=${{matrix.no_mpi}}
3435

3536
- name: Build
3637
env:
@@ -54,3 +55,20 @@ jobs:
5455
run: |
5556
cmake -S ${{github.workspace}}/doc -B ${{github.workspace}}/buildExample -DCMAKE_CXX_COMPILER=mpicxx -DSCOREC_PREFIX=${{github.workspace}}/build/install
5657
cmake --build ${{github.workspace}}/buildExample
58+
59+
- name: Build MPI-NoMPI Example
60+
# Test if a SCOREC_NO_MPI build works with MPI applications.
61+
if: >-
62+
matrix.compiler.name == 'GNU' && matrix.build_type == 'Release' &&
63+
matrix.no_mpi == 'ON'
64+
env:
65+
MPICH_CXX: ${{matrix.compiler.CXX}}
66+
MPICH_CC: ${{matrix.compiler.CC}}
67+
run: >
68+
cmake -S ${{github.workspace}}/example/mpi-nompi
69+
-B ${{github.workspace}}/example/mpi-nompi/build
70+
-DCMAKE_CXX_COMPILER=mpicxx
71+
-DSCOREC_PREFIX=${{github.workspace}}/build/install ;
72+
cmake --build ${{github.workspace}}/example/mpi-nompi/build ;
73+
ctest --test-dir ${{github.workspace}}/example/mpi-nompi/build
74+
--output-on-failure

CMakeLists.txt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ endif()
66
# This is the top level CMake file for the SCOREC build
77
cmake_minimum_required(VERSION 3.8)
88

9-
project(SCOREC VERSION 3.0.3 LANGUAGES CXX C)
9+
project(SCOREC VERSION 4.0.0 LANGUAGES CXX C)
1010

1111
include(cmake/bob.cmake)
1212
include(cmake/xsdk.cmake)
@@ -36,6 +36,15 @@ elseif(ENABLE_OMEGA_H)
3636
bob_set_cxx_standard(17)
3737
endif()
3838

39+
#
40+
# option related to MPI
41+
#
42+
option(SCOREC_NO_MPI "Disable MPI support. When enabled only serial execution is supported." OFF)
43+
message(STATUS "SCOREC_NO_MPI: ${SCOREC_NO_MPI}")
44+
if(SCOREC_NO_MPI AND ENABLE_CGNS)
45+
message(FATAL_ERROR "SCOREC_NO_MPI is incompatible with CGNS.")
46+
endif()
47+
3948
# Set some default compiler flags that should always be used
4049
if(NOT USE_XSDK_DEFAULTS)
4150
bob_set_shared_libs()
@@ -137,7 +146,10 @@ endif()
137146

138147
macro(scorec_export_library target)
139148
bob_export_target(${target})
140-
install(FILES ${HEADERS} DESTINATION include)
149+
install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
150+
target_include_directories(${target} INTERFACE
151+
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
152+
)
141153
endmacro(scorec_export_library)
142154

143155
if(ENABLE_SIMMETRIX)
@@ -168,6 +180,10 @@ if(ENABLE_CGNS)
168180
add_definitions(-DHAVE_CGNS)
169181
endif()
170182

183+
configure_file(SCOREC_config.h.in SCOREC_config.h)
184+
install(FILES "${CMAKE_BINARY_DIR}/SCOREC_config.h" DESTINATION include)
185+
include_directories(PUBLIC "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>")
186+
171187
# Include the SCOREC project packages
172188
add_subdirectory(lion)
173189
add_subdirectory(pcu)

SCOREC_config.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#ifndef SCOREC_CONFIG_H
2+
#define SCOREC_CONFIG_H
3+
4+
#cmakedefine SCOREC_NO_MPI
5+
6+
#endif // SCOREC_CONFIG_H
7+

apf/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ add_library(apf ${SOURCES})
9393
# Include directories
9494
target_include_directories(apf PUBLIC
9595
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
96-
$<INSTALL_INTERFACE:include>
9796
)
9897

9998
# Link this library to these others

apf/apfCGNS.cc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,9 @@ CellElementReturn WriteElements(const CGNS &cgns, apf::Mesh *m, apf::GlobalNumbe
545545
cgp_error_exit();
546546

547547
std::vector<int> allNumbersForThisType(m->getPCU()->Peers(), 0);
548-
MPI_Allgather(&numbersByElementType[o], 1, MPI_INT, allNumbersForThisType.data(), 1,
549-
MPI_INT, m->getPCU()->GetMPIComm());
548+
m->getPCU()->Allgather(
549+
&numbersByElementType[o], allNumbersForThisType.data(), 1
550+
);
550551

551552
cgsize_t num = 0;
552553
for (int i = 0; i < m->getPCU()->Self(); i++)
@@ -656,8 +657,7 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
656657
}
657658

658659
std::vector<int> allNumbersForThisType(m->getPCU()->Peers(), 0);
659-
MPI_Allgather(&number, 1, MPI_INT, allNumbersForThisType.data(), 1,
660-
MPI_INT, m->getPCU()->GetMPIComm());
660+
m->getPCU()->Allgather(&number, allNumbersForThisType.data(), 1);
661661

662662
cgsize_t num = 0;
663663
for (int i = 0; i < m->getPCU()->Self(); i++)
@@ -684,19 +684,16 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
684684
}
685685
}
686686
std::vector<int> cacheStarts(m->getPCU()->Peers(), 0);
687-
MPI_Allgather(&cacheStart, 1, MPI_INT, cacheStarts.data(), 1,
688-
MPI_INT, m->getPCU()->GetMPIComm());
687+
m->getPCU()->Allgather(&cacheStart, cacheStarts.data(), 1);
689688
std::vector<int> cacheEnds(m->getPCU()->Peers(), 0);
690-
MPI_Allgather(&cacheEnd, 1, MPI_INT, cacheEnds.data(), 1,
691-
MPI_INT, m->getPCU()->GetMPIComm());
689+
m->getPCU()->Allgather(&cacheEnd, cacheEnds.data(), 1);
692690
return std::make_pair(cacheStarts, cacheEnds);
693691
};
694692

695693
const auto globalElementList = [&m](const std::vector<cgsize_t> &bcList, std::vector<cgsize_t> &allElements) {
696694
std::vector<int> sizes(m->getPCU()->Peers(), 0); // important initialiser
697695
const int l = bcList.size();
698-
MPI_Allgather(&l, 1, MPI_INT, sizes.data(), 1,
699-
MPI_INT, m->getPCU()->GetMPIComm());
696+
m->getPCU()->Allgather(&l, sizes.data(), 1);
700697

701698
int totalLength = 0;
702699
for (const auto &i : sizes)
@@ -708,9 +705,15 @@ void AddBocosToMainBase(const CGNS &cgns, const CellElementReturn &cellResults,
708705
displacement[i] = displacement[i - 1] + sizes[i - 1];
709706

710707
allElements.resize(totalLength);
708+
#ifndef SCOREC_NO_MPI
709+
PCU_Comm comm;
710+
m->getPCU()->DupComm(&comm);
711711
MPI_Allgatherv(bcList.data(), bcList.size(), MPI_INT, allElements.data(),
712-
sizes.data(), displacement.data(), MPI_INT,
713-
m->getPCU()->GetMPIComm());
712+
sizes.data(), displacement.data(), MPI_INT, comm);
713+
MPI_Comm_free(&comm);
714+
#else
715+
std::copy(bcList.begin(), bcList.end(), allElements.begin());
716+
#endif
714717
};
715718

716719
const auto doVertexBC = [&](const auto &iter) {
@@ -1046,7 +1049,8 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
10461049
sizes[2] = 0; // nodes are unsorted, as defined by api
10471050

10481051
// Copy communicator
1049-
auto communicator = m->getPCU()->GetMPIComm();
1052+
PCU_Comm communicator;
1053+
m->getPCU()->DupComm(&communicator);
10501054
cgp_mpi_comm(communicator);
10511055
//
10521056
cgp_pio_mode(CGP_INDEPENDENT);
@@ -1134,6 +1138,9 @@ void WriteCGNS(const char *prefix, apf::Mesh *m, const apf::CGNSBCMap &cgnsBCMap
11341138
destroyGlobalNumbering(gcn);
11351139
//
11361140
cgp_close(cgns.index);
1141+
#ifndef SCOREC_NO_MPI
1142+
MPI_Comm_free(&communicator);
1143+
#endif
11371144
}
11381145
} // namespace
11391146

apf_cap/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ include(GNUInstallDirs)
3939

4040
target_include_directories(apf_cap PUBLIC
4141
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
42-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
4342
)
4443

4544
scorec_export_library(apf_cap)

apf_sim/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ target_link_libraries(apf_sim PUBLIC ${SIMMODSUITE_LIBS})
1919
target_include_directories(gmi_sim PUBLIC ${SIMMODSUITE_INCLUDE_DIR})
2020
target_include_directories(apf_sim PUBLIC
2121
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
22-
$<INSTALL_INTERFACE:include>
2322
)
2423

2524
option(ENABLE_FIELDSIM "Enable use of FieldSim from Simmetrix SimModSuite" FALSE)

can/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ add_library(can INTERFACE)
1111
# Include directories
1212
target_include_directories(can INTERFACE
1313
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
14-
$<INSTALL_INTERFACE:include>
1514
)
1615

1716
scorec_export_library(can)

crv/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ add_library(crv ${SOURCES})
3333
# Include directories
3434
target_include_directories(crv INTERFACE
3535
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
36-
$<INSTALL_INTERFACE:include>
3736
)
3837

3938
# Link this package to these libraries

doc/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ set(SCOREC_PREFIX "" CACHE STRING "Directory where SCOREC is installed")
1616
# If SCOREC_PREFIX was specified, only link to that directory,
1717
# i.e. don't link to another installation in /usr/lib by mistake
1818
if (SCOREC_PREFIX)
19-
find_package(SCOREC 3.0.0 REQUIRED CONFIG PATHS ${SCOREC_PREFIX} NO_DEFAULT_PATH)
19+
find_package(SCOREC 4 REQUIRED CONFIG PATHS ${SCOREC_PREFIX} NO_DEFAULT_PATH)
2020
else()
2121
# IF SCOREC_PREFIX was not specified, look in typical system directories,
2222
# and also in CMAKE_PREFIX_PATH (environment variable)
2323
find_package(
2424
SCOREC #package name, has to be SCOREC
25-
3.0.0 #version. can be omitted, and will match any installed version
25+
4 #version. can be omitted, and will match any installed version
2626
#greater than or equal to this one, as long as the major number
2727
#is the same
2828
REQUIRED #indicate that SCOREC is really needed to compile

0 commit comments

Comments
 (0)