From f36089a56cf4a7c8f0c968b0acc1160119151679 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 15 Jan 2024 06:26:40 +0100 Subject: [PATCH 1/4] Update VTK output format --- BasicSolver/3D-mpi-io/src/vtkWriter.c | 3 +-- BasicSolver/3D-seq/src/vtkWriter.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/BasicSolver/3D-mpi-io/src/vtkWriter.c b/BasicSolver/3D-mpi-io/src/vtkWriter.c index fe9dc3f..e00b072 100644 --- a/BasicSolver/3D-mpi-io/src/vtkWriter.c +++ b/BasicSolver/3D-mpi-io/src/vtkWriter.c @@ -88,8 +88,7 @@ void vtkScalar(VtkOptions* o, char* name, double* s) char* header = (char*)malloc(MAX_HEADER); char* cursor = header; - cursor += sprintf(cursor, "SCALARS %s double 1\n", name); - cursor += sprintf(cursor, "LOOKUP_TABLE default\n"); + cursor += sprintf(cursor, "SCALARS %s double\n", name); if (commIsMaster(&o->comm)) { MPI_File_write(o->fh, header, strlen(header), MPI_CHAR, MPI_STATUS_IGNORE); diff --git a/BasicSolver/3D-seq/src/vtkWriter.c b/BasicSolver/3D-seq/src/vtkWriter.c index 2f7e8c5..0565c0c 100644 --- a/BasicSolver/3D-seq/src/vtkWriter.c +++ b/BasicSolver/3D-seq/src/vtkWriter.c @@ -69,8 +69,7 @@ void vtkScalar(VtkOptions* o, char* name, double* s) printf("vtkWriter not initialize! Call vtkOpen first!\n"); exit(EXIT_FAILURE); } - fprintf(o->fh, "SCALARS %s float 1\n", name); - fprintf(o->fh, "LOOKUP_TABLE default\n"); + fprintf(o->fh, "SCALARS %s float\n", name); for (int k = 0; k < kmax; k++) { for (int j = 0; j < jmax; j++) { From aa5c98a436d96c755af8357d7b2beab9f040ca6a Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 15 Jan 2024 06:33:42 +0100 Subject: [PATCH 2/4] Add timing for file IO --- BasicSolver/3D-mpi-io/src/main.c | 6 ++++++ BasicSolver/3D-mpi/src/main.c | 6 ++++++ BasicSolver/3D-seq/src/main.c | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/BasicSolver/3D-mpi-io/src/main.c b/BasicSolver/3D-mpi-io/src/main.c index 8a1c88a..97739ac 100644 --- a/BasicSolver/3D-mpi-io/src/main.c +++ b/BasicSolver/3D-mpi-io/src/main.c @@ -73,11 +73,17 @@ int main(int argc, char** argv) printf("Solution took %.2fs\n", timeStop - timeStart); } + timeStart = getTimeStamp(); VtkOptions opts = { .grid = s.grid, .comm = s.comm }; vtkOpen(&opts, s.problem); vtkScalar(&opts, "pressure", s.p); vtkVector(&opts, "velocity", (VtkVector) { s.u, s.v, s.w }); vtkClose(&opts); + timeStop = getTimeStamp(); + + if (commIsMaster(&s.comm)) { + printf("Result output took %.2fs\n", timeStop - timeStart); + } commFinalize(&s.comm); return EXIT_SUCCESS; diff --git a/BasicSolver/3D-mpi/src/main.c b/BasicSolver/3D-mpi/src/main.c index cad1f8e..9bce50b 100644 --- a/BasicSolver/3D-mpi/src/main.c +++ b/BasicSolver/3D-mpi/src/main.c @@ -73,6 +73,7 @@ int main(int argc, char** argv) printf("Solution took %.2fs\n", timeStop - timeStart); } + timeStart = getTimeStamp(); double *pg, *ug, *vg, *wg; if (commIsMaster(&s.comm)) { @@ -104,6 +105,11 @@ int main(int argc, char** argv) vtkVector(&opts, "velocity", (VtkVector) { ug, vg, wg }); vtkClose(&opts); } + timeStop = getTimeStamp(); + + if (commIsMaster(&s.comm)) { + printf("Result output took %.2fs\n", timeStop - timeStart); + } commFinalize(&s.comm); return EXIT_SUCCESS; diff --git a/BasicSolver/3D-seq/src/main.c b/BasicSolver/3D-seq/src/main.c index 54cc9c9..83035dd 100644 --- a/BasicSolver/3D-seq/src/main.c +++ b/BasicSolver/3D-seq/src/main.c @@ -111,6 +111,7 @@ int main(int argc, char** argv) #endif printf("Solution took %.2fs\n", timeStop - timeStart); + timeStart = getTimeStamp(); double *pg, *ug, *vg, *wg; size_t bytesize = (size_t)(s.grid.imax * s.grid.jmax * s.grid.kmax) * sizeof(double); @@ -126,5 +127,11 @@ int main(int argc, char** argv) vtkScalar(&opts, "pressure", pg); vtkVector(&opts, "velocity", (VtkVector) { ug, vg, wg }); vtkClose(&opts); + timeStop = getTimeStamp(); + + if (commIsMaster(&s.comm)) { + printf("Result output took %.2fs\n", timeStop - timeStart); + } + return EXIT_SUCCESS; } From c0366a0140fc04989c7dc340636b23bcffc8337e Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 15 Jan 2024 06:48:17 +0100 Subject: [PATCH 3/4] Add MPI option to icc make include --- BasicSolver/3D-mpi/include_ICC.mk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/BasicSolver/3D-mpi/include_ICC.mk b/BasicSolver/3D-mpi/include_ICC.mk index 94b8e20..8f3a1fb 100644 --- a/BasicSolver/3D-mpi/include_ICC.mk +++ b/BasicSolver/3D-mpi/include_ICC.mk @@ -1,4 +1,10 @@ -CC = icc +ifeq ($(ENABLE_MPI),true) +CC = mpiicc +DEFINES = -D_MPI +else +CC = icc +endif + GCC = gcc LINKER = $(CC) From 4e8535f4a10f03090651c887cf9cf47850b84b7e Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Mon, 15 Jan 2024 06:55:05 +0100 Subject: [PATCH 4/4] Fix bugs --- BasicSolver/3D-mpi/include_ICC.mk | 2 +- BasicSolver/3D-mpi/src/comm.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BasicSolver/3D-mpi/include_ICC.mk b/BasicSolver/3D-mpi/include_ICC.mk index 8f3a1fb..6bedf55 100644 --- a/BasicSolver/3D-mpi/include_ICC.mk +++ b/BasicSolver/3D-mpi/include_ICC.mk @@ -15,6 +15,6 @@ endif VERSION = --version CFLAGS = -O3 -xHost -qopt-zmm-usage=high -std=c99 $(OPENMP) LFLAGS = $(OPENMP) -DEFINES = -D_GNU_SOURCE +DEFINES += -D_GNU_SOURCE# -DDEBUG INCLUDES = LIBS = diff --git a/BasicSolver/3D-mpi/src/comm.c b/BasicSolver/3D-mpi/src/comm.c index fb8f519..dbee6b7 100644 --- a/BasicSolver/3D-mpi/src/comm.c +++ b/BasicSolver/3D-mpi/src/comm.c @@ -445,7 +445,7 @@ void commCollectResult(Comm* c, for (int k = 1; k < kmaxLocal + 1; k++) { for (int j = 1; j < jmaxLocal + 1; j++) { for (int i = 1; i < imaxLocal + 1; i++) { - pg[idx++] = G(s->p, i, j, k); + pg[idx++] = G(p, i, j, k); } } } @@ -455,7 +455,7 @@ void commCollectResult(Comm* c, for (int k = 1; k < kmaxLocal + 1; k++) { for (int j = 1; j < jmaxLocal + 1; j++) { for (int i = 1; i < imaxLocal + 1; i++) { - ug[idx++] = (G(s->u, i, j, k) + G(s->u, i - 1, j, k)) / 2.0; + ug[idx++] = (G(u, i, j, k) + G(u, i - 1, j, k)) / 2.0; } } } @@ -465,7 +465,7 @@ void commCollectResult(Comm* c, for (int k = 1; k < kmaxLocal + 1; k++) { for (int j = 1; j < jmaxLocal + 1; j++) { for (int i = 1; i < imaxLocal + 1; i++) { - vg[idx++] = (G(s->v, i, j, k) + G(s->v, i, j - 1, k)) / 2.0; + vg[idx++] = (G(v, i, j, k) + G(v, i, j - 1, k)) / 2.0; } } } @@ -475,7 +475,7 @@ void commCollectResult(Comm* c, for (int k = 1; k < kmaxLocal + 1; k++) { for (int j = 1; j < jmaxLocal + 1; j++) { for (int i = 1; i < imaxLocal + 1; i++) { - wg[idx++] = (G(s->w, i, j, k) + G(s->w, i, j, k - 1)) / 2.0; + wg[idx++] = (G(w, i, j, k) + G(w, i, j, k - 1)) / 2.0; } } }