1# Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2# All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3# 4# SPDX-License-Identifier: BSD-2-Clause 5# 6# This file is part of CEED: http://github.com/ceed 7 8CONFIG ?= config.mk 9-include $(CONFIG) 10COMMON ?= common.mk 11-include $(COMMON) 12 13ifeq (,$(filter-out undefined default,$(origin CC))) 14 CC = gcc 15endif 16ifeq (,$(filter-out undefined default,$(origin CXX))) 17 CXX = g++ 18endif 19ifeq (,$(filter-out undefined default,$(origin FC))) 20 FC = gfortran 21endif 22ifeq (,$(filter-out undefined default,$(origin LINK))) 23 LINK = $(CC) 24endif 25ifeq (,$(filter-out undefined default,$(origin AR))) 26 AR = ar 27endif 28ifeq (,$(filter-out undefined default,$(origin ARFLAGS))) 29 ARFLAGS = crD 30endif 31NVCC ?= $(CUDA_DIR)/bin/nvcc 32NVCC_CXX ?= $(CXX) 33HIPCC ?= $(ROCM_DIR)/bin/hipcc 34SYCLCXX ?= $(CXX) 35SED ?= sed 36ifneq ($(EMSCRIPTEN),) 37 STATIC = 1 38 EXE_SUFFIX = .wasm 39 EM_LDFLAGS = -s TOTAL_MEMORY=256MB 40endif 41 42# ASAN must be left empty if you don't want to use it 43ASAN ?= 44 45# These are the values automatically detected here in the makefile. They are 46# augmented with LDFLAGS and LDLIBS from the environment/passed by command line, 47# if any. If the user sets CEED_LDFLAGS or CEED_LDLIBS, they are used *instead 48# of* what we populate here (thus that's advanced usage and not recommended). 49CEED_LDFLAGS ?= 50CEED_LDLIBS ?= 51 52UNDERSCORE ?= 1 53 54# Verbose mode, V or VERBOSE 55V ?= $(VERBOSE) 56 57# MFEM_DIR env variable should point to sibling directory 58ifneq ($(wildcard ../mfem/libmfem.*),) 59 MFEM_DIR ?= ../mfem 60endif 61 62# NEK5K_DIR env variable should point to sibling directory 63ifneq ($(wildcard ../Nek5000/*),) 64 NEK5K_DIR ?= $(abspath ../Nek5000) 65endif 66export NEK5K_DIR 67MPI ?= 1 68 69# CEED_DIR env for NEK5K testing 70export CEED_DIR = $(abspath .) 71 72# XSMM_DIR env variable should point to XSMM main (github.com/hfp/libxsmm) 73XSMM_DIR ?= ../libxsmm 74 75# OCCA_DIR env variable should point to OCCA main (github.com/libocca/occa) 76OCCA_DIR ?= ../occa/install 77 78# env variable MAGMA_DIR can be used too 79MAGMA_DIR ?= ../magma 80 81# Often /opt/cuda or /usr/local/cuda, but sometimes present on machines that don't support CUDA 82CUDA_DIR ?= 83CUDA_ARCH ?= 84 85# Often /opt/rocm, but sometimes present on machines that don't support HIP 86ROCM_DIR ?= 87HIP_ARCH ?= 88 89# Check for PETSc in ../petsc 90ifneq ($(wildcard ../petsc/lib/libpetsc.*),) 91 PETSC_DIR ?= ../petsc 92endif 93 94# Warning: SANTIZ options still don't run with /gpu/occa 95# export LSAN_OPTIONS=suppressions=.asanignore 96AFLAGS ?= -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer 97 98# Note: Intel oneAPI C/C++ compiler is now icx/icpx 99CC_VENDOR := $(subst icc_orig,icc,$(firstword $(filter gcc clang icc icc_orig oneAPI XL emcc,$(subst -, ,$(shell $(CC) --version))))) 100FC_VENDOR := $(if $(FC),$(firstword $(filter GNU ifort ifx XL,$(shell $(FC) --version 2>&1 || $(FC) -qversion)))) 101 102# Default extra flags by vendor 103MARCHFLAG.gcc := -march=native 104MARCHFLAG.clang := $(MARCHFLAG.gcc) 105MARCHFLAG.icc := 106MARCHFLAG.oneAPI := $(MARCHFLAG.clang) 107OMP_SIMD_FLAG.gcc := -fopenmp-simd 108OMP_SIMD_FLAG.clang := $(OMP_SIMD_FLAG.gcc) 109OMP_SIMD_FLAG.icc := -qopenmp-simd 110OMP_SIMD_FLAG.oneAPI := $(OMP_SIMD_FLAG.clang) 111SYCL_FLAG.gcc := 112SYCL_FLAG.clang := -fsycl 113SYCL_FLAG.icc := 114SYCL_FLAG.oneAPI := -fsycl 115OPT.gcc := -g -ffp-contract=fast 116OPT.clang := $(OPT.gcc) 117OPT.oneAPI := $(OPT.clang) 118OPT.emcc := 119CFLAGS.gcc := $(if $(STATIC),,-fPIC) -std=c99 -Wall -Wextra -Wno-unused-parameter -MMD -MP 120CFLAGS.clang := $(CFLAGS.gcc) 121CFLAGS.icc := $(CFLAGS.gcc) 122CFLAGS.oneAPI := $(CFLAGS.clang) 123CFLAGS.XL := $(if $(STATIC),,-qpic) -MMD 124CFLAGS.emcc := $(CFLAGS.clang) 125CXXFLAGS.gcc := $(if $(STATIC),,-fPIC) -std=c++11 -Wall -Wextra -Wno-unused-parameter -MMD -MP 126CXXFLAGS.clang := $(CXXFLAGS.gcc) 127CXXFLAGS.icc := $(CXXFLAGS.gcc) 128CXXFLAGS.oneAPI := $(CXXFLAGS.clang) 129CXXFLAGS.XL := $(if $(STATIC),,-qpic) -std=c++11 -MMD 130CXXFLAGS.emcc := $(CXXFLAGS.clang) 131FFLAGS.GNU := $(if $(STATIC),,-fPIC) -cpp -Wall -Wextra -Wno-unused-parameter -Wno-unused-dummy-argument -MMD -MP 132FFLAGS.ifort := $(if $(STATIC),,-fPIC) -cpp 133FFLAGS.ifx := $(FFLAGS.ifort) 134FFLAGS.XL := $(if $(STATIC),,-qpic) -ffree-form -qpreprocess -qextname -MMD 135 136# This check works with compilers that use gcc and clang. It fails with some 137# compilers; e.g., xlc apparently ignores all options when -E is passed, thus 138# succeeds with any flags. Users can pass MARCHFLAG=... if desired. 139cc_check_flag = $(shell $(CC) -E -Werror $(1) -x c /dev/null > /dev/null 2>&1 && echo 1) 140MARCHFLAG := $(MARCHFLAG.$(CC_VENDOR)) 141MARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG),-mcpu=native) 142MARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG)) 143 144OMP_SIMD_FLAG := $(OMP_SIMD_FLAG.$(CC_VENDOR)) 145OMP_SIMD_FLAG := $(if $(call cc_check_flag,$(OMP_SIMD_FLAG)),$(OMP_SIMD_FLAG)) 146 147# Error checking flags 148PEDANTIC ?= 149PEDANTICFLAGS ?= -Werror -pedantic 150 151OPT ?= -O $(MARCHFLAG) $(OPT.$(CC_VENDOR)) $(OMP_SIMD_FLAG) 152CFLAGS ?= $(OPT) $(CFLAGS.$(CC_VENDOR)) $(if $(PEDANTIC),$(PEDANTICFLAGS)) 153CXXFLAGS ?= $(OPT) $(CXXFLAGS.$(CC_VENDOR)) $(if $(PEDANTIC),$(PEDANTICFLAGS)) 154LIBCXX ?= -lstdc++ 155NVCCFLAGS ?= -ccbin $(CXX) -Xcompiler "$(OPT)" -Xcompiler -fPIC 156ifneq ($(CUDA_ARCH),) 157 NVCCFLAGS += -arch=$(CUDA_ARCH) 158endif 159HIPCCFLAGS ?= $(filter-out $(OMP_SIMD_FLAG),$(OPT)) -fPIC -munsafe-fp-atomics 160ifneq ($(HIP_ARCH),) 161 HIPCCFLAGS += --amdgpu-target=$(HIP_ARCH) 162endif 163 164SYCL_FLAG := $(SYCL_FLAG.$(CC_VENDOR)) 165SYCLFLAGS ?= $(SYCL_FLAG) -fPIC -std=c++17 $(filter-out -std=c++11,$(CXXFLAGS)) $(filter-out $(OMP_SIMD_FLAG),$(OPT)) 166FFLAGS ?= $(OPT) $(FFLAGS.$(FC_VENDOR)) 167 168ifeq ($(COVERAGE), 1) 169 CFLAGS += --coverage 170 CXXFLAGS += --coverage 171 CEED_LDFLAGS += --coverage 172endif 173 174CFLAGS += $(if $(ASAN),$(AFLAGS)) 175FFLAGS += $(if $(ASAN),$(AFLAGS)) 176CEED_LDFLAGS += $(if $(ASAN),$(AFLAGS)) 177CPPFLAGS += -I./include 178CEED_LDLIBS = -lm 179OBJDIR := build 180for_install := $(filter install,$(MAKECMDGOALS)) 181LIBDIR := $(if $(for_install),$(OBJDIR),lib) 182 183 184# Installation variables 185prefix ?= /usr/local 186bindir = $(prefix)/bin 187libdir = $(prefix)/lib 188includedir = $(prefix)/include 189pkgconfigdir = $(libdir)/pkgconfig 190INSTALL = install 191INSTALL_PROGRAM = $(INSTALL) 192INSTALL_DATA = $(INSTALL) -m644 193 194# Get number of processors of the machine 195NPROCS := $(shell getconf _NPROCESSORS_ONLN) 196# prepare make options to run in parallel 197MFLAGS := -j $(NPROCS) --warn-undefined-variables \ 198 --no-print-directory --no-keep-going 199 200PYTHON ?= python3 201PROVE ?= prove 202PROVE_OPTS ?= -j $(NPROCS) 203DARWIN := $(filter Darwin,$(shell uname -s)) 204SO_EXT := $(if $(DARWIN),dylib,so) 205 206ceed.pc := $(LIBDIR)/pkgconfig/ceed.pc 207libceed.so := $(LIBDIR)/libceed.$(SO_EXT) 208libceed.a := $(LIBDIR)/libceed.a 209libceed := $(if $(STATIC),$(libceed.a),$(libceed.so)) 210CEED_LIBS = -lceed 211libceed.c := $(filter-out interface/ceed-cuda.c interface/ceed-hip.c interface/ceed-jit-source-root-$(if $(for_install),default,install).c, $(wildcard interface/ceed*.c backends/*.c gallery/*.c)) 212gallery.c := $(wildcard gallery/*/ceed*.c) 213libceed.c += $(gallery.c) 214libceeds = $(libceed) 215BACKENDS_BUILTIN := /cpu/self/ref/serial /cpu/self/ref/blocked /cpu/self/opt/serial /cpu/self/opt/blocked 216BACKENDS_MAKE := $(BACKENDS_BUILTIN) 217TEST_BACKENDS := /cpu/self/tmpl /cpu/self/tmpl/sub 218 219# Tests 220tests.c := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.c)) 221tests.f := $(if $(FC),$(sort $(wildcard tests/t[0-9][0-9][0-9]-*.f90))) 222tests := $(tests.c:tests/%.c=$(OBJDIR)/%$(EXE_SUFFIX)) 223ctests := $(tests) 224tests += $(tests.f:tests/%.f90=$(OBJDIR)/%$(EXE_SUFFIX)) 225# Examples 226examples.c := $(sort $(wildcard examples/ceed/*.c)) 227examples.f := $(if $(FC),$(sort $(wildcard examples/ceed/*.f))) 228examples := $(examples.c:examples/ceed/%.c=$(OBJDIR)/%$(EXE_SUFFIX)) 229examples += $(examples.f:examples/ceed/%.f=$(OBJDIR)/%$(EXE_SUFFIX)) 230# MFEM Examples 231mfemexamples.cpp := $(sort $(wildcard examples/mfem/*.cpp)) 232mfemexamples := $(mfemexamples.cpp:examples/mfem/%.cpp=$(OBJDIR)/mfem-%) 233# Nek5K Examples 234nekexamples := $(OBJDIR)/nek-bps 235# PETSc Examples 236petscexamples.c := $(wildcard examples/petsc/*.c) 237petscexamples := $(petscexamples.c:examples/petsc/%.c=$(OBJDIR)/petsc-%) 238# Fluid Dynamics Examples 239fluidsexamples.c := $(sort $(wildcard examples/fluids/*.c)) 240fluidsexamples := $(fluidsexamples.c:examples/fluids/%.c=$(OBJDIR)/fluids-%) 241# Solid Mechanics Examples 242solidsexamples.c := $(sort $(wildcard examples/solids/*.c)) 243solidsexamples := $(solidsexamples.c:examples/solids/%.c=$(OBJDIR)/solids-%) 244 245# Backends/[ref, blocked, memcheck, opt, avx, occa, magma] 246ref.c := $(sort $(wildcard backends/ref/*.c)) 247blocked.c := $(sort $(wildcard backends/blocked/*.c)) 248ceedmemcheck.c := $(sort $(wildcard backends/memcheck/*.c)) 249opt.c := $(sort $(wildcard backends/opt/*.c)) 250avx.c := $(sort $(wildcard backends/avx/*.c)) 251xsmm.c := $(sort $(wildcard backends/xsmm/*.c)) 252cuda.c := $(sort $(wildcard backends/cuda/*.c)) 253cuda.cpp := $(sort $(wildcard backends/cuda/*.cpp)) 254cuda-ref.c := $(sort $(wildcard backends/cuda-ref/*.c)) 255cuda-ref.cpp := $(sort $(wildcard backends/cuda-ref/*.cpp)) 256cuda-ref.cu := $(sort $(wildcard backends/cuda-ref/kernels/*.cu)) 257cuda-shared.c := $(sort $(wildcard backends/cuda-shared/*.c)) 258cuda-shared.cu := $(sort $(wildcard backends/cuda-shared/kernels/*.cu)) 259cuda-gen.c := $(sort $(wildcard backends/cuda-gen/*.c)) 260cuda-gen.cpp := $(sort $(wildcard backends/cuda-gen/*.cpp)) 261cuda-gen.cu := $(sort $(wildcard backends/cuda-gen/kernels/*.cu)) 262occa.cpp := $(sort $(shell find backends/occa -type f -name *.cpp)) 263magma.c := $(sort $(wildcard backends/magma/*.c)) 264magma.cpp := $(sort $(wildcard backends/magma/*.cpp)) 265magma.cu := $(sort $(wildcard backends/magma/kernels/cuda/*.cu)) 266magma.hip := $(sort $(wildcard backends/magma/kernels/hip/*.hip.cpp)) 267hip.c := $(sort $(wildcard backends/hip/*.c)) 268hip.cpp := $(sort $(wildcard backends/hip/*.cpp)) 269hip-ref.c := $(sort $(wildcard backends/hip-ref/*.c)) 270hip-ref.cpp := $(sort $(wildcard backends/hip-ref/*.cpp)) 271hip-ref.hip := $(sort $(wildcard backends/hip-ref/kernels/*.hip.cpp)) 272hip-shared.c := $(sort $(wildcard backends/hip-shared/*.c)) 273hip-gen.c := $(sort $(wildcard backends/hip-gen/*.c)) 274hip-gen.cpp := $(sort $(wildcard backends/hip-gen/*.cpp)) 275sycl-core.cpp := $(sort $(wildcard backends/sycl/*.sycl.cpp)) 276sycl-ref.cpp := $(sort $(wildcard backends/sycl-ref/*.sycl.cpp)) 277sycl-shared.cpp:= $(sort $(wildcard backends/sycl-shared/*.sycl.cpp)) 278 279hip-all.c := interface/ceed-hip.c $(hip.c) $(hip-ref.c) $(hip-shared.c) $(hip-gen.c) 280hip-all.cpp := $(hip.cpp) $(hip-ref.cpp) $(hip-gen.cpp) 281 282# Quiet, color output 283quiet ?= $($(1)) 284 285# Cancel built-in and old-fashioned implicit rules which we don't use 286.SUFFIXES: 287 288.SECONDEXPANSION: # to expand $$(@D)/.DIR 289 290%/.DIR : 291 @mkdir -p $(@D) 292 @touch $@ 293 294.PRECIOUS: %/.DIR 295 296lib: $(libceed) $(ceed.pc) 297# run 'lib' target in parallel 298par:;@$(MAKE) $(MFLAGS) V=$(V) lib 299backend_status = $(if $(filter $1,$(BACKENDS_MAKE)), [backends: $1], [not found]) 300info: 301 $(info ------------------------------------) 302 $(info CC = $(CC)) 303 $(info CXX = $(CXX)) 304 $(info FC = $(FC)) 305 $(info CPPFLAGS = $(CPPFLAGS)) 306 $(info CFLAGS = $(value CFLAGS)) 307 $(info CXXFLAGS = $(value CXXFLAGS)) 308 $(info FFLAGS = $(value FFLAGS)) 309 $(info NVCCFLAGS = $(value NVCCFLAGS)) 310 $(info HIPCCFLAGS = $(value HIPCCFLAGS)) 311 $(info SYCLFLAGS = $(value SYCLFLAGS)) 312 $(info CEED_LDFLAGS = $(value CEED_LDFLAGS)) 313 $(info CEED_LDLIBS = $(value CEED_LDLIBS)) 314 $(info AR = $(AR)) 315 $(info ARFLAGS = $(ARFLAGS)) 316 $(info OPT = $(OPT)) 317 $(info AFLAGS = $(AFLAGS)) 318 $(info ASAN = $(or $(ASAN),(empty))) 319 $(info VERBOSE = $(or $(V),(empty)) [verbose=$(if $(V),on,off)]) 320 $(info ------------------------------------) 321 $(info MEMCHK_STATUS = $(MEMCHK_STATUS)$(call backend_status,$(MEMCHK_BACKENDS))) 322 $(info AVX_STATUS = $(AVX_STATUS)$(call backend_status,$(AVX_BACKENDS))) 323 $(info XSMM_DIR = $(XSMM_DIR)$(call backend_status,$(XSMM_BACKENDS))) 324 $(info OCCA_DIR = $(OCCA_DIR)$(call backend_status,$(OCCA_BACKENDS))) 325 $(info MAGMA_DIR = $(MAGMA_DIR)$(call backend_status,$(MAGMA_BACKENDS))) 326 $(info CUDA_DIR = $(CUDA_DIR)$(call backend_status,$(CUDA_BACKENDS))) 327 $(info ROCM_DIR = $(ROCM_DIR)$(call backend_status,$(HIP_BACKENDS))) 328 $(info SYCL_DIR = $(SYCL_DIR)$(call backend_status,$(SYCL_BACKENDS))) 329 $(info ------------------------------------) 330 $(info MFEM_DIR = $(MFEM_DIR)) 331 $(info NEK5K_DIR = $(NEK5K_DIR)) 332 $(info PETSC_DIR = $(PETSC_DIR)) 333 $(info ------------------------------------) 334 $(info prefix = $(prefix)) 335 $(info includedir = $(value includedir)) 336 $(info libdir = $(value libdir)) 337 $(info pkgconfigdir = $(value pkgconfigdir)) 338 $(info ------------------------------------) 339 @true 340info-backends: 341 $(info make: 'lib' with optional backends: $(filter-out $(BACKENDS_BUILTIN),$(BACKENDS))) 342 @true 343info-backends-all: 344 $(info make: 'lib' with backends: $(filter-out $(TEST_BACKENDS),$(BACKENDS))) 345 @true 346 347$(libceed.so) : CEED_LDFLAGS += $(if $(DARWIN), -install_name @rpath/$(notdir $(libceed.so))) 348 349# Standard Backends 350libceed.c += $(ref.c) 351libceed.c += $(blocked.c) 352libceed.c += $(opt.c) 353 354# Memcheck Backends 355MEMCHK_STATUS = Disabled 356MEMCHK := $(shell echo "$(HASH)include <valgrind/memcheck.h>" | $(CC) $(CPPFLAGS) -E - >/dev/null 2>&1 && echo 1) 357MEMCHK_BACKENDS = /cpu/self/memcheck/serial /cpu/self/memcheck/blocked 358ifeq ($(MEMCHK),1) 359 MEMCHK_STATUS = Enabled 360 libceed.c += $(ceedmemcheck.c) 361 BACKENDS_MAKE += $(MEMCHK_BACKENDS) 362endif 363 364# AVX Backeds 365AVX_STATUS = Disabled 366AVX_FLAG := $(if $(filter clang,$(CC_VENDOR)),+avx,-mavx) 367AVX := $(filter $(AVX_FLAG),$(shell $(CC) $(CFLAGS:-M%=) -v -E -x c /dev/null 2>&1)) 368AVX_BACKENDS = /cpu/self/avx/serial /cpu/self/avx/blocked 369ifneq ($(AVX),) 370 AVX_STATUS = Enabled 371 libceed.c += $(avx.c) 372 BACKENDS_MAKE += $(AVX_BACKENDS) 373endif 374 375# Collect list of libraries and paths for use in linking and pkg-config 376PKG_LIBS = 377# Stubs that will not be RPATH'd 378PKG_STUBS_LIBS = 379 380# libXSMM Backends 381XSMM_BACKENDS = /cpu/self/xsmm/serial /cpu/self/xsmm/blocked 382ifneq ($(wildcard $(XSMM_DIR)/lib/libxsmm.*),) 383 PKG_LIBS += -L$(abspath $(XSMM_DIR))/lib -lxsmm -ldl 384 MKL ?= 385 ifeq (,$(MKL)$(MKLROOT)) 386 BLAS_LIB = -lblas 387 else 388 ifneq ($(MKLROOT),) 389 # Some installs put everything inside an intel64 subdirectory, others not 390 MKL_LIBDIR = $(dir $(firstword $(wildcard $(MKLROOT)/lib/intel64/libmkl_sequential.* $(MKLROOT)/lib/libmkl_sequential.*))) 391 MKL_LINK = -L$(MKL_LIBDIR) 392 PKG_LIB_DIRS += $(MKL_LIBDIR) 393 endif 394 BLAS_LIB = $(MKL_LINK) -Wl,--push-state,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -Wl,--pop-state 395 endif 396 PKG_LIBS += $(BLAS_LIB) 397 libceed.c += $(xsmm.c) 398 $(xsmm.c:%.c=$(OBJDIR)/%.o) $(xsmm.c:%=%.tidy) : CPPFLAGS += -I$(XSMM_DIR)/include 399 BACKENDS_MAKE += $(XSMM_BACKENDS) 400endif 401 402# OCCA Backends 403OCCA_BACKENDS = /cpu/self/occa 404ifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),) 405 OCCA_MODES := $(shell LD_LIBRARY_PATH=$(OCCA_DIR)/lib $(OCCA_DIR)/bin/occa modes) 406 OCCA_BACKENDS += $(if $(filter OpenMP,$(OCCA_MODES)),/cpu/openmp/occa) 407 OCCA_BACKENDS += $(if $(filter dpcpp,$(OCCA_MODES)),/gpu/dpcpp/occa) 408 OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/gpu/opencl/occa) 409 OCCA_BACKENDS += $(if $(filter HIP,$(OCCA_MODES)),/gpu/hip/occa) 410 OCCA_BACKENDS += $(if $(filter CUDA,$(OCCA_MODES)),/gpu/cuda/occa) 411 412 $(libceeds) : CPPFLAGS += -I$(OCCA_DIR)/include 413 PKG_LIBS += -L$(abspath $(OCCA_DIR))/lib -locca 414 LIBCEED_CONTAINS_CXX = 1 415 libceed.cpp += $(occa.cpp) 416 BACKENDS_MAKE += $(OCCA_BACKENDS) 417endif 418 419# CUDA Backends 420ifneq ($(CUDA_DIR),) 421 CUDA_LIB_DIR := $(wildcard $(foreach d,lib lib64 lib/x86_64-linux-gnu,$(CUDA_DIR)/$d/libcudart.${SO_EXT})) 422 CUDA_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(CUDA_LIB_DIR)))) 423endif 424CUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs 425CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen 426ifneq ($(CUDA_LIB_DIR),) 427 $(libceeds) : CPPFLAGS += -I$(CUDA_DIR)/include 428 PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas 429 PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS) 430 LIBCEED_CONTAINS_CXX = 1 431 libceed.c += interface/ceed-cuda.c 432 libceed.c += $(cuda.c) $(cuda-ref.c) $(cuda-shared.c) $(cuda-gen.c) 433 libceed.cpp += $(cuda.cpp) $(cuda-ref.cpp) $(cuda-gen.cpp) 434 libceed.cu += $(cuda-ref.cu) $(cuda-shared.cu) $(cuda-gen.cu) 435 BACKENDS_MAKE += $(CUDA_BACKENDS) 436endif 437 438# HIP Backends 439HIP_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(ROCM_DIR)/$d/libamdhip64.${SO_EXT})) 440HIP_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(HIP_LIB_DIR)))) 441HIP_BACKENDS = /gpu/hip/ref /gpu/hip/shared /gpu/hip/gen 442ifneq ($(HIP_LIB_DIR),) 443 HIPCONFIG_CPPFLAGS := $(subst =,,$(shell $(ROCM_DIR)/bin/hipconfig -C)) 444 $(hip-all.c:%.c=$(OBJDIR)/%.o) $(hip-all.c:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS) 445 ifneq ($(CXX), $(HIPCC)) 446 $(hip-all.cpp:%.cpp=$(OBJDIR)/%.o) $(hip-all.cpp:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS) 447 endif 448 PKG_LIBS += -L$(abspath $(HIP_LIB_DIR)) -lamdhip64 -lhipblas 449 LIBCEED_CONTAINS_CXX = 1 450 libceed.c += $(hip-all.c) 451 libceed.cpp += $(hip-all.cpp) 452 libceed.hip += $(hip-ref.hip) 453 BACKENDS_MAKE += $(HIP_BACKENDS) 454endif 455 456# SYCL Backends 457SYCL_BACKENDS = /gpu/sycl/ref /gpu/sycl/shared 458ifneq ($(SYCL_DIR),) 459 SYCL_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(SYCL_DIR)/$d/libsycl.${SO_EXT})) 460 SYCL_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(SYCL_LIB_DIR)))) 461endif 462ifneq ($(SYCL_LIB_DIR),) 463 PKG_LIBS += $(SYCL_FLAG) -lze_loader 464 LIBCEED_CONTAINS_CXX = 1 465 libceed.sycl += $(sycl-core.cpp) $(sycl-ref.cpp) $(sycl-shared.cpp) 466 BACKENDS_MAKE += $(SYCL_BACKENDS) 467endif 468 469# MAGMA Backends 470ifneq ($(wildcard $(MAGMA_DIR)/lib/libmagma.*),) 471 MAGMA_ARCH=$(shell nm -g $(MAGMA_DIR)/lib/libmagma.* | grep -c "hipblas") 472 ifeq ($(MAGMA_ARCH), 0) #CUDA MAGMA 473 ifneq ($(CUDA_LIB_DIR),) 474 cuda_link = $(if $(STATIC),,-Wl,-rpath,$(CUDA_LIB_DIR)) -L$(CUDA_LIB_DIR) -lcublas -lcusparse -lcudart 475 omp_link = -fopenmp 476 magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(cuda_link) $(omp_link) 477 magma_link_shared = -L$(MAGMA_DIR)/lib $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma 478 magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static)) 479 PKG_LIBS += $(magma_link) 480 libceed.c += $(magma.c) 481 libceed.cpp += $(magma.cpp) 482 libceed.cu += $(magma.cu) 483 $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include 484 $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include 485 $(magma.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += --compiler-options=-fPIC -DADD_ -I$(MAGMA_DIR)/include -I$(MAGMA_DIR)/magmablas -I$(CUDA_DIR)/include 486 MAGMA_BACKENDS = /gpu/cuda/magma /gpu/cuda/magma/det 487 endif 488 else # HIP MAGMA 489 ifneq ($(HIP_LIB_DIR),) 490 HIP_LIB_DIR_MAGMA=$(ROCM_DIR)/lib 491 HIP_INC_DIR_MAGMA=$(ROCM_DIR)/include 492 omp_link = -fopenmp 493 hip_link = $(if $(STATIC),,-Wl,-rpath,$(HIP_LIB_DIR_MAGMA)) -L$(HIP_LIB_DIR_MAGMA) -lhipblas -lhipsparse -lamdhip64 494 magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(hip_link) $(omp_link) 495 magma_link_shared = -L$(MAGMA_DIR)/lib $(hip_link) $(omp_link) $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma 496 magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static)) 497 PKG_LIBS += $(magma_link) 498 libceed.c += $(magma.c) 499 libceed.cpp += $(magma.cpp) 500 libceed.hip += $(magma.hip) 501 $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += $(HIPCONFIG_CPPFLAGS) -I$(MAGMA_DIR)/include -I$(HIP_INC_DIR_MAGMA)/include -DCEED_MAGMA_USE_HIP -DADD_ 502 $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : CPPFLAGS += $(HIPCONFIG_CPPFLAGS) -I$(MAGMA_DIR)/include -I$(HIP_INC_DIR_MAGMA)/include -DCEED_MAGMA_USE_HIP -DADD_ 503 $(magma.hip:%.hip.cpp=$(OBJDIR)/%.o) : CPPFLAGS += -I$(MAGMA_DIR)/include -I$(MAGMA_DIR)/magmablas -I$(HIP_INC_DIR_MAGMA)/include -DCEED_MAGMA_USE_HIP -DADD_ 504 MAGMA_BACKENDS = /gpu/hip/magma /gpu/hip/magma/det 505 endif 506 endif 507 LIBCEED_CONTAINS_CXX = 1 508 BACKENDS_MAKE += $(MAGMA_BACKENDS) 509endif 510 511BACKENDS ?= $(BACKENDS_MAKE) 512export BACKENDS 513 514_pkg_ldflags = $(filter -L%,$(PKG_LIBS)) 515_pkg_ldlibs = $(filter-out -L%,$(PKG_LIBS)) 516$(libceeds) : CEED_LDFLAGS += $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS) 517$(libceeds) : CEED_LDLIBS += $(_pkg_ldlibs) 518ifeq ($(STATIC),1) 519$(examples) $(tests) : CEED_LDFLAGS += $(EM_LDFLAGS) $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS) 520$(examples) $(tests) : CEED_LDLIBS += $(_pkg_ldlibs) 521endif 522 523pkgconfig-libs-private = $(PKG_LIBS) 524ifeq ($(LIBCEED_CONTAINS_CXX),1) 525 $(libceeds) : LINK = $(CXX) 526 ifeq ($(STATIC),1) 527 $(examples) $(tests) : CEED_LDLIBS += $(LIBCXX) 528 pkgconfig-libs-private += $(LIBCXX) 529 endif 530endif 531 532# File names *-weak.c contain weak symbol definitions, which must be listed last 533# when creating shared or static libraries. 534weak_last = $(filter-out %-weak.o,$(1)) $(filter %-weak.o,$(1)) 535 536libceed.o = $(libceed.c:%.c=$(OBJDIR)/%.o) $(libceed.cpp:%.cpp=$(OBJDIR)/%.o) $(libceed.cu:%.cu=$(OBJDIR)/%.o) $(libceed.hip:%.hip.cpp=$(OBJDIR)/%.o) $(libceed.sycl:%.sycl.cpp=$(OBJDIR)/%.o) 537$(filter %fortran.o,$(libceed.o)) : CPPFLAGS += $(if $(filter 1,$(UNDERSCORE)),-DUNDERSCORE) 538$(libceed.o): | info-backends 539$(libceed.so) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR 540 $(call quiet,LINK) $(LDFLAGS) $(CEED_LDFLAGS) -shared -o $@ $^ $(CEED_LDLIBS) $(LDLIBS) 541 542$(libceed.a) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR 543 $(call quiet,AR) $(ARFLAGS) $@ $^ 544 545$(OBJDIR)/%.o : $(CURDIR)/%.c | $$(@D)/.DIR 546 $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 547 548$(OBJDIR)/%.o : $(CURDIR)/%.cpp | $$(@D)/.DIR 549 $(call quiet,CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(abspath $<) 550 551$(OBJDIR)/%.o : $(CURDIR)/%.cu | $$(@D)/.DIR 552 $(call quiet,NVCC) $(filter-out -Wno-unused-function, $(CPPFLAGS)) $(NVCCFLAGS) -c -o $@ $(abspath $<) 553 554$(OBJDIR)/%.o : $(CURDIR)/%.hip.cpp | $$(@D)/.DIR 555 $(call quiet,HIPCC) $(CPPFLAGS) $(HIPCCFLAGS) -c -o $@ $(abspath $<) 556 557$(OBJDIR)/%.o : $(CURDIR)/%.sycl.cpp | $$(@D)/.DIR 558 $(call quiet,SYCLCXX) $(SYCLFLAGS) $(CPPFLAGS) -c -o $@ $(abspath $<) 559 560$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.c | $$(@D)/.DIR 561 $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 562 563$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.f90 | $$(@D)/.DIR 564 $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 565 566$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.c | $$(@D)/.DIR 567 $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 568 569$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.f | $$(@D)/.DIR 570 $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 571 572$(OBJDIR)/mfem-% : examples/mfem/%.cpp $(libceed) | $$(@D)/.DIR 573 +$(MAKE) -C examples/mfem CEED_DIR=`pwd` \ 574 MFEM_DIR="$(abspath $(MFEM_DIR))" CXX=$(CXX) $* 575 cp examples/mfem/$* $@ 576 577# Note: Multiple Nek files cannot be built in parallel. The '+' here enables 578# this single Nek bps file to be built in parallel with other examples, 579# such as when calling `make prove-all -j2`. 580$(OBJDIR)/nek-bps : examples/nek/bps/bps.usr examples/nek/nek-examples.sh $(libceed) | $$(@D)/.DIR 581 +$(MAKE) -C examples MPI=$(MPI) CEED_DIR=`pwd` NEK5K_DIR="$(abspath $(NEK5K_DIR))" nek 582 mv examples/nek/build/bps $(OBJDIR)/bps 583 cp examples/nek/nek-examples.sh $(OBJDIR)/nek-bps 584 585# Several executables have common utilities, but we can't build the utilities 586# from separate submake invocations because they'll compete with each 587# other/corrupt output. So we put it in this utility library, but we don't want 588# to manually list source dependencies up at this level, so we'll just always 589# call recursive make to check that this utility is up to date. 590examples/petsc/libutils.a.PHONY: $(libceed) $(ceed.pc) 591 +$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` AR=$(AR) ARFLAGS=$(ARFLAGS) \ 592 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $(basename $(@F)) 593 594$(OBJDIR)/petsc-% : examples/petsc/%.c examples/petsc/libutils.a.PHONY $(libceed) $(ceed.pc) | $$(@D)/.DIR 595 +$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` \ 596 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 597 cp examples/petsc/$* $@ 598 599$(OBJDIR)/fluids-% : examples/fluids/%.c examples/fluids/src/*.c examples/fluids/*.h examples/fluids/problems/*.c examples/fluids/qfunctions/*.h $(libceed) $(ceed.pc) | $$(@D)/.DIR 600 +$(call quiet,MAKE) -C examples/fluids CEED_DIR=`pwd` \ 601 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 602 cp examples/fluids/$* $@ 603 604$(OBJDIR)/solids-% : examples/solids/%.c examples/solids/%.h \ 605 examples/solids/problems/*.c examples/solids/src/*.c \ 606 examples/solids/include/*.h examples/solids/problems/*.h examples/solids/qfunctions/*.h \ 607 $(libceed) $(ceed.pc) | $$(@D)/.DIR 608 +$(call quiet,MAKE) -C examples/solids CEED_DIR=`pwd` \ 609 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 610 cp examples/solids/$* $@ 611 612$(examples) : $(libceed) 613$(tests) : $(libceed) 614$(tests) $(examples) : override LDFLAGS += $(if $(STATIC),,-Wl,-rpath,$(abspath $(LIBDIR))) -L$(LIBDIR) 615 616run-% : $(OBJDIR)/% 617 @$(PYTHON) tests/junit.py --mode tap $(<:$(OBJDIR)/%=%) 618 619external_examples := \ 620 $(if $(MFEM_DIR),$(mfemexamples)) \ 621 $(if $(PETSC_DIR),$(petscexamples)) \ 622 $(if $(NEK5K_DIR),$(nekexamples)) \ 623 $(if $(PETSC_DIR),$(fluidsexamples)) \ 624 $(if $(PETSC_DIR),$(solidsexamples)) 625 626allexamples = $(examples) $(external_examples) 627 628# The test and prove targets can be controlled via pattern searches. The 629# default is to run tests and those examples that have no external dependencies. 630# Examples of finer grained control: 631# 632# make test search='petsc mfem' # PETSc and MFEM examples 633# make prove search='t3' # t3xx series tests 634# make junit search='ex petsc' # core ex* and PETSc tests 635search ?= t ex 636realsearch = $(search:%=%%) 637matched = $(foreach pattern,$(realsearch),$(filter $(OBJDIR)/$(pattern),$(tests) $(allexamples))) 638 639# Test core libCEED 640test : $(matched:$(OBJDIR)/%=run-%) 641 642# Run test target in parallel 643tst : ;@$(MAKE) $(MFLAGS) V=$(V) test 644# CPU C tests only for backend % 645ctc-% : $(ctests);@$(foreach tst,$(ctests),$(tst) /cpu/$*;) 646 647prove : $(matched) 648 $(info Testing backends: $(BACKENDS)) 649 $(PROVE) $(PROVE_OPTS) --exec 'tests/junit.py --mode tap' $(matched:$(OBJDIR)/%=%) 650# Run prove target in parallel 651prv : ;@$(MAKE) $(MFLAGS) V=$(V) prove 652 653prove-all : 654 +$(MAKE) prove realsearch=% 655 656junit-% : $(OBJDIR)/% 657 @printf " %10s %s\n" TEST $(<:$(OBJDIR)/%=%); $(PYTHON) tests/junit.py $(<:$(OBJDIR)/%=%) 658 659junit : $(matched:$(OBJDIR)/%=junit-%) 660 661all: $(alltests) 662 663examples : $(allexamples) 664ceedexamples : $(examples) 665nekexamples : $(nekexamples) 666mfemexamples : $(mfemexamples) 667petscexamples : $(petscexamples) 668 669# Benchmarks 670allbenchmarks = petsc-bps 671bench_targets = $(addprefix bench-,$(allbenchmarks)) 672.PHONY: $(bench_targets) benchmarks 673$(bench_targets): bench-%: $(OBJDIR)/% 674 cd benchmarks && ./benchmark.sh --ceed "$(BACKENDS_MAKE)" -r $(*).sh 675benchmarks: $(bench_targets) 676 677$(ceed.pc) : pkgconfig-prefix = $(abspath .) 678$(OBJDIR)/ceed.pc : pkgconfig-prefix = $(prefix) 679.INTERMEDIATE : $(OBJDIR)/ceed.pc 680%/ceed.pc : ceed.pc.template | $$(@D)/.DIR 681 @$(SED) \ 682 -e "s:%prefix%:$(pkgconfig-prefix):" \ 683 -e "s:%libs_private%:$(pkgconfig-libs-private):" $< > $@ 684 685$(OBJDIR)/interface/ceed-jit-source-root-default.o : CPPFLAGS += -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath ./include)/\"" 686$(OBJDIR)/interface/ceed-jit-source-root-install.o : CPPFLAGS += -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath $(includedir))/\"" 687 688install : $(libceed) $(OBJDIR)/ceed.pc 689 $(INSTALL) -d $(addprefix $(if $(DESTDIR),"$(DESTDIR)"),"$(includedir)"\ 690 "$(includedir)/ceed/" "$(includedir)/ceed/jit-source/"\ 691 "$(includedir)/ceed/jit-source/cuda/" "$(includedir)/ceed/jit-source/hip/"\ 692 "$(includedir)/ceed/jit-source/gallery/" "$(libdir)" "$(pkgconfigdir)") 693 $(INSTALL_DATA) include/ceed/ceed.h "$(DESTDIR)$(includedir)/ceed/" 694 $(INSTALL_DATA) include/ceed/types.h "$(DESTDIR)$(includedir)/ceed/" 695 $(INSTALL_DATA) include/ceed/ceed-f32.h "$(DESTDIR)$(includedir)/ceed/" 696 $(INSTALL_DATA) include/ceed/ceed-f64.h "$(DESTDIR)$(includedir)/ceed/" 697 $(INSTALL_DATA) include/ceed/fortran.h "$(DESTDIR)$(includedir)/ceed/" 698 $(INSTALL_DATA) include/ceed/backend.h "$(DESTDIR)$(includedir)/ceed/" 699 $(INSTALL_DATA) include/ceed/cuda.h "$(DESTDIR)$(includedir)/ceed/" 700 $(INSTALL_DATA) include/ceed/hip.h "$(DESTDIR)$(includedir)/ceed/" 701 $(INSTALL_DATA) include/ceed/hash.h "$(DESTDIR)$(includedir)/ceed/" 702 $(INSTALL_DATA) include/ceed/khash.h "$(DESTDIR)$(includedir)/ceed/" 703 $(INSTALL_DATA) $(libceed) "$(DESTDIR)$(libdir)/" 704 $(INSTALL_DATA) $(OBJDIR)/ceed.pc "$(DESTDIR)$(pkgconfigdir)/" 705 $(INSTALL_DATA) include/ceed.h "$(DESTDIR)$(includedir)/" 706 $(INSTALL_DATA) include/ceedf.h "$(DESTDIR)$(includedir)/" 707 $(INSTALL_DATA) $(wildcard include/ceed/jit-source/cuda/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/cuda/" 708 $(INSTALL_DATA) $(wildcard include/ceed/jit-source/hip/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/hip/" 709 $(INSTALL_DATA) $(wildcard include/ceed/jit-source/gallery/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/gallery/" 710 711.PHONY : all cln clean doxygen doc format lib install par print test tst prove prv prove-all junit examples tidy iwyu info info-backends info-backends-all 712 713cln clean : 714 $(RM) -r $(OBJDIR) $(LIBDIR) dist *egg* .pytest_cache *cffi* 715 $(call quiet,MAKE) -C examples clean NEK5K_DIR="$(abspath $(NEK5K_DIR))" 716 $(call quiet,MAKE) -C python/tests clean 717 $(RM) benchmarks/*output.txt 718 719distclean : clean 720 $(RM) -r doc/html doc/sphinx/build $(CONFIG) 721 722# Documentation 723DOXYGEN ?= doxygen 724doxygen : 725 $(DOXYGEN) -q Doxyfile 726 727doc-html doc-latexpdf doc-epub doc-livehtml : doc-% : doxygen 728 make -C doc/sphinx $* 729 730doc : doc-html 731 732# Style/Format 733CLANG_FORMAT ?= clang-format 734 735FORMAT_OPTS += -style=file -i 736 737format.ch := $(filter-out include/ceedf.h $(wildcard tests/t*-f.h), $(shell git ls-files *.[ch]pp *.[ch])) 738 739format-c : 740 $(CLANG_FORMAT) $(FORMAT_OPTS) $(format.ch) 741 742AUTOPEP8 = autopep8 743format-py : AUTOPEP8_ARGS = --in-place --aggressive 744format-py : 745 @$(AUTOPEP8) $(AUTOPEP8_ARGS) $(wildcard *.py python**/*.py python/tests/*.py examples**/*.py doc/sphinx/source**/*.py benchmarks/*.py) 746 747format : format-c format-py 748 749# Tidy 750CLANG_TIDY ?= clang-tidy 751 752%.c.tidy : %.c 753 $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c99 -I$(CUDA_DIR)/include -I$(ROCM_DIR)/include -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath ./include)/\"" 754 755%.cpp.tidy : %.cpp 756 $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c++11 -I$(CUDA_DIR)/include -I$(OCCA_DIR)/include -I$(ROCM_DIR)/include 757 758tidy-c : $(libceed.c:%=%.tidy) 759tidy-cpp : $(libceed.cpp:%=%.tidy) 760 761tidy : tidy-c tidy-cpp 762 763# Include-What-You-Use 764ifneq ($(wildcard ../iwyu/*),) 765 IWYU_DIR ?= ../iwyu 766 IWYU_CC ?= $(IWYU_DIR)/build/bin/include-what-you-use 767endif 768iwyu : 769 $(MAKE) -B CC=$(IWYU_CC) 770 771print : 772 @echo $(VAR)=$($(VAR)) 773 774print-% : 775 $(info [ variable name]: $*) 776 $(info [ origin]: $(origin $*)) 777 $(info [ flavor]: $(flavor $*)) 778 $(info [ value]: $(value $*)) 779 $(info [expanded value]: $($*)) 780 $(info ) 781 @true 782 783# "make configure" detects any variables passed on the command line or 784# previously set in config.mk, caching them in config.mk as simple 785# (:=) variables. Variables set in config.mk or on the command line 786# take precedence over the defaults provided in the file. Typical 787# usage: 788# 789# make configure CC=/path/to/my/cc CUDA_DIR=/opt/cuda 790# make 791# make prove 792# 793# The values in the file can be updated by passing them on the command 794# line, e.g., 795# 796# make configure CC=/path/to/other/clang 797 798# All variables to consider for caching 799CONFIG_VARS = CC CXX FC NVCC NVCC_CXX HIPCC \ 800 OPT CFLAGS CPPFLAGS CXXFLAGS FFLAGS NVCCFLAGS HIPCCFLAGS SYCLFLAGS \ 801 AR ARFLAGS LDFLAGS LDLIBS LIBCXX SED \ 802 MAGMA_DIR OCCA_DIR XSMM_DIR CUDA_DIR CUDA_ARCH MFEM_DIR PETSC_DIR NEK5K_DIR ROCM_DIR HIP_ARCH SYCL_DIR 803 804# $(call needs_save,CFLAGS) returns true (a nonempty string) if CFLAGS 805# was set on the command line or in config.mk (where it will appear as 806# a simple variable). 807needs_save = $(or $(filter command line,$(origin $(1))),$(filter simple,$(flavor $(1)))) 808 809configure : 810 $(file > $(CONFIG)) 811 $(foreach v,$(CONFIG_VARS),$(if $(call needs_save,$(v)),$(file >> $(CONFIG),$(v) := $($(v))))) 812 @echo "Configuration cached in $(CONFIG):" 813 @cat $(CONFIG) 814 815wheel : export MARCHFLAG = -march=generic 816wheel : export WHEEL_PLAT = manylinux2010_x86_64 817wheel : 818 docker run -it --user $(shell id -u):$(shell id -g) --rm -v $(PWD):/io -w /io \ 819 -e MARCHFLAG -e WHEEL_PLAT \ 820 quay.io/pypa/$(WHEEL_PLAT) python/make-wheels.sh 821 822.PHONY : configure wheel 823 824# Include *.d deps when not -B = --always-make: useful if the paths are wonky in a container 825-include $(if $(filter B,$(MAKEFLAGS)),,$(libceed.c:%.c=$(OBJDIR)/%.d) $(tests.c:tests/%.c=$(OBJDIR)/%.d)) 826