CUCOMP  = nvcc
CUFLAGS = -arch=sm_80

ifdef EBROOTOPENMPI
MPI_HOME+=$(EBROOTOPENMPI)
endif
ifdef EBROOTPSMPI
MPI_HOME+=$(EBROOTPSMPI)
endif

INCLUDES  = -I$(MPI_HOME)/include
LIBRARIES = -L$(MPI_HOME)/lib -lmpi

all: hello.cpu.out hello.gpu.out

hello.cpu.out: hello-world.c
	mpicc $< -o $@

hello.gpu.out: hello.gpu.o
	$(CUCOMP) $(CUFLAGS) $(LIBRARIES) $< -o $@

hello.gpu.o: hello-world.cu
	$(CUCOMP) $(CUFLAGS) $(INCLUDES) -c $< -o $@

.PHONY: clean

clean:
	rm -f hello.cpu.out hello.gpu.out *.o