diff src/parallel_execution/CMakeLists.txt @ 301:609bf62768b9

add -DUSE_CUDA=1 flag to cmake
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 12 Feb 2017 12:35:11 +0900
parents fd470e090403
children 8e7926f3e271
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Sun Feb 12 09:12:21 2017 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Sun Feb 12 12:35:11 2017 +0900
@@ -1,11 +1,19 @@
 cmake_minimum_required(VERSION 2.8)
 
+set(USE_CUDA,0)
+
 # -DUSE_CUDA
 #  add_definitions("-Wall -g -O")
 add_definitions("-Wall -g")
 
 set(CMAKE_C_COMPILER $ENV{CBC_COMPILER})
- 
+
+if (${USE_CUDA})
+    set(NVCCFLAG "-std=c++11" "-g" "-O0" )
+    set(CUDA_LINK_FLAGS "-framework CUDA -lc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Developer/NVIDIA/CUDA-8.0/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib") 
+    find_package(CUDA REQUIRED)
+endif()
+
 macro( GearsCommand )
     set( _OPTIONS_ARGS )
     set( _ONE_VALUE_ARGS TARGET )
@@ -21,6 +29,13 @@
                 DEPENDS   ${i} 
                 COMMAND  "perl" "generate_stub.pl" "-o" ${j} ${i}
             )
+        elseif (${i} MATCHES "\\.cu")
+            string(REGEX REPLACE "(.*).cbc" "c/\\1.ptx" j ${i})
+            add_custom_command (
+                OUTPUT    ${j} 
+                DEPENDS   ${i} 
+                COMMAND  nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
+            )
         else()
             set(j ${i})
         endif()
@@ -43,6 +58,15 @@
       main.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc
 )
 
+if (${USE_CUDA})
+    GearsCommand(
+      TARGET
+          GPUtwice
+      SOURCES 
+          main.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc  GPUWorker.cbc GPUtwice.cu
+    )
+endif()
+
 GearsCommand(
   TARGET
       queue_test