Mercurial > hg > Members > Moririn
view 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 source
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 ) set( _MULTI_VALUE_ARGS SOURCES ) cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) set (_Gears_CSOURCES) foreach(i ${_Gears_SOURCES}) if (${i} MATCHES "\\.cbc") string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) add_custom_command ( OUTPUT ${j} 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() list(APPEND _Gears_CSOURCES ${j}) endforeach(i) add_custom_command ( OUTPUT c/${_Gears_TARGET}-context.c DEPENDS ${_Gears_CSOURCES} COMMAND "perl" "generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CSOURCES} ) add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c) endmacro() GearsCommand( TARGET twice SOURCES 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 SOURCES test/queue_test.c SingleLinkedQueue.cbc ) GearsCommand( TARGET stack_test SOURCES test/stack_test.c SingleLinkedStack.cbc )