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

Add Mpi tests #271

Merged
merged 13 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: mpi4py/setup-mpi@v1
with:
mpi: intelmpi
- uses: actions/cache@v4
id: babeltrace2
env:
Expand Down Expand Up @@ -145,6 +147,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: mpi4py/setup-mpi@v1
with:
mpi: intelmpi
- uses: actions/cache@v4
id: babeltrace2
env:
Expand Down
12 changes: 7 additions & 5 deletions integration_tests/light_iprof_only_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RT_SIGNAL_FINISH=$((SIGRTMIN + 3))
SIGNAL_RECEIVED="false"
# Signal handler for capturing signals
handle_signal() {
echo "Received signal $1 from mpi_daemon"
echo "--Received signal $1 from mpi_daemon"
if [ "$1" == "RT_SIGNAL_READY" ]; then
SIGNAL_RECEIVED="true"
fi
Expand Down Expand Up @@ -42,18 +42,20 @@ PARENT_PID=$$
# Start sync daemon in the background
${THAPI_BIN_DIR}/sync_daemon_${THAPI_SYNC_DAEMON} $PARENT_PID &
DAEMON_PID=$!
# Wait for daemon to be ready
echo "Wait for daemon to be ready"
wait_for_signal
# Send signals to mpi_daemon to test synchronization
echo "Send Local and Global Barrier signal"
send_signal_blocking $RT_SIGNAL_LOCAL_BARRIER
send_signal_blocking $RT_SIGNAL_GLOBAL_BARRIER

# Run test program
"$@"

# Final synchronization after mpi_hello_world execution
echo "Send Local and Global Barrier signal"
send_signal_blocking $RT_SIGNAL_LOCAL_BARRIER
send_signal_blocking $RT_SIGNAL_GLOBAL_BARRIER
# Signal to terminate the mpi_daemon
echo "Send Termination signal"
send_signal_blocking $RT_SIGNAL_FINISH
wait $DAEMON_PID # Ensure daemon exits cleanly
echo "Wait for daemon to quit"
wait $DAEMON_PID
25 changes: 25 additions & 0 deletions integration_tests/mpi_helloworld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <mpi.h>
#include <stdio.h>

int main(int argc, char** argv) {
// Initialize the MPI environment
MPI_Init(&argc, &argv);

// Get the number of processes
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);

// Get the rank of the process
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

// Get the name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);

printf("Hello world from processor %s, rank %d out of %d rank.\n", processor_name, world_rank, world_size);
// Finalize the MPI environment.
MPI_Finalize();
return 0;
}
9 changes: 7 additions & 2 deletions integration_tests/parallel_execution.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ teardown_file() {
}

@test "sync_daemon_fs" {
THAPI_SYNC_DAEMON=fs THAPI_JOBID=0 timeout 20s $MPIRUN -n 2 ./integration_tests/light_iprof_only_sync.sh $THAPI_TEST_BIN
THAPI_SYNC_DAEMON=fs THAPI_JOBID=0 timeout 20s $MPIRUN -n 2 ./integration_tests/light_iprof_only_sync.sh $THAPI_TEST_BIN
}

@test "iprof_fs" {
THAPI_SYNC_DAEMON=fs THAPI_JOBID=0 $MPIRUN -n 2 $IPROF --debug 0 -- $THAPI_TEST_BIN
}

@test "sync_daemon_mpi" {
THAPI_SYNC_DAEMON=mpi THAPI_JOBID=0 timeout 20s $MPIRUN -n 2 ./integration_tests/light_iprof_only_sync.sh $THAPI_TEST_BIN
THAPI_SYNC_DAEMON=mpi THAPI_JOBID=0 timeout 20s $MPIRUN -n 2 ./integration_tests/light_iprof_only_sync.sh $THAPI_TEST_BIN
}

@test "iprof_mpi" {
THAPI_SYNC_DAEMON=mpi THAPI_JOBID=0 $MPIRUN -n 2 $IPROF --debug 0 -- $THAPI_TEST_BIN
}

@test "sync_daemon_mpi_launching_mpi_app" {
mpicc ./integration_tests/mpi_helloworld.c -o mpi_helloworld
THAPI_SYNC_DAEMON=mpi THAPI_JOBID=0 timeout 40s $MPIRUN -n 2 ./integration_tests/light_iprof_only_sync.sh ./mpi_helloworld
}
10 changes: 5 additions & 5 deletions xprof/sync_daemon_mpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ int MPIX_Init_Session(MPI_Session *lib_shandle, MPI_Comm *lib_comm) {
*/
CHECK_MPI(MPI_Session_get_info(*lib_shandle, &tinfo));
{
char out_value[100]; /* large enough */
char out_value[100] = {0};
int valuelen = sizeof(out_value);
int flag;
CHECK_MPI(MPI_Info_get_string(tinfo, mt_key, &valuelen, out_value, &flag));
CHECK_MPI(MPI_Info_get(tinfo, mt_key, valuelen, out_value, &flag));
if (flag == 0)
fprintf(stderr, "THAPI_SYNC_DAEMON_MPI Warning: Could not find key %s\n", mt_key);
if (strcmp(out_value, mt_value))
fprintf(stderr, "THAPI_SYNC_DAEMON_MPI Warning: Did not get MPI_THREAD_SINGLE, got %s\n",
out_value);
else if (strcmp(out_value, mt_value))
fprintf(stderr, "THAPI_SYNC_DAEMON_MPI Warning: Did not get %s, got %s\n",
mt_value, out_value);
}
/*
* create a group from the WORLD process set
Expand Down