diff --git a/src/heat/mpi/CMakeLists.txt b/src/heat/mpi/CMakeLists.txt index bf9ac14..3682f4b 100644 --- a/src/heat/mpi/CMakeLists.txt +++ b/src/heat/mpi/CMakeLists.txt @@ -10,7 +10,8 @@ endmacro() macro(mk_heat_mpi_nanos6 NAME SOURCE) mk_heat_mpi(${NAME} ${SOURCE}) - target_link_libraries(${NAME} PRIVATE Nanos6::wrapper) + target_compile_options(${NAME} PRIVATE "-fompss-2=libnanos6") + target_link_options(${NAME} PRIVATE "-fompss-2=libnanos6") endmacro() macro(mk_heat_mpi_nodes NAME SOURCE) @@ -18,6 +19,12 @@ macro(mk_heat_mpi_nodes NAME SOURCE) target_link_libraries(${NAME} PRIVATE Nodes::wrapper) endmacro() +macro(mk_heat_tampi_nanos6 NAME SOURCE) + mk_heat_mpi_nanos6(${NAME} ${SOURCE}) + target_link_libraries(${NAME} PRIVATE Tampi::tampi-c) +endmacro() + + # ------------------------------------------------------------------- add_library(heat_mpi_common STATIC main.c utils.c) @@ -35,3 +42,7 @@ if(NODES_FOUND) mk_heat_mpi_nodes(b6_heat_mpi_nodes_forkjoin solver_mpi_ompss2_forkjoin.c) mk_heat_mpi_nodes(b6_heat_mpi_nodes_tasks solver_mpi_ompss2_tasks.c) endif() + +if(NANOS6_FOUND AND TAMPI_FOUND) + mk_heat_tampi_nanos6(b6_heat_itampi_nanos6_tasks solver_itampi_ompss2_tasks.c) +endif() diff --git a/src/heat/mpi/main.c b/src/heat/mpi/main.c index e073740..718615f 100644 --- a/src/heat/mpi/main.c +++ b/src/heat/mpi/main.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -19,16 +20,7 @@ void generateImage(const HeatConfiguration *conf, int64_t rows, int64_t cols, in int main(int argc, char **argv) { -#if defined(TAMPI) - // TAMPI+OmpSs-2 variants - const int required = MPI_TASK_MULTIPLE; -#elif defined(_OMPSS_2) - // MPI+OmpSs-2 variants - const int required = MPI_THREAD_SERIALIZED; -#else - // MPI-only variants - const int required = MPI_THREAD_SINGLE; -#endif + const int required = mpi_level(); int provided; MPI_Init_thread(&argc, &argv, required, &provided); @@ -76,8 +68,10 @@ int main(int argc, char **argv) if (!rank) { int64_t totalElements = conf.rows*conf.cols; + //double time_element = (end-start)/(totalElements*conf.timesteps); double throughput = (totalElements*conf.timesteps)/(end-start); - throughput = throughput/1000000.0; + //throughput = throughput/1000000.0; + double residual = NAN; #ifdef _OMPSS_2 int threads = nanos6_get_num_cpus(); @@ -85,10 +79,17 @@ int main(int argc, char **argv) int threads = 1; #endif - fprintf(stdout, "rows, %ld, cols, %ld, rows/rank, %ld, total, %ld, total/rank, %ld, rbs, %d, " - "cbs, %d, ranks, %d, threads, %d, timesteps, %d, time, %f, Mupdates/s, %f\n", - conf.rows, conf.cols, conf.rows/nranks, totalElements, totalElements/nranks, - conf.rbs, conf.cbs, nranks, threads, conf.timesteps, end-start, throughput); + fprintf(stderr, "%14s %14s %14s %8s %8s %8s %8s %8s %8s\n", + "throughput", "time", "error", + "rows", "cols", + "rbs", "cbs", "threads", + "steps"); + fprintf(stdout, "%14e %14e %14e %8ld %8ld %8d %8d %8d %8d\n", + throughput, end-start, residual, + conf.rows, conf.cols, + conf.rbs, conf.cbs, threads, + conf.convergenceTimesteps); + } if (conf.generateImage) { diff --git a/src/heat/mpi/solver_itampi_ompss2_tasks.c b/src/heat/mpi/solver_itampi_ompss2_tasks.c index 7620a58..720587f 100644 --- a/src/heat/mpi/solver_itampi_ompss2_tasks.c +++ b/src/heat/mpi/solver_itampi_ompss2_tasks.c @@ -4,6 +4,17 @@ #include "utils.h" #include "common/heat.h" +const char * +summary(void) +{ + return "Parallel version using MPI + OmpSs-2 tasks + Non-blocking TAMPI"; +} + +int +mpi_level(void) +{ + return MPI_TASK_MULTIPLE; +} static inline void send(const double *data, int nelems, int dst, int tag) { @@ -55,6 +66,7 @@ static inline void gaussSeidelSolver(int64_t rows, int64_t cols, int rbs, int cb double solve(HeatConfiguration *conf, int64_t rows, int64_t cols, int timesteps, void *extraData) { + (void) extraData; double (*matrix)[cols] = (double (*)[cols]) conf->matrix; const int rbs = conf->rbs; const int cbs = conf->cbs; diff --git a/src/heat/mpi/solver_mpi.c b/src/heat/mpi/solver_mpi.c index 42f6932..12ac822 100644 --- a/src/heat/mpi/solver_mpi.c +++ b/src/heat/mpi/solver_mpi.c @@ -3,6 +3,12 @@ #include "utils.h" #include "common/heat.h" +int +mpi_level(void) +{ + return MPI_THREAD_SINGLE; +} + const char * summary(void) { diff --git a/src/heat/mpi/solver_mpi_nbuffer.c b/src/heat/mpi/solver_mpi_nbuffer.c index 52a1d78..41b92f7 100644 --- a/src/heat/mpi/solver_mpi_nbuffer.c +++ b/src/heat/mpi/solver_mpi_nbuffer.c @@ -8,6 +8,12 @@ typedef struct { MPI_Request recv; } HaloRequests; +int +mpi_level(void) +{ + return MPI_THREAD_SINGLE; +} + const char * summary(void) { diff --git a/src/heat/mpi/solver_mpi_ompss2_forkjoin.c b/src/heat/mpi/solver_mpi_ompss2_forkjoin.c index 72f7e35..1e9503f 100644 --- a/src/heat/mpi/solver_mpi_ompss2_forkjoin.c +++ b/src/heat/mpi/solver_mpi_ompss2_forkjoin.c @@ -3,6 +3,12 @@ #include "utils.h" #include "common/heat.h" +int +mpi_level(void) +{ + return MPI_THREAD_SERIALIZED; +} + const char * summary(void) { diff --git a/src/heat/mpi/solver_mpi_ompss2_tasks.c b/src/heat/mpi/solver_mpi_ompss2_tasks.c index c60cb60..43adf97 100644 --- a/src/heat/mpi/solver_mpi_ompss2_tasks.c +++ b/src/heat/mpi/solver_mpi_ompss2_tasks.c @@ -5,6 +5,12 @@ static int serial; +int +mpi_level(void) +{ + return MPI_THREAD_SERIALIZED; +} + const char * summary(void) { diff --git a/src/heat/mpi/utils.h b/src/heat/mpi/utils.h index ecfc088..15d3e74 100644 --- a/src/heat/mpi/utils.h +++ b/src/heat/mpi/utils.h @@ -17,5 +17,6 @@ typedef struct { void broadcastConfiguration(HeatConfiguration *configuration); void initializeWindows(HeatConfiguration *configuration, int64_t rows, int64_t cols, MPIRMAInfo *info); void finalizeWindows(MPIRMAInfo *info); +int mpi_level(void); #endif // MPI_UTILS_H