I am wonder why these two commands return two different results. First one is:
[root@node30 par-run-d2]# make -C NQU/
make: Entering directory `/home/ut/gpgpu-sim/benchmarks/par-run-d2/NQU'
nvcc -c -arch sm_11 --keep --compiler-options -fno-strict-aliasing \
-I. -I/usr/local/cuda//include/ -I/home/ut/NVIDIA_GPU_Computing_SDK/C//common/inc/ \
-L/home/ut/NVIDIA_GPU_Computing_SDK/C//lib -lcutil -DUNIX nqueen.cu -o nqueen
nqueen.cu(681): warning: variable "start" was declared but never referenced
nqueen.cu(681): warning: variable "end" was declared but never referenced
nqueen.cu(681): warning: variable "start" was declared but never referenced
nqueen.cu(681): warning: variable "end" was declared but never referenced
gcc -g -c nqueen.cu.cpp -o nqueen.cu_o
echo ../../..
../../..
../../../scripts/gen_ptxinfo
Generating nqueen.ptxinfo...
make: *** [nqueen.cu_o] Error 255
make: Leaving directory `/home/ut/gpgpu-sim/benchmarks/par-run-d2/NQU'
And the second one is:
[root@node30 par-run-d2]# cd NQU/
[root@node30 NQU]# make
g++ -g nqueen.cu_o -L../../../libcuda/ -lcuda \
-L/home/ut/NVIDIA_GPU_Computing_SDK/C//lib -lcutil \
-L../../../src/ -lgpgpusim \
-L../../../src/intersim -lintersim \
-L../../../src/cuda-sim/ -lgpgpu_ptx_sim \
-lm -lz -lGL -o gpgpu_ptx_sim__nqueen
rm -rf *.cpp*.i *.cpp*.ii *.cu.c *.cudafe*.* *.fatbin.c *.cu.cpp *.linkinfo *.cpp_o core *.cubin cubin.bin *_o *.hash nqueen
Any idea why “make -C X” differs from “cd X/; make” ?
The sequence
cd X; makeis changing the current directory of the invoking shell (the interactive shell of your terminal). Make that a sub-shell like(cd X; make)to avoid that, which is much longer to type thanmake -C Xwhich does thechdirsyscall inside themakeprocess so cannot change the working directory of the parent process (your interactive shell usually).Also the
-wflag behavior would be different. And most recursive$(MAKE)inMakefile-s are doing a-C somesubdirPS. Remember that the
cdshell built-in invokes the chdir(2) syscall which has no effect on the parent process.