This repository has been archived by the owner on Mar 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
76 lines (63 loc) · 2.47 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.8)
# HIP_PATH
IF(NOT DEFINED $ENV{HIP_PATH})
SET(HIP_PATH /opt/rocm/hip)
ELSE()
SET(HIP_PATH $ENV{HIP_PATH})
ENDIF()
# HCC_PATH
IF(NOT DEFINED $ENV{HCC_PATH})
SET(HCC_PATH /opt/rocm/hcc)
ELSE()
SET(HCC_PATH $ENV{HCC_PATH})
ENDIF()
# HIPBLAS_PATH
IF(NOT DEFINED $ENV{HIPBLAS_PATH})
SET(HIPBLAS_PATH /opt/rocm/hcblas/)
ELSE()
SET(HIPBLAS_PATH $ENV{HIPBLAS_PATH})
ENDIF()
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${CMAKE_MODULE_PATH}"
"${HIP_PATH}/cmake")
EXECUTE_PROCESS(COMMAND ${HIP_PATH}/bin/hipconfig -P OUTPUT_VARIABLE PLATFORM)
EXECUTE_PROCESS(COMMAND ${HIP_PATH}/bin/hipconfig --cpp_config OUTPUT_VARIABLE HIP_CXX_FLAGS)
SET(HIP_CXX_FLAGS "-D__HIP_PLATFORM_HCC__ -I/opt/rocm/hip/include -I/opt/rocm/hcc/include")
FIND_PACKAGE(Torch REQUIRED)
FIND_PACKAGE(HIP 1.0 REQUIRED)
IF(${HIP_PLATFORM} STREQUAL "nvcc") # NVCC
FIND_PACKAGE(CUDA 6.5 REQUIRED)
ELSE() # HCC
SET(HIP_HIPCC_FLAGS "-DGENERIC_GRID_LAUNCH=1 ${HIP_HIPCC_FLAGS}")
SET(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
SET(CMAKE_C_COMPILER ${HIP_HIPCC_EXECUTABLE})
SET(CMAKE_C_FLAGS "-std=c99 -Werror=implicit-function-declaration ${CMAKE_C_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${HIP_CXX_FLAGS}")
SET(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} ${HIP_CXX_FLAGS}")
ENDIF()
# # TODO: temporary blunt implements.
IF (${PLATFORM} MATCHES "hcc")
include_directories(${HCC_PATH}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/bolt/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/boost)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/boost)
ENDIF()
include_directories(${HIP_PATH}/include)
MESSAGE( STATUS "HIP_CXX_FLAGS: " ${HIP_CXX_FLAGS} )
MESSAGE( STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS} )
MESSAGE( STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} )
MESSAGE( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )
MESSAGE( STATUS "CMAKE_C_COMPILER: " ${CMAKE_C_COMPILER} )
INCLUDE_DIRECTORIES("${Torch_INSTALL_INCLUDE}/THC")
LINK_DIRECTORIES("${Torch_INSTALL_LIB}")
FILE(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/lib/THCUNN/THCUNN.h THCUNN_headers NEWLINE_CONSUME)
FILE(WRITE THCUNN_h.lua "return [[")
FILE(APPEND THCUNN_h.lua ${THCUNN_headers})
FILE(APPEND THCUNN_h.lua "]]")
FILE(GLOB luasrc *.lua)
ADD_SUBDIRECTORY(lib)
INSTALL(
FILES
${luasrc}
DESTINATION "${Torch_INSTALL_LUA_PATH_SUBDIR}/cunn")