-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix timeout support in multithreading
The clone wrapper was not used for thread creation. Thus threads were not registering themselves. Now a thread register at its first MPI call and the helper thread check if they are alive or not for unregistration Add a timeout test using another thread. Fix the existing timeout test to compile without warning and be more strict in checking the output
- Loading branch information
1 parent
9de05c9
commit a239ea9
Showing
8 changed files
with
70 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
project (timeout_omp) | ||
cmake_minimum_required (VERSION 3.0.0) | ||
|
||
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/timeout_omp_slow_add.cpp | ||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_timeout_omp_tests.sh | ||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
add_test (NAME MPI_Reduce_timeout_multithread | ||
COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/run_timeout_omp_tests.sh | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
set_tests_properties (MPI_Reduce_timeout_multithread PROPERTIES PASS_REGULAR_EXPRESSION "^0\n$" | ||
TIMEOUT 30) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
source ../etc/mpivars.sh || exit 1 | ||
|
||
|
||
mpicxx timeout_omp_slow_add.cpp -o timeout_omp_slow_add | ||
|
||
export WI4MPI_Reduce_timeout=1 | ||
${WI4MPI_MPRUN} ${WI4MPI_NPROC} ${WI4MPI_NCORE} ${WI4MPI_PARTITION} ${WI4MPI_EXTRA_OPTS} ./timeout_omp_slow_add &> timeout_omp_slow_add.log | ||
|
||
grep -q 'processus .* on host .* has reached a timeout' timeout_omp_slow_add.log | ||
|
||
echo $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <mpi.h> | ||
#include <unistd.h> | ||
#include <thread> | ||
|
||
void caller_mpi(int rank, MPI_Op slow_op) { | ||
int srank; | ||
MPI_Reduce(&rank, &srank, 1, MPI_INT, slow_op, 0, MPI_COMM_WORLD); | ||
} | ||
void slow_add(void *in, void *out, int *len, MPI_Datatype *dat) { | ||
int i; | ||
int *iin = (int *)in; | ||
int *iout = (int *)out; | ||
(*iout) = 0; | ||
for (i = 0; i < *len; i++) { | ||
(*iout) += iin[i]; | ||
if (*iin == 0) | ||
sleep(10); | ||
} | ||
} | ||
int main(int argc, char **argv) { | ||
int rank; | ||
MPI_Op slow_op; | ||
MPI_Init(&argc, &argv); | ||
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | ||
MPI_Op_create(&slow_add, 1, &slow_op); | ||
std::thread t1{caller_mpi, rank, slow_op}; | ||
t1.join(); | ||
MPI_Finalize(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters