10006be33SJames WrightCONFIG ?= config.mk 2066464baSJames Wright-include $(CONFIG) 30006be33SJames WrightCOMMON ?= common.mk 44f863122SJeremy L Thompson-include $(COMMON) 54f863122SJeremy L Thompson 60006be33SJames Wrightpkgconf-path = $(if $(wildcard $(1)/$(2).pc),$(1)/$(2).pc,$(2)) 7ea10196cSJeremy L Thompson 80006be33SJames Wright# Library dependencies 90006be33SJames Wright# Note: PETSC_ARCH can be undefined or empty for installations which do not use 100006be33SJames Wright# PETSC_ARCH - for example when using PETSc installed through Spack. 110006be33SJames Wrightifneq ($(wildcard ../petsc/lib/libpetsc.*),) 120006be33SJames Wright PETSC_DIR ?= ../petsc 130006be33SJames Wrightendif 140006be33SJames Wrightpetsc.pc := $(call pkgconf-path,$(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig,petsc) 150006be33SJames Wright 160006be33SJames WrightCEED_DIR ?= $(if $(wildcard $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/ceed.pc),$(PETSC_DIR)/$(PETSC_ARCH),../libCEED) 170006be33SJames Wrightceed.pc := $(call pkgconf-path,$(CEED_DIR)/lib/pkgconfig,ceed) 180006be33SJames Wright 19a39fefe2SJeremy L Thompsonpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | $(SED) -e 's/^"//g' -e 's/"$$//g') 200006be33SJames Wright 210006be33SJames Wright# Error checking flags 220006be33SJames WrightPEDANTIC ?= 230006be33SJames WrightPEDANTICFLAGS ?= -Werror -pedantic 240006be33SJames Wright 250006be33SJames WrightCC = $(call pkgconf, --variable=ccompiler $(petsc.pc) $(ceed.pc)) 26a515125bSLeila GhaffariCFLAGS = -std=c99 \ 270006be33SJames Wright $(call pkgconf, --variable=cflags_extra $(petsc.pc)) \ 280006be33SJames Wright $(call pkgconf, --cflags-only-other $(petsc.pc)) \ 290006be33SJames Wright $(OPT) 300006be33SJames WrightCPPFLAGS = $(call pkgconf, --cflags-only-I $(petsc.pc) $(ceed.pc)) \ 310006be33SJames Wright $(call pkgconf, --variable=cflags_dep $(petsc.pc)) 320006be33SJames WrightCXX = $(call pkgconf, --variable=cxxcompiler $(petsc.pc) $(ceed.pc)) 334c07ec22SJames WrightCXXFLAGS = -std=c++17 -Wno-deprecated -Wno-tautological-compare 340006be33SJames WrightLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(petsc.pc) $(ceed.pc)) 350006be33SJames WrightLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(petsc.pc))%, $(call pkgconf, --libs-only-L $(petsc.pc) $(ceed.pc))) 360006be33SJames WrightLDLIBS = $(call pkgconf, --libs-only-l $(petsc.pc) $(ceed.pc)) -lm -lstdc++ 37ea10196cSJeremy L Thompson 384c07ec22SJames Wright# ASAN must be left empty if you don't want to use it 394c07ec22SJames WrightASAN ?= 400006be33SJames Wright 414c07ec22SJames WrightAFLAGS ?= -fsanitize=address 427df379d9SJames WrightCFLAGS += $(if $(ASAN),$(AFLAGS)) 437df379d9SJames WrightFFLAGS += $(if $(ASAN),$(AFLAGS)) 447df379d9SJames WrightLDFLAGS += $(if $(ASAN),$(AFLAGS)) 450006be33SJames Wright 4645101827SJames WrightCPPFLAGS += -I./include 477df379d9SJames Wright 48a39fefe2SJeremy L Thompson# External tools 49a39fefe2SJeremy L ThompsonPYTHON ?= python3 50a39fefe2SJeremy L ThompsonSED ?= sed 51a39fefe2SJeremy L Thompson 524c07ec22SJames Wright# LibTorch 534c07ec22SJames WrightUSE_TORCH ?= 544c07ec22SJames Wrightifeq ($(USE_TORCH),1) 55a39fefe2SJeremy L Thompson libtorch.pc := $(shell $(PYTHON) ./pytorch_pkgconfig.py) 564c07ec22SJames Wright CPPFLAGS += $(call pkgconf, --cflags-only-I $(libtorch.pc)) 574c07ec22SJames Wright CXXFLAGS += $(call pkgconf, --cflags-only-other $(libtorch.pc)) 584c07ec22SJames Wright LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(libtorch.pc)) 590006be33SJames Wright LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(petsc.pc))%, $(call pkgconf, --libs-only-L $(libtorch.pc))) 604c07ec22SJames Wright LDLIBS += $(call pkgconf, --libs-only-l $(libtorch.pc)) 614c07ec22SJames Wright 624c07ec22SJames Wright src.cpp += $(sort $(wildcard $(PROBLEMDIR)/torch/*.cpp)) 634c07ec22SJames Wright src.c += $(sort $(wildcard $(PROBLEMDIR)/torch/*.c)) 644c07ec22SJames Wright 654c07ec22SJames Wright # Intel Pytorch EXtension (IPEX) 664c07ec22SJames Wright IPEX_DIR ?= 674c07ec22SJames Wright ifdef IPEX_DIR 684c07ec22SJames Wright LDFLAGS += -L$(IPEX_DIR)/lib/ 694c07ec22SJames Wright LDFLAGS += -Wl,-rpath,$(IPEX_DIR)/lib/ 704c07ec22SJames Wright LDLIBS += -lintel-ext-pt-gpu 714c07ec22SJames Wright endif 724c07ec22SJames Wrightendif 734c07ec22SJames Wright 744c07ec22SJames Wright# Source Files 75a515125bSLeila GhaffariOBJDIR := build 76a515125bSLeila GhaffariSRCDIR := src 77a515125bSLeila GhaffariPROBLEMDIR := problems 78ea10196cSJeremy L Thompson 79*149fb536SJames Wrightsrc.c := examples/navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c)) 804c07ec22SJames Wrightsrc.o = $(src.c:%.c=$(OBJDIR)/%.o) $(src.cpp:%.cpp=$(OBJDIR)/%.o) 81a515125bSLeila Ghaffari 829e6f9b5eSJames Wright# Path to install directory for SmartRedis. Example: /software/smartredis/install 839e6f9b5eSJames WrightSMARTREDIS_DIR ?= 849e6f9b5eSJames Wrightifdef SMARTREDIS_DIR 859e6f9b5eSJames Wright hiredis.pc := $(SMARTREDIS_DIR)/lib/pkgconfig/hiredis.pc 869e6f9b5eSJames Wright lsmartredis:= -lsmartredis 879e6f9b5eSJames Wright redis++.pc = $(wildcard $(SMARTREDIS_DIR)/lib/pkgconfig/redis++.pc $(SMARTREDIS_DIR)/lib64/pkgconfig/redis++.pc) 889e6f9b5eSJames Wright 899e6f9b5eSJames Wright CPPFLAGS += $(call pkgconf, --cflags-only-I $(hiredis.pc) $(redis++.pc)) 909e6f9b5eSJames Wright LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(hiredis.pc) $(redis++.pc)) 910006be33SJames Wright LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(petsc.pc))%, $(call pkgconf, --libs-only-L $(hiredis.pc) $(redis++.pc))) 929e6f9b5eSJames Wright LDLIBS += $(call pkgconf, --libs-only-l $(hiredis.pc) $(redis++.pc)) $(lsmartredis) 939e6f9b5eSJames Wright src.c += $(sort $(wildcard $(SRCDIR)/smartsim/*.c)) 949e6f9b5eSJames Wrightendif 952120e86cSJeremy L Thompson 96947fa354SJeremy L Thompsonall: navierstokes 972120e86cSJeremy L Thompson 982120e86cSJeremy L Thompson# Diagnostic information 992120e86cSJeremy L Thompsoninfo-basic: 1002120e86cSJeremy L Thompson $(info -----------------------------------------) 1012120e86cSJeremy L Thompson $(info | __ ______ _ ______________ |) 1022120e86cSJeremy L Thompson $(info | / / / / __ \/ | / / ____/ ____/ |) 1032120e86cSJeremy L Thompson $(info | / /_/ / / / / |/ / __/ / __/ |) 1042120e86cSJeremy L Thompson $(info | / __ / /_/ / /| / /___/ /___ |) 1052120e86cSJeremy L Thompson $(info | /_/ /_/\____/_/ |_/_____/_____/ |) 1062120e86cSJeremy L Thompson $(info -----------------------------------------) 1072120e86cSJeremy L Thompson $(info ) 1082120e86cSJeremy L Thompson $(info -----------------------------------------) 1092120e86cSJeremy L Thompson $(info ) 1102120e86cSJeremy L Thompson $(info Dependencies:) 1112120e86cSJeremy L Thompson $(info CEED_DIR = $(CEED_DIR)) 1122120e86cSJeremy L Thompson $(info PETSC_DIR = $(PETSC_DIR)) 1132120e86cSJeremy L Thompson $(info PETSC_ARCH = $(PETSC_ARCH)) 1142120e86cSJeremy L Thompson $(info ) 1152120e86cSJeremy L Thompson $(info Optional Dependencies:) 1162120e86cSJeremy L Thompson $(info SMARTREDIS_DIR = $(or $(SMARTREDIS_DIR),(not found))) 1172120e86cSJeremy L Thompson $(info USE_TORCH = $(USE_TORCH)) 1182120e86cSJeremy L Thompson $(info ) 1192120e86cSJeremy L Thompson $(info -----------------------------------------) 1202120e86cSJeremy L Thompson $(info ) 1212120e86cSJeremy L Thompson @true 1222120e86cSJeremy L Thompson 1232120e86cSJeremy L Thompsoninfo: 1242120e86cSJeremy L Thompson $(info -----------------------------------------) 1252120e86cSJeremy L Thompson $(info | __ ______ _ ______________ |) 1262120e86cSJeremy L Thompson $(info | / / / / __ \/ | / / ____/ ____/ |) 1272120e86cSJeremy L Thompson $(info | / /_/ / / / / |/ / __/ / __/ |) 1282120e86cSJeremy L Thompson $(info | / __ / /_/ / /| / /___/ /___ |) 1292120e86cSJeremy L Thompson $(info | /_/ /_/\____/_/ |_/_____/_____/ |) 1302120e86cSJeremy L Thompson $(info -----------------------------------------) 1312120e86cSJeremy L Thompson $(info ) 1322120e86cSJeremy L Thompson $(info -----------------------------------------) 1332120e86cSJeremy L Thompson $(info ) 1342120e86cSJeremy L Thompson $(info Dependencies:) 1352120e86cSJeremy L Thompson $(info CEED_DIR = $(CEED_DIR)) 1362120e86cSJeremy L Thompson $(info PETSC_DIR = $(PETSC_DIR)) 1372120e86cSJeremy L Thompson $(info PETSC_ARCH = $(PETSC_ARCH)) 1382120e86cSJeremy L Thompson $(info ) 1392120e86cSJeremy L Thompson $(info Optional Dependencies:) 1402120e86cSJeremy L Thompson $(info SMARTREDIS_DIR = $(or $(SMARTREDIS_DIR),(not found))) 1412120e86cSJeremy L Thompson $(info USE_TORCH = $(USE_TORCH)) 1422120e86cSJeremy L Thompson $(info ) 1432120e86cSJeremy L Thompson $(info -----------------------------------------) 1442120e86cSJeremy L Thompson $(info ) 1452120e86cSJeremy L Thompson $(info Build Options:) 1462120e86cSJeremy L Thompson $(info CC = $(CC)) 1472120e86cSJeremy L Thompson $(info CFLAGS = $(CFLAGS)) 1482120e86cSJeremy L Thompson $(info CPPFLAGS = $(CPPFLAGS)) 1492120e86cSJeremy L Thompson $(info LDFLAGS = $(LDFLAGS)) 1502120e86cSJeremy L Thompson $(info LDLIBS = $(LDLIBS)) 1512120e86cSJeremy L Thompson $(info AR = $(AR)) 1522120e86cSJeremy L Thompson $(info ARFLAGS = $(ARFLAGS)) 1532120e86cSJeremy L Thompson $(info OPT = $(OPT)) 1542120e86cSJeremy L Thompson $(info AFLAGS = $(AFLAGS)) 1552120e86cSJeremy L Thompson $(info ASAN = $(or $(ASAN),(empty))) 1562120e86cSJeremy L Thompson $(info VERBOSE = $(or $(V),(empty)) [verbose=$(if $(V),on,off)]) 1572120e86cSJeremy L Thompson $(info ) 1582120e86cSJeremy L Thompson $(info -----------------------------------------) 1592120e86cSJeremy L Thompson $(info ) 1602120e86cSJeremy L Thompson $(info Format and Style Options:) 1612120e86cSJeremy L Thompson $(info CLANG_FORMAT = $(CLANG_FORMAT)) 1622120e86cSJeremy L Thompson $(info FORMAT_OPTS = $(FORMAT_OPTS)) 1632120e86cSJeremy L Thompson $(info CLANG_TIDY = $(CLANG_TIDY)) 1642120e86cSJeremy L Thompson $(info TIDY_OPTS = $(TIDY_OPTS)) 1652120e86cSJeremy L Thompson $(info TIDY_FILE_OPTS = $(TIDY_FILE_OPTS)) 1662120e86cSJeremy L Thompson $(info ) 1672120e86cSJeremy L Thompson $(info -----------------------------------------) 1682120e86cSJeremy L Thompson $(info ) 1692120e86cSJeremy L Thompson @true 1709e6f9b5eSJames Wright 171d9688174SJeremy L Thompson# Get number of processors of the machine 172d9688174SJeremy L ThompsonNPROCS := $(shell getconf _NPROCESSORS_ONLN) 173d9688174SJeremy L Thompson# prepare make options to run in parallel 174d9688174SJeremy L ThompsonMFLAGS := -j $(NPROCS) --warn-undefined-variables \ 175d9688174SJeremy L Thompson --no-print-directory --no-keep-going 176d9688174SJeremy L Thompson 1770006be33SJames Wright$(OBJDIR)/navierstokes: $(src.o) | navierstokes 1780006be33SJames Wrightnavierstokes: $(src.o) | $(petsc.pc) $(ceed.pc) 1790006be33SJames Wright $(call quiet,LINK.o) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $(OBJDIR)/$@ 180a515125bSLeila Ghaffari 181a515125bSLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR 182a515125bSLeila Ghaffari%/.DIR : 183a515125bSLeila Ghaffari @mkdir -p $(@D) 184a515125bSLeila Ghaffari @touch $@ 185ea10196cSJeremy L Thompson 1864f863122SJeremy L Thompson# Quiet, color output 1874f863122SJeremy L Thompsonquiet ?= $($(1)) 1884f863122SJeremy L Thompson 189b03da087SJames Wright$(OBJDIR)/%.o : %.c | $$(@D)/.DIR 190a515125bSLeila Ghaffari $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 191a515125bSLeila Ghaffari 192b03da087SJames Wright$(OBJDIR)/%.o : %.cpp | $$(@D)/.DIR 1934c07ec22SJames Wright $(call quiet,CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(abspath $<) 1944c07ec22SJames Wright 1950006be33SJames Wrightprint: $(petsc.pc) $(ceed.pc) 196ea10196cSJeremy L Thompson $(info CC : $(CC)) 197ea10196cSJeremy L Thompson $(info CFLAGS : $(CFLAGS)) 198ea10196cSJeremy L Thompson $(info CPPFLAGS: $(CPPFLAGS)) 199ea10196cSJeremy L Thompson $(info LDFLAGS : $(LDFLAGS)) 200ea10196cSJeremy L Thompson $(info LDLIBS : $(LDLIBS)) 201ea10196cSJeremy L Thompson $(info OPT : $(OPT)) 202ea10196cSJeremy L Thompson @true 203ea10196cSJeremy L Thompson 2040e8fe9d5SJames Wrightprint-% : 2050e8fe9d5SJames Wright $(info [ variable name]: $*) 2060e8fe9d5SJames Wright $(info [ origin]: $(origin $*)) 2070e8fe9d5SJames Wright $(info [ flavor]: $(flavor $*)) 2080e8fe9d5SJames Wright $(info [ value]: $(value $*)) 2090e8fe9d5SJames Wright $(info [expanded value]: $($*)) 2100e8fe9d5SJames Wright $(info ) 2110e8fe9d5SJames Wright @true 2120e8fe9d5SJames Wright 213ea10196cSJeremy L Thompsonclean: 214a515125bSLeila Ghaffari $(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png 215ea10196cSJeremy L Thompson 2160006be33SJames Wright$(petsc.pc): 217ea10196cSJeremy L Thompson $(if $(wildcard $@),,$(error \ 218ea10196cSJeremy L Thompson PETSc config not found. Please set PETSC_DIR and PETSC_ARCH)) 219ea10196cSJeremy L Thompson 220ea10196cSJeremy L Thompson.PHONY: all print clean 221ea10196cSJeremy L Thompson 222aa34f9e7SJames Wright# Define test files 223*149fb536SJames Wrightexamples.c := $(sort $(wildcard examples/*.c)) 224*149fb536SJames Wrightexamples := $(examples.c:examples/%.c=$(OBJDIR)/%) 22567f3e659SJames Wrighttests.smartsim := test-smartsim 22667f3e659SJames Wrighttests += $(tests.smartsim:%=$(OBJDIR)/%) 2270006be33SJames Wright 22867f3e659SJames Wright$(tests.smartsim:%=$(OBJDIR)/%): $(OBJDIR)/navierstokes 2290006be33SJames Wright 230965d9f74SJames Wright# Documentation 231965d9f74SJames WrightDOXYGEN ?= doxygen 232965d9f74SJames WrightDOXYGENOPTS ?= -q 233965d9f74SJames Wrightdoxygen : 234965d9f74SJames Wright $(DOXYGEN) $(DOXYGENOPTS) Doxyfile 235965d9f74SJames Wright 236965d9f74SJames WrightSPHINXOPTS = 237965d9f74SJames WrightSPHINXBUILD = sphinx-build 238965d9f74SJames WrightSPHINXAUTOBUILD = sphinx-autobuild 23967f3e659SJames WrightSPHINXPROJ = HONEE 240965d9f74SJames WrightSPHINXBUILDDIR = doc/build 241965d9f74SJames Wright 242965d9f74SJames Wrightdoc-html doc-dirhtml doc-latexpdf doc-epub doc-help : doc-% : doxygen 243965d9f74SJames Wright @$(SPHINXBUILD) -M $* . "$(SPHINXBUILDDIR)" $(SPHINXOPTS) 244965d9f74SJames Wright 245965d9f74SJames Wrightdoc-livehtml : doxygen 246965d9f74SJames Wright @$(SPHINXAUTOBUILD) . "$(SPHINXBUILDDIR)" $(SPHINXOPTS) 247965d9f74SJames Wright 248965d9f74SJames Wrightdoc : doc-html 249965d9f74SJames Wright 250965d9f74SJames Wrightdoc-clean: 251965d9f74SJames Wright $(RM) -r doc/html doc/build 252965d9f74SJames Wright 253a39fefe2SJeremy L Thompson# Tidy 254a39fefe2SJeremy L ThompsonCLANG_TIDY ?= clang-tidy 255a39fefe2SJeremy L ThompsonTIDY_OPTS ?= --quiet 256a39fefe2SJeremy L ThompsonTIDY_FILE_OPTS += $(CPPFLAGS) --std=c99 257a39fefe2SJeremy L Thompson 258a39fefe2SJeremy L Thompson%.c.tidy : %.c 259a39fefe2SJeremy L Thompson $(call quiet,CLANG_TIDY) $(TIDY_OPTS) $^ -- $(TIDY_FILE_OPTS) 260a39fefe2SJeremy L Thompson 261a39fefe2SJeremy L Thompsontidy-c : $(src.c:%=%.tidy) 262a39fefe2SJeremy L Thompson 263a39fefe2SJeremy L Thompsontidy : tidy-c 264a39fefe2SJeremy L Thompson 265a39fefe2SJeremy L Thompson# Style 266a39fefe2SJeremy L ThompsonCLANG_FORMAT ?= clang-format 267a39fefe2SJeremy L ThompsonFORMAT_OPTS += -style=file -i 268a39fefe2SJeremy L ThompsonAUTOPEP8 ?= autopep8 269a39fefe2SJeremy L ThompsonAUTOPEP8_OPTS += --in-place --aggressive --max-line-length 120 270a39fefe2SJeremy L ThompsonSED_FMT_OPTS += -r 's/\s+$$//' -i 271a39fefe2SJeremy L Thompson 272a39fefe2SJeremy L Thompson%.format : % 273a39fefe2SJeremy L Thompson $(call quiet,CLANG_FORMAT) $(FORMAT_OPTS) $^ 274a39fefe2SJeremy L Thompson 27542aed787SJames Wrightformat.ch := $(shell git ls-files '*.[ch]pp' '*.[ch]') 276a39fefe2SJeremy L Thompsonformat.py := $(filter-out tests/junit-xml/junit_xml/__init__.py, $(shell git ls-files '*.py')) 27742aed787SJames Wrightformat.ot := $(shell git ls-files '*.md') 278a39fefe2SJeremy L Thompson 279a39fefe2SJeremy L Thompsonformat-c : 280a39fefe2SJeremy L Thompson $(call quiet,CLANG_FORMAT) $(FORMAT_OPTS) $(format.ch) 281a39fefe2SJeremy L Thompson 282a39fefe2SJeremy L Thompsonformat-py : 283a39fefe2SJeremy L Thompson $(call quiet,AUTOPEP8) $(AUTOPEP8_OPTS) $(format.py) 284a39fefe2SJeremy L Thompson 285a39fefe2SJeremy L Thompsonformat-ot : 286a39fefe2SJeremy L Thompson $(call quiet,SED) $(SED_FMT_OPTS) $(format.ot) 287a39fefe2SJeremy L Thompson 288a39fefe2SJeremy L Thompsonformat : format-c format-py format-ot 289a39fefe2SJeremy L Thompson 2900006be33SJames Wright# Testing 2910006be33SJames Wrightifeq ($(COVERAGE), 1) 2920006be33SJames Wright CFLAGS += --coverage 2930006be33SJames Wright LDFLAGS += --coverage 2940006be33SJames Wrightendif 2950006be33SJames Wright 2960006be33SJames WrightPROVE ?= prove 2970006be33SJames WrightPROVE_OPTS ?= -j $(NPROCS) 2980006be33SJames Wright 2990006be33SJames Wright# Set libCEED backends for testing 3000006be33SJames WrightCEED_BACKENDS ?= /cpu/self 3010006be33SJames Wrightexport CEED_BACKENDS 3020006be33SJames Wright 3030006be33SJames Wright# Set number processes for testing 3040006be33SJames WrightNPROC_TEST ?= 1 3050006be33SJames Wrightexport NPROC_TEST 3060006be33SJames Wright 3070006be33SJames Wright# Set pool size for testing 3080006be33SJames WrightNPROC_POOL ?= 1 3090006be33SJames Wrightexport NPROC_POOL 3100006be33SJames Wright 3110006be33SJames WrightJUNIT_BATCH ?= '' 3120006be33SJames Wright 3130006be33SJames Wrightrun-% : $(OBJDIR)/% 3140006be33SJames Wright @$(PYTHON) tests/junit.py --ceed-backends $(CEED_BACKENDS) --mode tap $(if $(SMARTREDIS_DIR),--smartredis_dir $(SMARTREDIS_DIR) ) $(if $(USE_TORCH),--has_torch $(USE_TORCH) )--nproc $(NPROC_TEST) --pool-size $(NPROC_POOL) $(<:$(OBJDIR)/%=%) 3150006be33SJames Wright 3160006be33SJames Wright# The test and prove targets can be controlled via pattern searches. The default 3170006be33SJames Wright# is to run all tests and examples. Examples of finer grained control: 3180006be33SJames Wright# 3190006be33SJames Wright# make prove search='t3' # t3xx series tests 3200006be33SJames Wright# make junit search='t ex' # core tests and examples 3210006be33SJames Wrightsearch ?= navierstokes 3220006be33SJames Wrightrealsearch = $(search:%=%%) 3230006be33SJames Wrightmatched = $(foreach pattern,$(realsearch),$(filter $(OBJDIR)/$(pattern),$(tests) $(examples))) 3240006be33SJames Wright 3250006be33SJames Wright# Test 3260006be33SJames Wrighttest : $(matched:$(OBJDIR)/%=run-%) 3270006be33SJames Wright 3280006be33SJames Wrighttst : ;@$(MAKE) $(MFLAGS) V=$(V) test 3290006be33SJames Wright 3300006be33SJames Wright# Test with TAP output 3310006be33SJames Wrightprove : $(matched) 3320006be33SJames Wright $(info Running unit tests) 3330006be33SJames Wright $(info - Testing with libCEED backends: $(CEED_BACKENDS)) 3340006be33SJames Wright $(info - Testing on $(NPROC_TEST) processes) 335d9688174SJeremy L Thompson $(PROVE) $(PROVE_OPTS) --exec '$(PYTHON) tests/junit.py --ceed-backends $(CEED_BACKENDS) --mode tap $(if $(SMARTREDIS_DIR),--smartredis_dir $(SMARTREDIS_DIR) ) $(if $(USE_TORCH),--has_torch $(USE_TORCH) )--nproc $(NPROC_TEST) --pool-size $(NPROC_POOL)' $(matched:$(OBJDIR)/%=%) 3360006be33SJames Wright 3370006be33SJames Wrightprv : ;@$(MAKE) $(MFLAGS) V=$(V) prove 3380006be33SJames Wright 3390006be33SJames Wrightprove-all : 3400006be33SJames Wright +$(MAKE) prove realsearch=% 3410006be33SJames Wright 3420006be33SJames Wright# Test with JUNIT output 3430006be33SJames Wrightjunit-% : $(OBJDIR)/% 344d9688174SJeremy L Thompson @printf " %10s %s\n" TEST $(<:$(OBJDIR)/%=%); $(PYTHON) tests/junit.py --junit-batch $(JUNIT_BATCH) --ceed-backends $(CEED_BACKENDS) $(if $(SMARTREDIS_DIR),--smartredis_dir $(SMARTREDIS_DIR) ) $(if $(USE_TORCH),--has_torch $(USE_TORCH) )--nproc $(NPROC_TEST) --pool-size $(NPROC_POOL) $(<:$(OBJDIR)/%=%) 3450006be33SJames Wright 3460006be33SJames Wrightjunit : $(matched:$(OBJDIR)/%=junit-%) 3470006be33SJames Wright 3480006be33SJames Wright 3490006be33SJames Wright# Configure 3500006be33SJames Wright# "make configure" detects any variables passed on the command line or 3510006be33SJames Wright# previously set in config.mk, caching them in config.mk as simple 3520006be33SJames Wright# (:=) variables. Variables set in config.mk or on the command line 3530006be33SJames Wright# take precedence over the defaults provided in the file. Typical 3540006be33SJames Wright# usage: 3550006be33SJames Wright# 3560006be33SJames Wright# make configure CC=/path/to/my/cc CUDA_DIR=/opt/cuda 3570006be33SJames Wright# make 3580006be33SJames Wright# make prove 3590006be33SJames Wright# 3600006be33SJames Wright# The values in the file can be updated by passing them on the command 3610006be33SJames Wright# line, e.g., 3620006be33SJames Wright# 3630006be33SJames Wright# make configure CC=/path/to/other/clang 3640006be33SJames Wright 3650006be33SJames Wright# All variables to consider for caching 3660006be33SJames WrightCONFIG_VARS = CEED_DIR PETSC_DIR PETSC_ARCH CCOPT CFLAGS CPPFLAGS AR ARFLAGS LDFLAGS LDLIBS SED USE_TORCH SMARTREDIS_DIR 3670006be33SJames Wright 3680006be33SJames Wright# $(call needs_save,CFLAGS) returns true (a nonempty string) if CFLAGS 3690006be33SJames Wright# was set on the command line or in config.mk (where it will appear as 3700006be33SJames Wright# a simple variable). 3710006be33SJames Wrightneeds_save = $(or $(filter command line,$(origin $(1))),$(filter simple,$(flavor $(1)))) 3720006be33SJames Wright 3730006be33SJames Wrightconfigure : 3740006be33SJames Wright $(file > $(CONFIG)) 3750006be33SJames Wright $(foreach v,$(CONFIG_VARS),$(if $(call needs_save,$(v)),$(file >> $(CONFIG),$(v) := $($(v))))) 3760006be33SJames Wright @echo "Configuration cached in $(CONFIG):" 3770006be33SJames Wright @cat $(CONFIG) 378a515125bSLeila Ghaffari 379a515125bSLeila Ghaffari-include $(src.o:%.o=%.d) 380