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 384 MKL ?= 385 ifeq (,$(MKL)$(MKLROOT)) 386 BLAS_LIB ?= -lblas -ldl 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 endif 393 BLAS_LIB ?= $(MKL_LINK) -Wl,--push-state,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -Wl,--pop-state 394 endif 395 PKG_LIBS += $(BLAS_LIB) 396 libceed.c += $(xsmm.c) 397 $(xsmm.c:%.c=$(OBJDIR)/%.o) $(xsmm.c:%=%.tidy) : CPPFLAGS += -I$(XSMM_DIR)/include 398 BACKENDS_MAKE += $(XSMM_BACKENDS) 399endif 400 401# OCCA Backends 402OCCA_BACKENDS = /cpu/self/occa 403ifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),) 404 OCCA_MODES := $(shell LD_LIBRARY_PATH=$(OCCA_DIR)/lib $(OCCA_DIR)/bin/occa modes) 405 OCCA_BACKENDS += $(if $(filter OpenMP,$(OCCA_MODES)),/cpu/openmp/occa) 406 OCCA_BACKENDS += $(if $(filter dpcpp,$(OCCA_MODES)),/gpu/dpcpp/occa) 407 OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/gpu/opencl/occa) 408 OCCA_BACKENDS += $(if $(filter HIP,$(OCCA_MODES)),/gpu/hip/occa) 409 OCCA_BACKENDS += $(if $(filter CUDA,$(OCCA_MODES)),/gpu/cuda/occa) 410 411 $(libceeds) : CPPFLAGS += -I$(OCCA_DIR)/include 412 PKG_LIBS += -L$(abspath $(OCCA_DIR))/lib -locca 413 LIBCEED_CONTAINS_CXX = 1 414 libceed.cpp += $(occa.cpp) 415 BACKENDS_MAKE += $(OCCA_BACKENDS) 416endif 417 418# CUDA Backends 419ifneq ($(CUDA_DIR),) 420 CUDA_LIB_DIR := $(wildcard $(foreach d,lib lib64 lib/x86_64-linux-gnu,$(CUDA_DIR)/$d/libcudart.${SO_EXT})) 421 CUDA_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(CUDA_LIB_DIR)))) 422endif 423CUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs 424CUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen 425ifneq ($(CUDA_LIB_DIR),) 426 $(libceeds) : CPPFLAGS += -I$(CUDA_DIR)/include 427 PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas 428 PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS) 429 LIBCEED_CONTAINS_CXX = 1 430 libceed.c += interface/ceed-cuda.c 431 libceed.c += $(cuda.c) $(cuda-ref.c) $(cuda-shared.c) $(cuda-gen.c) 432 libceed.cpp += $(cuda.cpp) $(cuda-ref.cpp) $(cuda-gen.cpp) 433 libceed.cu += $(cuda-ref.cu) $(cuda-shared.cu) $(cuda-gen.cu) 434 BACKENDS_MAKE += $(CUDA_BACKENDS) 435endif 436 437# HIP Backends 438HIP_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(ROCM_DIR)/$d/libamdhip64.${SO_EXT})) 439HIP_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(HIP_LIB_DIR)))) 440HIP_BACKENDS = /gpu/hip/ref /gpu/hip/shared /gpu/hip/gen 441ifneq ($(HIP_LIB_DIR),) 442 HIPCONFIG_CPPFLAGS := $(subst =,,$(shell $(ROCM_DIR)/bin/hipconfig -C)) 443 $(hip-all.c:%.c=$(OBJDIR)/%.o) $(hip-all.c:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS) 444 ifneq ($(CXX), $(HIPCC)) 445 $(hip-all.cpp:%.cpp=$(OBJDIR)/%.o) $(hip-all.cpp:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS) 446 endif 447 PKG_LIBS += -L$(abspath $(HIP_LIB_DIR)) -lamdhip64 -lhipblas 448 LIBCEED_CONTAINS_CXX = 1 449 libceed.c += $(hip-all.c) 450 libceed.cpp += $(hip-all.cpp) 451 libceed.hip += $(hip-ref.hip) 452 BACKENDS_MAKE += $(HIP_BACKENDS) 453endif 454 455# SYCL Backends 456SYCL_BACKENDS = /gpu/sycl/ref /gpu/sycl/shared 457ifneq ($(SYCL_DIR),) 458 SYCL_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(SYCL_DIR)/$d/libsycl.${SO_EXT})) 459 SYCL_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(SYCL_LIB_DIR)))) 460endif 461ifneq ($(SYCL_LIB_DIR),) 462 PKG_LIBS += $(SYCL_FLAG) -lze_loader 463 LIBCEED_CONTAINS_CXX = 1 464 libceed.sycl += $(sycl-core.cpp) $(sycl-ref.cpp) $(sycl-shared.cpp) 465 BACKENDS_MAKE += $(SYCL_BACKENDS) 466endif 467 468# MAGMA Backends 469ifneq ($(wildcard $(MAGMA_DIR)/lib/libmagma.*),) 470 MAGMA_ARCH=$(shell nm -g $(MAGMA_DIR)/lib/libmagma.* | grep -c "hipblas") 471 ifeq ($(MAGMA_ARCH), 0) #CUDA MAGMA 472 ifneq ($(CUDA_LIB_DIR),) 473 cuda_link = $(if $(STATIC),,-Wl,-rpath,$(CUDA_LIB_DIR)) -L$(CUDA_LIB_DIR) -lcublas -lcusparse -lcudart 474 omp_link = -fopenmp 475 magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(cuda_link) $(omp_link) 476 magma_link_shared = -L$(MAGMA_DIR)/lib $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma 477 magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static)) 478 PKG_LIBS += $(magma_link) 479 libceed.c += $(magma.c) 480 libceed.cpp += $(magma.cpp) 481 libceed.cu += $(magma.cu) 482 $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include 483 $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include 484 $(magma.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += --compiler-options=-fPIC -DADD_ -I$(MAGMA_DIR)/include -I$(MAGMA_DIR)/magmablas -I$(CUDA_DIR)/include 485 MAGMA_BACKENDS = /gpu/cuda/magma /gpu/cuda/magma/det 486 endif 487 else # HIP MAGMA 488 ifneq ($(HIP_LIB_DIR),) 489 HIP_LIB_DIR_MAGMA=$(ROCM_DIR)/lib 490 HIP_INC_DIR_MAGMA=$(ROCM_DIR)/include 491 omp_link = -fopenmp 492 hip_link = $(if $(STATIC),,-Wl,-rpath,$(HIP_LIB_DIR_MAGMA)) -L$(HIP_LIB_DIR_MAGMA) -lhipblas -lhipsparse -lamdhip64 493 magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(hip_link) $(omp_link) 494 magma_link_shared = -L$(MAGMA_DIR)/lib $(hip_link) $(omp_link) $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma 495 magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static)) 496 PKG_LIBS += $(magma_link) 497 libceed.c += $(magma.c) 498 libceed.cpp += $(magma.cpp) 499 libceed.hip += $(magma.hip) 500 $(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_ 501 $(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_ 502 $(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_ 503 MAGMA_BACKENDS = /gpu/hip/magma /gpu/hip/magma/det 504 endif 505 endif 506 LIBCEED_CONTAINS_CXX = 1 507 BACKENDS_MAKE += $(MAGMA_BACKENDS) 508endif 509 510BACKENDS ?= $(BACKENDS_MAKE) 511export BACKENDS 512 513_pkg_ldflags = $(filter -L%,$(PKG_LIBS)) 514_pkg_ldlibs = $(filter-out -L%,$(PKG_LIBS)) 515$(libceeds) : CEED_LDFLAGS += $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS) 516$(libceeds) : CEED_LDLIBS += $(_pkg_ldlibs) 517ifeq ($(STATIC),1) 518$(examples) $(tests) : CEED_LDFLAGS += $(EM_LDFLAGS) $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS) 519$(examples) $(tests) : CEED_LDLIBS += $(_pkg_ldlibs) 520endif 521 522pkgconfig-libs-private = $(PKG_LIBS) 523ifeq ($(LIBCEED_CONTAINS_CXX),1) 524 $(libceeds) : LINK = $(CXX) 525 ifeq ($(STATIC),1) 526 $(examples) $(tests) : CEED_LDLIBS += $(LIBCXX) 527 pkgconfig-libs-private += $(LIBCXX) 528 endif 529endif 530 531# File names *-weak.c contain weak symbol definitions, which must be listed last 532# when creating shared or static libraries. 533weak_last = $(filter-out %-weak.o,$(1)) $(filter %-weak.o,$(1)) 534 535libceed.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) 536$(filter %fortran.o,$(libceed.o)) : CPPFLAGS += $(if $(filter 1,$(UNDERSCORE)),-DUNDERSCORE) 537$(libceed.o): | info-backends 538$(libceed.so) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR 539 $(call quiet,LINK) $(LDFLAGS) $(CEED_LDFLAGS) -shared -o $@ $^ $(CEED_LDLIBS) $(LDLIBS) 540 541$(libceed.a) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR 542 $(call quiet,AR) $(ARFLAGS) $@ $^ 543 544$(OBJDIR)/%.o : $(CURDIR)/%.c | $$(@D)/.DIR 545 $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 546 547$(OBJDIR)/%.o : $(CURDIR)/%.cpp | $$(@D)/.DIR 548 $(call quiet,CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(abspath $<) 549 550$(OBJDIR)/%.o : $(CURDIR)/%.cu | $$(@D)/.DIR 551 $(call quiet,NVCC) $(filter-out -Wno-unused-function, $(CPPFLAGS)) $(NVCCFLAGS) -c -o $@ $(abspath $<) 552 553$(OBJDIR)/%.o : $(CURDIR)/%.hip.cpp | $$(@D)/.DIR 554 $(call quiet,HIPCC) $(CPPFLAGS) $(HIPCCFLAGS) -c -o $@ $(abspath $<) 555 556$(OBJDIR)/%.o : $(CURDIR)/%.sycl.cpp | $$(@D)/.DIR 557 $(call quiet,SYCLCXX) $(SYCLFLAGS) $(CPPFLAGS) -c -o $@ $(abspath $<) 558 559$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.c | $$(@D)/.DIR 560 $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 561 562$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.f90 | $$(@D)/.DIR 563 $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 564 565$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.c | $$(@D)/.DIR 566 $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 567 568$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.f | $$(@D)/.DIR 569 $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 570 571$(OBJDIR)/mfem-% : examples/mfem/%.cpp $(libceed) | $$(@D)/.DIR 572 +$(MAKE) -C examples/mfem CEED_DIR=`pwd` \ 573 MFEM_DIR="$(abspath $(MFEM_DIR))" CXX=$(CXX) $* 574 cp examples/mfem/$* $@ 575 576# Note: Multiple Nek files cannot be built in parallel. The '+' here enables 577# this single Nek bps file to be built in parallel with other examples, 578# such as when calling `make prove-all -j2`. 579$(OBJDIR)/nek-bps : examples/nek/bps/bps.usr examples/nek/nek-examples.sh $(libceed) | $$(@D)/.DIR 580 +$(MAKE) -C examples MPI=$(MPI) CEED_DIR=`pwd` NEK5K_DIR="$(abspath $(NEK5K_DIR))" nek 581 mv examples/nek/build/bps $(OBJDIR)/bps 582 cp examples/nek/nek-examples.sh $(OBJDIR)/nek-bps 583 584# Several executables have common utilities, but we can't build the utilities 585# from separate submake invocations because they'll compete with each 586# other/corrupt output. So we put it in this utility library, but we don't want 587# to manually list source dependencies up at this level, so we'll just always 588# call recursive make to check that this utility is up to date. 589examples/petsc/libutils.a.PHONY: $(libceed) $(ceed.pc) 590 +$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` AR=$(AR) ARFLAGS=$(ARFLAGS) \ 591 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $(basename $(@F)) 592 593$(OBJDIR)/petsc-% : examples/petsc/%.c examples/petsc/libutils.a.PHONY $(libceed) $(ceed.pc) | $$(@D)/.DIR 594 +$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` \ 595 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 596 cp examples/petsc/$* $@ 597 598$(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 599 +$(call quiet,MAKE) -C examples/fluids CEED_DIR=`pwd` \ 600 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 601 cp examples/fluids/$* $@ 602 603$(OBJDIR)/solids-% : examples/solids/%.c examples/solids/%.h \ 604 examples/solids/problems/*.c examples/solids/src/*.c \ 605 examples/solids/include/*.h examples/solids/problems/*.h examples/solids/qfunctions/*.h \ 606 $(libceed) $(ceed.pc) | $$(@D)/.DIR 607 +$(call quiet,MAKE) -C examples/solids CEED_DIR=`pwd` \ 608 PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 609 cp examples/solids/$* $@ 610 611$(examples) : $(libceed) 612$(tests) : $(libceed) 613$(tests) $(examples) : override LDFLAGS += $(if $(STATIC),,-Wl,-rpath,$(abspath $(LIBDIR))) -L$(LIBDIR) 614 615run-% : $(OBJDIR)/% 616 @$(PYTHON) tests/junit.py --mode tap $(<:$(OBJDIR)/%=%) 617 618external_examples := \ 619 $(if $(MFEM_DIR),$(mfemexamples)) \ 620 $(if $(PETSC_DIR),$(petscexamples)) \ 621 $(if $(NEK5K_DIR),$(nekexamples)) \ 622 $(if $(PETSC_DIR),$(fluidsexamples)) \ 623 $(if $(PETSC_DIR),$(solidsexamples)) 624 625allexamples = $(examples) $(external_examples) 626 627# The test and prove targets can be controlled via pattern searches. The 628# default is to run tests and those examples that have no external dependencies. 629# Examples of finer grained control: 630# 631# make test search='petsc mfem' # PETSc and MFEM examples 632# make prove search='t3' # t3xx series tests 633# make junit search='ex petsc' # core ex* and PETSc tests 634search ?= t ex 635realsearch = $(search:%=%%) 636matched = $(foreach pattern,$(realsearch),$(filter $(OBJDIR)/$(pattern),$(tests) $(allexamples))) 637 638# Test core libCEED 639test : $(matched:$(OBJDIR)/%=run-%) 640 641# Run test target in parallel 642tst : ;@$(MAKE) $(MFLAGS) V=$(V) test 643# CPU C tests only for backend % 644ctc-% : $(ctests);@$(foreach tst,$(ctests),$(tst) /cpu/$*;) 645 646prove : $(matched) 647 $(info Testing backends: $(BACKENDS)) 648 $(PROVE) $(PROVE_OPTS) --exec 'tests/junit.py --mode tap' $(matched:$(OBJDIR)/%=%) 649# Run prove target in parallel 650prv : ;@$(MAKE) $(MFLAGS) V=$(V) prove 651 652prove-all : 653 +$(MAKE) prove realsearch=% 654 655junit-% : $(OBJDIR)/% 656 @printf " %10s %s\n" TEST $(<:$(OBJDIR)/%=%); $(PYTHON) tests/junit.py $(<:$(OBJDIR)/%=%) 657 658junit : $(matched:$(OBJDIR)/%=junit-%) 659 660all: $(alltests) 661 662examples : $(allexamples) 663ceedexamples : $(examples) 664nekexamples : $(nekexamples) 665mfemexamples : $(mfemexamples) 666petscexamples : $(petscexamples) 667 668# Benchmarks 669allbenchmarks = petsc-bps 670bench_targets = $(addprefix bench-,$(allbenchmarks)) 671.PHONY: $(bench_targets) benchmarks 672$(bench_targets): bench-%: $(OBJDIR)/% 673 cd benchmarks && ./benchmark.sh --ceed "$(BACKENDS_MAKE)" -r $(*).sh 674benchmarks: $(bench_targets) 675 676$(ceed.pc) : pkgconfig-prefix = $(abspath .) 677$(OBJDIR)/ceed.pc : pkgconfig-prefix = $(prefix) 678.INTERMEDIATE : $(OBJDIR)/ceed.pc 679%/ceed.pc : ceed.pc.template | $$(@D)/.DIR 680 @$(SED) \ 681 -e "s:%prefix%:$(pkgconfig-prefix):" \ 682 -e "s:%libs_private%:$(pkgconfig-libs-private):" $< > $@ 683 684$(OBJDIR)/interface/ceed-jit-source-root-default.o : CPPFLAGS += -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath ./include)/\"" 685$(OBJDIR)/interface/ceed-jit-source-root-install.o : CPPFLAGS += -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath $(includedir))/\"" 686 687install : $(libceed) $(OBJDIR)/ceed.pc 688 $(INSTALL) -d $(addprefix $(if $(DESTDIR),"$(DESTDIR)"),"$(includedir)"\ 689 "$(includedir)/ceed/" "$(includedir)/ceed/jit-source/"\ 690 "$(includedir)/ceed/jit-source/cuda/" "$(includedir)/ceed/jit-source/hip/"\ 691 "$(includedir)/ceed/jit-source/gallery/" "$(libdir)" "$(pkgconfigdir)") 692 $(INSTALL_DATA) include/ceed/ceed.h "$(DESTDIR)$(includedir)/ceed/" 693 $(INSTALL_DATA) include/ceed/types.h "$(DESTDIR)$(includedir)/ceed/" 694 $(INSTALL_DATA) include/ceed/ceed-f32.h "$(DESTDIR)$(includedir)/ceed/" 695 $(INSTALL_DATA) include/ceed/ceed-f64.h "$(DESTDIR)$(includedir)/ceed/" 696 $(INSTALL_DATA) include/ceed/fortran.h "$(DESTDIR)$(includedir)/ceed/" 697 $(INSTALL_DATA) include/ceed/backend.h "$(DESTDIR)$(includedir)/ceed/" 698 $(INSTALL_DATA) include/ceed/cuda.h "$(DESTDIR)$(includedir)/ceed/" 699 $(INSTALL_DATA) include/ceed/hip.h "$(DESTDIR)$(includedir)/ceed/" 700 $(INSTALL_DATA) $(libceed) "$(DESTDIR)$(libdir)/" 701 $(INSTALL_DATA) $(OBJDIR)/ceed.pc "$(DESTDIR)$(pkgconfigdir)/" 702 $(INSTALL_DATA) include/ceed.h "$(DESTDIR)$(includedir)/" 703 $(INSTALL_DATA) include/ceedf.h "$(DESTDIR)$(includedir)/" 704 $(INSTALL_DATA) $(wildcard include/ceed/jit-source/cuda/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/cuda/" 705 $(INSTALL_DATA) $(wildcard include/ceed/jit-source/hip/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/hip/" 706 $(INSTALL_DATA) $(wildcard include/ceed/jit-source/gallery/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/gallery/" 707 708.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 709 710cln clean : 711 $(RM) -r $(OBJDIR) $(LIBDIR) dist *egg* .pytest_cache *cffi* 712 $(call quiet,MAKE) -C examples clean NEK5K_DIR="$(abspath $(NEK5K_DIR))" 713 $(call quiet,MAKE) -C python/tests clean 714 $(RM) benchmarks/*output.txt 715 716distclean : clean 717 $(RM) -r doc/html doc/sphinx/build $(CONFIG) 718 719# Documentation 720DOXYGEN ?= doxygen 721doxygen : 722 $(DOXYGEN) -q Doxyfile 723 724doc-html doc-latexpdf doc-epub doc-livehtml : doc-% : doxygen 725 make -C doc/sphinx $* 726 727doc : doc-html 728 729# Style/Format 730CLANG_FORMAT ?= clang-format 731 732FORMAT_OPTS += -style=file -i 733 734format.ch := $(filter-out include/ceedf.h $(wildcard tests/t*-f.h), $(shell git ls-files *.[ch]pp *.[ch])) 735 736format-c : 737 $(CLANG_FORMAT) $(FORMAT_OPTS) $(format.ch) 738 739AUTOPEP8 = autopep8 740format-py : AUTOPEP8_ARGS = --in-place --aggressive 741format-py : 742 @$(AUTOPEP8) $(AUTOPEP8_ARGS) $(wildcard *.py python**/*.py python/tests/*.py examples**/*.py doc/sphinx/source**/*.py benchmarks/*.py) 743 744format : format-c format-py 745 746# Tidy 747CLANG_TIDY ?= clang-tidy 748 749%.c.tidy : %.c 750 $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c99 -I$(CUDA_DIR)/include -I$(ROCM_DIR)/include -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath ./include)/\"" 751 752%.cpp.tidy : %.cpp 753 $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c++11 -I$(CUDA_DIR)/include -I$(OCCA_DIR)/include -I$(ROCM_DIR)/include 754 755tidy-c : $(libceed.c:%=%.tidy) 756tidy-cpp : $(libceed.cpp:%=%.tidy) 757 758tidy : tidy-c tidy-cpp 759 760# Include-What-You-Use 761ifneq ($(wildcard ../iwyu/*),) 762 IWYU_DIR ?= ../iwyu 763 IWYU_CC ?= $(IWYU_DIR)/build/bin/include-what-you-use 764endif 765iwyu : 766 $(MAKE) -B CC=$(IWYU_CC) 767 768print : 769 @echo $(VAR)=$($(VAR)) 770 771print-% : 772 $(info [ variable name]: $*) 773 $(info [ origin]: $(origin $*)) 774 $(info [ flavor]: $(flavor $*)) 775 $(info [ value]: $(value $*)) 776 $(info [expanded value]: $($*)) 777 $(info ) 778 @true 779 780# "make configure" detects any variables passed on the command line or 781# previously set in config.mk, caching them in config.mk as simple 782# (:=) variables. Variables set in config.mk or on the command line 783# take precedence over the defaults provided in the file. Typical 784# usage: 785# 786# make configure CC=/path/to/my/cc CUDA_DIR=/opt/cuda 787# make 788# make prove 789# 790# The values in the file can be updated by passing them on the command 791# line, e.g., 792# 793# make configure CC=/path/to/other/clang 794 795# All variables to consider for caching 796CONFIG_VARS = CC CXX FC NVCC NVCC_CXX HIPCC \ 797 OPT CFLAGS CPPFLAGS CXXFLAGS FFLAGS NVCCFLAGS HIPCCFLAGS SYCLFLAGS \ 798 AR ARFLAGS LDFLAGS LDLIBS LIBCXX SED \ 799 MAGMA_DIR OCCA_DIR XSMM_DIR CUDA_DIR CUDA_ARCH MFEM_DIR PETSC_DIR NEK5K_DIR ROCM_DIR HIP_ARCH SYCL_DIR 800 801# $(call needs_save,CFLAGS) returns true (a nonempty string) if CFLAGS 802# was set on the command line or in config.mk (where it will appear as 803# a simple variable). 804needs_save = $(or $(filter command line,$(origin $(1))),$(filter simple,$(flavor $(1)))) 805 806configure : 807 $(file > $(CONFIG)) 808 $(foreach v,$(CONFIG_VARS),$(if $(call needs_save,$(v)),$(file >> $(CONFIG),$(v) := $($(v))))) 809 @echo "Configuration cached in $(CONFIG):" 810 @cat $(CONFIG) 811 812wheel : export MARCHFLAG = -march=generic 813wheel : export WHEEL_PLAT = manylinux2010_x86_64 814wheel : 815 docker run -it --user $(shell id -u):$(shell id -g) --rm -v $(PWD):/io -w /io \ 816 -e MARCHFLAG -e WHEEL_PLAT \ 817 quay.io/pypa/$(WHEEL_PLAT) python/make-wheels.sh 818 819.PHONY : configure wheel 820 821# Include *.d deps when not -B = --always-make: useful if the paths are wonky in a container 822-include $(if $(filter B,$(MAKEFLAGS)),,$(libceed.c:%.c=$(OBJDIR)/%.d) $(tests.c:tests/%.c=$(OBJDIR)/%.d)) 823