Skip to content

Commit

Permalink
Merge pull request #37 from ORNL-Fusion/ctest_use_mpiexec
Browse files Browse the repository at this point in the history
Use mpiexec to run unit tests
  • Loading branch information
mbeidler3 authored Aug 6, 2024
2 parents 30baea8 + 81b940a commit 7ed0514
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 61 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ jobs:
needs: job_one
runs-on: ubuntu-latest
steps:
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v2
id: cpu-cores
- name: grab main project
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -83,7 +86,7 @@ jobs:
cd ./KORC
./build.sh
cd ./build && ctest --output-on-failure
cd ./build && ctest -j ${{ steps.cpu-cores.outputs.count }} --output-on-failure
- name: Show Cache
if: failure()
Expand Down
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
# ignore build directory
/build

# ignore all CMakeFile directories
**/CMakeFiles

# ignore all CmakeCache.txt files
CMakeCache.txt

# ignore all cmake_install.cmake files
cmake_install.cmake

# ignore all Makefile files generated by cmake
Makefile
src/Makefile
Expand All @@ -31,15 +22,11 @@ FIO/m3dc1_lib/makefile
#ignore files in OUT_TEST
**/OUT_TEST

# ignore CTest files
CTestTestfile.cmake
**/Testing

#ignore FIO build and install
/FIO/build
/FIO/install

#ignore all build files
*.o
*.mod
*.a
*.a
34 changes: 26 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,34 @@ target_link_libraries (xtest

set_property(TARGET xtest PROPERTY LINKER_LANGUAGE Fortran)

add_test (NAME egyro_test
COMMAND ${CMAKE_SOURCE_DIR}/test/egyro/korc_egyro.sh ${CMAKE_SOURCE_DIR}/test/egyro
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
configure_file(${CMAKE_SOURCE_DIR}/test/egyro/korc_egyro.sh.in ${CMAKE_BINARY_DIR}/egyro_test/korc_egyro.sh)
configure_file(${CMAKE_SOURCE_DIR}/test/mars/korc_mars.sh.in ${CMAKE_BINARY_DIR}/mars_test/korc_mars.sh)

if(USE_PSPLINE)
add_test (NAME mars_test
COMMAND ${CMAKE_SOURCE_DIR}/test/mars/korc_mars.sh ${CMAKE_SOURCE_DIR}/test/mars
add_test (NAME mars_test_1
COMMAND ${CMAKE_BINARY_DIR}/mars_test/korc_mars.sh 1
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set_tests_properties (mars_test_1 PROPERTIES PROCESSORS 1 ENVIRONMENT OMP_NUM_THREADS=1)
endif()

add_test (NAME unit_testing
COMMAND xtest TEST_OUT
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
foreach(RANK IN ITEMS 1 2 4 8 16)
if(${RANK} LESS_EQUAL ${MPIEXEC_MAX_NUMPROCS})
add_test (NAME egyro_test_${RANK}
COMMAND ${CMAKE_BINARY_DIR}/egyro_test/korc_egyro.sh ${RANK}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set_tests_properties (egyro_test_${RANK} PROPERTIES PROCESSORS ${RANK} ENVIRONMENT OMP_NUM_THREADS=1)

# if(USE_PSPLINE)
# add_test (NAME mars_test_${RANK}
# COMMAND ${CMAKE_BINARY_DIR}/mars_test/korc_mars.sh ${RANK}
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# set_tests_properties (mars_test_${RANK} PROPERTIES PROCESSORS ${RANK} ENVIRONMENT OMP_NUM_THREADS=1)
# endif()

add_test (NAME unit_testing_${RANK}
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${RANK} ./xtest TEST_OUT
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set_tests_properties (unit_testing_${RANK} PROPERTIES PROCESSORS ${RANK} ENVIRONMENT OMP_NUM_THREADS=1)
endif()
endforeach()

17 changes: 0 additions & 17 deletions test/egyro/korc_egyro.sh

This file was deleted.

18 changes: 18 additions & 0 deletions test/egyro/korc_egyro.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -ex

#define input file
INPUT_FILE="${CMAKE_SOURCE_DIR}/test/egyro/input_file_egyro.korc"
#define output directory
OUT_DIR="egyro_test/rank_$1"

#check that output directory doesn't exist so bash doesn't complain
if [ ! -d $OUT_DIR ]; then
mkdir -p $OUT_DIR
fi

#assumes binary directory ../KORC/build/bin was added to path
${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} $1 ./xkorc $INPUT_FILE $OUT_DIR/

h5diff -r -d 0.000001 $OUT_DIR/file_0.h5 ${CMAKE_SOURCE_DIR}/test/egyro/file_0.h5
21 changes: 0 additions & 21 deletions test/mars/korc_mars.sh

This file was deleted.

20 changes: 20 additions & 0 deletions test/mars/korc_mars.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -ex

#define input file
INPUT_FILE="${CMAKE_SOURCE_DIR}/test/mars/input_file_D3D_191366_1762ms_MARS.korc"
#define output directory
OUT_DIR="mars_test/rank_$1"

#check that output directory doesn't exist so bash doesn't complain
if [ ! -d $OUT_DIR ]; then
mkdir -p $OUT_DIR
fi
if [ ! -f D3D_191366_1762ms_MARS.h5 ]; then
ln -s ${CMAKE_SOURCE_DIR}/test/mars/D3D_191366_1762ms_MARS.h5 D3D_191366_1762ms_MARS.h5
fi

${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} $1 ./xkorc $INPUT_FILE $OUT_DIR/

h5diff -r -d 0.008 $OUT_DIR/file_0.h5 ${CMAKE_SOURCE_DIR}/test/mars/file_0_new_random.h5

0 comments on commit 7ed0514

Please sign in to comment.