include Makefile.cuda

HOSTNAME = $(shell hostname) 

ifeq ("$(HOSTNAME)","gpuschwarz ")
  MY_GENCODE_FLAGS = $(GENCODE_SM13) $(GENCODE_SM20) $(GENCODE_SM30)
endif

ifeq ("$(HOSTNAME)","magi1 ")
  MY_GENCODE_FLAGS = $(GENCODE_SM13) 
endif

# Default arch includes gencode for sm_10, sm_20, and other archs from GENCODE_ARCH declared in the makefile

all : vector_axpy thrust_axpy vector_axpy_v2

NVCCFLAGS += -use_fast_math
LDFLAGS       += -lcurand -lcublas

vector_axpy.o : vector_axpy.cu 
	$(NVCC) $(NVCCFLAGS) $(EXTRA_NVCCFLAGS) $(MY_GENCODE_FLAGS) $(INCLUDES) -o $@ -c $<
	
vector_axpy_v2.o : vector_axpy_v2.cu 
	$(NVCC) $(NVCCFLAGS) $(EXTRA_NVCCFLAGS) $(MY_GENCODE_FLAGS) $(INCLUDES) -o $@ -c $<

thrust_axpy.o : thrust_axpy.cu 
	$(NVCC) $(NVCCFLAGS) $(EXTRA_NVCCFLAGS) $(MY_GENCODE_FLAGS) $(INCLUDES) -o $@ -c $<


vector_axpy : vector_axpy.o
	$(GCC) $(CCFLAGS) -o $@ $+ $(LDFLAGS) $(EXTRA_LDFLAGS)
	
vector_axpy_v2 : vector_axpy_v2.o Init.o
	$(GCC) $(CCFLAGS) -o $@ $+ $(LDFLAGS) $(EXTRA_LDFLAGS)
	
thrust_axpy : thrust_axpy.o

HOST :
	echo a$(HOSTNAME)a

CLEAN : 
	@rm -rf vector_axpy *.log *.lol *.aux *.dvi *.out *.pdf *.toc *~ *.o *.out *.err

run_magi : vector_axpy
	sbatch -p GPU --gres=gpu:1 exo_axpy.run

