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