From 52189acea8c5e73dfb2ebf5dbb37ae9f6702e9d8 Mon Sep 17 00:00:00 2001
From: Rafael Ravedutti <rafaelravedutti@gmail.com>
Date: Sat, 30 Dec 2023 21:02:33 +0100
Subject: [PATCH] Adjust NVCC flags and print DEM setup info

Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
---
 .gitignore              |  8 ++++----
 Makefile                |  4 +++-
 runtime/dem_sc_grid.hpp | 17 +++++++++++++++++
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/.gitignore b/.gitignore
index 37f64d4..33b4e18 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,10 +10,10 @@ obj
 obj_cpu
 obj_gpu
 todo*
-lj_cpu
-lj_gpu
-lj.cu
-lj.cpp
+md_cpu
+md_gpu
+md.cu
+md.cpp
 dem_cpu
 dem_gpu
 dem.cu
diff --git a/Makefile b/Makefile
index 0e23434..967a1a9 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,9 @@ DEBUG_FLAGS=
 
 # CUDA settings
 NVCC=nvcc
-NVCC_FLAGS=-O3 -mavx2 -mfma
+#NVCC_FLAGS=-O3 -mavx2 -mfma
+NVCC_FLAGS=-O3 -arch=sm_80 -mavx2 -mfma -ffast-math -funroll-loops --forward-unknown-to-host-compiler
+#NVCC_FLAGS=-O3 -arch=sm_80 -march=native -ffast-math -funroll-loops --forward-unknown-to-host-compiler
 NVCC_PATH:="$(shell which ${NVCC})"
 CUDA_FLAGS=-DENABLE_CUDA_AWARE_MPI
 CUDART_FLAGS=-lcudart -L /apps/SPACK/0.19.1/opt/linux-almalinux8-zen/gcc-8.5.0/nvhpc-23.7-bzxcokzjvx4stynglo4u2ffpljajzlam/Linux_x86_64/23.7/cuda/12.2/targets/x86_64-linux/lib
diff --git a/runtime/dem_sc_grid.hpp b/runtime/dem_sc_grid.hpp
index fae3056..8c85ce6 100644
--- a/runtime/dem_sc_grid.hpp
+++ b/runtime/dem_sc_grid.hpp
@@ -151,6 +151,23 @@ int dem_sc_grid(PairsSimulation *ps, double xmax, double ymax, double zmax, doub
         last_uid++;
     }
 
+    int global_nparticles = nparticles;
+    if(ps->getDomainPartitioner()->getWorldSize() > 1) {
+        MPI_Allreduce(&nparticles, &global_nparticles, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+    }
+
+    if(ps->getDomainPartitioner()->getRank() == 0) {
+        std::cout << "DEM Simple-Cubic Grid" << std::endl;
+        std::cout << "Domain size: <" << xmax << ", " << ymax << ", " << zmax << ">" << std::endl;
+        std::cout << "Spacing: " << spacing << std::endl;
+        std::cout << "Diameter: " << diameter
+                  << " (min = " << min_diameter << ", max = " << max_diameter << ")" << std::endl;
+        std::cout << "Initial velocity: " << initial_velocity << std::endl;
+        std::cout << "Particle density: " << particle_density << std::endl;
+        std::cout << "Number of types: " << ntypes << std::endl;
+        std::cout << "Number of particles: " << global_nparticles << std::endl;
+    }
+
     return nparticles;
 }
 
-- 
GitLab