Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mpiexec to run unit tests #37

Merged
merged 16 commits into from
Aug 6, 2024
Merged
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
Loading