Mercurial > hg > Gears > GearsAgda
annotate src/parallel_execution/CMakeLists.txt @ 352:3e01e963eb2d
Fix compile error for calc example but not work
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 16 Jun 2017 16:29:27 +0900 |
parents | 9578c38c10d1 |
children | b07078bd1f2c |
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}) |
312
7dd5a7d52a67
USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
308
diff
changeset
|
9 add_definitions("-Wall -g") |
325
7d664be4efa5
Run docker container
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
323
diff
changeset
|
10 set(CMAKE_C_FLAGS "-lpthread") |
312
7dd5a7d52a67
USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
308
diff
changeset
|
11 |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
12 |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
13 if (${USE_CUDA}) |
312
7dd5a7d52a67
USE_CUDAWorker flag only for CUDAtwice
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
308
diff
changeset
|
14 include_directories("/usr/local/cuda/include") |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
15 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
|
16 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
|
17 find_package(CUDA REQUIRED) |
305 | 18 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
19 endif() |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
20 |
302 | 21 |
198 | 22 macro( GearsCommand ) |
23 set( _OPTIONS_ARGS ) | |
24 set( _ONE_VALUE_ARGS TARGET ) | |
25 set( _MULTI_VALUE_ARGS SOURCES ) | |
26 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) | |
255 | 27 |
256 | 28 set (_Gears_CSOURCES) |
29 foreach(i ${_Gears_SOURCES}) | |
30 if (${i} MATCHES "\\.cbc") | |
31 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) | |
32 add_custom_command ( | |
33 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
|
34 DEPENDS ${i} |
256 | 35 COMMAND "perl" "generate_stub.pl" "-o" ${j} ${i} |
36 ) | |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
37 elseif (${i} MATCHES "\\.cu") |
302 | 38 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
|
39 add_custom_command ( |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
40 OUTPUT ${j} |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
41 DEPENDS ${i} |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
42 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
|
43 ) |
270 | 44 else() |
256 | 45 set(j ${i}) |
270 | 46 endif() |
256 | 47 list(APPEND _Gears_CSOURCES ${j}) |
48 endforeach(i) | |
49 | |
210
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
50 add_custom_command ( |
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
51 OUTPUT c/${_Gears_TARGET}-context.c |
256 | 52 DEPENDS ${_Gears_CSOURCES} |
255 | 53 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
|
54 ) |
255 | 55 add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c) |
198 | 56 endmacro() |
57 | |
210
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
58 |
198 | 59 GearsCommand( |
60 TARGET | |
61 twice | |
62 SOURCES | |
325
7d664be4efa5
Run docker container
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
323
diff
changeset
|
63 examples/twice.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc |
278 | 64 ) |
65 | |
326
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
325
diff
changeset
|
66 GearsCommand( |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
325
diff
changeset
|
67 TARGET |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
325
diff
changeset
|
68 calc |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
325
diff
changeset
|
69 SOURCES |
352
3e01e963eb2d
Fix compile error for calc example but not work
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents:
347
diff
changeset
|
70 examples/calc.cbc examples/Add.cbc examples/Mult.cbc examples/calc.cbc CPUWorker.cbc time.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc |
326
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
325
diff
changeset
|
71 ) |
f23f6d0aa4e9
Add examples/calc.cbc and build but not work
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
325
diff
changeset
|
72 |
308 | 73 if (${USE_CUDA}) |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
74 GearsCommand( |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
75 TARGET |
302 | 76 CUDAtwice |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
77 SOURCES |
329
8592a1d161b7
Move CUDAtwice example to examples directory
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
326
diff
changeset
|
78 main.cbc RedBlackTree.cbc compare.c SingleLinkedStack.cbc CPUWorker.cbc time.cbc twice.cbc TaskManagerImpl.cbc SingleLinkedQueue.cbc SynchronizedQueue.cbc SemaphoreImpl.cbc CUDAWorker.cbc examples/CUDAtwice.cbc examples/CUDAtwice.cu cuda.c |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
79 ) |
319
a15511b1a6e0
separate cuda.c, and USE_CUDA_MAIN_THREAD flag
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
312
diff
changeset
|
80 set_target_properties(CUDAtwice PROPERTIES COMPILE_FLAGS "-Wall -g -DUSE_CUDAWorker=1 -DUSE_CUDA_MAIN_THREAD") |
301
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
81 endif() |
609bf62768b9
add -DUSE_CUDA=1 flag to cmake
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
286
diff
changeset
|
82 |
278 | 83 GearsCommand( |
84 TARGET | |
85 queue_test | |
86 SOURCES | |
322
366baa247572
Use generate_stub for queue_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
319
diff
changeset
|
87 test/queue_test.cbc SingleLinkedQueue.cbc |
86 | 88 ) |
89 | |
202 | 90 GearsCommand( |
91 TARGET | |
210
ba56dab79dc4
separate code init for each executable
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
208
diff
changeset
|
92 stack_test |
202 | 93 SOURCES |
323
131a04a70dd8
Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
322
diff
changeset
|
94 test/stack_test.cbc SingleLinkedStack.cbc |
202 | 95 ) |
96 |