ENERGY ?= YES

ifeq ($(ENERGY), YES)
OPTIONS += -D_ENERGY_PMT_

# enable RAPL
OPTIONS += -D_ENERGY_RAPL_
# enable NVIDIA
OPTIONS += -D_ENERGY_NVIDIA_
# enable AMD
OPTIONS += # -D_ENERGY_AMD_

PMT   = /leonardo/home/userexternal/dgoz0000/lib/pmt/local
INC   = -I$(PMT)/include
LIB   = -L$(PMT)/lib64 -lpmt -lm

endif

NVC   = nvc
NVCPP = nvc++ -std=c++17
CPP   = g++ -std=c++17
OPT   = -O3 -mp=gpu,multicore -gpu=ccnative,debug,lineinfo -target=gpu -Minfo=all -v

all: multiple_devices
.PHONY: clean test

energy_pmt_methods.o: energy/energy_pmt_methods.cpp energy/energy_pmt.h energy/energy_pmt_methods.h Makefile
	$(CPP) $(OPTIONS) $(INC) -c $< -o $@

multiple_devices.o: multiple_devices.c energy/energy_pmt.h Makefile
	$(NVC) $(OPT) $(OPTIONS) -c $< -o $@

multiple_devices: multiple_devices.o energy_pmt_methods.o
	$(NVCPP) $(OPT) $(OPTIONS) $^ -o $@ $(LIB)

test: multiple_devices
	./multiple_devices

clean:
	rm -rf *.o multiple_devices *~ ./energy/*~
