Hello, I have a project that runs just fine from nsight eclipse.
I created a makefile and it compiles fine but when I try to run it ,it gives segmentaion fault.
I noticed this:
In my code , I print some values :
NbOfCDV : 286752
NbOfSTD : 286720
NbOfNOI : 32
TotalSize: 298713088 bytes
When the code is being executed from makefile ,it gives :
NbOfCDV : 286752
NbOfSTD : 0
NbOfNOI : 0
TotalSize: 8386658489117799521 bytes
!!!
What am I doing wrong??
Makefile:
PROJECT_NAME = Calc
# Location of the CUDA Toolkit
CUDA_PATH = /usr/local/cuda-6.5
CUDA_BIN_PATH ?= $(CUDA_PATH)/bin
# compiler
GCC = gcc
NVCC = $(CUDA_BIN_PATH)/nvcc
# Compiler flags
CCFLAGS := -m64 -std=c99
NVCCFLAGS := --target-cpu-architecture x86 -m64 -rdc=true
LDFLAGS := -lcudart -lcublas_device -lcudadevrt -lcublas -lcuda -lm
DLINKFLAGS := -lcublas_device -lcudadevrt -lcublas -lcudart
#debug
DEBUG ?= 0
ifeq (DEBUG, 1)
CCFLAGS += -DDEBUG -g
NVCCFLAGS += -DDEBUG -g -G
else
CCFLAGS += -DNDEBUG
NVCCFLAGS += -DNDEBUG
endif
# Common includes and library paths
INCLUDES := -I/usr/local/cuda-6.5/include ...
LIBRARIES := -L/usr/local/cuda-6.5/lib64 ...
# CUDA code generation flags
GENCODE_SM35 := -gencode arch=compute_35,code=sm_35
GENCODE_FLAGS := $(GENCODE_SM35)
# Target rules
.PHONY: all
all: build
build: $(PROJECT_NAME)
Calc.o:Calc.cu
$(NVCC) $(NVCCFLAGS) $(MKLFLAGS) $(GENCODE_FLAGS) $(INCLUDES) -c $<
$(NVCC) -dlink $(GENCODE_FLAGS) $(DLINKFLAGS) -o Calc_link.o $@
PhListFile.o:PhListFile.c
$(GCC) $(CCFLAGS) $(INCLUDES) -c $<
PhFilesUtil.o:PhFilesUtil.c
$(GCC) $(CCFLAGS) $(INCLUDES) -c $<
$(PROJECT_NAME):Calc.o Calc_link.o PhListFile.o PhFilesUtil.o
$(GCC) $(CCFLAGS) -o $@ $+ $(LIBRARIES) $(LDFLAGS)
run: build
./$(PROJECT_NAME)
.PHONY: clean
clean:
rm -f *.o $(PROJECT_NAME)