From 788f27276092a83365d668b80a64415a1e1e8bf6 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Mon, 15 Apr 2024 15:25:05 +0200 Subject: [PATCH] Merge heat files into a single directory Gaspi is still pending. --- src/heat/CMakeLists.txt | 89 ++++++++++++++++++- src/heat/common/main.c | 52 ----------- src/heat/{common => }/heat.h | 0 src/heat/{common => }/kernel.c | 2 +- src/heat/{mpi/main.c => main_mpi.c} | 4 +- src/heat/{smp/main.c => main_smp.c} | 2 +- src/heat/{common => }/misc.c | 0 src/heat/mpi/CMakeLists.txt | 48 ---------- src/heat/{Makefile => old.Makefile} | 0 src/heat/smp/CMakeLists.txt | 33 ------- .../{mpi => }/solver_itampi_ompss2_tasks.c | 4 +- src/heat/{mpi => }/solver_mpi.c | 4 +- src/heat/{mpi => }/solver_mpi_nbuffer.c | 4 +- .../{mpi => }/solver_mpi_ompss2_forkjoin.c | 4 +- src/heat/{mpi => }/solver_mpi_ompss2_tasks.c | 4 +- src/heat/{mpi => }/solver_mpirma_nbuffer.c | 4 +- .../{mpi => }/solver_mpirma_ompss2_tasks.c | 4 +- src/heat/{smp => }/solver_ompss2.c | 2 +- src/heat/{smp => }/solver_ompss2_residual.c | 2 +- src/heat/{smp => }/solver_ompss2_taskloop.c | 2 +- src/heat/{smp => }/solver_seq.c | 2 +- .../{mpi => }/solver_tampi_ompss2_tasks.c | 2 +- .../{mpi => }/solver_tampirma_ompss2_tasks.c | 2 +- src/heat/{mpi/utils.c => utils_mpi.c} | 4 +- src/heat/{mpi/utils.h => utils_mpi.h} | 2 +- 25 files changed, 112 insertions(+), 164 deletions(-) delete mode 100644 src/heat/common/main.c rename src/heat/{common => }/heat.h (100%) rename src/heat/{common => }/kernel.c (99%) rename src/heat/{mpi/main.c => main_mpi.c} (98%) rename src/heat/{smp/main.c => main_smp.c} (97%) rename src/heat/{common => }/misc.c (100%) delete mode 100644 src/heat/mpi/CMakeLists.txt rename src/heat/{Makefile => old.Makefile} (100%) delete mode 100644 src/heat/smp/CMakeLists.txt rename src/heat/{mpi => }/solver_itampi_ompss2_tasks.c (98%) rename src/heat/{mpi => }/solver_mpi.c (97%) rename src/heat/{mpi => }/solver_mpi_nbuffer.c (98%) rename src/heat/{mpi => }/solver_mpi_ompss2_forkjoin.c (97%) rename src/heat/{mpi => }/solver_mpi_ompss2_tasks.c (98%) rename src/heat/{mpi => }/solver_mpirma_nbuffer.c (98%) rename src/heat/{mpi => }/solver_mpirma_ompss2_tasks.c (98%) rename src/heat/{smp => }/solver_ompss2.c (97%) rename src/heat/{smp => }/solver_ompss2_residual.c (98%) rename src/heat/{smp => }/solver_ompss2_taskloop.c (97%) rename src/heat/{smp => }/solver_seq.c (96%) rename src/heat/{mpi => }/solver_tampi_ompss2_tasks.c (98%) rename src/heat/{mpi => }/solver_tampirma_ompss2_tasks.c (99%) rename src/heat/{mpi/utils.c => utils_mpi.c} (98%) rename src/heat/{mpi/utils.h => utils_mpi.h} (94%) diff --git a/src/heat/CMakeLists.txt b/src/heat/CMakeLists.txt index 7edf742..4374eb2 100644 --- a/src/heat/CMakeLists.txt +++ b/src/heat/CMakeLists.txt @@ -1,12 +1,93 @@ -add_library(heat_kernel STATIC common/kernel.c) +# --- Common to all --- + +add_library(heat_kernel STATIC kernel.c) target_include_directories(heat_kernel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_compile_options(heat_kernel PRIVATE -Rpass-analysis=loop-vectorize -ffast-math) -add_library(heat_common STATIC common/misc.c) +add_library(heat_common STATIC misc.c) target_include_directories(heat_common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(heat_common PUBLIC m heat_kernel) -add_subdirectory(smp) -add_subdirectory(mpi) +# --- SMP based --- + +add_library(heat_smp_common STATIC main_smp.c) +target_link_libraries(heat_smp_common PUBLIC heat_common) + +macro(mk_heat_smp NAME SOURCE) + mk_bench(${NAME}) + target_sources(${NAME} PRIVATE ${SOURCE}) + target_link_libraries(${NAME} PRIVATE heat_smp_common) +endmacro() + +# No requisites +mk_heat_smp(heat_seq solver_seq.c) + +if(NANOS6_FOUND) + macro(mk_heat_nanos6 NAME SOURCE) + mk_heat_smp(${NAME} ${SOURCE}) + target_compile_options(${NAME} PRIVATE "-fompss-2=libnanos6") + target_link_options(${NAME} PRIVATE "-fompss-2=libnanos6") + endmacro() + + mk_heat_nanos6(heat_nanos6 solver_ompss2.c) + mk_heat_nanos6(heat_nanos6_residual solver_ompss2_residual.c) +endif() + +message(STATUS "NODES FOUND = ${NODES_FOUND}") +if(NODES_FOUND) + macro(mk_heat_nodes NAME SOURCE) + mk_heat_smp(${NAME} ${SOURCE}) + target_link_libraries(${NAME} PRIVATE Nodes::nodes) + endmacro() + + mk_heat_nodes(heat_nodes solver_ompss2.c) + mk_heat_nodes(heat_nodes_residual solver_ompss2_residual.c) +endif() + +# --- MPI based --- + +if(MPI_FOUND) + add_library(heat_mpi_common STATIC main_mpi.c utils_mpi.c) + target_link_libraries(heat_mpi_common PUBLIC heat_common MPI::MPI_C) + + macro(mk_heat_mpi NAME SOURCE) + mk_bench(${NAME}) + target_sources(${NAME} PRIVATE ${SOURCE}) + target_link_libraries(${NAME} PRIVATE heat_mpi_common) + endmacro() + mk_heat_mpi(heat_mpi solver_mpi.c) + mk_heat_mpi(heat_mpi_nbuffer solver_mpi_nbuffer.c) + + if(NANOS6_FOUND) + macro(mk_heat_mpi_nanos6 NAME SOURCE) + mk_heat_mpi(${NAME} ${SOURCE}) + target_compile_options(${NAME} PRIVATE "-fompss-2=libnanos6") + target_link_options(${NAME} PRIVATE "-fompss-2=libnanos6") + endmacro() + mk_heat_mpi_nanos6(heat_mpi_nanos6_forkjoin solver_mpi_ompss2_forkjoin.c) + mk_heat_mpi_nanos6(heat_mpi_nanos6_tasks solver_mpi_ompss2_tasks.c) + + if(TAMPI_FOUND) + macro(mk_heat_tampi_nanos6 NAME SOURCE) + mk_heat_mpi_nanos6(${NAME} ${SOURCE}) + target_link_libraries(${NAME} PRIVATE Tampi::tampi-c) + endmacro() + mk_heat_tampi_nanos6(heat_itampi_nanos6_tasks solver_itampi_ompss2_tasks.c) + endif() + endif() + + if(NODES_FOUND) + macro(mk_heat_mpi_nodes NAME SOURCE) + mk_heat_mpi(${NAME} ${SOURCE}) + target_link_libraries(${NAME} PRIVATE Nodes::nodes) + endmacro() + mk_heat_mpi_nodes(heat_mpi_nodes_forkjoin solver_mpi_ompss2_forkjoin.c) + mk_heat_mpi_nodes(heat_mpi_nodes_tasks solver_mpi_ompss2_tasks.c) + endif() +endif() + +# --- GASPI --- + +# TODO diff --git a/src/heat/common/main.c b/src/heat/common/main.c deleted file mode 100644 index 9ff1a91..0000000 --- a/src/heat/common/main.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include -#include - -#include "common/heat.h" - - -int main(int argc, char **argv) -{ - HeatConfiguration conf; - readConfiguration(argc, argv, &conf); - refineConfiguration(&conf, conf.rbs, conf.cbs); - if (conf.verbose) - printConfiguration(&conf); - - int64_t rows = conf.rows+2; - int64_t cols = conf.cols+2; - - initialize(&conf, rows, cols, 0); - - if (conf.warmup) - solve(&conf, rows, cols, 1, NULL); - - // Solve the problem - double start = getTime(); - double residual = solve(&conf, rows, cols, conf.timesteps, NULL); - double end = getTime(); - - int64_t totalElements = conf.rows*conf.cols; - double throughput = (totalElements*conf.timesteps)/(end-start); - -#ifdef _OMPSS_2 - int threads = sysconf(_SC_NPROCESSORS_ONLN); -#else - int threads = 1; -#endif - - fprintf(stderr,"%8s %8s %8s %8s %8s %8s %14s %14s %14s", - "rows", "cols", "rbs", "cbs", "threads", - "steps", "error", "time", "updates/s\n"); - fprintf(stdout, "%8ld %8ld %8d %8d %8d %8d %14e %14e %14e\n", - conf.rows, conf.cols, - conf.rbs, conf.cbs, threads, - conf.convergenceTimesteps, residual, end-start, throughput); - - if (conf.generateImage) - writeImage(conf.imageFileName, conf.matrix, rows, cols); - - finalize(&conf); - - return 0; -} diff --git a/src/heat/common/heat.h b/src/heat/heat.h similarity index 100% rename from src/heat/common/heat.h rename to src/heat/heat.h diff --git a/src/heat/common/kernel.c b/src/heat/kernel.c similarity index 99% rename from src/heat/common/kernel.c rename to src/heat/kernel.c index aadc896..32d67df 100644 --- a/src/heat/common/kernel.c +++ b/src/heat/kernel.c @@ -1,6 +1,6 @@ #include #include -#include "common/heat.h" +#include "heat.h" #ifndef SIMD void computeBlock(const int64_t rows, const int64_t cols, diff --git a/src/heat/mpi/main.c b/src/heat/main_mpi.c similarity index 98% rename from src/heat/mpi/main.c rename to src/heat/main_mpi.c index 718615f..af980a1 100644 --- a/src/heat/mpi/main.c +++ b/src/heat/main_mpi.c @@ -4,8 +4,8 @@ #include #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" #ifdef TAMPI #include diff --git a/src/heat/smp/main.c b/src/heat/main_smp.c similarity index 97% rename from src/heat/smp/main.c rename to src/heat/main_smp.c index ff7acdb..5d29b7d 100644 --- a/src/heat/smp/main.c +++ b/src/heat/main_smp.c @@ -2,7 +2,7 @@ #include #include -#include "common/heat.h" +#include "heat.h" int main(int argc, char **argv) diff --git a/src/heat/common/misc.c b/src/heat/misc.c similarity index 100% rename from src/heat/common/misc.c rename to src/heat/misc.c diff --git a/src/heat/mpi/CMakeLists.txt b/src/heat/mpi/CMakeLists.txt deleted file mode 100644 index 3682f4b..0000000 --- a/src/heat/mpi/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -if(NOT MPI_FOUND) - return() -endif() - -macro(mk_heat_mpi NAME SOURCE) - mk_bench(${NAME}) - target_sources(${NAME} PRIVATE ${SOURCE}) - target_link_libraries(${NAME} PRIVATE heat_mpi_common) -endmacro() - -macro(mk_heat_mpi_nanos6 NAME SOURCE) - mk_heat_mpi(${NAME} ${SOURCE}) - target_compile_options(${NAME} PRIVATE "-fompss-2=libnanos6") - target_link_options(${NAME} PRIVATE "-fompss-2=libnanos6") -endmacro() - -macro(mk_heat_mpi_nodes NAME SOURCE) - mk_heat_mpi(${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) -target_link_libraries(heat_mpi_common PUBLIC heat_common MPI::MPI_C) - -mk_heat_mpi(b6_heat_mpi solver_mpi.c) -mk_heat_mpi(b6_heat_mpi_nbuffer solver_mpi_nbuffer.c) - -if(NANOS6_FOUND) - mk_heat_mpi_nanos6(b6_heat_mpi_nanos6_forkjoin solver_mpi_ompss2_forkjoin.c) - mk_heat_mpi_nanos6(b6_heat_mpi_nanos6_tasks solver_mpi_ompss2_tasks.c) -endif() - -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/Makefile b/src/heat/old.Makefile similarity index 100% rename from src/heat/Makefile rename to src/heat/old.Makefile diff --git a/src/heat/smp/CMakeLists.txt b/src/heat/smp/CMakeLists.txt deleted file mode 100644 index 17b1f73..0000000 --- a/src/heat/smp/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -macro(mk_heat_smp NAME SOURCE) - mk_bench(${NAME}) - target_sources(${NAME} PRIVATE ${SOURCE}) - target_link_libraries(${NAME} PRIVATE heat_smp_common) -endmacro() - -macro(mk_heat_nanos6 NAME SOURCE) - mk_heat_smp(${NAME} ${SOURCE}) - target_compile_options(${NAME} PRIVATE "-fompss-2=libnanos6") - target_link_options(${NAME} PRIVATE "-fompss-2=libnanos6") -endmacro() - -macro(mk_heat_nodes NAME SOURCE) - mk_heat_smp(${NAME} ${SOURCE}) - target_link_libraries(${NAME} PRIVATE Nodes::wrapper) -endmacro() - -# ------------------------------------------------------------------- - -add_library(heat_smp_common STATIC main.c) -target_link_libraries(heat_smp_common PUBLIC heat_common) - -mk_heat_smp(b6_heat_seq solver_seq.c) - -if(NANOS6_FOUND) - mk_heat_nanos6(b6_heat_nanos6 solver_ompss2.c) - mk_heat_nanos6(b6_heat_nanos6_residual solver_ompss2_residual.c) -endif() - -if(NODES_FOUND) - mk_heat_nodes(b6_heat_nodes solver_ompss2.c) - mk_heat_nodes(b6_heat_nodes_residual solver_ompss2_residual.c) -endif() diff --git a/src/heat/mpi/solver_itampi_ompss2_tasks.c b/src/heat/solver_itampi_ompss2_tasks.c similarity index 98% rename from src/heat/mpi/solver_itampi_ompss2_tasks.c rename to src/heat/solver_itampi_ompss2_tasks.c index 720587f..25966eb 100644 --- a/src/heat/mpi/solver_itampi_ompss2_tasks.c +++ b/src/heat/solver_itampi_ompss2_tasks.c @@ -1,8 +1,8 @@ #include #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" const char * summary(void) diff --git a/src/heat/mpi/solver_mpi.c b/src/heat/solver_mpi.c similarity index 97% rename from src/heat/mpi/solver_mpi.c rename to src/heat/solver_mpi.c index 12ac822..7cfa786 100644 --- a/src/heat/mpi/solver_mpi.c +++ b/src/heat/solver_mpi.c @@ -1,7 +1,7 @@ #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" int mpi_level(void) diff --git a/src/heat/mpi/solver_mpi_nbuffer.c b/src/heat/solver_mpi_nbuffer.c similarity index 98% rename from src/heat/mpi/solver_mpi_nbuffer.c rename to src/heat/solver_mpi_nbuffer.c index 41b92f7..0d76b6c 100644 --- a/src/heat/mpi/solver_mpi_nbuffer.c +++ b/src/heat/solver_mpi_nbuffer.c @@ -1,7 +1,7 @@ #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" typedef struct { MPI_Request send; diff --git a/src/heat/mpi/solver_mpi_ompss2_forkjoin.c b/src/heat/solver_mpi_ompss2_forkjoin.c similarity index 97% rename from src/heat/mpi/solver_mpi_ompss2_forkjoin.c rename to src/heat/solver_mpi_ompss2_forkjoin.c index 1e9503f..d5b2de6 100644 --- a/src/heat/mpi/solver_mpi_ompss2_forkjoin.c +++ b/src/heat/solver_mpi_ompss2_forkjoin.c @@ -1,7 +1,7 @@ #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" int mpi_level(void) diff --git a/src/heat/mpi/solver_mpi_ompss2_tasks.c b/src/heat/solver_mpi_ompss2_tasks.c similarity index 98% rename from src/heat/mpi/solver_mpi_ompss2_tasks.c rename to src/heat/solver_mpi_ompss2_tasks.c index 43adf97..7e6ce91 100644 --- a/src/heat/mpi/solver_mpi_ompss2_tasks.c +++ b/src/heat/solver_mpi_ompss2_tasks.c @@ -1,7 +1,7 @@ #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" static int serial; diff --git a/src/heat/mpi/solver_mpirma_nbuffer.c b/src/heat/solver_mpirma_nbuffer.c similarity index 98% rename from src/heat/mpi/solver_mpirma_nbuffer.c rename to src/heat/solver_mpirma_nbuffer.c index ae9c918..55acc80 100644 --- a/src/heat/mpi/solver_mpirma_nbuffer.c +++ b/src/heat/solver_mpirma_nbuffer.c @@ -3,8 +3,8 @@ #include #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" typedef struct { MPI_Request send; diff --git a/src/heat/mpi/solver_mpirma_ompss2_tasks.c b/src/heat/solver_mpirma_ompss2_tasks.c similarity index 98% rename from src/heat/mpi/solver_mpirma_ompss2_tasks.c rename to src/heat/solver_mpirma_ompss2_tasks.c index 6f25ff4..c438f22 100644 --- a/src/heat/mpi/solver_mpirma_ompss2_tasks.c +++ b/src/heat/solver_mpirma_ompss2_tasks.c @@ -1,7 +1,7 @@ #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" static int serial; diff --git a/src/heat/smp/solver_ompss2.c b/src/heat/solver_ompss2.c similarity index 97% rename from src/heat/smp/solver_ompss2.c rename to src/heat/solver_ompss2.c index 8b4ad9c..92170e7 100644 --- a/src/heat/smp/solver_ompss2.c +++ b/src/heat/solver_ompss2.c @@ -1,4 +1,4 @@ -#include "common/heat.h" +#include "heat.h" const char * summary(void) diff --git a/src/heat/smp/solver_ompss2_residual.c b/src/heat/solver_ompss2_residual.c similarity index 98% rename from src/heat/smp/solver_ompss2_residual.c rename to src/heat/solver_ompss2_residual.c index 17d59b3..2064a3d 100644 --- a/src/heat/smp/solver_ompss2_residual.c +++ b/src/heat/solver_ompss2_residual.c @@ -1,7 +1,7 @@ #include #include -#include "common/heat.h" +#include "heat.h" const char * summary(void) diff --git a/src/heat/smp/solver_ompss2_taskloop.c b/src/heat/solver_ompss2_taskloop.c similarity index 97% rename from src/heat/smp/solver_ompss2_taskloop.c rename to src/heat/solver_ompss2_taskloop.c index 7bf065b..7f14e12 100644 --- a/src/heat/smp/solver_ompss2_taskloop.c +++ b/src/heat/solver_ompss2_taskloop.c @@ -1,4 +1,4 @@ -#include "common/heat.h" +#include "heat.h" const char * summary(void) diff --git a/src/heat/smp/solver_seq.c b/src/heat/solver_seq.c similarity index 96% rename from src/heat/smp/solver_seq.c rename to src/heat/solver_seq.c index 456ac86..9f3ad62 100644 --- a/src/heat/smp/solver_seq.c +++ b/src/heat/solver_seq.c @@ -1,4 +1,4 @@ -#include "common/heat.h" +#include "heat.h" const char * summary(void) diff --git a/src/heat/mpi/solver_tampi_ompss2_tasks.c b/src/heat/solver_tampi_ompss2_tasks.c similarity index 98% rename from src/heat/mpi/solver_tampi_ompss2_tasks.c rename to src/heat/solver_tampi_ompss2_tasks.c index 75c8060..ed421b3 100644 --- a/src/heat/mpi/solver_tampi_ompss2_tasks.c +++ b/src/heat/solver_tampi_ompss2_tasks.c @@ -2,7 +2,7 @@ #include #include "utils.h" -#include "common/heat.h" +#include "heat.h" static inline void send(const double *data, int nelems, int dst, int tag) diff --git a/src/heat/mpi/solver_tampirma_ompss2_tasks.c b/src/heat/solver_tampirma_ompss2_tasks.c similarity index 99% rename from src/heat/mpi/solver_tampirma_ompss2_tasks.c rename to src/heat/solver_tampirma_ompss2_tasks.c index fdcdfac..62331e2 100644 --- a/src/heat/mpi/solver_tampirma_ompss2_tasks.c +++ b/src/heat/solver_tampirma_ompss2_tasks.c @@ -2,7 +2,7 @@ #include #include "utils.h" -#include "common/heat.h" +#include "heat.h" static inline void fence(MPI_Win win) diff --git a/src/heat/mpi/utils.c b/src/heat/utils_mpi.c similarity index 98% rename from src/heat/mpi/utils.c rename to src/heat/utils_mpi.c index ff18643..f23cd7d 100644 --- a/src/heat/mpi/utils.c +++ b/src/heat/utils_mpi.c @@ -4,8 +4,8 @@ #include #include -#include "utils.h" -#include "common/heat.h" +#include "utils_mpi.h" +#include "heat.h" int rank; int nranks; diff --git a/src/heat/mpi/utils.h b/src/heat/utils_mpi.h similarity index 94% rename from src/heat/mpi/utils.h rename to src/heat/utils_mpi.h index 15d3e74..b96d552 100644 --- a/src/heat/mpi/utils.h +++ b/src/heat/utils_mpi.h @@ -3,7 +3,7 @@ #include -#include "common/heat.h" +#include "heat.h" extern int rank; extern int nranks;