From a94a4d2d0556407b94021a6dbb2e18b9915c8e45 Mon Sep 17 00:00:00 2001 From: Bob Caddy Date: Fri, 3 Mar 2023 16:03:28 -0500 Subject: [PATCH 1/3] Remove C & and enable bugprone-signed-char-misuse --- .clang-tidy | 1 - src/mpi/MPI_Comm_node.h | 14 -------------- src/mpi/mpi_routines.cpp | 4 ---- 3 files changed, 19 deletions(-) delete mode 100644 src/mpi/MPI_Comm_node.h diff --git a/.clang-tidy b/.clang-tidy index 65e459e56..8af502682 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -43,7 +43,6 @@ Checks: "*, -bugprone-macro-parentheses, -bugprone-narrowing-conversions, -bugprone-reserved-identifier, - -bugprone-signed-char-misuse, -bugprone-string-integer-assignment, -cert-dcl37-c, -cert-dcl50-cpp, diff --git a/src/mpi/MPI_Comm_node.h b/src/mpi/MPI_Comm_node.h deleted file mode 100644 index eaa975aef..000000000 --- a/src/mpi/MPI_Comm_node.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef MPI_COMM_NODE -#define MPI_COMM_NODE - -#include - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus -MPI_Comm MPI_Comm_node(int *pid, int *np); -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif // MPI_COMM_NODE diff --git a/src/mpi/mpi_routines.cpp b/src/mpi/mpi_routines.cpp index 2a464c8a4..f35a72952 100644 --- a/src/mpi/mpi_routines.cpp +++ b/src/mpi/mpi_routines.cpp @@ -8,7 +8,6 @@ #include "../global/global.h" #include "../io/io.h" - #include "../mpi/MPI_Comm_node.h" #include "../mpi/cuda_mpi_routines.h" #include "../utils/error_handling.h" @@ -21,7 +20,6 @@ int procID_node; /*process rank on node*/ int nproc_node; /*number of MPI processes on node*/ MPI_Comm world; /*global communicator*/ -MPI_Comm node; /*global communicator*/ MPI_Datatype MPI_CHREAL; /*set equal to MPI_FLOAT or MPI_DOUBLE*/ @@ -216,8 +214,6 @@ void InitializeChollaMPI(int *pargc, char **pargv[]) } #endif - /*set up node communicator*/ - node = MPI_Comm_node(&procID_node, &nproc_node); // #ifdef ONLY_PARTICLES // chprintf("ONLY_PARTICLES: Initializing without CUDA support.\n"); // #else From 4a92255f98962ac2be1bf7eeeb5111042d096437 Mon Sep 17 00:00:00 2001 From: Bob Caddy Date: Fri, 3 Mar 2023 16:19:17 -0500 Subject: [PATCH 2/3] Remove all support for C in the build system --- .github/workflows/build_and_lint.yml | 3 --- Makefile | 25 ++++--------------------- builds/make.host.c3po | 3 --- builds/make.host.crc | 3 --- builds/make.host.frontier | 4 ---- builds/make.host.github | 5 ----- builds/make.host.lux | 3 --- builds/make.host.poplar | 3 --- builds/make.host.poplar.aomp | 3 --- builds/make.host.poplar.cce+hip | 3 --- builds/make.host.shamrock | 3 --- builds/make.host.spock | 4 ---- builds/make.host.summit | 3 --- builds/make.host.tornado | 3 --- builds/setup.poplar.aomp.sh | 3 +-- tools/analyze_tidy_checks.py | 6 ++---- 16 files changed, 7 insertions(+), 70 deletions(-) diff --git a/.github/workflows/build_and_lint.yml b/.github/workflows/build_and_lint.yml index 0ea34c687..d0a42529f 100644 --- a/.github/workflows/build_and_lint.yml +++ b/.github/workflows/build_and_lint.yml @@ -88,9 +88,6 @@ jobs: - name: Display tidy_results_cpp.log if: ${{ (matrix.container.name == 'CUDA') && (always()) }} run: cat tidy_results_cpp.log - - name: Display tidy_results_c.log - if: ${{ (matrix.container.name == 'CUDA') && (always()) }} - run: cat tidy_results_c.log - name: Display tidy_results_gpu.log if: ${{ (matrix.container.name == 'CUDA') && (always()) }} run: cat tidy_results_gpu.log diff --git a/Makefile b/Makefile index 782eaf71c..302654aac 100644 --- a/Makefile +++ b/Makefile @@ -17,13 +17,11 @@ DIRS := src src/analysis src/chemistry_gpu src/cooling src/cooling_grackle s SUFFIX ?= .$(TYPE).$(MACHINE) -CFILES := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.c)) CPPFILES := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.cpp)) GPUFILES := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.cu)) # Build a list of all potential object files so cleaning works properly -CLEAN_OBJS := $(subst .c,.o,$(CFILES)) \ - $(subst .cpp,.o,$(CPPFILES)) \ +CLEAN_OBJS := $(subst .cpp,.o,$(CPPFILES)) \ $(subst .cu,.o,$(GPUFILES)) # Check if it should include testing flags @@ -49,30 +47,24 @@ ifeq ($(ADD_TEST_FLAGS), yes) SUFFIX := $(strip $(SUFFIX)).tests LIBS += -L$(GOOGLETEST_ROOT)/lib64 -pthread -lgtest -lhdf5_cpp TEST_FLAGS = -I$(GOOGLETEST_ROOT)/include - CFLAGS += $(TEST_FLAGS) CXXFLAGS += $(TEST_FLAGS) GPUFLAGS += $(TEST_FLAGS) else # This isn't a test build so clear out testing related files - CFILES := $(filter-out src/system_tests/% %_tests.c,$(CFILES)) CPPFILES := $(filter-out src/system_tests/% %_tests.cpp,$(CPPFILES)) CPPFILES := $(filter-out src/utils/testing_utilities.cpp,$(CPPFILES)) GPUFILES := $(filter-out src/system_tests/% %_tests.cu,$(GPUFILES)) endif -OBJS := $(subst .c,.o,$(CFILES)) \ - $(subst .cpp,.o,$(CPPFILES)) \ +OBJS := $(subst .cpp,.o,$(CPPFILES)) \ $(subst .cu,.o,$(GPUFILES)) #-- Set default compilers and flags -CC ?= cc CXX ?= CC -CFLAGS_OPTIMIZE ?= -g -Ofast CXXFLAGS_OPTIMIZE ?= -g -Ofast -std=c++17 GPUFLAGS_OPTIMIZE ?= -g -O3 -std=c++17 -CFLAGS_DEBUG ?= -g -O0 CXXFLAGS_DEBUG ?= -g -O0 -std=c++17 ifdef HIPCONFIG GPUFLAGS_DEBUG ?= -g -O0 -std=c++17 @@ -82,13 +74,11 @@ endif BUILD ?= OPTIMIZE -CFLAGS += $(CFLAGS_$(BUILD)) CXXFLAGS += $(CXXFLAGS_$(BUILD)) GPUFLAGS += $(GPUFLAGS_$(BUILD)) #-- Add flags and libraries as needed -CFLAGS += $(DFLAGS) -Isrc CXXFLAGS += $(DFLAGS) -Isrc GPUFLAGS += $(DFLAGS) -Isrc @@ -170,7 +160,7 @@ ifeq ($(findstring -DCHEMISTRY_GPU,$(DFLAGS)),-DCHEMISTRY_GPU) DFLAGS += -DSCALAR endif -.SUFFIXES: .c .cpp .cu .o +.SUFFIXES: .cpp .cu .o EXEC := bin/cholla$(SUFFIX) @@ -184,17 +174,14 @@ DFLAGS += $(MACRO_FLAGS) LIBS_CLANG_TIDY := $(subst -I/, -isystem /,$(LIBS)) LIBS_CLANG_TIDY += -isystem $(MPI_ROOT)/include CXXFLAGS_CLANG_TIDY := $(subst -I/, -isystem /,$(LDFLAGS)) -CFLAGS_CLANG_TIDY := $(subst -I/, -isystem /,$(CFLAGS)) GPUFLAGS_CLANG_TIDY := $(subst -I/, -isystem /,$(GPUFLAGS)) GPUFLAGS_CLANG_TIDY := $(filter-out -ccbin=mpicxx -fmad=false --expt-extended-lambda,$(GPUFLAGS)) GPUFLAGS_CLANG_TIDY += --cuda-host-only --cuda-path=$(CUDA_ROOT) -isystem /clang/includes CPPFILES_TIDY := $(CPPFILES) -CFILES_TIDY := $(CFILES) GPUFILES_TIDY := $(GPUFILES) ifdef TIDY_FILES CPPFILES_TIDY := $(filter $(TIDY_FILES), $(CPPFILES_TIDY)) - CFILES_TIDY := $(filter $(TIDY_FILES), $(CFILES_TIDY)) GPUFILES_TIDY := $(filter $(TIDY_FILES), $(GPUFILES_TIDY)) endif @@ -202,9 +189,6 @@ $(EXEC): prereq-build $(OBJS) mkdir -p bin/ && $(LD) $(LDFLAGS) $(OBJS) -o $(EXEC) $(LIBS) eval $(EXTRA_COMMANDS) -%.o: %.c - $(CC) $(CFLAGS) -c $< -o $@ - %.o: %.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ @@ -221,9 +205,8 @@ tidy: # - --warnings-as-errors= Upgrade all warnings to error, good for CI clang-tidy --verify-config (time clang-tidy $(CLANG_TIDY_ARGS) $(CPPFILES_TIDY) -- $(DFLAGS) $(CXXFLAGS_CLANG_TIDY) $(LIBS_CLANG_TIDY)) > tidy_results_cpp.log 2>&1 & \ - (time clang-tidy $(CLANG_TIDY_ARGS) $(CFILES_TIDY) -- $(DFLAGS) $(CFLAGS_CLANG_TIDY) $(LIBS_CLANG_TIDY)) > tidy_results_c.log 2>&1 & \ (time clang-tidy $(CLANG_TIDY_ARGS) $(GPUFILES_TIDY) -- $(DFLAGS) $(GPUFLAGS_CLANG_TIDY) $(LIBS_CLANG_TIDY)) > tidy_results_gpu.log 2>&1 & \ - for i in 1 2 3; do wait -n; done + for i in 1 2; do wait -n; done clean: rm -f $(CLEAN_OBJS) diff --git a/builds/make.host.c3po b/builds/make.host.c3po index 02f658896..dc5e3d8eb 100644 --- a/builds/make.host.c3po +++ b/builds/make.host.c3po @@ -1,8 +1,5 @@ #-- Compiler and flags for different build type -CC = mpicc CXX = mpicxx -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 CXXFLAGS_DEBUG = -g -O0 -std=c++17 ${F_OFFLOAD} CXXFLAGS_OPTIMIZE = -g -Ofast -std=c++17 ${F_OFFLOAD} GPUFLAGS_DEBUG = -g -G -cudart shared -O0 -std=c++17 -ccbin=mpicxx -Xcompiler -rdynamic diff --git a/builds/make.host.crc b/builds/make.host.crc index a4e87553e..e0c20e162 100644 --- a/builds/make.host.crc +++ b/builds/make.host.crc @@ -1,9 +1,6 @@ #-- Compiler and flags for different build type -CC = mpicc CXX = mpicxx -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -Ofast CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 GPUFLAGS_OPTIMIZE = -g -O3 -std=c++17 diff --git a/builds/make.host.frontier b/builds/make.host.frontier index d9efba818..bae874c78 100644 --- a/builds/make.host.frontier +++ b/builds/make.host.frontier @@ -1,13 +1,9 @@ #-- make.host for Frontier at the OLCF with #-- Compiler and flags for different build type -CC = cc CXX = CC #GPUCXX ?= CC -x hip GPUCXX ?= hipcc -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 - CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -g -Ofast -std=c++17 -Wno-unused-result diff --git a/builds/make.host.github b/builds/make.host.github index 0dea956fc..46da09349 100644 --- a/builds/make.host.github +++ b/builds/make.host.github @@ -1,8 +1,5 @@ #-- Compiler and flags for different build type -CC = mpicc CXX = mpicxx -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 CXXFLAGS_DEBUG = -g -O0 -std=c++17 ${F_OFFLOAD} CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 ${F_OFFLOAD} GPUFLAGS_DEBUG = -g -G -cudart shared -O0 -std=c++17 @@ -27,8 +24,6 @@ GOOGLETEST_ROOT := ${GOOGLETEST_ROOT} ifdef HIPCONFIG MPI_ROOT := ${MPI_ROOT} - CFLAGS_DEBUG += -fPIE - CFLAGS_OPTIMIZE += -fPIE CXXFLAGS_DEBUG += -fPIE CXXFLAGS_OPTIMIZE += -fPIE GPUFLAGS_DEBUG += -fPIE diff --git a/builds/make.host.lux b/builds/make.host.lux index f17986700..edf4e42c0 100644 --- a/builds/make.host.lux +++ b/builds/make.host.lux @@ -1,10 +1,7 @@ #-- make.inc for the Shamrock Server #-- Compiler and flags for different build type -CC = mpicc CXX = mpicxx -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 GPUFLAGS = -std=c++17 diff --git a/builds/make.host.poplar b/builds/make.host.poplar index f44851847..f029e09e6 100644 --- a/builds/make.host.poplar +++ b/builds/make.host.poplar @@ -1,10 +1,7 @@ #-- make.inc for Poplar, COE cluster at HPE #-- Compiler and flags for different build type -CC = cc CXX = CC -CFLAGS_DEBUG = -g -O0 ${F_OFFLOAD} -CFLAGS_OPTIMIZE = -Ofast ${F_OFFLOAD} CXXFLAGS_DEBUG = -g -O0 -std=c++17 ${F_OFFLOAD} CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 ${F_OFFLOAD} diff --git a/builds/make.host.poplar.aomp b/builds/make.host.poplar.aomp index cac6b50b1..e87fe68e2 100644 --- a/builds/make.host.poplar.aomp +++ b/builds/make.host.poplar.aomp @@ -1,11 +1,8 @@ #-- make.inc for Poplar, COE cluster at HPE #-- Compiler and flags for different build type -CC = mpicc CXX = mpicxx HIPCONFIG = $(shell hipconfig -C) -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -Ofast CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 diff --git a/builds/make.host.poplar.cce+hip b/builds/make.host.poplar.cce+hip index 94963fb8a..b83268e12 100644 --- a/builds/make.host.poplar.cce+hip +++ b/builds/make.host.poplar.cce+hip @@ -1,11 +1,8 @@ #-- make.inc for Poplar, HPE COE cluster #-- Compiler and flags for different build type -CC = cc CXX = CC HIPCONFIG = $(shell hipconfig -C) -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -Ofast CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 diff --git a/builds/make.host.shamrock b/builds/make.host.shamrock index cc849b051..eec8d48e6 100644 --- a/builds/make.host.shamrock +++ b/builds/make.host.shamrock @@ -1,12 +1,9 @@ #-- make.inc for the Lux Cluster #-- Compiler and flags for different build type -CC = mpicc CXX = mpicxx #CC = gcc #CXX = g++ -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 diff --git a/builds/make.host.spock b/builds/make.host.spock index 8cac7c086..9dfc41676 100644 --- a/builds/make.host.spock +++ b/builds/make.host.spock @@ -1,12 +1,8 @@ #-- make.inc for Spock EAS at the OLCF with #-- Compiler and flags for different build type -CC = cc CXX = CC -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 - CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -g -Ofast -std=c++17 diff --git a/builds/make.host.summit b/builds/make.host.summit index ab1feda42..a9f5337f5 100644 --- a/builds/make.host.summit +++ b/builds/make.host.summit @@ -2,10 +2,7 @@ # https://www.olcf.ornl.gov/summit/ #-- Compiler and flags for different build type -CC = mpicc CXX = mpicxx -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 CXXFLAGS_DEBUG = -g -O0 -std=c++17 ${F_OFFLOAD} CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 ${F_OFFLOAD} GPUFLAGS_DEBUG = -g -O0 -std=c++17 -ccbin=mpicxx -G -cudart shared diff --git a/builds/make.host.tornado b/builds/make.host.tornado index e8cf09a62..cdcf5483f 100644 --- a/builds/make.host.tornado +++ b/builds/make.host.tornado @@ -1,10 +1,7 @@ #-- make.inc for the Lux Cluster #-- Compiler and flags for different build type -CC = gcc CXX = g++ -CFLAGS_DEBUG = -g -O0 -CFLAGS_OPTIMIZE = -g -O2 CXXFLAGS_DEBUG = -g -O0 -std=c++17 CXXFLAGS_OPTIMIZE = -Ofast -std=c++17 diff --git a/builds/setup.poplar.aomp.sh b/builds/setup.poplar.aomp.sh index 7b83e5ab7..d692711fe 100755 --- a/builds/setup.poplar.aomp.sh +++ b/builds/setup.poplar.aomp.sh @@ -1,12 +1,11 @@ #!/bin/bash module purge -module load craype-x86-naples craype-network-infiniband +module load craype-x86-naples craype-network-infiniband module load shared slurm module use /home/users/twhite/share/modulefiles module load ompi/4.0.4-rocm-3.9 hdf5 -export OMPI_CC=$(which clang) export OMPI_CXX=$(which clang) export CHOLLA_MACHINE=poplar.aomp diff --git a/tools/analyze_tidy_checks.py b/tools/analyze_tidy_checks.py index 0ea286920..de5c86313 100755 --- a/tools/analyze_tidy_checks.py +++ b/tools/analyze_tidy_checks.py @@ -6,7 +6,7 @@ failures a check represents. When running, make sure that you have already run clang-tidy with all the - checks you want enabled since this script looks for the 3 tidy_results_*.log + checks you want enabled since this script looks for the 2 tidy_results_*.log files in the root directory of Cholla ================================================================================ """ @@ -35,14 +35,12 @@ def main(): def loadTidyResults(chollaPath): - with open(chollaPath / "tidy_results_c.log", "r") as file: - cData = file.read() with open(chollaPath / "tidy_results_cpp.log", "r") as file: cppData = file.read() with open(chollaPath / "tidy_results_gpu.log", "r") as file: gpuData = file.read() - return cData + cppData + gpuData + return cppData + gpuData def getEnabledChecks(chollaPath): From e67dc1d4d433837c969a873ced5a1c00ae29d3db Mon Sep 17 00:00:00 2001 From: Bob Caddy Date: Tue, 7 Mar 2023 14:53:35 -0500 Subject: [PATCH 3/3] Remove .c files again after bad rebase --- src/mpi/MPI_Comm_node.c | 66 ----------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/mpi/MPI_Comm_node.c diff --git a/src/mpi/MPI_Comm_node.c b/src/mpi/MPI_Comm_node.c deleted file mode 100644 index 80edaf594..000000000 --- a/src/mpi/MPI_Comm_node.c +++ /dev/null @@ -1,66 +0,0 @@ -#ifdef MPI_CHOLLA - #include "../mpi/MPI_Comm_node.h" - - #include - #include - #include - -/*! \fn int djb2_hash(char *str) - * \brief Simple hash function by Dan Bernstein */ -int djb2_hash(char *str); - -/*! \fn MPI_Comm MPI_Comm_node(void) - * \brief Returns an MPI_Comm for processes on each node.*/ -MPI_Comm MPI_Comm_node(int *myid_node, int *nproc_node) -{ - int myid; // global rank - int nproc; // global rank - char pname[MPI_MAX_PROCESSOR_NAME]; // node hostname - int pname_length; // length of node hostname - int hash; // hash of node hostname - - MPI_Comm node_comm; // communicator for the procs on each node - - // get the global process rank - MPI_Comm_rank(MPI_COMM_WORLD, &myid); - MPI_Comm_size(MPI_COMM_WORLD, &nproc); - - // if we're the only process, then just return - // the global rank, size, and comm - if (nproc == 1) { - *myid_node = myid; - *nproc_node = nproc; - return MPI_COMM_WORLD; - } - - // get the hostname of the node - MPI_Get_processor_name(pname, &pname_length); - - // hash the name of the node - hash = abs(djb2_hash(pname)); - - // printf("hash %d\n",hash); - - // split the communicator - MPI_Comm_split(MPI_COMM_WORLD, hash, myid, &node_comm); - - // get size and rank - MPI_Comm_rank(node_comm, myid_node); - MPI_Comm_size(node_comm, nproc_node); - - // return the communicator for processors on the node - return node_comm; -} - -/*! \fn int djb2_hash(char *str) - * \brief Simple hash function by Dan Bernstein */ -int djb2_hash(char *str) -{ - int hash = 5381; - int c; - while ((c = *str++)) { - hash = ((hash << 5) + hash) + c; - } /*hash*33 + c*/ - return hash; -} -#endif /*MPI_CHOLLA*/