Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all C code and build system support for C. Enable bugprone-signed-char-misuse clang-tidy check #259

Merged
merged 3 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/build_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 4 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -184,27 +174,21 @@ 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

$(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 $@

Expand All @@ -221,9 +205,8 @@ tidy:
# - --warnings-as-errors=<string> 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)
Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.c3po
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.crc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 0 additions & 4 deletions builds/make.host.frontier
Original file line number Diff line number Diff line change
@@ -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

Expand Down
5 changes: 0 additions & 5 deletions builds/make.host.github
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.lux
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.poplar
Original file line number Diff line number Diff line change
@@ -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}

Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.poplar.aomp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.poplar.cce+hip
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.shamrock
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 0 additions & 4 deletions builds/make.host.spock
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.summit
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions builds/make.host.tornado
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions builds/setup.poplar.aomp.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
66 changes: 0 additions & 66 deletions src/mpi/MPI_Comm_node.c

This file was deleted.

14 changes: 0 additions & 14 deletions src/mpi/MPI_Comm_node.h

This file was deleted.

4 changes: 0 additions & 4 deletions src/mpi/mpi_routines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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*/

Expand Down Expand Up @@ -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
Expand Down
Loading