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

Run tests in parallel on CI #49

Merged
merged 11 commits into from
Feb 22, 2024
Merged

Conversation

Nanoseb
Copy link
Collaborator

@Nanoseb Nanoseb commented Feb 21, 2024

closes #20

@Nanoseb Nanoseb added the test To do with the unit test and CI label Feb 21, 2024
@Nanoseb Nanoseb self-assigned this Feb 21, 2024
@Nanoseb
Copy link
Collaborator Author

Nanoseb commented Feb 21, 2024

I had to use --oversubscribe because the CI runner doesn't seem to have more than 1 core. Though it shouldn't matter for the logic of the tests themselves.

@Nanoseb Nanoseb marked this pull request as ready for review February 21, 2024 18:36
@Nanoseb Nanoseb removed the request for review from semi-h February 21, 2024 18:50
@@ -43,5 +47,5 @@ foreach(testfile IN LISTS TESTSRC)
find_package(OpenMP REQUIRED)
target_link_libraries(${test_name} PRIVATE OpenMP::OpenMP_Fortran)

add_test(NAME ${test_name} COMMAND sh -c "mpirun -np 1 ${test_name}")
add_test(NAME ${test_name} COMMAND sh -c "mpirun --oversubscribe -np ${CMAKE_CTEST_NPROCS} ${test_name}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allocator and reorder tests are the ones that doesn't require a parallel run. Both of them don't do any communication and even in a full simulation with multiple ranks they're always local to their own rank. Running these on multiple ranks is still a valid test but if we can avoid this easily it is better I guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point, though I can't think of a clean way of doing it yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a function to build the test definition, I'll see if I can dig out an example where I've done this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like the following should work

function(define_test test_name np)
  add_test(NAME ${test_name} COMMAND sh -c "mpirun --oversubscribe -np ${np} ...")
endfunction()

# Make a single process test (assumes there is a test_foo target)
define_test(test_foo 1)

# Make a parallel test
define_test(test_bar ${CMAKE_CTEST_NPROCS})

Copy link
Member

@pbartholomew08 pbartholomew08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, otherwise looks good to me.

tests/CMakeLists.txt Show resolved Hide resolved
@semi-h
Copy link
Member

semi-h commented Feb 22, 2024

Can we specify number of ranks we want to test with somehow when building with a command line option? Or do we have to edit the relevant line in the CMakeLists.txt?

@Nanoseb
Copy link
Collaborator Author

Nanoseb commented Feb 22, 2024

Can we specify number of ranks we want to test with somehow when building with a command line option? Or do we have to edit the relevant line in the CMakeLists.txt?

Yes, you don't have to edit the CMakeLists.txt file. It is set to 4 by default, but is accessible via the CMAKE_CTEST_NPROCS variable so cmake -DCMAKE_CTEST_NPROCS=42 ... will work too. Or editing it later on via ccmake.

@pbartholomew08 pbartholomew08 merged commit 9cc1505 into xcompact3d:main Feb 22, 2024
2 checks passed
@Nanoseb Nanoseb deleted the parallel-tests branch February 22, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test To do with the unit test and CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run tests in parallel in github actions
3 participants