10c784865Scamierjs# Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC. 20c784865Scamierjs# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 30c784865Scamierjs# All Rights reserved. See files LICENSE and NOTICE for details. 40d9661cdSTzanio# 50d9661cdSTzanio# This file is part of CEED, a collection of benchmarks, miniapps, software 60d9661cdSTzanio# libraries and APIs for efficient high-order finite element and spectral 70d9661cdSTzanio# element discretizations for exascale applications. For more information and 80d9661cdSTzanio# source code availability see http://github.com/ceed. 90d9661cdSTzanio# 100d9661cdSTzanio# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 110d9661cdSTzanio# a collaborative effort of two U.S. Department of Energy organizations (Office 120d9661cdSTzanio# of Science and the National Nuclear Security Administration) responsible for 130d9661cdSTzanio# the planning and preparation of a capable exascale ecosystem, including 140d9661cdSTzanio# software, applications, hardware, advanced system engineering and early 150d9661cdSTzanio# testbed platforms, in support of the nation's exascale computing imperative. 160d9661cdSTzanio 17b0ab70ddSJed BrownCONFIG ?= config.mk 18b0ab70ddSJed Brown-include $(CONFIG) 19777ff853SJeremy L ThompsonCOMMON ?= common.mk 20777ff853SJeremy L Thompson-include $(COMMON) 211571c99dSValeria Barra 22dc753d40SJed Brownifeq (,$(filter-out undefined default,$(origin CC))) 236ed738d9SJed Brown CC = gcc 24dc753d40SJed Brownendif 25241a4b83SYohannifeq (,$(filter-out undefined default,$(origin CXX))) 26241a4b83SYohann CXX = g++ 27241a4b83SYohannendif 28dc753d40SJed Brownifeq (,$(filter-out undefined default,$(origin FC))) 2981c9eb91SStan Tomov FC = gfortran 30dc753d40SJed Brownendif 31241a4b83SYohannifeq (,$(filter-out undefined default,$(origin LINK))) 32241a4b83SYohann LINK = $(CC) 33241a4b83SYohannendif 34196a75e4SJed BrownNVCC ?= $(CUDA_DIR)/bin/nvcc 353c83ce1dSJed BrownNVCC_CXX ?= $(CXX) 3630f4f45fSnbeamsHIPCC ?= $(HIP_DIR)/bin/hipcc 37e86995feScamierjs 383b56482dScamierjs# ASAN must be left empty if you don't want to use it 390a7eccc5ScamierjsASAN ?= 406850bcb5Scamierjs 41e86995feScamierjsLDFLAGS ?= 4232d74c32SThilina RathnayakeUNDERSCORE ?= 1 431b58aefaScamierjs 44f9fa8c39Sjeremylt# MFEM_DIR env variable should point to sibling directory 45bf3e26f6SVeselin Dobrevifneq ($(wildcard ../mfem/libmfem.*),) 469ba53df8Sjeremylt MFEM_DIR ?= ../mfem 47f9fa8c39Sjeremyltendif 48f9fa8c39Sjeremylt 494d1cd9fcSJeremy L Thompson# NEK5K_DIR env variable should point to sibling directory 504d1cd9fcSJeremy L Thompsonifneq ($(wildcard ../Nek5000/*),) 5186a4271fSThilina Rathnayake NEK5K_DIR ?= $(abspath ../Nek5000) 524d1cd9fcSJeremy L Thompsonendif 5386a4271fSThilina Rathnayakeexport NEK5K_DIR 5486a4271fSThilina RathnayakeMPI ?= 1 5586a4271fSThilina Rathnayake 5686a4271fSThilina Rathnayake# CEED_DIR env for NEK5K testing 5786a4271fSThilina Rathnayakeexport CEED_DIR = $(abspath .) 584d1cd9fcSJeremy L Thompson 598d713cf6Sjeremylt# XSMM_DIR env variable should point to XSMM master (github.com/hfp/libxsmm) 608d713cf6SjeremyltXSMM_DIR ?= ../libxsmm 618d713cf6Sjeremylt 6212123fd5Scamierjs# OCCA_DIR env variable should point to OCCA master (github.com/libocca/occa) 637f5ff99bSVeselin DobrevOCCA_DIR ?= ../occa 64f797d7b2Scamierjs 655a9ca9adSVeselin Dobrev# env variable MAGMA_DIR can be used too 66ab352fbeSnbeamsMAGMA_DIR ?= ../magma 675a9ca9adSVeselin Dobrev# If CUDA_DIR is not set, check for nvcc, or resort to /usr/local/cuda 68ab352fbeSnbeamsCUDA_DIR ?= $(or $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir \ 695a9ca9adSVeselin Dobrev $(shell which nvcc 2> /dev/null))))),/usr/local/cuda) 706fa87394SnbeamsHIP_DIR ?= /opt/rocm 7182b77998SStan Tomov 722f4d9adbSJeremy L Thompson# Check for PETSc in ../petsc 732f4d9adbSJeremy L Thompsonifneq ($(wildcard ../petsc/lib/libpetsc.*),) 742f4d9adbSJeremy L Thompson PETSC_DIR ?= ../petsc 752f4d9adbSJeremy L Thompsonendif 762f4d9adbSJeremy L Thompson 77bf000209STzanio# Warning: SANTIZ options still don't run with /gpu/occa 7812123fd5Scamierjs# export LSAN_OPTIONS=suppressions=.asanignore 79c12ddcb5ScamierjsAFLAGS = -fsanitize=address #-fsanitize=undefined -fno-omit-frame-pointer 8032d74c32SThilina Rathnayake 81c7f533e0SJed BrownCC_VENDOR := $(patsubst gcc%,gcc,$(firstword $(filter gcc% clang icc XL,$(shell $(CC) --version)))) 8213d950b4SJed BrownFC_VENDOR := $(firstword $(filter GNU ifort XL,$(shell $(FC) --version 2>&1 || $(FC) -qversion))) 8313d950b4SJed Brown 8413d950b4SJed Brown# Default extra flags by vendor 8513d950b4SJed BrownMARCHFLAG.gcc := -march=native 8613d950b4SJed BrownMARCHFLAG.clang := $(MARCHFLAG.gcc) 8713d950b4SJed BrownMARCHFLAG.icc := 8813d950b4SJed BrownOMP_SIMD_FLAG.gcc := -fopenmp-simd 8913d950b4SJed BrownOMP_SIMD_FLAG.clang := $(OMP_SIMD_FLAG.gcc) 9013d950b4SJed BrownOMP_SIMD_FLAG.icc := -qopenmp-simd 9113d950b4SJed BrownOPT.gcc := -ffp-contract=fast 9213d950b4SJed BrownOPT.clang := $(OPT.gcc) 9313d950b4SJed BrownCFLAGS.gcc := -fPIC -std=c99 -Wall -Wextra -Wno-unused-parameter -MMD -MP 9413d950b4SJed BrownCFLAGS.clang := $(CFLAGS.gcc) 9513d950b4SJed BrownCFLAGS.icc := $(CFLAGS.gcc) 9613d950b4SJed BrownCFLAGS.XL := -qpic -MMD 9713d950b4SJed BrownCXXFLAGS.gcc := -fPIC -std=c++11 -Wall -Wextra -Wno-unused-parameter -MMD -MP 9813d950b4SJed BrownCXXFLAGS.clang := $(CXXFLAGS.gcc) 9913d950b4SJed BrownCXXFLAGS.icc := $(CXXFLAGS.gcc) 10013d950b4SJed BrownCXXFLAGS.XL := -qpic -MMD 10113d950b4SJed BrownFFLAGS.GNU := -fPIC -cpp -Wall -Wextra -Wno-unused-parameter -Wno-unused-dummy-argument -MMD -MP 10213d950b4SJed BrownFFLAGS.ifort := -fPIC -cpp 10313d950b4SJed BrownFFLAGS.XL := -qpic -ffree-form -qpreprocess -qextname -MMD 104cf4a56afSJed Brown 105d9bc9eefSJed Brown# This check works with compilers that use gcc and clang. It fails with some 106d9bc9eefSJed Brown# compilers; e.g., xlc apparently ignores all options when -E is passed, thus 107d9bc9eefSJed Brown# succeeds with any flags. Users can pass MARCHFLAG=... if desired. 108d9bc9eefSJed Browncc_check_flag = $(shell $(CC) -E -Werror $(1) -x c /dev/null > /dev/null 2>&1 && echo 1) 10913d950b4SJed BrownMARCHFLAG := $(MARCHFLAG.$(CC_VENDOR)) 110f766a8abSJed BrownMARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG),-mcpu=native) 111f766a8abSJed BrownMARCHFLAG := $(if $(call cc_check_flag,$(MARCHFLAG)),$(MARCHFLAG)) 112b9c05c73SJed Brown 11313d950b4SJed BrownOMP_SIMD_FLAG := $(OMP_SIMD_FLAG.$(CC_VENDOR)) 114f766a8abSJed BrownOMP_SIMD_FLAG := $(if $(call cc_check_flag,$(OMP_SIMD_FLAG)),$(OMP_SIMD_FLAG)) 115cf4a56afSJed Brown 11613d950b4SJed BrownOPT ?= -O -g $(MARCHFLAG) $(OPT.$(CC_VENDOR)) $(OMP_SIMD_FLAG) 11713d950b4SJed BrownCFLAGS ?= $(OPT) $(CFLAGS.$(CC_VENDOR)) 11813d950b4SJed BrownCXXFLAGS ?= $(OPT) $(CXXFLAGS.$(CC_VENDOR)) 119b0ab70ddSJed BrownNVCCFLAGS ?= -ccbin $(CXX) -Xcompiler "$(OPT)" -Xcompiler -fPIC 1204b1a2981SnbeamsHIPCCFLAGS ?= $(OPT) -fPIC 12113d950b4SJed BrownFFLAGS ?= $(OPT) $(FFLAGS.$(FC_VENDOR)) 12232d74c32SThilina Rathnayake 123a6f4783aSJed Brownifeq ($(COVERAGE), 1) 124a6f4783aSJed Brown CFLAGS += --coverage 125a6f4783aSJed Brown LDFLAGS += --coverage 126a6f4783aSJed Brownendif 127a6f4783aSJed Brown 1284dd6f121ScamierjsCFLAGS += $(if $(ASAN),$(AFLAGS)) 1294dd6f121ScamierjsFFLAGS += $(if $(ASAN),$(AFLAGS)) 1304dd6f121ScamierjsLDFLAGS += $(if $(ASAN),$(AFLAGS)) 13141a90898SJed BrownCPPFLAGS += -I./include 132582447c9SJed BrownLDLIBS = -lm 13391b7489eSJed BrownOBJDIR := build 1346ea7c6c1SJed BrownLIBDIR := lib 1356ea7c6c1SJed Brown 136d5217624SJed Brown# Installation variables 137d5217624SJed Brownprefix ?= /usr/local 138d5217624SJed Brownbindir = $(prefix)/bin 139d5217624SJed Brownlibdir = $(prefix)/lib 140d5217624SJed Brownincludedir = $(prefix)/include 141d5217624SJed Brownpkgconfigdir = $(libdir)/pkgconfig 142d5217624SJed BrownINSTALL = install 143d5217624SJed BrownINSTALL_PROGRAM = $(INSTALL) 144d5217624SJed BrownINSTALL_DATA = $(INSTALL) -m644 145d5217624SJed Brown 1463b56482dScamierjs# Get number of processors of the machine 14769762e1fScamierjsNPROCS := $(shell getconf _NPROCESSORS_ONLN) 1483b56482dScamierjs# prepare make options to run in parallel 14982985883ScamierjsMFLAGS := -j $(NPROCS) --warn-undefined-variables \ 15021ae6867Scamierjs --no-print-directory --no-keep-going 15187e762eaSJed Brown 1528ec9d54bSJed BrownPYTHON ?= python3 153bfa078e6SJed BrownPROVE ?= prove 1543a1ec3cdSJed BrownPROVE_OPTS ?= -j $(NPROCS) 1555c719ab0SJed BrownDARWIN := $(filter Darwin,$(shell uname -s)) 1565c719ab0SJed BrownSO_EXT := $(if $(DARWIN),dylib,so) 1579df38c42SVeselin Dobrev 1586ea7c6c1SJed Brownceed.pc := $(LIBDIR)/pkgconfig/ceed.pc 15991b7489eSJed Brownlibceed := $(LIBDIR)/libceed.$(SO_EXT) 1607e68d260SJed BrownCEED_LIBS = -lceed 161d7b241e6Sjeremyltlibceed.c := $(wildcard interface/ceed*.c) 162288c0443SJeremy L Thompsongallery.c := $(wildcard gallery/*/ceed*.c) 163288c0443SJeremy L Thompsonlibceed.c += $(gallery.c) 164265be9c8Sjeremyltlibceed_test := $(LIBDIR)/libceed_test.$(SO_EXT) 16576af460cSJed Brownlibceeds = $(libceed) $(libceed_test) 166265be9c8SjeremyltBACKENDS_BUILTIN := /cpu/self/ref/serial /cpu/self/ref/blocked /cpu/self/opt/serial /cpu/self/opt/blocked 167d20f937dSJed BrownBACKENDS := $(BACKENDS_BUILTIN) 168bf000209STzanio 169bf000209STzanio# Tests 17057c64913Sjeremylttests.c := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.c)) 1718980d4a7Sjeremylttests.f := $(sort $(wildcard tests/t[0-9][0-9][0-9]-*.f90)) 17291b7489eSJed Browntests := $(tests.c:tests/%.c=$(OBJDIR)/%) 1733f3e7340Scamierjsctests := $(tests) 1748980d4a7Sjeremylttests += $(tests.f:tests/%.f90=$(OBJDIR)/%) 17586a4271fSThilina Rathnayake# Examples 176182fbe45STzanioexamples.c := $(sort $(wildcard examples/ceed/*.c)) 177182fbe45STzanioexamples.f := $(sort $(wildcard examples/ceed/*.f)) 178182fbe45STzanioexamples := $(examples.c:examples/ceed/%.c=$(OBJDIR)/%) 179182fbe45STzanioexamples += $(examples.f:examples/ceed/%.f=$(OBJDIR)/%) 18086a4271fSThilina Rathnayake# MFEM Examples 1812158b1b0Sjeremyltmfemexamples.cpp := $(sort $(wildcard examples/mfem/*.cpp)) 18216c6c054SJed Brownmfemexamples := $(mfemexamples.cpp:examples/mfem/%.cpp=$(OBJDIR)/mfem-%) 18386a4271fSThilina Rathnayake# Nek5K Examples 18486a4271fSThilina Rathnayakenekexamples := $(OBJDIR)/nek-bps 18586a4271fSThilina Rathnayake# PETSc Examples 1866f87d196Sjeremyltpetscexamples.c := $(wildcard examples/petsc/*.c) 187e797ab98SJed Brownpetscexamples := $(petscexamples.c:examples/petsc/%.c=$(OBJDIR)/petsc-%) 188ccaff030SJeremy L Thompson# Fluid Dynamics Examples 189ccaff030SJeremy L Thompsonfluidsexamples.c := $(sort $(wildcard examples/fluids/*.c)) 190ccaff030SJeremy L Thompsonfluidsexamples := $(fluidsexamples.c:examples/fluids/%.c=$(OBJDIR)/fluids-%) 191ccaff030SJeremy L Thompson# Solid Mechanics Examples 192ccaff030SJeremy L Thompsonsolidsexamples.c := $(sort $(wildcard examples/solids/*.c)) 193ccaff030SJeremy L Thompsonsolidsexamples := $(solidsexamples.c:examples/solids/%.c=$(OBJDIR)/solids-%) 194e797ab98SJed Brown 19586a4271fSThilina Rathnayake# Backends/[ref, blocked, template, memcheck, opt, avx, occa, magma] 196ae3cba82Scamierjsref.c := $(sort $(wildcard backends/ref/*.c)) 19789c6efa4Sjeremyltblocked.c := $(sort $(wildcard backends/blocked/*.c)) 198a718229cSjeremylttemplate.c := $(sort $(wildcard backends/template/*.c)) 19989c6efa4Sjeremyltceedmemcheck.c := $(sort $(wildcard backends/memcheck/*.c)) 20089c6efa4Sjeremyltopt.c := $(sort $(wildcard backends/opt/*.c)) 20189c6efa4Sjeremyltavx.c := $(sort $(wildcard backends/avx/*.c)) 20289c6efa4Sjeremyltxsmm.c := $(sort $(wildcard backends/xsmm/*.c)) 2039f0427d9SYohanncuda.c := $(sort $(wildcard backends/cuda/*.c)) 2044d537eeaSYohanncuda.cpp := $(sort $(wildcard backends/cuda/*.cpp)) 205b2573fe1SJeremy L Thompsoncuda.cu := $(sort $(wildcard backends/cuda/kernels/*.cu)) 20655ae60f9SYohanncuda-reg.c := $(sort $(wildcard backends/cuda-reg/*.c)) 207b2573fe1SJeremy L Thompsoncuda-reg.cu := $(sort $(wildcard backends/cuda-reg/kernels/*.cu)) 208c532df63SYohanncuda-shared.c := $(sort $(wildcard backends/cuda-shared/*.c)) 209b2573fe1SJeremy L Thompsoncuda-shared.cu := $(sort $(wildcard backends/cuda-shared/kernels/*.cu)) 210241a4b83SYohanncuda-gen.c := $(sort $(wildcard backends/cuda-gen/*.c)) 211241a4b83SYohanncuda-gen.cpp := $(sort $(wildcard backends/cuda-gen/*.cpp)) 212b2573fe1SJeremy L Thompsoncuda-gen.cu := $(sort $(wildcard backends/cuda-gen/kernels/*.cu)) 213*9647a07eSDavid Medinaocca.cpp := $(sort $(shell find backends/occa -type f -name *.cpp)) 214a07e8cf1SNatalie Beamsmagma.c := $(sort $(wildcard backends/magma/*.c)) 215b2573fe1SJeremy L Thompsonmagma.cu := $(sort $(wildcard backends/magma/kernels/*.cu)) 21630f4f45fSnbeamship.c := $(sort $(wildcard backends/hip/*.c)) 217f0f820a0SJeremy L Thompsonhip.cpp := $(sort $(wildcard backends/hip/*.cpp)) 218f0f820a0SJeremy L Thompsonhip.hip := $(sort $(wildcard backends/hip/kernels/*.hip.cpp)) 21982985883Scamierjs 220777ff853SJeremy L Thompson# Quiet, color output 221777ff853SJeremy L Thompsonquiet ?= $($(1)) 22221ae6867Scamierjs 223da72e7fcSJed Brown# Cancel built-in and old-fashioned implicit rules which we don't use 2249df38c42SVeselin Dobrev.SUFFIXES: 225da72e7fcSJed Brown 22691b7489eSJed Brown.SECONDEXPANSION: # to expand $$(@D)/.DIR 2279df38c42SVeselin Dobrev 22891b7489eSJed Brown%/.DIR : 22991b7489eSJed Brown @mkdir -p $(@D) 23091b7489eSJed Brown @touch $@ 23191b7489eSJed Brown 23291b7489eSJed Brown.PRECIOUS: %/.DIR 23391b7489eSJed Brown 23423072ed2SVeselin Dobrevlib: $(libceed) $(ceed.pc) 23523072ed2SVeselin Dobrev# run 'lib' target in parallel 2362f4d9adbSJeremy L Thompsonpar:;@$(MAKE) $(MFLAGS) V=$(V) lib 237d20f937dSJed Brownbackend_status = $(if $(filter $1,$(BACKENDS)), [backends: $1], [not found]) 238bf3e26f6SVeselin Dobrevinfo: 239bf3e26f6SVeselin Dobrev $(info ------------------------------------) 240bf3e26f6SVeselin Dobrev $(info CC = $(CC)) 241241a4b83SYohann $(info CXX = $(CXX)) 242bf3e26f6SVeselin Dobrev $(info FC = $(FC)) 243bf3e26f6SVeselin Dobrev $(info CPPFLAGS = $(CPPFLAGS)) 244bf3e26f6SVeselin Dobrev $(info CFLAGS = $(value CFLAGS)) 245241a4b83SYohann $(info CXXFLAGS = $(value CXXFLAGS)) 246bf3e26f6SVeselin Dobrev $(info FFLAGS = $(value FFLAGS)) 247bf3e26f6SVeselin Dobrev $(info NVCCFLAGS = $(value NVCCFLAGS)) 248b7a997cfSjeremylt $(info HIPCCFLAGS = $(value HIPCCFLAGS)) 249bf3e26f6SVeselin Dobrev $(info LDFLAGS = $(value LDFLAGS)) 250bf3e26f6SVeselin Dobrev $(info LDLIBS = $(LDLIBS)) 251bf3e26f6SVeselin Dobrev $(info OPT = $(OPT)) 252bf3e26f6SVeselin Dobrev $(info AFLAGS = $(AFLAGS)) 253bf3e26f6SVeselin Dobrev $(info ASAN = $(or $(ASAN),(empty))) 254bf3e26f6SVeselin Dobrev $(info V = $(or $(V),(empty)) [verbose=$(if $(V),on,off)]) 255bf3e26f6SVeselin Dobrev $(info ------------------------------------) 2561ef3f58fSjeremylt $(info MEMCHK_STATUS = $(MEMCHK_STATUS)$(call backend_status,/cpu/self/memcheck/serial /cpu/sef/memcheck/blocked)) 25784a01de5SJeremy L Thompson $(info AVX_STATUS = $(AVX_STATUS)$(call backend_status,/cpu/self/avx/serial /cpu/self/avx/blocked)) 25884a01de5SJeremy L Thompson $(info XSMM_DIR = $(XSMM_DIR)$(call backend_status,/cpu/self/xsmm/serial /cpu/self/xsmm/blocked)) 259*9647a07eSDavid Medina $(info OCCA_DIR = $(OCCA_DIR)$(call backend_status,$(OCCA_BACKENDS))) 260cb23e90cSJeremy L Thompson $(info MAGMA_DIR = $(MAGMA_DIR)$(call backend_status,/gpu/magma /gpu/magma/det)) 261ab9cabdeSVeselin Dobrev $(info CUDA_DIR = $(CUDA_DIR)$(call backend_status,$(CUDA_BACKENDS))) 26230f4f45fSnbeams $(info HIP_DIR = $(HIP_DIR)$(call backend_status,$(HIP_BACKENDS))) 263bf3e26f6SVeselin Dobrev $(info ------------------------------------) 264bf3e26f6SVeselin Dobrev $(info MFEM_DIR = $(MFEM_DIR)) 2654d1cd9fcSJeremy L Thompson $(info NEK5K_DIR = $(NEK5K_DIR)) 266bf3e26f6SVeselin Dobrev $(info PETSC_DIR = $(PETSC_DIR)) 267bf3e26f6SVeselin Dobrev $(info ------------------------------------) 268bf3e26f6SVeselin Dobrev $(info prefix = $(prefix)) 269bf3e26f6SVeselin Dobrev $(info includedir = $(value includedir)) 270bf3e26f6SVeselin Dobrev $(info libdir = $(value libdir)) 271bf3e26f6SVeselin Dobrev $(info pkgconfigdir = $(value pkgconfigdir)) 272bf3e26f6SVeselin Dobrev $(info ------------------------------------) 273bf3e26f6SVeselin Dobrev @true 27423072ed2SVeselin Dobrevinfo-backends: 275d20f937dSJed Brown $(info make: 'lib' with optional backends: $(filter-out $(BACKENDS_BUILTIN),$(BACKENDS))) 2762f4d9adbSJeremy L Thompson.PHONY: lib all par info info-backends 2770e439e50SJed Brown 27824d002f4SJed Brown$(libceed) : LDFLAGS += $(if $(DARWIN), -install_name @rpath/$(notdir $(libceed))) 27976af460cSJed Brown$(libceed_test) : LDFLAGS += $(if $(DARWIN), -install_name @rpath/$(notdir $(libceed_test))) 28069762e1fScamierjs 28148fffa06Sjeremylt# Standard Backends 28287174f08SJed Brownlibceed.c += $(ref.c) 2834a2e7687Sjeremyltlibceed.c += $(blocked.c) 28489c6efa4Sjeremyltlibceed.c += $(opt.c) 28523072ed2SVeselin Dobrev 286265be9c8Sjeremylt# Testing Backends 287265be9c8Sjeremylttest_backends.c := $(template.c) 288265be9c8SjeremyltTEST_BACKENDS := /cpu/self/tmpl /cpu/self/tmpl/sub 289265be9c8Sjeremylt 290fc7cf9a0Sjeremylt# Memcheck Backend 291bdc3149dSjeremyltMEMCHK_STATUS = Disabled 292b8fb44e7SJed BrownMEMCHK := $(shell echo "\#include <valgrind/memcheck.h>" | $(CC) $(CPPFLAGS) -E - >/dev/null 2>&1 && echo 1) 293bdc3149dSjeremyltifeq ($(MEMCHK),1) 294bdc3149dSjeremylt MEMCHK_STATUS = Enabled 295fc7cf9a0Sjeremylt libceed.c += $(ceedmemcheck.c) 2961ef3f58fSjeremylt BACKENDS += /cpu/self/memcheck/serial /cpu/self/memcheck/blocked 297fc7cf9a0Sjeremyltendif 298fc7cf9a0Sjeremylt 29948fffa06Sjeremylt# AVX Backed 30048fffa06SjeremyltAVX_STATUS = Disabled 301cf4a56afSJed BrownAVX_FLAG := $(if $(filter clang,$(CC_VENDOR)),+avx,-mavx) 302cf4a56afSJed BrownAVX := $(filter $(AVX_FLAG),$(shell $(CC) $(OPT) -v -E -x c /dev/null 2>&1)) 303cf4a56afSJed Brownifneq ($(AVX),) 30448fffa06Sjeremylt AVX_STATUS = Enabled 30548fffa06Sjeremylt libceed.c += $(avx.c) 30684a01de5SJeremy L Thompson BACKENDS += /cpu/self/avx/serial /cpu/self/avx/blocked 30748fffa06Sjeremyltendif 30848fffa06Sjeremylt 3098d713cf6Sjeremylt# libXSMM Backends 3108d713cf6Sjeremyltifneq ($(wildcard $(XSMM_DIR)/lib/libxsmm.*),) 31176af460cSJed Brown $(libceeds) : LDFLAGS += -L$(XSMM_DIR)/lib -Wl,-rpath,$(abspath $(XSMM_DIR)/lib) 31276af460cSJed Brown $(libceeds) : LDLIBS += -lxsmm -ldl 31300723591Sjeremylt MKL ?= 31400723591Sjeremylt ifeq (,$(MKL)$(MKLROOT)) 315c0ea1048SJed Brown BLAS_LIB = -lblas 3165462ed45Sjeremylt else 31772e1b2f7SJeremy L Thompson ifneq ($(MKLROOT),) 318ff56800aSJed Brown # Some installs put everything inside an intel64 subdirectory, others not 319ff56800aSJed Brown MKL_LIBDIR = $(dir $(firstword $(wildcard $(MKLROOT)/lib/intel64/libmkl_sequential.* $(MKLROOT)/lib/libmkl_sequential.*))) 320ff56800aSJed Brown MKL_LINK = -L$(MKL_LIBDIR) -Wl,-rpath,$(MKL_LIBDIR) 32172e1b2f7SJeremy L Thompson endif 3227b49ae6cSjeremylt BLAS_LIB = $(MKL_LINK) -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl 3235462ed45Sjeremylt endif 324c0ea1048SJed Brown $(libceeds) : LDLIBS += $(BLAS_LIB) 3258d713cf6Sjeremylt libceed.c += $(xsmm.c) 326683faae0SJed Brown $(xsmm.c:%.c=$(OBJDIR)/%.o) $(xsmm.c:%=%.tidy) : CPPFLAGS += -I$(XSMM_DIR)/include 3278d713cf6Sjeremylt BACKENDS += /cpu/self/xsmm/serial /cpu/self/xsmm/blocked 3288d713cf6Sjeremyltendif 3298d713cf6Sjeremylt 33048fffa06Sjeremylt# OCCA Backends 331*9647a07eSDavid MedinaOCCA_BACKENDS = /cpu/occa/serial 3327f5ff99bSVeselin Dobrevifneq ($(wildcard $(OCCA_DIR)/lib/libocca.*),) 333*9647a07eSDavid Medina OCCA_MODES := $(shell $(OCCA_DIR)/bin/occa modes) 334*9647a07eSDavid Medina OCCA_BACKENDS += $(if $(filter OpenMP,$(OCCA_MODES)),/cpu/occa/openmp) 335*9647a07eSDavid Medina# OCCA_BACKENDS += $(if $(filter OpenCL,$(OCCA_MODES)),/opencl/occa) 336*9647a07eSDavid Medina OCCA_BACKENDS += $(if $(filter HIP,$(OCCA_MODES)),/gpu/occa/hip) 337*9647a07eSDavid Medina OCCA_BACKENDS += $(if $(filter CUDA,$(OCCA_MODES)),/gpu/occa/cuda) 338*9647a07eSDavid Medina 339*9647a07eSDavid Medina $(libceeds) : CPPFLAGS += -I$(OCCA_DIR)/include 34076af460cSJed Brown $(libceeds) : LDFLAGS += -L$(OCCA_DIR)/lib -Wl,-rpath,$(abspath $(OCCA_DIR)/lib) 34176af460cSJed Brown $(libceeds) : LDLIBS += -locca 342*9647a07eSDavid Medina $(libceeds) : LINK = $(CXX) 343*9647a07eSDavid Medina libceed.cpp += $(occa.cpp) 344*9647a07eSDavid Medina BACKENDS += $(OCCA_BACKENDS) 34521ae6867Scamierjsendif 34623072ed2SVeselin Dobrev 34786a4271fSThilina Rathnayake# CUDA Backends 3485a9ca9adSVeselin DobrevCUDA_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(CUDA_DIR)/$d/libcudart.${SO_EXT})) 3495a9ca9adSVeselin DobrevCUDA_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(CUDA_LIB_DIR)))) 3503dd0010eSvaleriabarraCUDA_LIB_DIR_STUBS := $(CUDA_LIB_DIR)/stubs 351241a4b83SYohannCUDA_BACKENDS = /gpu/cuda/ref /gpu/cuda/reg /gpu/cuda/shared /gpu/cuda/gen 3525a9ca9adSVeselin Dobrevifneq ($(CUDA_LIB_DIR),) 3539d77422eSJed Brown $(libceeds) : CPPFLAGS += -I$(CUDA_DIR)/include 35476af460cSJed Brown $(libceeds) : LDFLAGS += -L$(CUDA_LIB_DIR) -Wl,-rpath,$(abspath $(CUDA_LIB_DIR)) 35548e4fcd3SJeremy L Thompson $(libceeds) : LDLIBS += -lcudart -lnvrtc -lcuda -lcublas 356241a4b83SYohann $(libceeds) : LINK = $(CXX) 357241a4b83SYohann libceed.c += $(cuda.c) $(cuda-reg.c) $(cuda-shared.c) $(cuda-gen.c) 3584d537eeaSYohann libceed.cpp += $(cuda.cpp) $(cuda-gen.cpp) 359241a4b83SYohann libceed.cu += $(cuda.cu) $(cuda-reg.cu) $(cuda-shared.cu) $(cuda-gen.cu) 360ab9cabdeSVeselin Dobrev BACKENDS += $(CUDA_BACKENDS) 3619f0427d9SYohannendif 3629f0427d9SYohann 36330f4f45fSnbeams# HIP Backends 36430f4f45fSnbeamsHIP_LIB_DIR := $(wildcard $(foreach d,lib lib64,$(HIP_DIR)/$d/libhiprtc.${SO_EXT})) 36530f4f45fSnbeamsHIP_LIB_DIR := $(patsubst %/,%,$(dir $(firstword $(HIP_LIB_DIR)))) 36630f4f45fSnbeamsHIP_BACKENDS = /gpu/hip/ref 36730f4f45fSnbeamsifneq ($(HIP_LIB_DIR),) 3683f9cf3a4Snbeams $(libceeds) : HIPCCFLAGS += -I./include 36930f4f45fSnbeams ifneq ($(CXX), $(HIPCC)) 370cdd1636dSnbeams CPPFLAGS += $(subst =,,$(shell $(HIP_DIR)/bin/hipconfig -C)) 37130f4f45fSnbeams endif 3721aa86be0Snbeams CPPFLAGS += -I$(HIP_DIR)/include -Wno-unused-function 373a233dbfeSnbeams $(libceeds) : LDFLAGS += -L$(HIP_LIB_DIR) -Wl,-rpath,$(abspath $(HIP_LIB_DIR)) 3743f9cf3a4Snbeams $(libceeds) : LDLIBS += -lhip_hcc -lhiprtc -lhipblas 37530f4f45fSnbeams $(libceeds) : LINK = $(CXX) 37630f4f45fSnbeams libceed.hip += $(hip.hip) 37730f4f45fSnbeams libceed.cpp += $(hip.cpp) 37830f4f45fSnbeams libceed.c += $(hip.c) 37930f4f45fSnbeams BACKENDS += $(HIP_BACKENDS) 38030f4f45fSnbeamsendif 38130f4f45fSnbeams 3829f0427d9SYohann# MAGMA Backend 3839f0427d9SYohannifneq ($(wildcard $(MAGMA_DIR)/lib/libmagma.*),) 3849f0427d9SYohann ifneq ($(CUDA_LIB_DIR),) 3851dc2661bSVeselin Dobrev cuda_link = -Wl,-rpath,$(CUDA_LIB_DIR) -L$(CUDA_LIB_DIR) -lcublas -lcusparse -lcudart 3861dc2661bSVeselin Dobrev omp_link = -fopenmp 3871dc2661bSVeselin Dobrev magma_link_static = -L$(MAGMA_DIR)/lib -lmagma $(cuda_link) $(omp_link) 3887692a9b0SVeselin Dobrev magma_link_shared = -L$(MAGMA_DIR)/lib -Wl,-rpath,$(abspath $(MAGMA_DIR)/lib) -lmagma 3897692a9b0SVeselin Dobrev magma_link := $(if $(wildcard $(MAGMA_DIR)/lib/libmagma.${SO_EXT}),$(magma_link_shared),$(magma_link_static)) 39076af460cSJed Brown $(libceeds) : LDLIBS += $(magma_link) 3917692a9b0SVeselin Dobrev $(tests) $(examples) : LDLIBS += $(magma_link) 392a07e8cf1SNatalie Beams libceed.c += $(magma.c) 393a07e8cf1SNatalie Beams libceed.cu += $(magma.cu) 394a07e8cf1SNatalie Beams $(magma.c:%.c=$(OBJDIR)/%.o) $(magma.c:%=%.tidy) : CPPFLAGS += -DADD_ -I$(MAGMA_DIR)/include -I$(CUDA_DIR)/include 395a07e8cf1SNatalie Beams $(magma.cu:%.cu=$(OBJDIR)/%.o) : CPPFLAGS += --compiler-options=-fPIC -DADD_ -I$(MAGMA_DIR)/include -I$(MAGMA_DIR)/magmablas -I$(MAGMA_DIR)/control -I$(CUDA_DIR)/include 396cb23e90cSJeremy L Thompson BACKENDS += /gpu/magma /gpu/magma/det 39782b77998SStan Tomov endif 3985a9ca9adSVeselin Dobrevendif 399755585ceSStan Tomov 400ce41f623SJed Brownexport BACKENDS 401ce41f623SJed Brown 402cfb6011cSnbeamslibceed.o = $(libceed.c:%.c=$(OBJDIR)/%.o) $(libceed.cpp:%.cpp=$(OBJDIR)/%.o) $(libceed.cu:%.cu=$(OBJDIR)/%.o) $(libceed.hip:%.hip.cpp=$(OBJDIR)/%.o) 4034c7bddedSJed Brown$(filter %fortran.o,$(libceed.o)) : CPPFLAGS += $(if $(filter 1,$(UNDERSCORE)),-DUNDERSCORE) 40423072ed2SVeselin Dobrev$(libceed.o): | info-backends 40523072ed2SVeselin Dobrev$(libceed) : $(libceed.o) | $$(@D)/.DIR 406241a4b83SYohann $(call quiet,LINK) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) 40791b7489eSJed Brown 40858e8d3b7SJed Brown$(OBJDIR)/%.o : $(CURDIR)/%.c | $$(@D)/.DIR 409b5b03409SJed Brown $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 410ae3cba82Scamierjs 411241a4b83SYohann$(OBJDIR)/%.o : $(CURDIR)/%.cpp | $$(@D)/.DIR 412241a4b83SYohann $(call quiet,CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(abspath $<) 413241a4b83SYohann 41458e8d3b7SJed Brown$(OBJDIR)/%.o : $(CURDIR)/%.cu | $$(@D)/.DIR 415777ff853SJeremy L Thompson $(call quiet,NVCC) $(filter-out -Wno-unused-function, $(CPPFLAGS)) $(NVCCFLAGS) -c -o $@ $(abspath $<) 416755585ceSStan Tomov 417cfb6011cSnbeams$(OBJDIR)/%.o : $(CURDIR)/%.hip.cpp | $$(@D)/.DIR 41830f4f45fSnbeams $(call quiet,HIPCC) $(HIPCCFLAGS) -c -o $@ $(abspath $<) 41930f4f45fSnbeams 420b5b03409SJed Brown$(OBJDIR)/% : tests/%.c | $$(@D)/.DIR 421843fcb4bSJed Brown $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS) 42278b5556aScamierjs 4238980d4a7Sjeremylt$(OBJDIR)/% : tests/%.f90 | $$(@D)/.DIR 424843fcb4bSJed Brown $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS) 42532d74c32SThilina Rathnayake 426182fbe45STzanio$(OBJDIR)/% : examples/ceed/%.c | $$(@D)/.DIR 427843fcb4bSJed Brown $(call quiet,LINK.c) $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS) 42891b7489eSJed Brown 429182fbe45STzanio$(OBJDIR)/% : examples/ceed/%.f | $$(@D)/.DIR 430843fcb4bSJed Brown $(call quiet,LINK.F) -DSOURCE_DIR='"$(abspath $(<D))/"' $(CEED_LDFLAGS) -o $@ $(abspath $<) $(CEED_LIBS) $(LDLIBS) 431673d494eSThilina Rathnayake 43216c6c054SJed Brown$(OBJDIR)/mfem-% : examples/mfem/%.cpp $(libceed) | $$(@D)/.DIR 433c4216f28SJed Brown +$(MAKE) -C examples/mfem CEED_DIR=`pwd` \ 434722eb117SJeremy L Thompson MFEM_DIR="$(abspath $(MFEM_DIR))" CXX=$(CXX) $* 43516c6c054SJed Brown mv examples/mfem/$* $@ 43616c6c054SJed Brown 43786a4271fSThilina Rathnayake# Note: Multiple Nek files cannot be built in parallel. The '+' here enables 43886a4271fSThilina Rathnayake# this single Nek bps file to be built in parallel with other examples, 43986a4271fSThilina Rathnayake# such as when calling `make prove-all -j2`. 44086a4271fSThilina Rathnayake$(OBJDIR)/nek-bps : examples/nek/bps/bps.usr examples/nek/nek-examples.sh $(libceed) | $$(@D)/.DIR 44186a4271fSThilina Rathnayake +$(MAKE) -C examples MPI=$(MPI) CEED_DIR=`pwd` NEK5K_DIR="$(abspath $(NEK5K_DIR))" nek 44286a4271fSThilina Rathnayake mv examples/nek/build/bps $(OBJDIR)/bps 44386a4271fSThilina Rathnayake cp examples/nek/nek-examples.sh $(OBJDIR)/nek-bps 44486a4271fSThilina Rathnayake 4457f6cf205SJed Brown$(OBJDIR)/petsc-% : examples/petsc/%.c $(libceed) $(ceed.pc) | $$(@D)/.DIR 446c4216f28SJed Brown +$(MAKE) -C examples/petsc CEED_DIR=`pwd` \ 447f766a8abSJed Brown PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 448e797ab98SJed Brown mv examples/petsc/$* $@ 449e797ab98SJed Brown 450ccaff030SJeremy L Thompson$(OBJDIR)/fluids-% : examples/fluids/%.c $(libceed) $(ceed.pc) | $$(@D)/.DIR 451ccaff030SJeremy L Thompson +$(MAKE) -C examples/fluids CEED_DIR=`pwd` \ 452f766a8abSJed Brown PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 453ccaff030SJeremy L Thompson mv examples/fluids/$* $@ 454ccaff030SJeremy L Thompson 455ccaff030SJeremy L Thompson$(OBJDIR)/solids-% : examples/solids/%.c $(libceed) $(ceed.pc) | $$(@D)/.DIR 456ccaff030SJeremy L Thompson +$(MAKE) -C examples/solids CEED_DIR=`pwd` \ 457722eb117SJeremy L Thompson PETSC_DIR="$(abspath $(PETSC_DIR))" OPT="$(OPT)" $* 458ccaff030SJeremy L Thompson mv examples/solids/$* $@ 4592774d5cbSJeremy L Thompson 460567e4d0aSJed Brownlibceed_test.o = $(test_backends.c:%.c=$(OBJDIR)/%.o) 46176af460cSJed Brown$(libceed_test) : $(libceed.o) $(libceed_test.o) | $$(@D)/.DIR 462241a4b83SYohann $(call quiet,LINK) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) 463265be9c8Sjeremylt 464265be9c8Sjeremylt$(examples) : $(libceed) 46576af460cSJed Brown$(tests) : $(libceed_test) 46676af460cSJed Brown$(tests) : CEED_LIBS = -lceed_test 467fc377ca6SJed Brown$(tests) $(examples) : LDFLAGS += -Wl,-rpath,$(abspath $(LIBDIR)) -L$(LIBDIR) 4684859b599SJed Brown 469686de4acSJed Brownrun-t% : BACKENDS += $(TEST_BACKENDS) 470dad465e7SJed Brownrun-% : $(OBJDIR)/% 471d1f7f8d3SJed Brown @tests/tap.sh $(<:$(OBJDIR)/%=%) 472686de4acSJed Brown 473686de4acSJed Brownexternal_examples := \ 474686de4acSJed Brown $(if $(MFEM_DIR),$(mfemexamples)) \ 475686de4acSJed Brown $(if $(PETSC_DIR),$(petscexamples)) \ 476b974e86eSJed Brown $(if $(NEK5K_DIR),$(nekexamples)) \ 477ccaff030SJeremy L Thompson $(if $(PETSC_DIR),$(fluidsexamples)) \ 478ccaff030SJeremy L Thompson $(if $(PETSC_DIR),$(solidsexamples)) 479686de4acSJed Brown 480686de4acSJed Brownallexamples = $(examples) $(external_examples) 481686de4acSJed Brown 482686de4acSJed Brown# The test and prove targets can be controlled via pattern searches. The 483686de4acSJed Brown# default is to run tests and those examples that have no external dependencies. 484686de4acSJed Brown# Examples of finer grained control: 485686de4acSJed Brown# 486686de4acSJed Brown# make test search='petsc mfem' # PETSc and MFEM examples 487686de4acSJed Brown# make prove search='t3' # t3xx series tests 488686de4acSJed Brown# make junit search='ex petsc' # core ex* and PETSc tests 489686de4acSJed Brownsearch ?= t ex 490686de4acSJed Brownrealsearch = $(search:%=%%) 491686de4acSJed Brownmatched = $(foreach pattern,$(realsearch),$(filter $(OBJDIR)/$(pattern),$(tests) $(allexamples))) 492686de4acSJed Brown 4932158b1b0Sjeremylt# Test core libCEED 494686de4acSJed Browntest : $(matched:$(OBJDIR)/%=run-%) 4952158b1b0Sjeremylt 49686a4271fSThilina Rathnayake# Run test target in parallel 4976850bcb5Scamierjstst : ;@$(MAKE) $(MFLAGS) V=$(V) test 4983b56482dScamierjs# CPU C tests only for backend % 4993f3e7340Scamierjsctc-% : $(ctests);@$(foreach tst,$(ctests),$(tst) /cpu/$*;) 5004859b599SJed Brown 501686de4acSJed Brownprove : BACKENDS += $(TEST_BACKENDS) 50286a4271fSThilina Rathnayakeprove : $(matched) 503a5dc8077SJed Brown $(info Testing backends: $(BACKENDS)) 504686de4acSJed Brown $(PROVE) $(PROVE_OPTS) --exec 'tests/tap.sh' $(matched:$(OBJDIR)/%=%) 50586a4271fSThilina Rathnayake# Run prove target in parallel 5066850bcb5Scamierjsprv : ;@$(MAKE) $(MFLAGS) V=$(V) prove 507bfa078e6SJed Brown 508686de4acSJed Brownprove-all : 509686de4acSJed Brown +$(MAKE) prove realsearch=% 510686de4acSJed Brown 511686de4acSJed Brownjunit-t% : BACKENDS += $(TEST_BACKENDS) 5128ec9d54bSJed Brownjunit-% : $(OBJDIR)/% 513bdb0bdbbSJed Brown @printf " %10s %s\n" TEST $(<:$(OBJDIR)/%=%); $(PYTHON) tests/junit.py $(<:$(OBJDIR)/%=%) 5148ec9d54bSJed Brown 51576174befSjeremyltjunit : $(matched:$(OBJDIR)/%=junit-%) 5168ec9d54bSJed Brown 5172f4d9adbSJeremy L Thompsonall: $(alltests) 5182f4d9adbSJeremy L Thompson 5192f4d9adbSJeremy L Thompsonexamples : $(allexamples) 52086a4271fSThilina Rathnayakeceedexamples : $(examples) 52186a4271fSThilina Rathnayakenekexamples : $(nekexamples) 52286a4271fSThilina Rathnayakemfemexamples : $(mfemexamples) 52386a4271fSThilina Rathnayakepetscexamples : $(petscexamples) 5242f4d9adbSJeremy L Thompson 5252f4d9adbSJeremy L Thompson# Benchmarks 5260c59ef15SJeremy L Thompsonallbenchmarks = petsc-bps 5274e79ff5bSVeselin Dobrevbench_targets = $(addprefix bench-,$(allbenchmarks)) 5284e79ff5bSVeselin Dobrev.PHONY: $(bench_targets) benchmarks 5294e79ff5bSVeselin Dobrev$(bench_targets): bench-%: $(OBJDIR)/% 5302f4d9adbSJeremy L Thompson cd benchmarks && ./benchmark.sh --ceed "$(BACKENDS)" -r $(*).sh 5314e79ff5bSVeselin Dobrevbenchmarks: $(bench_targets) 5322c6ea02fSJed Brown 5336ea7c6c1SJed Brown$(ceed.pc) : pkgconfig-prefix = $(abspath .) 534d5217624SJed Brown$(OBJDIR)/ceed.pc : pkgconfig-prefix = $(prefix) 535d5217624SJed Brown.INTERMEDIATE : $(OBJDIR)/ceed.pc 5366ea7c6c1SJed Brown%/ceed.pc : ceed.pc.template | $$(@D)/.DIR 5376ea7c6c1SJed Brown @sed "s:%prefix%:$(pkgconfig-prefix):" $< > $@ 5380e439e50SJed Brown 539d5217624SJed Browninstall : $(libceed) $(OBJDIR)/ceed.pc 540bf3e26f6SVeselin Dobrev $(INSTALL) -d $(addprefix $(if $(DESTDIR),"$(DESTDIR)"),"$(includedir)"\ 541*9647a07eSDavid Medina "$(libdir)" "$(pkgconfigdir)") 5421e25a746SJed Brown $(INSTALL_DATA) include/ceed.h "$(DESTDIR)$(includedir)/" 543f91e0974SThilina Rathnayake $(INSTALL_DATA) include/ceedf.h "$(DESTDIR)$(includedir)/" 5441e25a746SJed Brown $(INSTALL_DATA) $(libceed) "$(DESTDIR)$(libdir)/" 5451e25a746SJed Brown $(INSTALL_DATA) $(OBJDIR)/ceed.pc "$(DESTDIR)$(pkgconfigdir)/" 546d5217624SJed Brown 547*9647a07eSDavid Medina.PHONY : cln clean doxygen doc lib install all print test tst prove prv prove-all junit examples style style-c style-py tidy info info-backends 548d635b4c6Scamierjs 5496e5d1fd9Scamierjscln clean : 5505cd88e3aSjeremylt $(RM) -r $(OBJDIR) $(LIBDIR) dist *egg* .pytest_cache *cffi* 55186a4271fSThilina Rathnayake $(MAKE) -C examples clean NEK5K_DIR="$(abspath $(NEK5K_DIR))" 5525cd88e3aSjeremylt $(MAKE) -C tests/python clean 553196a75e4SJed Brown $(RM) benchmarks/*output.txt 5544859b599SJed Brown 55507838a1cSTzaniodistclean : clean 55621d92382SJed Brown $(RM) -r doc/html doc/sphinx/build $(CONFIG) 55707838a1cSTzanio 5584c4400c7SValeria BarraDOXYGEN ?= doxygen 5594c4400c7SValeria Barradoxygen : 5604c4400c7SValeria Barra $(DOXYGEN) Doxyfile 5614c4400c7SValeria Barra 562b4d76956SJed Browndoc-html doc-latexpdf doc-epub : doc-% : doxygen 5634c4400c7SValeria Barra make -C doc/sphinx $* 5644c4400c7SValeria Barra 5654c4400c7SValeria Barradoc : doc-html 5667bd3a522STzanio 5677a7b0fa3SJed Brownstyle-c : 56820b73d85SJed Brown @astyle --options=.astylerc \ 569752c3701SJeremy L Thompson $(filter-out include/ceedf.h $(wildcard tests/t*-f.h), \ 57020b73d85SJed Brown $(wildcard include/*.h interface/*.[ch] tests/*.[ch] backends/*/*.[ch] \ 571ccaff030SJeremy L Thompson examples/*/*/*.[ch] examples/*/*.[ch] examples/*/*.[ch]pp gallery/*/*.[ch])) 5720dbfdfc5SJed Brown 5737a7b0fa3SJed BrownAUTOPEP8 = autopep8 5747a7b0fa3SJed Brownstyle-py : AUTOPEP8_ARGS = --in-place --aggressive 5757a7b0fa3SJed Brownstyle-py : 576dec49e00SJed Brown @$(AUTOPEP8) $(AUTOPEP8_ARGS) $(wildcard *.py python**/*.py tests/python**/*.py examples**/*.py doc/sphinx/source**/*.py benchmarks/*.py) 5777a7b0fa3SJed Brown 5787a7b0fa3SJed Brownstyle : style-c style-py 5797a7b0fa3SJed Brown 580683faae0SJed BrownCLANG_TIDY ?= clang-tidy 581*9647a07eSDavid Medina 582683faae0SJed Brown%.c.tidy : %.c 5834c0d97c4SJeremy L Thompson $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c99 -I$(CUDA_DIR)/include 584683faae0SJed Brown 585*9647a07eSDavid Medina%.cpp.tidy : %.cpp 586*9647a07eSDavid Medina $(CLANG_TIDY) $(TIDY_OPTS) $^ -- $(CPPFLAGS) --std=c++11 -I$(CUDA_DIR)/include -I$(OCCA_DIR)/include 587*9647a07eSDavid Medina 588*9647a07eSDavid Medinatidy_c : $(libceed.c:%=%.tidy) 589*9647a07eSDavid Medinatidy_cpp : $(libceed.cpp:%=%.tidy) 590*9647a07eSDavid Medina 591*9647a07eSDavid Medinatidy : tidy_c tidy_cpp 592683faae0SJed Brown 5934859b599SJed Brownprint : 5944859b599SJed Brown @echo $(VAR)=$($(VAR)) 595582447c9SJed Brown 5969df38c42SVeselin Dobrevprint-% : 5979df38c42SVeselin Dobrev $(info [ variable name]: $*) 5989df38c42SVeselin Dobrev $(info [ origin]: $(origin $*)) 5997bcc1ce4SJed Brown $(info [ flavor]: $(flavor $*)) 6009df38c42SVeselin Dobrev $(info [ value]: $(value $*)) 6019df38c42SVeselin Dobrev $(info [expanded value]: $($*)) 6029df38c42SVeselin Dobrev $(info ) 6039df38c42SVeselin Dobrev @true 6049df38c42SVeselin Dobrev 605b0ab70ddSJed Brown# "make configure" detects any variables passed on the command line or 606b0ab70ddSJed Brown# previously set in config.mk, caching them in config.mk as simple 607b0ab70ddSJed Brown# (:=) variables. Variables set in config.mk or on the command line 608b0ab70ddSJed Brown# take precedence over the defaults provided in the file. Typical 609b0ab70ddSJed Brown# usage: 610d3c6b40fSJed Brown# 611d3c6b40fSJed Brown# make configure CC=/path/to/my/cc CUDA_DIR=/opt/cuda 612d3c6b40fSJed Brown# make 613d3c6b40fSJed Brown# make prove 614b0ab70ddSJed Brown# 615b0ab70ddSJed Brown# The values in the file can be updated by passing them on the command 616b0ab70ddSJed Brown# line, e.g., 617b0ab70ddSJed Brown# 618b0ab70ddSJed Brown# make configure CC=/path/to/other/clang 619b0ab70ddSJed Brown 620b0ab70ddSJed Brown# All variables to consider for caching 62130f4f45fSnbeamsCONFIG_VARS = CC CXX FC NVCC NVCC_CXX HIPCC \ 62230f4f45fSnbeams OPT CFLAGS CPPFLAGS CXXFLAGS FFLAGS NVCCFLAGS HIPCCFLAGS \ 623b0ab70ddSJed Brown LDFLAGS LDLIBS \ 62430f4f45fSnbeams MAGMA_DIR XSMM_DIR CUDA_DIR MFEM_DIR PETSC_DIR NEK5K_DIR HIP_DIR 625b0ab70ddSJed Brown 626b0ab70ddSJed Brown# $(call needs_save,CFLAGS) returns true (a nonempty string) if CFLAGS 627b0ab70ddSJed Brown# was set on the command line or in config.mk (where it will appear as 628b0ab70ddSJed Brown# a simple variable). 629b0ab70ddSJed Brownneeds_save = $(or $(filter command line,$(origin $(1))),$(filter simple,$(flavor $(1)))) 630b0ab70ddSJed Brown 631d3c6b40fSJed Brownconfigure : 632b0ab70ddSJed Brown $(file > $(CONFIG)) 633b0ab70ddSJed Brown $(foreach v,$(CONFIG_VARS),$(if $(call needs_save,$(v)),$(file >> $(CONFIG),$(v) := $($(v))))) 634b0ab70ddSJed Brown @echo "Configuration cached in $(CONFIG):" 635b0ab70ddSJed Brown @cat $(CONFIG) 636d3c6b40fSJed Brown 63761130325SJed Brownwheel : export MARCHFLAG = -march=generic 63861130325SJed Brownwheel : export WHEEL_PLAT = manylinux2010_x86_64 63937c134eaSJed Brownwheel : 640dabe13fcSJed Brown docker run -it --user $(shell id -u):$(shell id -g) --rm -v $(PWD):/io -w /io \ 64161130325SJed Brown -e MARCHFLAG -e WHEEL_PLAT \ 64261130325SJed Brown quay.io/pypa/$(WHEEL_PLAT) python/make-wheels.sh 643d3c6b40fSJed Brown 64437c134eaSJed Brown.PHONY : configure wheel 64537c134eaSJed Brown 64637c134eaSJed Brown# Include *.d deps when not -B = --always-make: useful if the paths are wonky in a container 64737c134eaSJed Brown-include $(if $(filter B,$(MAKEFLAGS)),,$(libceed.c:%.c=$(OBJDIR)/%.d) $(tests.c:tests/%.c=$(OBJDIR)/%.d)) 648