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
85 lines (70 loc) · 2.36 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
77
78
79
80
81
82
83
84
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()
# 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_CURRENT_SOURCE_DIR}/lib/THC/cmake
${CMAKE_MODULE_PATH}
"${HIP_PATH}/cmake")
EXECUTE_PROCESS(COMMAND ${HIP_PATH}/bin/hipconfig -P OUTPUT_VARIABLE PLATFORM)
include(HipTorchWrap)
FIND_PACKAGE(Torch REQUIRED)
FIND_PACKAGE(HIP 1.0 REQUIRED)
IF(${PLATFORM} STREQUAL "nvcc")
FIND_PACKAGE(CUDA 6.5 REQUIRED)
FIND_PACKAGE(MAGMA)
ENDIF()
EXECUTE_PROCESS(
COMMAND ${HIP_PATH}/bin/hipconfig --cpp_config OUTPUT_VARIABLE HIP_CXX_FLAGS)
IF(${PLATFORM} MATCHES "hcc")
SET(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
ENDIF()
IF (NOT WIN32)
SET(
CMAKE_C_FLAGS
"-std=c99 -Werror=implicit-function-declaration ${CMAKE_C_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${HIP_CXX_FLAGS}")
ENDIF (NOT WIN32)
IF(CUDA_HAS_FP16 OR NOT ${CUDA_VERSION} LESS 7.5 OR ${PLATFORM} MATCHES "hcc")
# TODO: NEEL FP!6 support
# SET(CMAKE_C_FLAGS "-DCUDA_HAS_FP16=1 ${CMAKE_C_FLAGS}")
SET(
CMAKE_CXX_FLAGS
"-std=c++11 -DCUDA_HAS_FP16=1 ${CMAKE_CXX_FLAGS} ${HIP_CXX_FLAGS}")
ENDIF()
INCLUDE_DIRECTORIES(${HIP_PATH}/include)
INCLUDE_DIRECTORIES(${HIPBLAS_PATH}/include)
# TODO: temporary blunt implements.
IF (${PLATFORM} MATCHES "hcc")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/bolt/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/boost)
ENDIF()
ADD_SUBDIRECTORY(lib)
INCLUDE_DIRECTORIES(BEFORE "${CMAKE_CURRENT_BINARY_DIR}/lib/THC")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/lib/THC")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/torch")
LINK_DIRECTORIES("${HIP_PATH}/lib")
SET(src Storage.cc init.cc Tensor.cc TensorMath.cc TensorOperator.cc torch/utils.c)
SET(luasrc init.lua Tensor.lua FFI.lua test/test.lua)
ADD_HIP_TORCH_WRAP(HipTensormathwrap TensorMath.lua)
ADD_TORCH_PACKAGE(cutorch "${src}" "${luasrc}")
IF(${PLATFORM} MATCHES "hcc")
TARGET_LINK_LIBRARIES(cutorch luaT THC hip_hcc)
ELSEIF(${PLATFORM} MATCHES "nvcc")
TARGET_LINK_LIBRARIES(cutorch luaT THC)
ENDIF()
IF(LUALIB)
TARGET_LINK_LIBRARIES(cutorch ${LUALIB})
ENDIF()