NVCC = nvcc 
CC = gcc
CXX = g++ 

NVCCFLAGS   := -m64 -I/usr/local/cuda-5.5/samples/common/inc
GENCODE_SM13    := -gencode arch=compute_13,code=\"sm_13,compute_13\"
GENCODE_SM20    := -gencode arch=compute_20,code=sm_20
GENCODE_SM30    := -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\"
GENCODE_FLAGS   := $(GENCODE_SM13) $(GENCODE_SM20) $(GENCODE_SM30)
TBB_FLAGS = -I/usr/local/cuda/include -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_TBB 
OMP_FLAGS = -I/usr/local/cuda/include -fopenmp -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP

all : thrust_rand thrust_curand thrust_vectorAdd thrust_vectorAddV2 thrust_vectorAddV2TBB thrust_vectorAddV2OMP

thrust_rand : thrust_rand.o 
	$(NVCC) $(NVCCFLAGS) $(GENCODE_FLAGS)  -o thrust_rand  thrust_rand.o
	
thrust_curand : thrust_curand.o 
	$(NVCC) $(NVCCFLAGS) $(GENCODE_FLAGS)  -o thrust_curand  thrust_curand.o -lcurand
	
thrust_vectorAdd : thrust_vectorAdd.o walltime.o
	$(NVCC) $(NVCCFLAGS) $(GENCODE_FLAGS)  -o thrust_vectorAdd  thrust_vectorAdd.o walltime.o -lcurand
	
thrust_vectorAddV2 : thrust_vectorAddV2.cu walltime.o
	$(NVCC) $(NVCCFLAGS) $(GENCODE_FLAGS)  -o thrust_vectorAddV2  thrust_vectorAddV2.cu walltime.o 

thrust_vectorAddV2TBB : walltime.o
	$(CXX)  $(TBB_FLAGS) -c thrust_vectorAddV2.cpp
	$(CXX) -o thrust_vectorAddV2TBB  thrust_vectorAddV2.o walltime.o -ltbb
	
thrust_vectorAddV2OMP : walltime.o
	$(CXX)  $(OMP_FLAGS) -c thrust_vectorAddV2.cpp
	$(CXX) -o thrust_vectorAddV2OMP  thrust_vectorAddV2.o walltime.o -lgomp
	
walltime.o : walltime.c
	$(CXX)  -c walltime.c

clean :
	rm -f *.o thrust_rand thrust_curand thrust_vectorAdd thrust_vectorAddV2 thrust_vectorAddV2OMP thrust_vectorAddV2TBB *~ 

.SUFFIXES: .cu

%.o: %.cu 
	$(NVCC) $(NVCCFLAGS) $(GENCODE_FLAGS) -c  $<