Issue #511: Automatically determine location of CUDA toolkit when building GPU Manager 03/303/7
authorHarshit Dokania <hdokani2@illinois.edu>
Tue, 1 Jul 2014 21:01:43 +0000 (16:01 -0500)
committerHarshit Dokania <hdokani2@illinois.edu>
Wed, 2 Jul 2014 03:56:03 +0000 (22:56 -0500)
Change-Id: I7d3c4336fed5a9469ea05bac56d5a34d29084423

build
src/arch/cuda/hybridAPI/Makefile

diff --git a/build b/build
index b19c4f6185030036a4e15689ca9e9bd8b223cdd7..834e2bba7f3a9e4942bd2a0d9454d264b5636b3d 100755 (executable)
--- a/build
+++ b/build
@@ -199,6 +199,7 @@ TestIfOption() {
 
 # start
 
+BUILD_CUDA=0
 MAKEOPTS=""
 OPTS=""
 BOPTS=""
@@ -438,12 +439,26 @@ do
           BOPTS="$BOPTS $1"
           [ $1 =  "bigemulator" ] && BUILD_EMULATOR=1
           [ $1 =  "bigsim" ] && BUILD_EMULATOR=1
+          [ $1 =  "cuda"   ] && BUILD_CUDA=1
         fi
         shift
        ;;
   esac
 done
 
+if [ $BUILD_CUDA -eq 1 ]; then
+  echo "checking for CUDA toolkit directory"
+  CUDA_CANDIDATE_DIRS="$CUDATOOLKIT_HOME /usr/local/cuda /usr/lib/nvidia-cuda-toolkit"
+  for dir in $CUDA_CANDIDATE_DIRS; do
+    if test -d "$dir"; then
+      CUDA_DIR="$dir"
+      HAVE_CUDA="yes"
+      echo "CUDA_DIR=$CUDA_DIR"
+      break
+    fi
+  done
+fi
+
 [ "x$VERSION" = "x" ] && syntax && exit 1
 
 if test -n "$WITH_PRODUCTION" -a $BUILD_EMULATOR -eq 1 -a -z "$ENABLE_TRACING"
@@ -599,6 +614,9 @@ then
     for i in $BOPTS
     do
       echo '#include "'conv-mach-$i.h'"' >> $ConvHeader
+      if [ $BUILD_CUDA -eq 1 ]; then
+        echo 'CUDA_DIR="'$CUDA_DIR'"'>>$ConvSh
+      fi
       echo '. $CHARMINC/'"conv-mach-$i.sh" >> $ConvSh
     done
 fi
index 08a8883a6c07cfa58e3accb9401c77960c8e0272..c37297b7e977e4b872839917ba26a5b6d2332187 100644 (file)
@@ -1,10 +1,10 @@
 #CUDA_DIR=/usr/local/cuda
 CHARMDIR=../..
 CHARMC=$(CHARMDIR)/bin/charmc
-
-NVCC = $(CUDA_DIR)/bin/nvcc
+CUDA_PATH=$(shell CHARMINC=../.; . $$CHARMINC/conv-mach-opt.sh; echo $$CUDA_DIR;  )
+NVCC = $(CUDA_PATH)/bin/nvcc
 NVCC_FLAGS = -c -use_fast_math -DGPU_MEMPOOL #-DGPU_PROFILE -DGPU_TRACE #-DGPU_MEMPOOL_DEBUG -DGPU_WRQ_VERBOSE #-device-debug -deviceemu
-NVCC_INC = -I$(CUDA_DIR)/include -I.. 
+NVCC_INC = -I$(CUDA_PATH)/include -I..
 
 all: libs
        cp libcudahybridapi.a $(CHARMDIR)/lib