Skip to content

Commit

Permalink
reduce test updated and functional
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkenny committed Aug 22, 2024
1 parent 0492f32 commit 88eed71
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
47 changes: 15 additions & 32 deletions src/sst/elements/mask-mpi/tests/reduce.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,52 +44,35 @@ Questions? Contact [email protected]

#define ssthg_app_name reduce

#include <stddef.h>
#include <stdio.h>
#include <iostream>

#include <mask_mpi.h>
#include <mercury/common/skeleton.h>

int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);

// Get number of processes and check that 8 processes are used
int size;
int size, rank;
MPI_Comm_size(MPI_COMM_WORLD, &size);
if(size != 8)
{
printf("This application is meant to be run with 8 MPI processes.\n");
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
}

// Get my rank
int my_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);

// Define my value
int values[8];
for(int i = 0; i < 8; i++)
{
values[i] = my_rank;
int* values = new int[size];
for(int i = 0; i < size; i++) {
if(i <= rank)
values[i] = 0;
else
values[i] = 1;
}
printf("Process %d, my value = %d\n", my_rank, values[my_rank]);
for (int i = 0; i < 8; i++) {
printf("%d ", values[i]);
}
printf("\n");

MPI_Barrier(MPI_COMM_WORLD);

int recv_values[8];
MPI_Reduce(values, recv_values, 8, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (my_rank == 0) {
if (recv_values[0] == recv_values[7] && recv_values[0] == 28)
printf("SUCCESS! %d\n",recv_values[0]);
int* recv_values = new int[size];
MPI_Reduce(values, recv_values, size, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if(rank == 0) {
for(int i = 0; i < size; ++i) {
printf("recv_values[%d]=%d\n",i, recv_values[i]);
}
}

MPI_Finalize();

return EXIT_SUCCESS;
return 0;
}
9 changes: 9 additions & 0 deletions src/sst/elements/mask-mpi/tests/refFiles/test_reduce.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
recv_values[0]=0
recv_values[1]=1
recv_values[2]=2
recv_values[3]=3
recv_values[4]=4
recv_values[5]=5
recv_values[6]=6
recv_values[7]=7
Simulation is complete, simulated time: 1.21395 us
10 changes: 10 additions & 0 deletions src/sst/elements/mask-mpi/tests/testsuite_default_mask_mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ def test_sendrecv(self):
os.environ["SST_LIB_PATH"] = path + ":" + libdir
self.mask_mpi_template("test_sendrecv")

def test_reduce(self):
testdir = self.get_testsuite_dir()
libdir = sstsimulator_conf_get_value_str("SST_ELEMENT_LIBRARY","SST_ELEMENT_LIBRARY_LIBDIR")
path = os.environ.get("SST_LIB_PATH")
if path is None or path == "":
os.environ["SST_LIB_PATH"] = libdir
else:
os.environ["SST_LIB_PATH"] = path + ":" + libdir
self.mask_mpi_template("test_reduce")

#####

def mask_mpi_template(self, testcase, striptotail=0):
Expand Down

0 comments on commit 88eed71

Please sign in to comment.