diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index a4f7ba63..a42d076a 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -15,7 +15,7 @@ jobs: - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - name: Install MPI - run: sudo apt-get update && sudo apt-get install -y libopenmpi-dev openmpi-bin + run: sudo apt-get update && sudo apt-get install -y libopenmpi-dev openmpi-bin cmake - name: Check out repository code uses: actions/checkout@v4 - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Install MPI - run: sudo apt-get update && sudo apt-get install -y mpich + run: sudo apt-get update && sudo apt-get install -y mpich cmake - name: Check out repository code uses: actions/checkout@v4 - name: Build Kokkos diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 0db0b856..852cbd40 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -20,6 +20,13 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(mpitest) +add_executable(test-mpi test_mpi.cpp) +add_test(NAME test-mpi-1 + COMMAND mpirun -np 1 ./test-mpi +) +add_test(NAME test-mpi-2 + COMMAND mpirun -np 2 ./test-mpi +) add_executable(test-main test_main.cpp test_initfinalize.cpp @@ -29,6 +36,7 @@ add_executable(test-main test_main.cpp target_link_libraries(test-main KokkosComm gtest gtest_mpi) add_test(NAME test-main - COMMAND mpirun -np 2 ./test-main) + COMMAND mpirun -np 2 ./test-main +) diff --git a/unit_tests/test_mpi.cpp b/unit_tests/test_mpi.cpp new file mode 100644 index 00000000..e8c3685b --- /dev/null +++ b/unit_tests/test_mpi.cpp @@ -0,0 +1,13 @@ +#include + +int main(int argc, char *argv[]) { + // Initialize MPI before any call to gtest_mpi + MPI_Init(&argc, &argv); + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if (0 == rank) { + std::cout << "Hello from rank " << rank << "\n"; + } + MPI_Finalize(); + return 0; +} \ No newline at end of file