Mercurial > hg > Gears > GearsAgda
annotate src/parallel_execution/CMakeLists.txt @ 302:8e7926f3e271
fix CUDAWorker
author | ikkun |
---|---|
date | Mon, 13 Feb 2017 17:58:04 +0900 |
parents | 609bf62768b9 |
children | 1dbaef86593b |
rev | line source |
---|---|
86 | 1 cmake_minimum_required(VERSION 2.8) |
2 | |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
3 set(USE_CUDA,0) |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
4 |
101 | 5 # -DUSE_CUDA |
138 | 6 # add_definitions("-Wall -g -O") |
86 | 7 |
131
a4507906938c
Fix compile error but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
117
diff
changeset
|
8 set(CMAKE_C_COMPILER $ENV{CBC_COMPILER}) |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
9 |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
10 if (${USE_CUDA}) |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
11 set(NVCCFLAG "-std=c++11" "-g" "-O0" ) |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
12 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") |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
13 find_package(CUDA REQUIRED) |
302 | 14 add_definitions("-Wall -g -DUSE_CUDAWorker") |
15 else() | |
16 add_definitions("-Wall -g") | |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
17 endif() |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
18 |
302 | 19 |
198 | 20 macro( GearsCommand ) |
21 set( _OPTIONS_ARGS ) | |
22 set( _ONE_VALUE_ARGS TARGET ) | |
23 set( _MULTI_VALUE_ARGS SOURCES ) | |
24 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) | |
255 | 25 |
256 | 26 set (_Gears_CSOURCES) |
27 foreach(i ${_Gears_SOURCES}) | |
28 if (${i} MATCHES "\\.cbc") | |
29 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) | |
30 add_custom_command ( | |
31 OUTPUT ${j} | |
259
195518ab62fc
fix type gathering pattern match in generate_stub.pl
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
257
diff
changeset
|
32 DEPENDS ${i} |
256 | 33 COMMAND "perl" "generate_stub.pl" "-o" ${j} ${i} |
34 ) | |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
35 elseif (${i} MATCHES "\\.cu") |
302 | 36 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
37 add_custom_command ( |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
38 OUTPUT ${j} |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
39 DEPENDS ${i} |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
40 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
41 ) |
270 | 42 else() |
256 | 43 set(j ${i}) |
270 | 44 endif() |
256 | 45 list(APPEND _Gears_CSOURCES ${j}) |
46 endforeach(i) | |
47 | |
210
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
48 add_custom_command ( |
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
49 OUTPUT c/${_Gears_TARGET}-context.c |
256 | 50 DEPENDS ${_Gears_CSOURCES} |
255 | 51 COMMAND "perl" "generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CSOURCES} |
210
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
52 ) |
255 | 53 add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c) |
198 | 54 endmacro() |
55 | |
210
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
56 |
198 | 57 GearsCommand( |
58 TARGET | |
59 twice | |
60 SOURCES | |
286 | 61 main.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc |
278 | 62 ) |
63 | |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
64 if (${USE_CUDA}) |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
65 GearsCommand( |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
66 TARGET |
302 | 67 CUDAtwice |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
68 SOURCES |
302 | 69 main.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc CUDAWorker.cbc CUDAtwice.cu |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
70 ) |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
71 endif() |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
72 |
278 | 73 GearsCommand( |
74 TARGET | |
75 queue_test | |
76 SOURCES | |
77 test/queue_test.c SingleLinkedQueue.cbc | |
86 | 78 ) |
79 | |
202 | 80 GearsCommand( |
81 TARGET | |
210
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
82 stack_test |
202 | 83 SOURCES |
278 | 84 test/stack_test.c SingleLinkedStack.cbc |
202 | 85 ) |
86 |