15aed82e4SJeremy L Thompson# Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 29bca2fcfSJed Brown# All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 30d9661cdSTzanio# 49bca2fcfSJed Brown# SPDX-License-Identifier: BSD-2-Clause 50d9661cdSTzanio# 69bca2fcfSJed Brown# This file is part of CEED: http://github.com/ceed 70d9661cdSTzanio 8*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 9*8baf801dSJeremy L Thompson# Configuration 10*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 11*8baf801dSJeremy L Thompson 12*8baf801dSJeremy L Thompson# config.mk stores cached configuration variables 13b0ab70ddSJed BrownCONFIG ?= config.mk 14b0ab70ddSJed Brown-include $(CONFIG) 15*8baf801dSJeremy L Thompson 16*8baf801dSJeremy L Thompson# common.mk holds definitions used in various makefiles throughout the project 17777ff853SJeremy L ThompsonCOMMON ?= common.mk 18777ff853SJeremy L Thompson-include $(COMMON) 191571c99dSValeria Barra 20*8baf801dSJeremy L Thompson# Quiet, color output 21*8baf801dSJeremy L Thompsonquiet ?= $($(1)) 22*8baf801dSJeremy L Thompson 23*8baf801dSJeremy L Thompson# Cancel built-in and old-fashioned implicit rules which we don't use 24*8baf801dSJeremy L Thompson.SUFFIXES: 25*8baf801dSJeremy L Thompson 26*8baf801dSJeremy L Thompson.SECONDEXPANSION: # to expand $$(@D)/.DIR 27*8baf801dSJeremy L Thompson 28*8baf801dSJeremy L Thompson%/.DIR : 29*8baf801dSJeremy L Thompson @mkdir -p $(@D) 30*8baf801dSJeremy L Thompson @touch $@ 31*8baf801dSJeremy L Thompson 32*8baf801dSJeremy L Thompson.PRECIOUS: %/.DIR 33*8baf801dSJeremy L Thompson 34*8baf801dSJeremy L Thompson 35*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 36*8baf801dSJeremy L Thompson# Root directories for backend dependencies 37*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 38*8baf801dSJeremy L Thompson 39*8baf801dSJeremy L Thompson# XSMM_DIR env variable should point to XSMM main (github.com/hfp/libxsmm) 40*8baf801dSJeremy L ThompsonXSMM_DIR ?= ../libxsmm 41*8baf801dSJeremy L Thompson 42*8baf801dSJeremy L Thompson# Often /opt/cuda or /usr/local/cuda, but sometimes present on machines that don't support CUDA 43*8baf801dSJeremy L ThompsonCUDA_DIR ?= 44*8baf801dSJeremy L ThompsonCUDA_ARCH ?= 45*8baf801dSJeremy L Thompson 46*8baf801dSJeremy L Thompson# Often /opt/rocm, but sometimes present on machines that don't support HIP 47*8baf801dSJeremy L ThompsonROCM_DIR ?= 48*8baf801dSJeremy L ThompsonHIP_ARCH ?= 49*8baf801dSJeremy L Thompson 50*8baf801dSJeremy L Thompson# env variable MAGMA_DIR can be used too 51*8baf801dSJeremy L ThompsonMAGMA_DIR ?= ../magma 52*8baf801dSJeremy L Thompson 53*8baf801dSJeremy L Thompson# OCCA_DIR env variable should point to OCCA main (github.com/libocca/occa) 54*8baf801dSJeremy L ThompsonOCCA_DIR ?= ../occa/install 55*8baf801dSJeremy L Thompson 56*8baf801dSJeremy L Thompson 57*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 58*8baf801dSJeremy L Thompson# Compiler flags 59*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 60*8baf801dSJeremy L Thompson 61*8baf801dSJeremy L Thompson# Detect user compiler options and set defaults 62dc753d40SJed Brownifeq (,$(filter-out undefined default,$(origin CC))) 636ed738d9SJed Brown CC = gcc 64dc753d40SJed Brownendif 65241a4b83SYohannifeq (,$(filter-out undefined default,$(origin CXX))) 66241a4b83SYohann CXX = g++ 67241a4b83SYohannendif 68dc753d40SJed Brownifeq (,$(filter-out undefined default,$(origin FC))) 6981c9eb91SStan Tomov FC = gfortran 70dc753d40SJed Brownendif 71241a4b83SYohannifeq (,$(filter-out undefined default,$(origin LINK))) 72241a4b83SYohann LINK = $(CC) 73241a4b83SYohannendif 741d013790SJed Brownifeq (,$(filter-out undefined default,$(origin AR))) 751d013790SJed Brown AR = ar 761d013790SJed Brownendif 771d013790SJed Brownifeq (,$(filter-out undefined default,$(origin ARFLAGS))) 781d013790SJed Brown ARFLAGS = crD 791d013790SJed Brownendif 80196a75e4SJed BrownNVCC ?= $(CUDA_DIR)/bin/nvcc 813c83ce1dSJed BrownNVCC_CXX ?= $(CXX) 82023b8a51Sabdelfattah83HIPCC ?= $(ROCM_DIR)/bin/hipcc 83bd882c8aSJames WrightSYCLCXX ?= $(CXX) 841d013790SJed BrownSED ?= sed 850bd9ac94SJed Brownifneq ($(EMSCRIPTEN),) 860bd9ac94SJed Brown STATIC = 1 870bd9ac94SJed Brown EXE_SUFFIX = .wasm 880bd9ac94SJed Brown EM_LDFLAGS = -s TOTAL_MEMORY=256MB 890bd9ac94SJed Brownendif 90e86995feScamierjs 913b56482dScamierjs# ASAN must be left empty if you don't want to use it 920a7eccc5ScamierjsASAN ?= 936850bcb5Scamierjs 943696039aSJed Brown# These are the values automatically detected here in the makefile. They are 953696039aSJed Brown# augmented with LDFLAGS and LDLIBS from the environment/passed by command line, 963696039aSJed Brown# if any. If the user sets CEED_LDFLAGS or CEED_LDLIBS, they are used *instead 973696039aSJed Brown# of* what we populate here (thus that's advanced usage and not recommended). 983696039aSJed BrownCEED_LDFLAGS ?= 993696039aSJed BrownCEED_LDLIBS ?= 1007c735608SJed Brown 10132d74c32SThilina RathnayakeUNDERSCORE ?= 1 1021b58aefaScamierjs 1038df0376fSJeremy L Thompson# Verbose mode, V or VERBOSE 1048df0376fSJeremy L ThompsonV ?= $(VERBOSE) 1058df0376fSJeremy L Thompson 106bf000209STzanio# Warning: SANTIZ options still don't run with /gpu/occa 107fb651866SJed BrownAFLAGS ?= -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer 10832d74c32SThilina Rathnayake 1098ca0bbaeSjeremylt# Note: Intel oneAPI C/C++ compiler is now icx/icpx 1104c4eae0cSSebastian GrimbergCC_VENDOR := $(firstword $(filter gcc (GCC) clang icc icc_orig oneAPI XL emcc,$(subst -, ,$(shell $(CC) --version)))) 1114c4eae0cSSebastian GrimbergCC_VENDOR := $(subst (GCC),gcc,$(subst icc_orig,icc,$(CC_VENDOR))) 1120be03a92SJeremy L ThompsonFC_VENDOR := $(if $(FC),$(firstword $(filter GNU ifort ifx XL,$(shell $(FC) --version 2>&1 || $(FC) -qversion)))) 11313d950b4SJed Brown 11413d950b4SJed Brown# Default extra flags by vendor 11513d950b4SJed BrownMARCHFLAG.gcc := -march=native 11613d950b4SJed BrownMARCHFLAG.clang := $(MARCHFLAG.gcc) 11713d950b4SJed BrownMARCHFLAG.icc := 1180be03a92SJeremy L ThompsonMARCHFLAG.oneAPI := $(MARCHFLAG.clang) 11913d950b4SJed BrownOMP_SIMD_FLAG.gcc := -fopenmp-simd 12013d950b4SJed BrownOMP_SIMD_FLAG.clang := $(OMP_SIMD_FLAG.gcc) 12113d950b4SJed BrownOMP_SIMD_FLAG.icc := -qopenmp-simd 12258c07c4fSSebastian GrimbergOMP_SIMD_FLAG.oneAPI := $(OMP_SIMD_FLAG.icc) 12358c07c4fSSebastian GrimbergOMP_FLAG.gcc := -fopenmp 12458c07c4fSSebastian GrimbergOMP_FLAG.clang := $(OMP_FLAG.gcc) 12558c07c4fSSebastian GrimbergOMP_FLAG.icc := -qopenmp 12658c07c4fSSebastian GrimbergOMP_FLAG.oneAPI := $(OMP_FLAG.icc) 127bd882c8aSJames WrightSYCL_FLAG.gcc := 128bd882c8aSJames WrightSYCL_FLAG.clang := -fsycl 129bd882c8aSJames WrightSYCL_FLAG.icc := 1306ca0f394SUmesh UnnikrishnanSYCL_FLAG.oneAPI := -fsycl -fno-sycl-id-queries-fit-in-int 1310bd9ac94SJed BrownOPT.gcc := -g -ffp-contract=fast 13213d950b4SJed BrownOPT.clang := $(OPT.gcc) 13358c07c4fSSebastian GrimbergOPT.icc := $(OPT.gcc) 1340be03a92SJeremy L ThompsonOPT.oneAPI := $(OPT.clang) 1350bd9ac94SJed BrownOPT.emcc := 1360bd9ac94SJed BrownCFLAGS.gcc := $(if $(STATIC),,-fPIC) -std=c99 -Wall -Wextra -Wno-unused-parameter -MMD -MP 1378b45a169SnbeamsCFLAGS.clang := $(CFLAGS.gcc) 13813d950b4SJed BrownCFLAGS.icc := $(CFLAGS.gcc) 1390be03a92SJeremy L ThompsonCFLAGS.oneAPI := $(CFLAGS.clang) 1400bd9ac94SJed BrownCFLAGS.XL := $(if $(STATIC),,-qpic) -MMD 1410bd9ac94SJed BrownCFLAGS.emcc := $(CFLAGS.clang) 1420bd9ac94SJed BrownCXXFLAGS.gcc := $(if $(STATIC),,-fPIC) -std=c++11 -Wall -Wextra -Wno-unused-parameter -MMD -MP 1438b45a169SnbeamsCXXFLAGS.clang := $(CXXFLAGS.gcc) 14413d950b4SJed BrownCXXFLAGS.icc := $(CXXFLAGS.gcc) 1450be03a92SJeremy L ThompsonCXXFLAGS.oneAPI := $(CXXFLAGS.clang) 1460bd9ac94SJed BrownCXXFLAGS.XL := $(if $(STATIC),,-qpic) -std=c++11 -MMD 1470bd9ac94SJed BrownCXXFLAGS.emcc := $(CXXFLAGS.clang) 1480bd9ac94SJed BrownFFLAGS.GNU := $(if $(STATIC),,-fPIC) -cpp -Wall -Wextra -Wno-unused-parameter -Wno-unused-dummy-argument -MMD -MP 1490bd9ac94SJed BrownFFLAGS.ifort := $(if $(STATIC),,-fPIC) -cpp 1500be03a92SJeremy L ThompsonFFLAGS.ifx := $(FFLAGS.ifort) 1510bd9ac94SJed BrownFFLAGS.XL := $(if $(STATIC),,-qpic) -ffree-form -qpreprocess -qextname -MMD 152cf4a56afSJed Brown 153d9bc9eefSJed Brown# This check works with compilers that use gcc and clang. It fails with some 154d9bc9eefSJed Brown# compilers; e.g., xlc apparently ignores all options when -E is passed, thus 155d9bc9eefSJed Brown# succeeds with any flags. Users can pass MARCHFLAG=... if desired. 156d9bc9eefSJed Browncc_check_flag = $(shell $(CC) -E -Werror $(1) -x c /dev/null > /dev/null 2>&1 && echo 1) 15713d950b4SJed BrownMARCHFLAG := $(MARCHFLAG.$(CC_VENDOR)) 158f766a8abSJed BrownMARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG),-mcpu=native) 159f766a8abSJed BrownMARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG)) 160b9c05c73SJed Brown 16113d950b4SJed BrownOMP_SIMD_FLAG := $(OMP_SIMD_FLAG.$(CC_VENDOR)) 162f766a8abSJed BrownOMP_SIMD_FLAG := $(if $(call cc_check_flag,$(OMP_SIMD_FLAG)),$(OMP_SIMD_FLAG)) 163cf4a56afSJed Brown 1642c2ea1dbSJeremy L Thompson# Error checking flags 1652c2ea1dbSJeremy L ThompsonPEDANTIC ?= 1662c2ea1dbSJeremy L ThompsonPEDANTICFLAGS ?= -Werror -pedantic 1672c2ea1dbSJeremy L Thompson 168*8baf801dSJeremy L Thompson# Compiler flags 1690bd9ac94SJed BrownOPT ?= -O $(MARCHFLAG) $(OPT.$(CC_VENDOR)) $(OMP_SIMD_FLAG) 1702c2ea1dbSJeremy L ThompsonCFLAGS ?= $(OPT) $(CFLAGS.$(CC_VENDOR)) $(if $(PEDANTIC),$(PEDANTICFLAGS)) 1712c2ea1dbSJeremy L ThompsonCXXFLAGS ?= $(OPT) $(CXXFLAGS.$(CC_VENDOR)) $(if $(PEDANTIC),$(PEDANTICFLAGS)) 17258c07c4fSSebastian GrimbergFFLAGS ?= $(OPT) $(FFLAGS.$(FC_VENDOR)) 1731d013790SJed BrownLIBCXX ?= -lstdc++ 174b0ab70ddSJed BrownNVCCFLAGS ?= -ccbin $(CXX) -Xcompiler "$(OPT)" -Xcompiler -fPIC 175bd057117Snbeamsifneq ($(CUDA_ARCH),) 176bd057117Snbeams NVCCFLAGS += -arch=$(CUDA_ARCH) 177bd057117Snbeamsendif 178b3c5430cSnbeamsHIPCCFLAGS ?= $(filter-out $(OMP_SIMD_FLAG),$(OPT)) -fPIC -munsafe-fp-atomics 179bd057117Snbeamsifneq ($(HIP_ARCH),) 1805e82904bSJeremy L Thompson HIPCCFLAGS += --offload-arch=$(HIP_ARCH) 181bd057117Snbeamsendif 182bd882c8aSJames WrightSYCL_FLAG := $(SYCL_FLAG.$(CC_VENDOR)) 183bd882c8aSJames WrightSYCLFLAGS ?= $(SYCL_FLAG) -fPIC -std=c++17 $(filter-out -std=c++11,$(CXXFLAGS)) $(filter-out $(OMP_SIMD_FLAG),$(OPT)) 18458c07c4fSSebastian Grimberg 18558c07c4fSSebastian GrimbergOPENMP ?= 18658c07c4fSSebastian Grimbergifneq ($(OPENMP),) 18758c07c4fSSebastian Grimberg OMP_FLAG := $(OMP_FLAG.$(CC_VENDOR)) 18858c07c4fSSebastian Grimberg OMP_FLAG := $(if $(call cc_check_flag,$(OMP_FLAG)),$(OMP_FLAG)) 18958c07c4fSSebastian Grimberg CFLAGS += $(OMP_FLAG) 19058c07c4fSSebastian Grimberg CEED_LDFLAGS += $(OMP_FLAG) 19158c07c4fSSebastian Grimbergendif 19232d74c32SThilina Rathnayake 193a6f4783aSJed Brownifeq ($(COVERAGE), 1) 194a6f4783aSJed Brown CFLAGS += --coverage 195568410ffSJeremy L Thompson CXXFLAGS += --coverage 1963696039aSJed Brown CEED_LDFLAGS += --coverage 197a6f4783aSJed Brownendif 198a6f4783aSJed Brown 1995766aa57SJeremy L ThompsonCFLAGS += $(if $(ASAN),$(AFLAGS)) 2004dd6f121ScamierjsFFLAGS += $(if $(ASAN),$(AFLAGS)) 2013696039aSJed BrownCEED_LDFLAGS += $(if $(ASAN),$(AFLAGS)) 20241a90898SJed BrownCPPFLAGS += -I./include 2033696039aSJed BrownCEED_LDLIBS = -lm 20491b7489eSJed BrownOBJDIR := build 20572fa462dSJed Brownfor_install := $(filter install,$(MAKECMDGOALS)) 20672fa462dSJed BrownLIBDIR := $(if $(for_install),$(OBJDIR),lib) 20772fa462dSJed Brown 208d5217624SJed Brown# Installation variables 209d5217624SJed Brownprefix ?= /usr/local 210d5217624SJed Brownbindir = $(prefix)/bin 211d5217624SJed Brownlibdir = $(prefix)/lib 212d5217624SJed Brownincludedir = $(prefix)/include 213d5217624SJed Brownpkgconfigdir = $(libdir)/pkgconfig 214d5217624SJed BrownINSTALL = install 215d5217624SJed BrownINSTALL_PROGRAM = $(INSTALL) 216d5217624SJed BrownINSTALL_DATA = $(INSTALL) -m644 217d5217624SJed Brown 2183b56482dScamierjs# Get number of processors of the machine 21969762e1fScamierjsNPROCS := $(shell getconf _NPROCESSORS_ONLN) 2203b56482dScamierjs# prepare make options to run in parallel 22182985883ScamierjsMFLAGS := -j $(NPROCS) --warn-undefined-variables \ 22221ae6867Scamierjs --no-print-directory --no-keep-going 22387e762eaSJed Brown 2248ec9d54bSJed BrownPYTHON ?= python3 225bfa078e6SJed BrownPROVE ?= prove 2263a1ec3cdSJed BrownPROVE_OPTS ?= -j $(NPROCS) 2275c719ab0SJed BrownDARWIN := $(filter Darwin,$(shell uname -s)) 2285c719ab0SJed BrownSO_EXT := $(if $(DARWIN),dylib,so) 2299df38c42SVeselin Dobrev 2306ea7c6c1SJed Brownceed.pc := $(LIBDIR)/pkgconfig/ceed.pc 2311d013790SJed Brownlibceed.so := $(LIBDIR)/libceed.$(SO_EXT) 2321d013790SJed Brownlibceed.a := $(LIBDIR)/libceed.a 23378a9fcb6SJeremy L Thompsonlibceed := $(if $(STATIC),$(libceed.a),$(libceed.so)) 2347e68d260SJed BrownCEED_LIBS = -lceed 2358e3e54ccSjeremyltlibceeds = $(libceed) 236265be9c8SjeremyltBACKENDS_BUILTIN := /cpu/self/ref/serial /cpu/self/ref/blocked /cpu/self/opt/serial /cpu/self/opt/blocked 237422b683aSjeremyltBACKENDS_MAKE := $(BACKENDS_BUILTIN) 238bf000209STzanio 239e797ab98SJed Brown 240*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 241*8baf801dSJeremy L Thompson# Root directories for examples using external libraries 242*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 243*8baf801dSJeremy L Thompson 244*8baf801dSJeremy L Thompson# DEAL_II_DIR env variable should point to sibling directory 245*8baf801dSJeremy L Thompsonifneq ($(wildcard ../dealii/install/lib/libdeal_II.*),) 246*8baf801dSJeremy L Thompson DEAL_II_DIR ?= ../dealii/install 247*8baf801dSJeremy L Thompsonendif 248*8baf801dSJeremy L Thompson# Export for deal.II testing 249*8baf801dSJeremy L Thompsonexport DEAL_II_DIR 250*8baf801dSJeremy L Thompson 251*8baf801dSJeremy L Thompson# MFEM_DIR env variable should point to sibling directory 252*8baf801dSJeremy L Thompsonifneq ($(wildcard ../mfem/libmfem.*),) 253*8baf801dSJeremy L Thompson MFEM_DIR ?= ../mfem 254*8baf801dSJeremy L Thompsonendif 255*8baf801dSJeremy L Thompson 256*8baf801dSJeremy L Thompson# NEK5K_DIR env variable should point to sibling directory 257*8baf801dSJeremy L Thompsonifneq ($(wildcard ../Nek5000/*),) 258*8baf801dSJeremy L Thompson NEK5K_DIR ?= $(abspath ../Nek5000) 259*8baf801dSJeremy L Thompsonendif 260*8baf801dSJeremy L Thompson# Exports for NEK5K testing 261*8baf801dSJeremy L Thompsonexport CEED_DIR = $(abspath .) 262*8baf801dSJeremy L Thompsonexport NEK5K_DIR 263*8baf801dSJeremy L ThompsonMPI ?= 1 264*8baf801dSJeremy L Thompson 265*8baf801dSJeremy L Thompson# Check for PETSc in ../petsc 266*8baf801dSJeremy L Thompsonifneq ($(wildcard ../petsc/lib/libpetsc.*),) 267*8baf801dSJeremy L Thompson PETSC_DIR ?= ../petsc 268*8baf801dSJeremy L Thompsonendif 269*8baf801dSJeremy L Thompson 270*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 271*8baf801dSJeremy L Thompson# Build the library (default target) 272*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 273*8baf801dSJeremy L Thompson 274*8baf801dSJeremy L Thompsonlib: $(libceed) $(ceed.pc) 275*8baf801dSJeremy L Thompson# run 'lib' target in parallel 276*8baf801dSJeremy L Thompsonpar:;@$(MAKE) $(MFLAGS) V=$(V) lib 277*8baf801dSJeremy L Thompson 278*8baf801dSJeremy L Thompson$(libceed.so) : CEED_LDFLAGS += $(if $(DARWIN), -install_name @rpath/$(notdir $(libceed.so))) 279*8baf801dSJeremy L Thompson 280*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 281*8baf801dSJeremy L Thompson# Source files 282*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 283*8baf801dSJeremy L Thompson 284*8baf801dSJeremy L Thompson# Interface and gallery 285*8baf801dSJeremy L Thompsonlibceed.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)) 286*8baf801dSJeremy L Thompsongallery.c := $(wildcard gallery/*/ceed*.c) 287*8baf801dSJeremy L Thompsonlibceed.c += $(gallery.c) 288*8baf801dSJeremy L Thompson 289*8baf801dSJeremy L Thompson# Backends 290*8baf801dSJeremy L Thompson# - CPU 291ae3cba82Scamierjsref.c := $(sort $(wildcard backends/ref/*.c)) 29289c6efa4Sjeremyltblocked.c := $(sort $(wildcard backends/blocked/*.c)) 29389c6efa4Sjeremyltceedmemcheck.c := $(sort $(wildcard backends/memcheck/*.c)) 29489c6efa4Sjeremyltopt.c := $(sort $(wildcard backends/opt/*.c)) 29589c6efa4Sjeremyltavx.c := $(sort $(wildcard backends/avx/*.c)) 29689c6efa4Sjeremyltxsmm.c := $(sort $(wildcard backends/xsmm/*.c)) 297*8baf801dSJeremy L Thompson# - GPU 2989f0427d9SYohanncuda.c := $(sort $(wildcard backends/cuda/*.c)) 299c9c2c079SJeremy L Thompsoncuda.cpp := $(sort $(wildcard backends/cuda/*.cpp)) 3007fcac036SJeremy L Thompsoncuda-ref.c := $(sort $(wildcard backends/cuda-ref/*.c)) 3017fcac036SJeremy L Thompsoncuda-ref.cpp := $(sort $(wildcard backends/cuda-ref/*.cpp)) 3027fcac036SJeremy L Thompsoncuda-ref.cu := $(sort $(wildcard backends/cuda-ref/kernels/*.cu)) 303c532df63SYohanncuda-shared.c := $(sort $(wildcard backends/cuda-shared/*.c)) 304b2573fe1SJeremy L Thompsoncuda-shared.cu := $(sort $(wildcard backends/cuda-shared/kernels/*.cu)) 305241a4b83SYohanncuda-gen.c := $(sort $(wildcard backends/cuda-gen/*.c)) 306241a4b83SYohanncuda-gen.cpp := $(sort $(wildcard backends/cuda-gen/*.cpp)) 307b2573fe1SJeremy L Thompsoncuda-gen.cu := $(sort $(wildcard backends/cuda-gen/kernels/*.cu)) 30830f4f45fSnbeamship.c := $(sort $(wildcard backends/hip/*.c)) 309f0f820a0SJeremy L Thompsonhip.cpp := $(sort $(wildcard backends/hip/*.cpp)) 3107fcac036SJeremy L Thompsonhip-ref.c := $(sort $(wildcard backends/hip-ref/*.c)) 3117fcac036SJeremy L Thompsonhip-ref.cpp := $(sort $(wildcard backends/hip-ref/*.cpp)) 3127fcac036SJeremy L Thompsonhip-ref.hip := $(sort $(wildcard backends/hip-ref/kernels/*.hip.cpp)) 3137d8d0e25Snbeamship-shared.c := $(sort $(wildcard backends/hip-shared/*.c)) 3147d8d0e25Snbeamship-gen.c := $(sort $(wildcard backends/hip-gen/*.c)) 3157d8d0e25Snbeamship-gen.cpp := $(sort $(wildcard backends/hip-gen/*.cpp)) 316bd882c8aSJames Wrightsycl-core.cpp := $(sort $(wildcard backends/sycl/*.sycl.cpp)) 317bd882c8aSJames Wrightsycl-ref.cpp := $(sort $(wildcard backends/sycl-ref/*.sycl.cpp)) 318bd882c8aSJames Wrightsycl-shared.cpp:= $(sort $(wildcard backends/sycl-shared/*.sycl.cpp)) 3196ca0f394SUmesh Unnikrishnansycl-gen.cpp := $(sort $(wildcard backends/sycl-gen/*.sycl.cpp)) 320*8baf801dSJeremy L Thompsonmagma.c := $(sort $(wildcard backends/magma/*.c)) 321*8baf801dSJeremy L Thompsonmagma.cpp := $(sort $(wildcard backends/magma/*.cpp)) 322*8baf801dSJeremy L Thompsonocca.cpp := $(sort $(shell find backends/occa -type f -name *.cpp)) 32382985883Scamierjs 324f150ce52SJed Brownhip-all.c := interface/ceed-hip.c $(hip.c) $(hip-ref.c) $(hip-shared.c) $(hip-gen.c) 325f150ce52SJed Brownhip-all.cpp := $(hip.cpp) $(hip-ref.cpp) $(hip-gen.cpp) 326f150ce52SJed Brown 327*8baf801dSJeremy L Thompson# Tests 328*8baf801dSJeremy L Thompsontests.c := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.c)) 329*8baf801dSJeremy L Thompsontests.f := $(if $(FC),$(sort $(wildcard tests/t[0-9][0-9][0-9]-*.f90))) 330*8baf801dSJeremy L Thompsontests := $(tests.c:tests/%.c=$(OBJDIR)/%$(EXE_SUFFIX)) 331*8baf801dSJeremy L Thompsonctests := $(tests) 332*8baf801dSJeremy L Thompsontests += $(tests.f:tests/%.f90=$(OBJDIR)/%$(EXE_SUFFIX)) 33321ae6867Scamierjs 334*8baf801dSJeremy L Thompson# Examples 335*8baf801dSJeremy L Thompsonexamples.c := $(sort $(wildcard examples/ceed/*.c)) 336*8baf801dSJeremy L Thompsonexamples.f := $(if $(FC),$(sort $(wildcard examples/ceed/*.f))) 337*8baf801dSJeremy L Thompsonexamples := $(examples.c:examples/ceed/%.c=$(OBJDIR)/%$(EXE_SUFFIX)) 338*8baf801dSJeremy L Thompsonexamples += $(examples.f:examples/ceed/%.f=$(OBJDIR)/%$(EXE_SUFFIX)) 339da72e7fcSJed Brown 340*8baf801dSJeremy L Thompson# deal.II Examples 341*8baf801dSJeremy L Thompsondealiiexamples := $(OBJDIR)/dealii-bps 3429df38c42SVeselin Dobrev 343*8baf801dSJeremy L Thompson# MFEM Examples 344*8baf801dSJeremy L Thompsonmfemexamples.cpp := $(sort $(wildcard examples/mfem/*.cpp)) 345*8baf801dSJeremy L Thompsonmfemexamples := $(mfemexamples.cpp:examples/mfem/%.cpp=$(OBJDIR)/mfem-%) 34691b7489eSJed Brown 347*8baf801dSJeremy L Thompson# Nek5K Examples 348*8baf801dSJeremy L Thompsonnekexamples := $(OBJDIR)/nek-bps 34991b7489eSJed Brown 350*8baf801dSJeremy L Thompson# PETSc Examples 351*8baf801dSJeremy L Thompsonpetscexamples.c := $(wildcard examples/petsc/*.c) 352*8baf801dSJeremy L Thompsonpetscexamples := $(petscexamples.c:examples/petsc/%.c=$(OBJDIR)/petsc-%) 353*8baf801dSJeremy L Thompson 354*8baf801dSJeremy L Thompson# Fluid Dynamics Example 355*8baf801dSJeremy L Thompsonfluidsexamples.c := $(sort $(wildcard examples/fluids/*.c)) 356*8baf801dSJeremy L Thompsonfluidsexamples := $(fluidsexamples.c:examples/fluids/%.c=$(OBJDIR)/fluids-%) 357*8baf801dSJeremy L Thompson 358*8baf801dSJeremy L Thompson# Solid Mechanics Example 359*8baf801dSJeremy L Thompsonsolidsexamples.c := $(sort $(wildcard examples/solids/*.c)) 360*8baf801dSJeremy L Thompsonsolidsexamples := $(solidsexamples.c:examples/solids/%.c=$(OBJDIR)/solids-%) 361*8baf801dSJeremy L Thompson 362*8baf801dSJeremy L Thompson 363*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 364*8baf801dSJeremy L Thompson# View configuration options 365*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 366*8baf801dSJeremy L Thompson 367422b683aSjeremyltbackend_status = $(if $(filter $1,$(BACKENDS_MAKE)), [backends: $1], [not found]) 368*8baf801dSJeremy L Thompson 369bf3e26f6SVeselin Dobrevinfo: 370bf3e26f6SVeselin Dobrev $(info ------------------------------------) 371bf3e26f6SVeselin Dobrev $(info CC = $(CC)) 372241a4b83SYohann $(info CXX = $(CXX)) 373bf3e26f6SVeselin Dobrev $(info FC = $(FC)) 374bf3e26f6SVeselin Dobrev $(info CPPFLAGS = $(CPPFLAGS)) 3754e62717cSJames Wright $(info CFLAGS = $(CFLAGS)) 3764e62717cSJames Wright $(info CXXFLAGS = $(CXXFLAGS)) 3774e62717cSJames Wright $(info FFLAGS = $(FFLAGS)) 3784e62717cSJames Wright $(info NVCCFLAGS = $(NVCCFLAGS)) 3794e62717cSJames Wright $(info HIPCCFLAGS = $(HIPCCFLAGS)) 3804e62717cSJames Wright $(info SYCLFLAGS = $(SYCLFLAGS)) 3814e62717cSJames Wright $(info CEED_LDFLAGS = $(CEED_LDFLAGS)) 3824e62717cSJames Wright $(info CEED_LDLIBS = $(CEED_LDLIBS)) 3831d013790SJed Brown $(info AR = $(AR)) 3841d013790SJed Brown $(info ARFLAGS = $(ARFLAGS)) 385bf3e26f6SVeselin Dobrev $(info OPT = $(OPT)) 386bf3e26f6SVeselin Dobrev $(info AFLAGS = $(AFLAGS)) 387bf3e26f6SVeselin Dobrev $(info ASAN = $(or $(ASAN),(empty))) 3888df0376fSJeremy L Thompson $(info VERBOSE = $(or $(V),(empty)) [verbose=$(if $(V),on,off)]) 389bf3e26f6SVeselin Dobrev $(info ------------------------------------) 390ae945beaSJeremy L Thompson $(info MEMCHK_STATUS = $(MEMCHK_STATUS)$(call backend_status,$(MEMCHK_BACKENDS))) 391ae945beaSJeremy L Thompson $(info AVX_STATUS = $(AVX_STATUS)$(call backend_status,$(AVX_BACKENDS))) 392ae945beaSJeremy L Thompson $(info XSMM_DIR = $(XSMM_DIR)$(call backend_status,$(XSMM_BACKENDS))) 3939647a07eSDavid Medina $(info OCCA_DIR = $(OCCA_DIR)$(call backend_status,$(OCCA_BACKENDS))) 39440461fa4Snbeams $(info MAGMA_DIR = $(MAGMA_DIR)$(call backend_status,$(MAGMA_BACKENDS))) 395ab9cabdeSVeselin Dobrev $(info CUDA_DIR = $(CUDA_DIR)$(call backend_status,$(CUDA_BACKENDS))) 396023b8a51Sabdelfattah83 $(info ROCM_DIR = $(ROCM_DIR)$(call backend_status,$(HIP_BACKENDS))) 397bd882c8aSJames Wright $(info SYCL_DIR = $(SYCL_DIR)$(call backend_status,$(SYCL_BACKENDS))) 398bf3e26f6SVeselin Dobrev $(info ------------------------------------) 399bf3e26f6SVeselin Dobrev $(info MFEM_DIR = $(MFEM_DIR)) 4004d1cd9fcSJeremy L Thompson $(info NEK5K_DIR = $(NEK5K_DIR)) 401bf3e26f6SVeselin Dobrev $(info PETSC_DIR = $(PETSC_DIR)) 4028c81f8b0SPeter Munch $(info DEAL_II_DIR = $(DEAL_II_DIR)) 403bf3e26f6SVeselin Dobrev $(info ------------------------------------) 404bf3e26f6SVeselin Dobrev $(info prefix = $(prefix)) 405bf3e26f6SVeselin Dobrev $(info includedir = $(value includedir)) 406bf3e26f6SVeselin Dobrev $(info libdir = $(value libdir)) 407bf3e26f6SVeselin Dobrev $(info pkgconfigdir = $(value pkgconfigdir)) 408bf3e26f6SVeselin Dobrev $(info ------------------------------------) 409bf3e26f6SVeselin Dobrev @true 410*8baf801dSJeremy L Thompson 41123072ed2SVeselin Dobrevinfo-backends: 412d20f937dSJed Brown $(info make: 'lib' with optional backends: $(filter-out $(BACKENDS_BUILTIN),$(BACKENDS))) 413422b683aSjeremylt @true 414*8baf801dSJeremy L Thompson 415422b683aSjeremyltinfo-backends-all: 4167b64fac9SJeremy L Thompson $(info make: 'lib' with backends: $(BACKENDS)) 417422b683aSjeremylt @true 4180e439e50SJed Brown 419*8baf801dSJeremy L Thompson 420*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 421*8baf801dSJeremy L Thompson# Backends 422*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 42369762e1fScamierjs 42448fffa06Sjeremylt# Standard Backends 42587174f08SJed Brownlibceed.c += $(ref.c) 4264a2e7687Sjeremyltlibceed.c += $(blocked.c) 42789c6efa4Sjeremyltlibceed.c += $(opt.c) 42823072ed2SVeselin Dobrev 4295120064bSJeremy L Thompson# Memcheck Backends 430bdc3149dSjeremyltMEMCHK_STATUS = Disabled 4316b5c14f7SJed BrownMEMCHK := $(shell echo "$(HASH)include <valgrind/memcheck.h>" | $(CC) $(CPPFLAGS) -E - >/dev/null 2>&1 && echo 1) 432ae945beaSJeremy L ThompsonMEMCHK_BACKENDS = /cpu/self/memcheck/serial /cpu/self/memcheck/blocked 433bdc3149dSjeremyltifeq ($(MEMCHK),1) 434bdc3149dSjeremylt MEMCHK_STATUS = Enabled 435fc7cf9a0Sjeremylt libceed.c += $(ceedmemcheck.c) 436422b683aSjeremylt BACKENDS_MAKE += $(MEMCHK_BACKENDS) 437fc7cf9a0Sjeremyltendif 438fc7cf9a0Sjeremylt 4395120064bSJeremy L Thompson# AVX Backeds 44048fffa06SjeremyltAVX_STATUS = Disabled 441cf4a56afSJed BrownAVX_FLAG := $(if $(filter clang,$(CC_VENDOR)),+avx,-mavx) 44259e56409SJed BrownAVX := $(filter $(AVX_FLAG),$(shell $(CC) $(CFLAGS:-M%=) -v -E -x c /dev/null 2>&1)) 443ae945beaSJeremy L ThompsonAVX_BACKENDS = /cpu/self/avx/serial /cpu/self/avx/blocked 444cf4a56afSJed Brownifneq ($(AVX),) 44548fffa06Sjeremylt AVX_STATUS = Enabled 44648fffa06Sjeremylt libceed.c += $(avx.c) 447422b683aSjeremylt BACKENDS_MAKE += $(AVX_BACKENDS) 44848fffa06Sjeremyltendif 44948fffa06Sjeremylt 4501d013790SJed Brown# Collect list of libraries and paths for use in linking and pkg-config 4511d013790SJed BrownPKG_LIBS = 4527c735608SJed Brown# Stubs that will not be RPATH'd 4537c735608SJed BrownPKG_STUBS_LIBS = 4541d013790SJed Brown 4558d713cf6Sjeremylt# libXSMM Backends 456ae945beaSJeremy L ThompsonXSMM_BACKENDS = /cpu/self/xsmm/serial /cpu/self/xsmm/blocked 4578d713cf6Sjeremyltifneq ($(wildcard $(XSMM_DIR)/lib/libxsmm.*),) 4584548da4eSSebastian Grimberg PKG_LIBS += -L$(abspath $(XSMM_DIR))/lib -lxsmm 45900723591Sjeremylt MKL ?= 46000723591Sjeremylt ifeq (,$(MKL)$(MKLROOT)) 4614548da4eSSebastian Grimberg BLAS_LIB ?= -lblas -ldl 4625462ed45Sjeremylt else 46372e1b2f7SJeremy L Thompson ifneq ($(MKLROOT),) 464ff56800aSJed Brown # Some installs put everything inside an intel64 subdirectory, others not 465ff56800aSJed Brown MKL_LIBDIR = $(dir $(firstword $(wildcard $(MKLROOT)/lib/intel64/libmkl_sequential.* $(MKLROOT)/lib/libmkl_sequential.*))) 4661d013790SJed Brown MKL_LINK = -L$(MKL_LIBDIR) 46772e1b2f7SJeremy L Thompson endif 4684548da4eSSebastian Grimberg BLAS_LIB ?= $(MKL_LINK) -Wl,--push-state,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -Wl,--pop-state 4695462ed45Sjeremylt endif 4701d013790SJed Brown PKG_LIBS += $(BLAS_LIB) 4718d713cf6Sjeremylt libceed.c += $(xsmm.c) 472683faae0SJed Brown $(xsmm.c:%.c=$(OBJDIR)/%.o) $(xsmm.c:%=%.tidy) : CPPFLAGS += -I$(XSMM_DIR)/include 473422b683aSjeremylt BACKENDS_MAKE += $(XSMM_BACKENDS) 4748d713cf6Sjeremyltendif 4758d713cf6Sjeremylt 47686a4271fSThilina Rathnayake# CUDA Backends 47768c150f8SJed Brownifneq ($(CUDA_DIR),) 47868c150f8SJed Brown CUDA_LIB_DIR := $(wildcard $(foreach d,lib lib64 lib/x86_64-linux-gnu,$(CUDA_DIR)/$d/libcudart.${SO_EXT})) 4795a9ca9adSVeselin Dobrev CUDA_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(CUDA_LIB_DIR)))) 48068c150f8SJed Brownendif 4813dd0010eSvaleriabarraCUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs 482461525f5SNatalie BeamsCUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/shared /gpu/cuda/gen 4835a9ca9adSVeselin Dobrevifneq ($(CUDA_LIB_DIR),) 4849d77422eSJed Brown $(libceeds) : CPPFLAGS += -I$(CUDA_DIR)/include 4851d013790SJed Brown PKG_LIBS += -L$(abspath $(CUDA_LIB_DIR)) -lcudart -lnvrtc -lcuda -lcublas 4867c735608SJed Brown PKG_STUBS_LIBS += -L$(CUDA_LIB_DIR_STUBS) 4871d013790SJed Brown LIBCEED_CONTAINS_CXX = 1 488af7ca75eSjeremylt libceed.c += interface/ceed-cuda.c 4897fcac036SJeremy L Thompson libceed.c += $(cuda.c) $(cuda-ref.c) $(cuda-shared.c) $(cuda-gen.c) 490c9c2c079SJeremy L Thompson libceed.cpp += $(cuda.cpp) $(cuda-ref.cpp) $(cuda-gen.cpp) 4917fcac036SJeremy L Thompson libceed.cu += $(cuda-ref.cu) $(cuda-shared.cu) $(cuda-gen.cu) 492422b683aSjeremylt BACKENDS_MAKE += $(CUDA_BACKENDS) 4939f0427d9SYohannendif 4949f0427d9SYohann 49530f4f45fSnbeams# HIP Backends 496023b8a51Sabdelfattah83HIP_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(ROCM_DIR)/$d/libamdhip64.${SO_EXT})) 49730f4f45fSnbeamsHIP_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(HIP_LIB_DIR)))) 4987d8d0e25SnbeamsHIP_BACKENDS = /gpu/hip/ref /gpu/hip/shared /gpu/hip/gen 49930f4f45fSnbeamsifneq ($(HIP_LIB_DIR),) 500f150ce52SJed Brown HIPCONFIG_CPPFLAGS := $(subst =,,$(shell $(ROCM_DIR)/bin/hipconfig -C)) 501f150ce52SJed Brown $(hip-all.c:%.c=$(OBJDIR)/%.o) $(hip-all.c:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS) 50230f4f45fSnbeams ifneq ($(CXX), $(HIPCC)) 503f150ce52SJed Brown $(hip-all.cpp:%.cpp=$(OBJDIR)/%.o) $(hip-all.cpp:%=%.tidy): CPPFLAGS += $(HIPCONFIG_CPPFLAGS) 50430f4f45fSnbeams endif 5051d013790SJed Brown PKG_LIBS += -L$(abspath $(HIP_LIB_DIR)) -lamdhip64 -lhipblas 5061d013790SJed Brown LIBCEED_CONTAINS_CXX = 1 507f150ce52SJed Brown libceed.c += $(hip-all.c) 508f150ce52SJed Brown libceed.cpp += $(hip-all.cpp) 5097fcac036SJeremy L Thompson libceed.hip += $(hip-ref.hip) 510422b683aSjeremylt BACKENDS_MAKE += $(HIP_BACKENDS) 51130f4f45fSnbeamsendif 51230f4f45fSnbeams 513bd882c8aSJames Wright# SYCL Backends 5146ca0f394SUmesh UnnikrishnanSYCL_BACKENDS = /gpu/sycl/ref /gpu/sycl/shared /gpu/sycl/gen 515bd882c8aSJames Wrightifneq ($(SYCL_DIR),) 516bd882c8aSJames Wright SYCL_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(SYCL_DIR)/$d/libsycl.${SO_EXT})) 517bd882c8aSJames Wright SYCL_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(SYCL_LIB_DIR)))) 518bd882c8aSJames Wrightendif 519bd882c8aSJames Wrightifneq ($(SYCL_LIB_DIR),) 520bd882c8aSJames Wright PKG_LIBS += $(SYCL_FLAG) -lze_loader 521bd882c8aSJames Wright LIBCEED_CONTAINS_CXX = 1 5226ca0f394SUmesh Unnikrishnan libceed.sycl += $(sycl-core.cpp) $(sycl-ref.cpp) $(sycl-shared.cpp) $(sycl-gen.cpp) 523bd882c8aSJames Wright BACKENDS_MAKE += $(SYCL_BACKENDS) 524bd882c8aSJames Wrightendif 525bd882c8aSJames Wright 5265120064bSJeremy L Thompson# MAGMA Backends 5279f0427d9SYohannifneq ($(wildcard $(MAGMA_DIR)/lib/libmagma.*),) 52845f29434Snbeams MAGMA_ARCH=$(shell nm -g $(MAGMA_DIR)/lib/libmagma.* | grep -c "hipblas") 52945f29434Snbeams ifeq ($(MAGMA_ARCH), 0) # CUDA MAGMA 5309f0427d9SYohann ifneq ($(CUDA_LIB_DIR),) 531dacf7c88SJed Brown cuda_link = $(if $(STATIC),,-Wl,-rpath,$(CUDA_LIB_DIR)) -L$(CUDA_LIB_DIR) -lcublas -lcusparse -lcudart 5321dc2661bSVeselin Dobrev omp_link = -fopenmp 5331dc2661bSVeselin Dobrev magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(cuda_link) $(omp_link) 534dacf7c88SJed Brown magma_link_shared = -L$(MAGMA_DIR)/lib $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma 5357692a9b0SVeselin Dobrev magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static)) 5361d013790SJed Brown PKG_LIBS += $(magma_link) 537a07e8cf1SNatalie Beams libceed.c += $(magma.c) 5382dc3fb5fSabdelfattah83 libceed.cpp += $(magma.cpp) 539a07e8cf1SNatalie Beams $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include 5402dc3fb5fSabdelfattah83 $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include 54140461fa4Snbeams MAGMA_BACKENDS = /gpu/cuda/magma /gpu/cuda/magma/det 54245f29434Snbeams endif 54345f29434Snbeams else # HIP MAGMA 544969f2b10Snbeams ifneq ($(HIP_LIB_DIR),) 545969f2b10Snbeams omp_link = -fopenmp 546ae93e896SSebastian Grimberg hip_link = $(if $(STATIC),,-Wl,-rpath,$(HIP_LIB_DIR)) -L$(HIP_LIB_DIR) -lhipblas -lhipsparse -lamdhip64 547969f2b10Snbeams magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(hip_link) $(omp_link) 548023b8a51Sabdelfattah83 magma_link_shared = -L$(MAGMA_DIR)/lib $(hip_link) $(omp_link) $(if $(STATIC),,-Wl,-rpath,$(abspath $(MAGMA_DIR)/lib)) -lmagma 549969f2b10Snbeams magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static)) 5501d013790SJed Brown PKG_LIBS += $(magma_link) 551969f2b10Snbeams libceed.c += $(magma.c) 5522dc3fb5fSabdelfattah83 libceed.cpp += $(magma.cpp) 553ae93e896SSebastian Grimberg $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += $(HIPCONFIG_CPPFLAGS) -I$(MAGMA_DIR)/include -I$(ROCM_DIR)/include -DCEED_MAGMA_USE_HIP -DADD_ 554ae93e896SSebastian Grimberg $(magma.cpp:%.cpp=$(OBJDIR)/%.o) $(magma.cpp:%=%.tidy) : CPPFLAGS += $(HIPCONFIG_CPPFLAGS) -I$(MAGMA_DIR)/include -I$(ROCM_DIR)/include -DCEED_MAGMA_USE_HIP -DADD_ 55540461fa4Snbeams MAGMA_BACKENDS = /gpu/hip/magma /gpu/hip/magma/det 556969f2b10Snbeams endif 55782b77998SStan Tomov endif 5581d013790SJed Brown LIBCEED_CONTAINS_CXX = 1 559422b683aSjeremylt BACKENDS_MAKE += $(MAGMA_BACKENDS) 5605a9ca9adSVeselin Dobrevendif 561755585ceSStan Tomov 562*8baf801dSJeremy L Thompson# OCCA Backends 563*8baf801dSJeremy L ThompsonOCCA_BACKENDS = /cpu/self/occa 564*8baf801dSJeremy L Thompsonifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),) 565*8baf801dSJeremy L Thompson OCCA_MODES := $(shell LD_LIBRARY_PATH=$(OCCA_DIR)/lib $(OCCA_DIR)/bin/occa modes) 566*8baf801dSJeremy L Thompson OCCA_BACKENDS += $(if $(filter OpenMP,$(OCCA_MODES)),/cpu/openmp/occa) 567*8baf801dSJeremy L Thompson OCCA_BACKENDS += $(if $(filter dpcpp,$(OCCA_MODES)),/gpu/dpcpp/occa) 568*8baf801dSJeremy L Thompson OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/gpu/opencl/occa) 569*8baf801dSJeremy L Thompson OCCA_BACKENDS += $(if $(filter HIP,$(OCCA_MODES)),/gpu/hip/occa) 570*8baf801dSJeremy L Thompson OCCA_BACKENDS += $(if $(filter CUDA,$(OCCA_MODES)),/gpu/cuda/occa) 571*8baf801dSJeremy L Thompson $(libceeds) : CPPFLAGS += -I$(OCCA_DIR)/include 572*8baf801dSJeremy L Thompson PKG_LIBS += -L$(abspath $(OCCA_DIR))/lib -locca 573*8baf801dSJeremy L Thompson LIBCEED_CONTAINS_CXX = 1 574*8baf801dSJeremy L Thompson libceed.cpp += $(occa.cpp) 575*8baf801dSJeremy L Thompson BACKENDS_MAKE += $(OCCA_BACKENDS) 576*8baf801dSJeremy L Thompsonendif 577*8baf801dSJeremy L Thompson 5785de894e4SJeremy L ThompsonBACKENDS ?= $(BACKENDS_MAKE) 579ce41f623SJed Brownexport BACKENDS 580ce41f623SJed Brown 581*8baf801dSJeremy L Thompson 582*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 583*8baf801dSJeremy L Thompson# Linker Flags 584*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 5851d013790SJed Brown_pkg_ldflags = $(filter -L%,$(PKG_LIBS)) 5861d013790SJed Brown_pkg_ldlibs = $(filter-out -L%,$(PKG_LIBS)) 587dacf7c88SJed Brown$(libceeds) : CEED_LDFLAGS += $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS) 5883696039aSJed Brown$(libceeds) : CEED_LDLIBS += $(_pkg_ldlibs) 5891d013790SJed Brownifeq ($(STATIC),1) 5900bd9ac94SJed Brown $(examples) $(tests) : CEED_LDFLAGS += $(EM_LDFLAGS) $(_pkg_ldflags) $(if $(STATIC),,$(_pkg_ldflags:-L%=-Wl,-rpath,%)) $(PKG_STUBS_LIBS) 5913696039aSJed Brown $(examples) $(tests) : CEED_LDLIBS += $(_pkg_ldlibs) 5921d013790SJed Brownendif 5931d013790SJed Brown 5941d013790SJed Brownpkgconfig-libs-private = $(PKG_LIBS) 5951d013790SJed Brownifeq ($(LIBCEED_CONTAINS_CXX),1) 5961d013790SJed Brown $(libceeds) : LINK = $(CXX) 5971d013790SJed Brown ifeq ($(STATIC),1) 5983696039aSJed Brown $(examples) $(tests) : CEED_LDLIBS += $(LIBCXX) 5991d013790SJed Brown pkgconfig-libs-private += $(LIBCXX) 6001d013790SJed Brown endif 6011d013790SJed Brownendif 6021d013790SJed Brown 603*8baf801dSJeremy L Thompson 604*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 605*8baf801dSJeremy L Thompson# Building core library components 606*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 607*8baf801dSJeremy L Thompson 6081d013790SJed Brown# File names *-weak.c contain weak symbol definitions, which must be listed last 6091d013790SJed Brown# when creating shared or static libraries. 6101d013790SJed Brownweak_last = $(filter-out %-weak.o,$(1)) $(filter %-weak.o,$(1)) 6111d013790SJed Brown 612bd882c8aSJames Wrightlibceed.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) 6134c7bddedSJed Brown$(filter %fortran.o,$(libceed.o)) : CPPFLAGS += $(if $(filter 1,$(UNDERSCORE)),-DUNDERSCORE) 61423072ed2SVeselin Dobrev$(libceed.o): | info-backends 6151d013790SJed Brown$(libceed.so) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR 6163696039aSJed Brown $(call quiet,LINK) $(LDFLAGS) $(CEED_LDFLAGS) -shared -o $@ $^ $(CEED_LDLIBS) $(LDLIBS) 61791b7489eSJed Brown 6181d013790SJed Brown$(libceed.a) : $(call weak_last,$(libceed.o)) | $$(@D)/.DIR 6191d013790SJed Brown $(call quiet,AR) $(ARFLAGS) $@ $^ 6201d013790SJed Brown 62158e8d3b7SJed Brown$(OBJDIR)/%.o : $(CURDIR)/%.c | $$(@D)/.DIR 622b5b03409SJed Brown $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 623ae3cba82Scamierjs 624241a4b83SYohann$(OBJDIR)/%.o : $(CURDIR)/%.cpp | $$(@D)/.DIR 625241a4b83SYohann $(call quiet,CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(abspath $<) 626241a4b83SYohann 62758e8d3b7SJed Brown$(OBJDIR)/%.o : $(CURDIR)/%.cu | $$(@D)/.DIR 628777ff853SJeremy L Thompson $(call quiet,NVCC) $(filter-out -Wno-unused-function, $(CPPFLAGS)) $(NVCCFLAGS) -c -o $@ $(abspath $<) 629755585ceSStan Tomov 630cfb6011cSnbeams$(OBJDIR)/%.o : $(CURDIR)/%.hip.cpp | $$(@D)/.DIR 631f150ce52SJed Brown $(call quiet,HIPCC) $(CPPFLAGS) $(HIPCCFLAGS) -c -o $@ $(abspath $<) 63230f4f45fSnbeams 633bd882c8aSJames Wright$(OBJDIR)/%.o : $(CURDIR)/%.sycl.cpp | $$(@D)/.DIR 634bd882c8aSJames Wright $(call quiet,SYCLCXX) $(SYCLFLAGS) $(CPPFLAGS) -c -o $@ $(abspath $<) 635bd882c8aSJames Wright 6366ca0f394SUmesh Unnikrishnan$(OBJDIR)/%.o : $(CURDIR)/%.sycl.cpp | $$(@D)/.DIR 6376ca0f394SUmesh Unnikrishnan $(call quiet,SYCLCXX) $(SYCLFLAGS) $(CPPFLAGS) -c -o $@ $(abspath $<) 6386ca0f394SUmesh Unnikrishnan 639e3e35afdSJed Brown$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.c | $$(@D)/.DIR 640255dad32SJeremy L Thompson $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) -I./tests/test-include 64178b5556aScamierjs 642e3e35afdSJed Brown$(OBJDIR)/%$(EXE_SUFFIX) : tests/%.f90 | $$(@D)/.DIR 6433696039aSJed Brown $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 64432d74c32SThilina Rathnayake 645e3e35afdSJed Brown$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.c | $$(@D)/.DIR 6463696039aSJed Brown $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 64791b7489eSJed Brown 648e3e35afdSJed Brown$(OBJDIR)/%$(EXE_SUFFIX) : examples/ceed/%.f | $$(@D)/.DIR 6493696039aSJed Brown $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(CEED_LDLIBS) $(LDLIBS) 650673d494eSThilina Rathnayake 651*8baf801dSJeremy L Thompson 652*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 653*8baf801dSJeremy L Thompson# Building examples 654*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 655*8baf801dSJeremy L Thompson 656*8baf801dSJeremy L Thompson# deal.II 657*8baf801dSJeremy L Thompson# Note: Invoking deal.II's CMAKE build system here 658*8baf801dSJeremy L Thompson$(OBJDIR)/dealii-bps : examples/deal.II/*.cc examples/deal.II/*.h $(libceed) | $$(@D)/.DIR 659*8baf801dSJeremy L Thompson mkdir -p examples/deal.II/build 660*8baf801dSJeremy L Thompson cmake -B examples/deal.II/build -S examples/deal.II -DDEAL_II_DIR=$(DEAL_II_DIR) -DCEED_DIR=$(PWD) 661*8baf801dSJeremy L Thompson +$(call quiet,MAKE) -C examples/deal.II/build 662*8baf801dSJeremy L Thompson cp examples/deal.II/build/bps $(OBJDIR)/dealii-bps 663*8baf801dSJeremy L Thompson 664*8baf801dSJeremy L Thompson# MFEM 66516c6c054SJed Brown$(OBJDIR)/mfem-% : examples/mfem/%.cpp $(libceed) | $$(@D)/.DIR 666c4216f28SJed Brown +$(MAKE) -C examples/mfem CEED_DIR=`pwd` \ 667722eb117SJeremy L Thompson MFEM_DIR="$(abspath $(MFEM_DIR))" CXX=$(CXX) $* 668636cccdbSjeremylt cp examples/mfem/$* $@ 66916c6c054SJed Brown 670*8baf801dSJeremy L Thompson# Nek5000 67186a4271fSThilina Rathnayake# Note: Multiple Nek files cannot be built in parallel. The '+' here enables 67286a4271fSThilina Rathnayake# this single Nek bps file to be built in parallel with other examples, 67386a4271fSThilina Rathnayake# such as when calling `make prove-all -j2`. 67486a4271fSThilina Rathnayake$(OBJDIR)/nek-bps : examples/nek/bps/bps.usr examples/nek/nek-examples.sh $(libceed) | $$(@D)/.DIR 67586a4271fSThilina Rathnayake +$(MAKE) -C examples MPI=$(MPI) CEED_DIR=`pwd` NEK5K_DIR="$(abspath $(NEK5K_DIR))" nek 67686a4271fSThilina Rathnayake mv examples/nek/build/bps $(OBJDIR)/bps 67786a4271fSThilina Rathnayake cp examples/nek/nek-examples.sh $(OBJDIR)/nek-bps 67886a4271fSThilina Rathnayake 679*8baf801dSJeremy L Thompson# PETSc 680386a09edSJed Brown# Several executables have common utilities, but we can't build the utilities 681386a09edSJed Brown# from separate submake invocations because they'll compete with each 682386a09edSJed Brown# other/corrupt output. So we put it in this utility library, but we don't want 683386a09edSJed Brown# to manually list source dependencies up at this level, so we'll just always 684386a09edSJed Brown# call recursive make to check that this utility is up to date. 685386a09edSJed Brownexamples/petsc/libutils.a.PHONY: $(libceed) $(ceed.pc) 686386a09edSJed Brown +$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` AR=$(AR) ARFLAGS=$(ARFLAGS) \ 687386a09edSJed Brown PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $(basename $(@F)) 688386a09edSJed Brown 689386a09edSJed Brown$(OBJDIR)/petsc-% : examples/petsc/%.c examples/petsc/libutils.a.PHONY $(libceed) $(ceed.pc) | $$(@D)/.DIR 690386a09edSJed Brown +$(call quiet,MAKE) -C examples/petsc CEED_DIR=`pwd` \ 691f766a8abSJed Brown PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 692636cccdbSjeremylt cp examples/petsc/$* $@ 693e797ab98SJed Brown 694*8baf801dSJeremy L Thompson# Fluid dynamics proxy application 6953e0c2f3fSJeremy L Thompson$(OBJDIR)/fluids-% : examples/fluids/%.c examples/fluids/src/*.c examples/fluids/*.h examples/fluids/include/*.h examples/fluids/problems/*.c examples/fluids/qfunctions/*.h $(libceed) $(ceed.pc) examples/fluids/Makefile | $$(@D)/.DIR 6969aeb05eaSJed Brown +$(call quiet,MAKE) -C examples/fluids CEED_DIR=`pwd` \ 697f766a8abSJed Brown PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 698636cccdbSjeremylt cp examples/fluids/$* $@ 699ccaff030SJeremy L Thompson 700*8baf801dSJeremy L Thompson# Solid mechanics proxy application 701b571f289SJed Brown$(OBJDIR)/solids-% : examples/solids/%.c examples/solids/%.h \ 702b571f289SJed Brown examples/solids/problems/*.c examples/solids/src/*.c \ 703b571f289SJed Brown examples/solids/include/*.h examples/solids/problems/*.h examples/solids/qfunctions/*.h \ 704b571f289SJed Brown $(libceed) $(ceed.pc) | $$(@D)/.DIR 7059aeb05eaSJed Brown +$(call quiet,MAKE) -C examples/solids CEED_DIR=`pwd` \ 706722eb117SJeremy L Thompson PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 707636cccdbSjeremylt cp examples/solids/$* $@ 7082774d5cbSJeremy L Thompson 709*8baf801dSJeremy L Thompsonexamples : $(allexamples) 710*8baf801dSJeremy L Thompsonceedexamples : $(examples) 711*8baf801dSJeremy L Thompsonnekexamples : $(nekexamples) 712*8baf801dSJeremy L Thompsonmfemexamples : $(mfemexamples) 713*8baf801dSJeremy L Thompsonpetscexamples : $(petscexamples) 714*8baf801dSJeremy L Thompson 715*8baf801dSJeremy L Thompsonexternal_examples := \ 716*8baf801dSJeremy L Thompson $(if $(MFEM_DIR),$(mfemexamples)) \ 717*8baf801dSJeremy L Thompson $(if $(PETSC_DIR),$(petscexamples)) \ 718*8baf801dSJeremy L Thompson $(if $(NEK5K_DIR),$(nekexamples)) \ 719*8baf801dSJeremy L Thompson $(if $(DEAL_II_DIR),$(dealiiexamples)) \ 720*8baf801dSJeremy L Thompson $(if $(PETSC_DIR),$(fluidsexamples)) \ 721*8baf801dSJeremy L Thompson $(if $(PETSC_DIR),$(solidsexamples)) 722*8baf801dSJeremy L Thompson 723*8baf801dSJeremy L Thompsonallexamples = $(examples) $(external_examples) 724*8baf801dSJeremy L Thompson 725265be9c8Sjeremylt$(examples) : $(libceed) 7268e3e54ccSjeremylt$(tests) : $(libceed) 727dacf7c88SJed Brown$(tests) $(examples) : override LDFLAGS += $(if $(STATIC),,-Wl,-rpath,$(abspath $(LIBDIR))) -L$(LIBDIR) 7284859b599SJed Brown 729*8baf801dSJeremy L Thompson 730*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 731*8baf801dSJeremy L Thompson# Testing 732*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 733*8baf801dSJeremy L Thompson 7341b16049aSZach Atkins# Set number processes for testing 7351b16049aSZach AtkinsNPROC_TEST ?= 1 7361b16049aSZach Atkinsexport NPROC_TEST 7371b16049aSZach Atkins 73819868e18SZach Atkins# Set pool size for testing 73919868e18SZach AtkinsNPROC_POOL ?= 1 74019868e18SZach Atkinsexport NPROC_POOL 74119868e18SZach Atkins 742dad465e7SJed Brownrun-% : $(OBJDIR)/% 7433e0c2f3fSJeremy L Thompson @$(PYTHON) tests/junit.py --mode tap --ceed-backends $(BACKENDS) --nproc $(NPROC_TEST) --pool-size $(NPROC_POOL) $(<:$(OBJDIR)/%=%) 744686de4acSJed Brown 745686de4acSJed Brown# The test and prove targets can be controlled via pattern searches. The 746686de4acSJed Brown# default is to run tests and those examples that have no external dependencies. 747686de4acSJed Brown# Examples of finer grained control: 748686de4acSJed Brown# 749686de4acSJed Brown# make test search='petsc mfem' # PETSc and MFEM examples 750686de4acSJed Brown# make prove search='t3' # t3xx series tests 751686de4acSJed Brown# make junit search='ex petsc' # core ex* and PETSc tests 752686de4acSJed Brownsearch ?= t ex 753686de4acSJed Brownrealsearch = $(search:%=%%) 754686de4acSJed Brownmatched = $(foreach pattern,$(realsearch),$(filter $(OBJDIR)/$(pattern),$(tests) $(allexamples))) 7551b16049aSZach AtkinsJUNIT_BATCH ?= '' 756686de4acSJed Brown 7572158b1b0Sjeremylt# Test core libCEED 758686de4acSJed Browntest : $(matched:$(OBJDIR)/%=run-%) 7592158b1b0Sjeremylt 76086a4271fSThilina Rathnayake# Run test target in parallel 7616850bcb5Scamierjstst : ;@$(MAKE) $(MFLAGS) V=$(V) test 7623b56482dScamierjs# CPU C tests only for backend % 7633f3e7340Scamierjsctc-% : $(ctests);@$(foreach tst,$(ctests),$(tst) /cpu/$*;) 7644859b599SJed Brown 765*8baf801dSJeremy L Thompson# Testing with TAP format 766*8baf801dSJeremy L Thompson# https://testanything.org/tap-specification.html 76786a4271fSThilina Rathnayakeprove : $(matched) 768a5dc8077SJed Brown $(info Testing backends: $(BACKENDS)) 7693e0c2f3fSJeremy L Thompson $(PROVE) $(PROVE_OPTS) --exec '$(PYTHON) tests/junit.py --mode tap --ceed-backends $(BACKENDS) --nproc $(NPROC_TEST) --pool-size $(NPROC_POOL)' $(matched:$(OBJDIR)/%=%) 77086a4271fSThilina Rathnayake# Run prove target in parallel 7716850bcb5Scamierjsprv : ;@$(MAKE) $(MFLAGS) V=$(V) prove 772bfa078e6SJed Brown 773686de4acSJed Brownprove-all : 774686de4acSJed Brown +$(MAKE) prove realsearch=% 775686de4acSJed Brown 7768ec9d54bSJed Brownjunit-% : $(OBJDIR)/% 7773e0c2f3fSJeremy L Thompson @printf " %10s %s\n" TEST $(<:$(OBJDIR)/%=%); $(PYTHON) tests/junit.py --ceed-backends $(BACKENDS) --nproc $(NPROC_TEST) --pool-size $(NPROC_POOL) --junit-batch $(JUNIT_BATCH) $(<:$(OBJDIR)/%=%) 7788ec9d54bSJed Brown 77976174befSjeremyltjunit : $(matched:$(OBJDIR)/%=junit-%) 7808ec9d54bSJed Brown 7812f4d9adbSJeremy L Thompsonall: $(alltests) 7822f4d9adbSJeremy L Thompson 7832f4d9adbSJeremy L Thompson# Benchmarks 7840c59ef15SJeremy L Thompsonallbenchmarks = petsc-bps 7854e79ff5bSVeselin Dobrevbench_targets = $(addprefix bench-,$(allbenchmarks)) 7864e79ff5bSVeselin Dobrev.PHONY: $(bench_targets) benchmarks 7874e79ff5bSVeselin Dobrev$(bench_targets): bench-%: $(OBJDIR)/% 7887b64fac9SJeremy L Thompson cd benchmarks && ./benchmark.sh --ceed "$(BACKENDS)" -r $(*).sh 7894e79ff5bSVeselin Dobrevbenchmarks: $(bench_targets) 7902c6ea02fSJed Brown 7916ea7c6c1SJed Brown$(ceed.pc) : pkgconfig-prefix = $(abspath .) 792d5217624SJed Brown$(OBJDIR)/ceed.pc : pkgconfig-prefix = $(prefix) 793d5217624SJed Brown.INTERMEDIATE : $(OBJDIR)/ceed.pc 7946ea7c6c1SJed Brown%/ceed.pc : ceed.pc.template | $$(@D)/.DIR 7951d013790SJed Brown @$(SED) \ 7961d013790SJed Brown -e "s:%prefix%:$(pkgconfig-prefix):" \ 7971d013790SJed Brown -e "s:%libs_private%:$(pkgconfig-libs-private):" $< > $@ 7980e439e50SJed Brown 7996ed4cbd1SJeremy L Thompson$(OBJDIR)/interface/ceed-jit-source-root-default.o : CPPFLAGS += -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath ./include)/\"" 8006ed4cbd1SJeremy L Thompson$(OBJDIR)/interface/ceed-jit-source-root-install.o : CPPFLAGS += -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath $(includedir))/\"" 8015766aa57SJeremy L Thompson 802*8baf801dSJeremy L Thompson 803*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 804*8baf801dSJeremy L Thompson# Installation 805*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 806d5217624SJed Browninstall : $(libceed) $(OBJDIR)/ceed.pc 807bf3e26f6SVeselin Dobrev $(INSTALL) -d $(addprefix $(if $(DESTDIR),"$(DESTDIR)"),"$(includedir)"\ 808a0154adeSJed Brown "$(includedir)/ceed/" "$(includedir)/ceed/jit-source/"\ 809a0154adeSJed Brown "$(includedir)/ceed/jit-source/cuda/" "$(includedir)/ceed/jit-source/hip/"\ 810ae93e896SSebastian Grimberg "$(includedir)/ceed/jit-source/gallery/" "$(includedir)/ceed/jit-source/magma/"\ 811ae93e896SSebastian Grimberg "$(includedir)/ceed/jit-source/sycl/" "$(libdir)" "$(pkgconfigdir)") 812ec3da8bcSJed Brown $(INSTALL_DATA) include/ceed/ceed.h "$(DESTDIR)$(includedir)/ceed/" 813c9c2c079SJeremy L Thompson $(INSTALL_DATA) include/ceed/types.h "$(DESTDIR)$(includedir)/ceed/" 81480a9ef05SNatalie Beams $(INSTALL_DATA) include/ceed/ceed-f32.h "$(DESTDIR)$(includedir)/ceed/" 81580a9ef05SNatalie Beams $(INSTALL_DATA) include/ceed/ceed-f64.h "$(DESTDIR)$(includedir)/ceed/" 816ec3da8bcSJed Brown $(INSTALL_DATA) include/ceed/fortran.h "$(DESTDIR)$(includedir)/ceed/" 817ec3da8bcSJed Brown $(INSTALL_DATA) include/ceed/backend.h "$(DESTDIR)$(includedir)/ceed/" 818ec3da8bcSJed Brown $(INSTALL_DATA) include/ceed/cuda.h "$(DESTDIR)$(includedir)/ceed/" 819ec3da8bcSJed Brown $(INSTALL_DATA) include/ceed/hip.h "$(DESTDIR)$(includedir)/ceed/" 8201e25a746SJed Brown $(INSTALL_DATA) $(libceed) "$(DESTDIR)$(libdir)/" 8211e25a746SJed Brown $(INSTALL_DATA) $(OBJDIR)/ceed.pc "$(DESTDIR)$(pkgconfigdir)/" 822ec3da8bcSJed Brown $(INSTALL_DATA) include/ceed.h "$(DESTDIR)$(includedir)/" 823ec3da8bcSJed Brown $(INSTALL_DATA) include/ceedf.h "$(DESTDIR)$(includedir)/" 824a0154adeSJed Brown $(INSTALL_DATA) $(wildcard include/ceed/jit-source/cuda/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/cuda/" 825a0154adeSJed Brown $(INSTALL_DATA) $(wildcard include/ceed/jit-source/hip/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/hip/" 826a0154adeSJed Brown $(INSTALL_DATA) $(wildcard include/ceed/jit-source/gallery/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/gallery/" 827ae93e896SSebastian Grimberg $(INSTALL_DATA) $(wildcard include/ceed/jit-source/magma/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/magma/" 828ae93e896SSebastian Grimberg $(INSTALL_DATA) $(wildcard include/ceed/jit-source/sycl/*.h) "$(DESTDIR)$(includedir)/ceed/jit-source/sycl/" 829d5217624SJed Brown 830d635b4c6Scamierjs 831*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 832*8baf801dSJeremy L Thompson# Cleaning 833*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 8346e5d1fd9Scamierjscln clean : 8355cd88e3aSjeremylt $(RM) -r $(OBJDIR) $(LIBDIR) dist *egg* .pytest_cache *cffi* 8369aeb05eaSJed Brown $(call quiet,MAKE) -C examples clean NEK5K_DIR="$(abspath $(NEK5K_DIR))" 8379aeb05eaSJed Brown $(call quiet,MAKE) -C python/tests clean 838196a75e4SJed Brown $(RM) benchmarks/*output.txt 8394859b599SJed Brown 84007838a1cSTzaniodistclean : clean 84121d92382SJed Brown $(RM) -r doc/html doc/sphinx/build $(CONFIG) 84207838a1cSTzanio 843*8baf801dSJeremy L Thompson 844*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 8452b730f8bSJeremy L Thompson# Documentation 846*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 8474c4400c7SValeria BarraDOXYGEN ?= doxygen 8485cd6c1fbSSebastian Grimberg 8494c4400c7SValeria Barradoxygen : 85063be1c69SJed Brown $(DOXYGEN) -q Doxyfile 8514c4400c7SValeria Barra 85274c2e4b1SJed Browndoc-html doc-latexpdf doc-epub doc-livehtml : doc-% : doxygen 8534c4400c7SValeria Barra make -C doc/sphinx $* 8544c4400c7SValeria Barra 8554c4400c7SValeria Barradoc : doc-html 8567bd3a522STzanio 857*8baf801dSJeremy L Thompson 858*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 859*8baf801dSJeremy L Thompson# Linting utilities 860*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 861*8baf801dSJeremy L Thompson 8622b730f8bSJeremy L Thompson# Style/Format 8632b730f8bSJeremy L ThompsonCLANG_FORMAT ?= clang-format 8645cd6c1fbSSebastian GrimbergCLANG_FORMAT_OPTS += -style=file -i 8655cd6c1fbSSebastian GrimbergAUTOPEP8 ?= autopep8 8662fee3251SSebastian GrimbergAUTOPEP8_OPTS += --in-place --aggressive --max-line-length 120 8672b730f8bSJeremy L Thompson 868b73fa92cSJeremy L Thompsonformat.ch := $(filter-out include/ceedf.h $(wildcard tests/t*-f.h), $(shell git ls-files '*.[ch]pp' '*.[ch]' '*.cu')) 8692fee3251SSebastian Grimbergformat.py := $(filter-out tests/junit-xml/junit_xml/__init__.py, $(shell git ls-files '*.py')) 870b9d14e73SJeremy L Thompsonformat.ot := $(filter-out doc/sphinx/source/CODE_OF_CONDUCT.md doc/sphinx/source/CONTRIBUTING.md, $(shell git ls-files '*.md' '*.f90')) 8712b730f8bSJeremy L Thompson 8722b730f8bSJeremy L Thompsonformat-c : 8735cd6c1fbSSebastian Grimberg $(CLANG_FORMAT) $(CLANG_FORMAT_OPTS) $(format.ch) 8740dbfdfc5SJed Brown 8752b730f8bSJeremy L Thompsonformat-py : 8765cd6c1fbSSebastian Grimberg $(AUTOPEP8) $(AUTOPEP8_OPTS) $(format.py) 8777a7b0fa3SJed Brown 878b9d14e73SJeremy L Thompsonformat-ot: 879b9d14e73SJeremy L Thompson @$(SED) -r 's/\s+$$//' -i $(format.ot) 880b9d14e73SJeremy L Thompson 881b9d14e73SJeremy L Thompsonformat : format-c format-py format-ot 8828c210c3eSJeremy L Thompson 8838c210c3eSJeremy L Thompson# Vermin - python version requirements 8848c210c3eSJeremy L ThompsonVERMIN ?= vermin 8858c210c3eSJeremy L ThompsonVERMIN_OPTS += -t=3.7- --violations 8868c210c3eSJeremy L Thompson 8878c210c3eSJeremy L Thompsonvermin : 8888c210c3eSJeremy L Thompson $(VERMIN) $(VERMIN_OPTS) $(format.py) 8897a7b0fa3SJed Brown 8902b730f8bSJeremy L Thompson# Tidy 891683faae0SJed BrownCLANG_TIDY ?= clang-tidy 8929647a07eSDavid Medina 893683faae0SJed Brown%.c.tidy : %.c 8946ed4cbd1SJeremy L Thompson $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c99 -I$(CUDA_DIR)/include -I$(ROCM_DIR)/include -DCEED_JIT_SOURCE_ROOT_DEFAULT="\"$(abspath ./include)/\"" 895683faae0SJed Brown 8969647a07eSDavid Medina%.cpp.tidy : %.cpp 897023b8a51Sabdelfattah83 $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c++11 -I$(CUDA_DIR)/include -I$(OCCA_DIR)/include -I$(ROCM_DIR)/include 8989647a07eSDavid Medina 8992b730f8bSJeremy L Thompsontidy-c : $(libceed.c:%=%.tidy) 9002b730f8bSJeremy L Thompsontidy-cpp : $(libceed.cpp:%=%.tidy) 9019647a07eSDavid Medina 9022b730f8bSJeremy L Thompsontidy : tidy-c tidy-cpp 903683faae0SJed Brown 90449aac155SJeremy L Thompson# Include-What-You-Use 905db52d626SJeremy L Thompsonifneq ($(wildcard ../iwyu/*),) 906db52d626SJeremy L Thompson IWYU_DIR ?= ../iwyu 9079c06f60aSJeremy L Thompson IWYU_CC ?= $(IWYU_DIR)/build/bin/include-what-you-use 908db52d626SJeremy L Thompsonendif 90949aac155SJeremy L Thompsoniwyu : 91049aac155SJeremy L Thompson $(MAKE) -B CC=$(IWYU_CC) 911db52d626SJeremy L Thompson 912*8baf801dSJeremy L Thompson 913*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 914*8baf801dSJeremy L Thompson# Variable printing for debugging 915*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 916*8baf801dSJeremy L Thompson 9174859b599SJed Brownprint : 9184859b599SJed Brown @echo $(VAR)=$($(VAR)) 919582447c9SJed Brown 9209df38c42SVeselin Dobrevprint-% : 9219df38c42SVeselin Dobrev $(info [ variable name]: $*) 9229df38c42SVeselin Dobrev $(info [ origin]: $(origin $*)) 9237bcc1ce4SJed Brown $(info [ flavor]: $(flavor $*)) 9249df38c42SVeselin Dobrev $(info [ value]: $(value $*)) 9259df38c42SVeselin Dobrev $(info [expanded value]: $($*)) 9269df38c42SVeselin Dobrev $(info ) 9279df38c42SVeselin Dobrev @true 9289df38c42SVeselin Dobrev 929*8baf801dSJeremy L Thompson 930*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 931*8baf801dSJeremy L Thompson# Configuration caching 932*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 933b0ab70ddSJed Brown# "make configure" detects any variables passed on the command line or 934b0ab70ddSJed Brown# previously set in config.mk, caching them in config.mk as simple 935b0ab70ddSJed Brown# (:=) variables. Variables set in config.mk or on the command line 936b0ab70ddSJed Brown# take precedence over the defaults provided in the file. Typical 937b0ab70ddSJed Brown# usage: 938d3c6b40fSJed Brown# 939d3c6b40fSJed Brown# make configure CC=/path/to/my/cc CUDA_DIR=/opt/cuda 940d3c6b40fSJed Brown# make 941d3c6b40fSJed Brown# make prove 942b0ab70ddSJed Brown# 943b0ab70ddSJed Brown# The values in the file can be updated by passing them on the command 944b0ab70ddSJed Brown# line, e.g., 945b0ab70ddSJed Brown# 946b0ab70ddSJed Brown# make configure CC=/path/to/other/clang 947b0ab70ddSJed Brown 948b0ab70ddSJed Brown# All variables to consider for caching 94930f4f45fSnbeamsCONFIG_VARS = CC CXX FC NVCC NVCC_CXX HIPCC \ 950bd882c8aSJames Wright OPT CFLAGS CPPFLAGS CXXFLAGS FFLAGS NVCCFLAGS HIPCCFLAGS SYCLFLAGS \ 9511d013790SJed Brown AR ARFLAGS LDFLAGS LDLIBS LIBCXX SED \ 9523e0c2f3fSJeremy L Thompson MAGMA_DIR OCCA_DIR XSMM_DIR CUDA_DIR CUDA_ARCH MFEM_DIR PETSC_DIR NEK5K_DIR ROCM_DIR HIP_ARCH SYCL_DIR 953b0ab70ddSJed Brown 954b0ab70ddSJed Brown# $(call needs_save,CFLAGS) returns true (a nonempty string) if CFLAGS 955b0ab70ddSJed Brown# was set on the command line or in config.mk (where it will appear as 956b0ab70ddSJed Brown# a simple variable). 957b0ab70ddSJed Brownneeds_save = $(or $(filter command line,$(origin $(1))),$(filter simple,$(flavor $(1)))) 958b0ab70ddSJed Brown 959d3c6b40fSJed Brownconfigure : 960b0ab70ddSJed Brown $(file > $(CONFIG)) 961b0ab70ddSJed Brown $(foreach v,$(CONFIG_VARS),$(if $(call needs_save,$(v)),$(file >> $(CONFIG),$(v) := $($(v))))) 962b0ab70ddSJed Brown @echo "Configuration cached in $(CONFIG):" 963b0ab70ddSJed Brown @cat $(CONFIG) 964d3c6b40fSJed Brown 965*8baf801dSJeremy L Thompson 966*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 967*8baf801dSJeremy L Thompson# Building Python wheels for deployment 968*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 96961130325SJed Brownwheel : export MARCHFLAG = -march=generic 97061130325SJed Brownwheel : export WHEEL_PLAT = manylinux2010_x86_64 97137c134eaSJed Brownwheel : 972dabe13fcSJed Brown docker run -it --user $(shell id -u):$(shell id -g) --rm -v $(PWD):/io -w /io \ 97361130325SJed Brown -e MARCHFLAG -e WHEEL_PLAT \ 97461130325SJed Brown quay.io/pypa/$(WHEEL_PLAT) python/make-wheels.sh 975d3c6b40fSJed Brown 976*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 977*8baf801dSJeremy L Thompson# Phony targets 978*8baf801dSJeremy L Thompson# ------------------------------------------------------------ 979*8baf801dSJeremy L Thompson# These targets are not files but rather commands to run 980*8baf801dSJeremy L Thompson.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 configure wheel 981*8baf801dSJeremy L Thompson 98237c134eaSJed Brown 98337c134eaSJed Brown# Include *.d deps when not -B = --always-make: useful if the paths are wonky in a container 98437c134eaSJed Brown-include $(if $(filter B,$(MAKEFLAGS)),,$(libceed.c:%.c=$(OBJDIR)/%.d) $(tests.c:tests/%.c=$(OBJDIR)/%.d)) 985