1ea10196cSJeremy L Thompson# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2ea10196cSJeremy L Thompson# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3ea10196cSJeremy L Thompson# reserved. See files LICENSE and NOTICE for details. 4ea10196cSJeremy L Thompson# 5ea10196cSJeremy L Thompson# This file is part of CEED, a collection of benchmarks, miniapps, software 6ea10196cSJeremy L Thompson# libraries and APIs for efficient high-order finite element and spectral 7ea10196cSJeremy L Thompson# element discretizations for exascale applications. For more information and 8727da7e7SJeremy L Thompson# source code availability see http://github.com/ceed 9ea10196cSJeremy L Thompson# 10ea10196cSJeremy L Thompson# The CEED research is supported by the Exascale Computing Project (17-SC-20-SC) 11ea10196cSJeremy L Thompson# a collaborative effort of two U.S. Department of Energy organizations (Office 12ea10196cSJeremy L Thompson# of Science and the National Nuclear Security Administration) responsible for 13ea10196cSJeremy L Thompson# the planning and preparation of a capable exascale ecosystem, including 14ea10196cSJeremy L Thompson# software, applications, hardware, advanced system engineering and early 15ea10196cSJeremy L Thompson# testbed platforms, in support of the nation's exascale computing imperative. 16ea10196cSJeremy L Thompson 17066464baSJames WrightCONFIG ?= ../../config.mk 18066464baSJames Wright-include $(CONFIG) 194f863122SJeremy L ThompsonCOMMON ?= ../../common.mk 204f863122SJeremy L Thompson-include $(COMMON) 214f863122SJeremy L Thompson 22ea10196cSJeremy L ThompsonPETSc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/PETSc.pc 23ea10196cSJeremy L ThompsonCEED_DIR ?= ../.. 24ea10196cSJeremy L Thompsonceed.pc := $(CEED_DIR)/lib/pkgconfig/ceed.pc 25ea10196cSJeremy L Thompson 26ea10196cSJeremy L ThompsonCC = $(call pkgconf, --variable=ccompiler $(PETSc.pc) $(ceed.pc)) 27a515125bSLeila GhaffariCFLAGS = -std=c99 \ 28a515125bSLeila Ghaffari $(call pkgconf, --variable=cflags_extra $(PETSc.pc)) \ 29a515125bSLeila Ghaffari $(call pkgconf, --cflags-only-other $(PETSc.pc)) \ 30f0b65372SJed Brown $(OPT) $(OPT_EXAMPLES) 31a515125bSLeila GhaffariCPPFLAGS = $(call pkgconf, --cflags-only-I $(PETSc.pc) $(ceed.pc)) \ 32a515125bSLeila Ghaffari $(call pkgconf, --variable=cflags_dep $(PETSc.pc)) 33*4c07ec22SJames WrightCXX = $(call pkgconf, --variable=cxxcompiler $(PETSc.pc) $(ceed.pc)) 34*4c07ec22SJames WrightCXXFLAGS = -std=c++17 -Wno-deprecated -Wno-tautological-compare 35ea10196cSJeremy L ThompsonLDFLAGS = $(call pkgconf, --libs-only-L --libs-only-other $(PETSc.pc) $(ceed.pc)) 36ea10196cSJeremy L ThompsonLDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(PETSc.pc) $(ceed.pc))) 37*4c07ec22SJames WrightLDLIBS = $(call pkgconf, --libs-only-l $(PETSc.pc) $(ceed.pc)) -lm -lstdc++ 38ea10196cSJeremy L Thompson 39*4c07ec22SJames Wright# Address Sanitizer Setup 40*4c07ec22SJames Wright# ASAN must be left empty if you don't want to use it 41*4c07ec22SJames WrightASAN ?= 42*4c07ec22SJames WrightAFLAGS ?= -fsanitize=address 43*4c07ec22SJames Wright# Also: -fsanitize=undefined -fno-omit-frame-pointer 447df379d9SJames WrightCFLAGS += $(if $(ASAN),$(AFLAGS)) 457df379d9SJames WrightFFLAGS += $(if $(ASAN),$(AFLAGS)) 467df379d9SJames WrightLDFLAGS += $(if $(ASAN),$(AFLAGS)) 4745101827SJames WrightCPPFLAGS += -I./include 487df379d9SJames Wright 49*4c07ec22SJames Wright# LibTorch 50*4c07ec22SJames WrightUSE_TORCH ?= 51*4c07ec22SJames Wrightifeq ($(USE_TORCH),1) 52*4c07ec22SJames Wright libtorch.pc := $(shell python ./pytorch_pkgconfig.py) 53*4c07ec22SJames Wright CPPFLAGS += $(call pkgconf, --cflags-only-I $(libtorch.pc)) 54*4c07ec22SJames Wright CXXFLAGS += $(call pkgconf, --cflags-only-other $(libtorch.pc)) 55*4c07ec22SJames Wright LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(libtorch.pc)) 56*4c07ec22SJames Wright LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(libtorch.pc))) 57*4c07ec22SJames Wright LDLIBS += $(call pkgconf, --libs-only-l $(libtorch.pc)) 58*4c07ec22SJames Wright 59*4c07ec22SJames Wright src.cpp += $(sort $(wildcard $(PROBLEMDIR)/torch/*.cpp)) 60*4c07ec22SJames Wright src.c += $(sort $(wildcard $(PROBLEMDIR)/torch/*.c)) 61*4c07ec22SJames Wright 62*4c07ec22SJames Wright # Intel Pytorch EXtension (IPEX) 63*4c07ec22SJames Wright IPEX_DIR ?= 64*4c07ec22SJames Wright ifdef IPEX_DIR 65*4c07ec22SJames Wright LDFLAGS += -L$(IPEX_DIR)/lib/ 66*4c07ec22SJames Wright LDFLAGS += -Wl,-rpath,$(IPEX_DIR)/lib/ 67*4c07ec22SJames Wright LDLIBS += -lintel-ext-pt-gpu 68*4c07ec22SJames Wright endif 69*4c07ec22SJames Wrightendif 70*4c07ec22SJames Wright 71*4c07ec22SJames Wright# Source Files 72a515125bSLeila GhaffariOBJDIR := build 73a515125bSLeila GhaffariSRCDIR := src 74a515125bSLeila GhaffariPROBLEMDIR := problems 75ea10196cSJeremy L Thompson 76a515125bSLeila Ghaffarisrc.c := navierstokes.c $(sort $(wildcard $(PROBLEMDIR)/*.c)) $(sort $(wildcard $(SRCDIR)/*.c)) 77*4c07ec22SJames Wrightsrc.o = $(src.c:%.c=$(OBJDIR)/%.o) $(src.cpp:%.cpp=$(OBJDIR)/%.o) 78a515125bSLeila Ghaffari 799e6f9b5eSJames Wright# Path to install directory for SmartRedis. Example: /software/smartredis/install 809e6f9b5eSJames WrightSMARTREDIS_DIR ?= 819e6f9b5eSJames Wrightifdef SMARTREDIS_DIR 829e6f9b5eSJames Wright hiredis.pc := $(SMARTREDIS_DIR)/lib/pkgconfig/hiredis.pc 839e6f9b5eSJames Wright lsmartredis:= -lsmartredis 849e6f9b5eSJames Wright redis++.pc = $(wildcard $(SMARTREDIS_DIR)/lib/pkgconfig/redis++.pc $(SMARTREDIS_DIR)/lib64/pkgconfig/redis++.pc) 859e6f9b5eSJames Wright 869e6f9b5eSJames Wright CPPFLAGS += $(call pkgconf, --cflags-only-I $(hiredis.pc) $(redis++.pc)) 879e6f9b5eSJames Wright LDFLAGS += $(call pkgconf, --libs-only-L --libs-only-other $(hiredis.pc) $(redis++.pc)) 889e6f9b5eSJames Wright LDFLAGS += $(patsubst -L%, $(call pkgconf, --variable=ldflag_rpath $(PETSc.pc))%, $(call pkgconf, --libs-only-L $(hiredis.pc) $(redis++.pc))) 899e6f9b5eSJames Wright LDLIBS += $(call pkgconf, --libs-only-l $(hiredis.pc) $(redis++.pc)) $(lsmartredis) 909e6f9b5eSJames Wright src.c += $(sort $(wildcard $(SRCDIR)/smartsim/*.c)) 919e6f9b5eSJames Wrightendif 929e6f9b5eSJames Wright 93a515125bSLeila Ghaffariall: navierstokes 94a515125bSLeila Ghaffari 95a515125bSLeila Ghaffarinavierstokes: $(src.o) | $(PETSc.pc) $(ceed.pc) 96*4c07ec22SJames Wright $(call quiet,LINK.o) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ 97a515125bSLeila Ghaffari 98a515125bSLeila Ghaffari.SECONDEXPANSION: # to expand $$(@D)/.DIR 99a515125bSLeila Ghaffari%/.DIR : 100a515125bSLeila Ghaffari @mkdir -p $(@D) 101a515125bSLeila Ghaffari @touch $@ 102ea10196cSJeremy L Thompson 1034f863122SJeremy L Thompson# Quiet, color output 1044f863122SJeremy L Thompsonquiet ?= $($(1)) 1054f863122SJeremy L Thompson 106a515125bSLeila Ghaffari$(OBJDIR)/%.o : %.c | $$(@D)/.DIR 107a515125bSLeila Ghaffari $(call quiet,CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(abspath $<) 108a515125bSLeila Ghaffari 109*4c07ec22SJames Wright$(OBJDIR)/%.o : %.cpp | $$(@D)/.DIR 110*4c07ec22SJames Wright $(call quiet,CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(abspath $<) 111*4c07ec22SJames Wright 112ea10196cSJeremy L Thompsonprint: $(PETSc.pc) $(ceed.pc) 113ea10196cSJeremy L Thompson $(info CC : $(CC)) 114ea10196cSJeremy L Thompson $(info CFLAGS : $(CFLAGS)) 115ea10196cSJeremy L Thompson $(info CPPFLAGS: $(CPPFLAGS)) 116ea10196cSJeremy L Thompson $(info LDFLAGS : $(LDFLAGS)) 117ea10196cSJeremy L Thompson $(info LDLIBS : $(LDLIBS)) 118ea10196cSJeremy L Thompson $(info OPT : $(OPT)) 119ea10196cSJeremy L Thompson @true 120ea10196cSJeremy L Thompson 1210e8fe9d5SJames Wrightprint-% : 1220e8fe9d5SJames Wright $(info [ variable name]: $*) 1230e8fe9d5SJames Wright $(info [ origin]: $(origin $*)) 1240e8fe9d5SJames Wright $(info [ flavor]: $(flavor $*)) 1250e8fe9d5SJames Wright $(info [ value]: $(value $*)) 1260e8fe9d5SJames Wright $(info [expanded value]: $($*)) 1270e8fe9d5SJames Wright $(info ) 1280e8fe9d5SJames Wright @true 1290e8fe9d5SJames Wright 130ea10196cSJeremy L Thompsonclean: 131a515125bSLeila Ghaffari $(RM) -r $(OBJDIR) navierstokes *.vtu *.bin* *.csv *.png 132ea10196cSJeremy L Thompson 133ea10196cSJeremy L Thompson$(PETSc.pc): 134ea10196cSJeremy L Thompson $(if $(wildcard $@),,$(error \ 135ea10196cSJeremy L Thompson PETSc config not found. Please set PETSC_DIR and PETSC_ARCH)) 136ea10196cSJeremy L Thompson 137ea10196cSJeremy L Thompson.PHONY: all print clean 138ea10196cSJeremy L Thompson 1390e8fe9d5SJames Wrightpkgconf = $(shell pkg-config $(if $(STATIC),--static) $1 | sed -e 's/^"//g' -e 's/"$$//g') 140a515125bSLeila Ghaffari 141a515125bSLeila Ghaffari-include $(src.o:%.o=%.d) 142