|
24 | 24 | # SOFTWARE. |
25 | 25 | ###################################################################################### |
26 | 26 |
|
27 | | -############################################ |
28 | | -# COYOTE SOFTWARE PACKAGE # |
29 | | -############################################ |
30 | | -# @brief Set-up all the necessary libs, includes and source file compile the Coyote software |
31 | | - |
32 | | -cmake_minimum_required(VERSION 3.5) |
33 | | - |
34 | | -############################## |
35 | | -# USER OPTIONS # |
36 | | -############################# |
37 | | -# Build with AVX support |
38 | | -set(EN_AVX "1" CACHE STRING "AVX enabled.") |
39 | | - |
40 | | -# Build with support for ROCm (AMD GPUs) |
41 | | -set(EN_GPU "0" CACHE STRING "AMD GPU enabled.") |
42 | | - |
43 | | -############################## |
44 | | -# BUILD CONFIG # |
45 | | -############################# |
46 | | -set(CYT_LANG CXX) |
47 | | - |
48 | | -set(EN_SIM 0 CACHE STRING "Build for simulation.") |
49 | | -set(SIM_DIR "" CACHE STRING "Directory that contains simulation project.") |
50 | | -string(COMPARE EQUAL "${SIM_DIR}" "" result) |
51 | | -if(NOT result) |
52 | | - set(EN_SIM 1) |
53 | | -endif() |
54 | | - |
55 | | -# Find GPU libraries |
56 | | -if(EN_GPU) |
57 | | - if(NOT DEFINED ROCM_PATH) |
58 | | - if(DEFINED ENV{ROCM_PATH}) |
59 | | - set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCM has been installed") |
60 | | - elseif(DEFINED ENV{HIP_PATH}) |
61 | | - set(ROCM_PATH "$ENV{HIP_PATH}/.." CACHE PATH "Path to which ROCM has been installed") |
62 | | - else() |
63 | | - set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to which ROCM has been installed") |
64 | | - endif() |
65 | | - endif() |
66 | | - |
67 | | - file(STRINGS "${ROCM_PATH}/.info/version" ROCM_VERSION) |
68 | | - message("-- Found ROCm: ${ROCM_VERSION}") |
69 | | - |
70 | | - if (NOT DEFINED CMAKE_CXX_COMPILER) |
71 | | - set(CMAKE_CXX_COMPILER ${ROCM_PATH}/bin/hipcc) |
72 | | - endif() |
73 | | - |
74 | | - if(NOT DEFINED HIP_PATH) |
75 | | - if(NOT DEFINED ENV{HIP_PATH}) |
76 | | - set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed") |
77 | | - else() |
78 | | - set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed") |
79 | | - endif() |
80 | | - endif() |
81 | | - |
82 | | - if(NOT DEFINED HCC_PATH) |
83 | | - if(DEFINED ENV{HCC_PATH}) |
84 | | - set(HCC_PATH $ENV{HCC_PATH} CACHE PATH "Path to which HCC has been installed") |
85 | | - else() |
86 | | - set(HCC_PATH "${ROCM_PATH}/hcc" CACHE PATH "Path to which HCC has been installed") |
87 | | - endif() |
88 | | - set(HCC_HOME "${HCC_PATH}") |
89 | | - endif() |
90 | | - |
91 | | - if(NOT DEFINED HIP_CLANG_PATH) |
92 | | - if(NOT DEFINED ENV{HIP_CLANG_PATH}) |
93 | | - set(HIP_CLANG_PATH "${ROCM_PATH}/llvm/bin" CACHE PATH "Path to which HIP compatible clang binaries have been installed") |
94 | | - else() |
95 | | - set(HIP_CLANG_PATH $ENV{HIP_CLANG_PATH} CACHE PATH "Path to which HIP compatible clang binaries have been installed") |
96 | | - endif() |
97 | | - endif() |
98 | | - |
99 | | - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${HIP_PATH}/cmake" ) |
100 | | - list(APPEND CMAKE_PREFIX_PATH |
101 | | - "${HIP_PATH}/lib/cmake" |
102 | | - "${HIP_PATH}/../lib/cmake" |
103 | | - ) |
104 | | - |
105 | | - find_package(HIP QUIET) |
106 | | - if(HIP_FOUND) |
107 | | - message(STATUS "Found HIP: " ${HIP_VERSION}) |
108 | | - else() |
109 | | - message(FATAL_ERROR "Could not find HIP. Ensure that HIP is either installed in /opt/rocm/hip or the variable HIP_PATH is set to point to the right location.") |
110 | | - endif() |
111 | | - find_package(hip REQUIRED) |
112 | | - |
113 | | - set(CYT_LANG ${CYT_LANG} HIP) |
114 | | -endif() |
115 | | - |
116 | | -# Create a Coyote lib |
117 | | -project( |
118 | | - Coyote |
119 | | - VERSION 2.0.0 |
120 | | - DESCRIPTION "Coyote library" |
121 | | - LANGUAGES ${CYT_LANG} |
| 27 | +message(WARNING "FindCoyoteSW is deprecated. Instead, you can choose one of two options:\n" |
| 28 | + "1. If you're including Coyote as a git submodule, you can use the add_subdirectory(...)" |
| 29 | + " directive in CMake. As an example, the following snippet of FindCoyoteSW:\n" |
| 30 | + " set(CYT_DIR \$\{CMAKE_SOURCE_DIR\}/../coyote)\n" |
| 31 | + " set(CMAKE_MODULE_PATH \$\{CMAKE_MODULE_PATH\} \$\{CYT_DIR\}/cmake)\n" |
| 32 | + " find_package(CoyoteSW REQUIRED)\n" |
| 33 | + "can be replaced with:\n" |
| 34 | + " add_subdirectory(../coyote/sw coyote)\n" |
| 35 | + "Please refer to the add_subdirectory documentation for more details.\n" |
| 36 | + "2. If you're integrating Coyote into third-party software, it's likely that dependencies" |
| 37 | + " are managed out-of-tree, and thus submodules are not used. In that case, you can install" |
| 38 | + " coyote as a system library (by building the CMake project in sw/ and running `make install`)" |
| 39 | + " and use CMake's find_package functionality as follows:" |
| 40 | + "\n" |
| 41 | + " find_package(Coyote REQUIRED)\n" |
| 42 | + "In both cases, you can then link Coyote into your project using:" |
| 43 | + "\n" |
| 44 | + " target_link_libraries(<project> PRIVATE Coyote)\n" |
| 45 | + " target_include_directories(<project> PRIVATE \$\{COYOTE_INCLUDE_DIRS\})\n" |
122 | 46 | ) |
123 | | -set(CMAKE_DEBUG_POSTFIX d) |
124 | | - |
125 | | -# Specify C++ standard, compile time options |
126 | | -set(CMAKE_CXX_STANDARD 17) |
127 | | -set(CMAKE_CXX_STANDARD_REQUIRED True) |
128 | | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -march=native -O3") |
129 | | - |
130 | | -# Source files, includes |
131 | | -file(GLOB CYT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/../sw/src/*.cpp") |
132 | | -if(EN_SIM) |
133 | | - list(FILTER CYT_SOURCES EXCLUDE REGEX ".*cThread\\.cpp$") |
134 | | - file(GLOB SIM_SOURCES "${CMAKE_CURRENT_LIST_DIR}/../sim/sw/src/*.cpp") |
135 | | - list(APPEND CYT_SOURCES ${SIM_SOURCES}) |
136 | | -endif() |
137 | | -add_library(Coyote SHARED ${CYT_SOURCES}) |
138 | | - |
139 | | -# Output directories |
140 | | -if (NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) |
141 | | - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") |
142 | | -endif() |
143 | | - |
144 | | -if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
145 | | - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") |
146 | | -endif() |
147 | | - |
148 | | -# Header includes |
149 | | -set(CYT_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/../sw/include) |
150 | | -if(EN_SIM) |
151 | | - list(APPEND CYT_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/../sim/sw/include) |
152 | | -endif() |
153 | | -target_include_directories(Coyote PUBLIC ${CYT_INCLUDE_PATH}) |
154 | | -target_link_directories(Coyote PUBLIC /usr/local/lib) |
155 | | - |
156 | | -# Additional libraries |
157 | | -find_package(Boost COMPONENTS program_options REQUIRED) |
158 | | -target_link_libraries(Coyote PUBLIC ${Boost_LIBRARIES}) |
159 | | - |
160 | | -# Additional flags, depending on AVX or GPU support |
161 | | -if(EN_AVX) |
162 | | - target_compile_definitions(Coyote PUBLIC EN_AVX) |
163 | | - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx") |
164 | | -endif() |
165 | | - |
166 | | -if(EN_GPU) |
167 | | - target_compile_definitions(Coyote PUBLIC EN_GPU) |
168 | | - |
169 | | - # Include GPU directories |
170 | | - target_include_directories(Coyote |
171 | | - PUBLIC |
172 | | - $<BUILD_INTERFACE:${ROCM_PATH}/include> |
173 | | - $<BUILD_INTERFACE:${ROCM_PATH}/include/hsa> |
174 | | - ) |
175 | | - |
176 | | - # Add GPU libraries |
177 | | - target_link_libraries(Coyote PUBLIC hip::device numa pthread drm drm_amdgpu rt dl hsa-runtime64 hsakmt) |
178 | | - |
179 | | -endif() |
180 | | -if (EN_SIM) |
181 | | - target_compile_definitions(Coyote PUBLIC SIM_DIR="${SIM_DIR}") |
182 | | -endif() |
183 | | - |
184 | 47 |
|
| 48 | +add_subdirectory(${CYT_DIR}/sw) |
0 commit comments