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