CMakeLists.txt 5.6 KB
Newer Older
Paul's avatar
Paul committed
1
2
3
4

list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hip /opt/rocm/hcc)
find_package(miopen)

5
6
7
8
# rocblas
find_package(rocblas REQUIRED PATHS /opt/rocm)
message(STATUS "Build with rocblas")

Paul's avatar
Paul committed
9
10
11
12
if(NOT TARGET MIOpen)
    message(SEND_ERROR "Cant find miopen")
endif()

Paul's avatar
Paul committed
13
add_library(migraphx_device
14
    device/acos.cpp
15
    device/acosh.cpp
Paul's avatar
Paul committed
16
    device/add.cpp
17
18
19
20
    device/add_clip.cpp
    device/add_relu.cpp
    device/add_sigmoid.cpp
    device/add_tanh.cpp
Shucai Xiao's avatar
Shucai Xiao committed
21
22
    device/argmax.cpp
    device/argmin.cpp
23
    device/asin.cpp
24
    device/asinh.cpp
25
    device/atan.cpp
26
    device/atanh.cpp
27
28
29
    device/ceil.cpp
    device/clip.cpp
    device/concat.cpp
30
    device/contiguous.cpp
31
    device/convert.cpp
32
33
34
35
36
37
    device/cos.cpp
    device/cosh.cpp
    device/div.cpp
    device/erf.cpp
    device/exp.cpp
    device/floor.cpp
38
    device/gather.cpp
kahmed10's avatar
kahmed10 committed
39
    device/gelu.cpp
40
    device/int8_gemm_pack.cpp
kahmed10's avatar
kahmed10 committed
41
    device/layernorm.cpp
42
43
44
45
46
47
48
49
50
    device/log.cpp
    device/logsoftmax.cpp
    device/max.cpp
    device/min.cpp
    device/mul.cpp
    device/mul_add.cpp
    device/mul_add_relu.cpp
    device/pad.cpp
    device/pow.cpp
Shucai Xiao's avatar
Shucai Xiao committed
51
    device/prelu.cpp
kahmed10's avatar
kahmed10 committed
52
    device/recip.cpp
53
    device/reduce_max.cpp
54
    device/reduce_mean.cpp
Shucai Xiao's avatar
Shucai Xiao committed
55
    device/reduce_min.cpp
56
    device/reduce_sum.cpp
Shucai Xiao's avatar
Shucai Xiao committed
57
    device/reduce_prod.cpp
58
59
60
61
    device/relu.cpp
    device/round.cpp
    device/rsqrt.cpp
    device/sigmoid.cpp
Shucai Xiao's avatar
Shucai Xiao committed
62
    device/sign.cpp
63
64
65
66
67
68
69
70
    device/sin.cpp
    device/sinh.cpp
    device/softmax.cpp
    device/sqdiff.cpp
    device/sqrt.cpp
    device/sub.cpp
    device/tan.cpp
    device/tanh.cpp
Shucai Xiao's avatar
Shucai Xiao committed
71
    device/rnn_variable_seq_lens.cpp
72
    device/equal.cpp
73
)
Paul's avatar
Paul committed
74
set_target_properties(migraphx_device PROPERTIES EXPORT_NAME device)
Paul's avatar
Paul committed
75
rocm_set_soversion(migraphx_device ${MIGRAPHX_SO_VERSION})
Paul's avatar
Paul committed
76
rocm_clang_tidy_check(migraphx_device)
Paul's avatar
Paul committed
77
target_compile_options(migraphx_device PRIVATE -std=c++17 -fno-gpu-rdc -Wno-unused-command-line-argument -Xclang -fallow-half-arguments-and-returns)
Paul Fultz II's avatar
Paul Fultz II committed
78
79
80
81
82
83
84
target_link_libraries(migraphx_device migraphx hip::device -fno-gpu-rdc -Wno-invalid-command-line-argument -Wno-unused-command-line-argument)
if(CMAKE_CXX_COMPILER MATCHES ".*hcc")
    set(AMDGPU_TARGETS "gfx803;gfx900;gfx906" CACHE STRING "")
    foreach(AMDGPU_TARGET ${AMDGPU_TARGETS})
        target_compile_options(migraphx_device PRIVATE -amdgpu-target=${AMDGPU_TARGET})
        target_link_libraries(migraphx_device -amdgpu-target=${AMDGPU_TARGET})
    endforeach()
Paul's avatar
Paul committed
85
86
else()
    target_compile_options(migraphx_device PRIVATE -Wno-cuda-compat)
Paul Fultz II's avatar
Paul Fultz II committed
87
endif()
88
89
90
91
92
check_cxx_compiler_flag("--cuda-host-only -fhip-lambda-host-device -x hip" HAS_HIP_LAMBDA_HOST_DEVICE)
if(HAS_HIP_LAMBDA_HOST_DEVICE)
  message(STATUS "Enable -fhip-lambda-host-device")
  target_compile_options(migraphx_device PRIVATE -fhip-lambda-host-device)
endif()
Paul's avatar
Paul committed
93
94
target_include_directories(migraphx_device PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
target_include_directories(migraphx_device PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/device/include>)
95

Paul's avatar
Paul committed
96
add_library(migraphx_gpu
97
    analyze_streams.cpp
Shucai Xiao's avatar
Shucai Xiao committed
98
99
    argmax.cpp
    argmin.cpp
100
    eliminate_workspace.cpp
Paul's avatar
Paul committed
101
    fuse_ops.cpp
Paul's avatar
Paul committed
102
    hip.cpp
Paul's avatar
Paul committed
103
    target.cpp
Paul's avatar
Paul committed
104
    lowering.cpp
wsttiger's avatar
wsttiger committed
105
106
    pooling.cpp
    convolution.cpp
kahmed10's avatar
kahmed10 committed
107
    deconvolution.cpp
108
    quant_convolution.cpp
109
    softmax.cpp
110
    logsoftmax.cpp
111
    concat.cpp
Khalique's avatar
Khalique committed
112
    leaky_relu.cpp
113
    batch_norm_inference.cpp
Paul's avatar
Paul committed
114
    write_literals.cpp
115
    rocblas.cpp
Khalique's avatar
Khalique committed
116
    abs.cpp
Khalique's avatar
Khalique committed
117
    elu.cpp
118
    pad.cpp
119
    gather.cpp
Shucai Xiao's avatar
Shucai Xiao committed
120
    convert.cpp
Khalique's avatar
Khalique committed
121
    lrn.cpp
Paul's avatar
Paul committed
122
    schedule_model.cpp
123
    adjust_allocation.cpp
124
    pack_int8_args.cpp
Khalique's avatar
Khalique committed
125
    clip.cpp
126
127
    int8_gemm_pack.cpp
    int8_conv_pack.cpp
128
    gemm_impl.cpp
129
    preallocate_param.cpp
Shucai Xiao's avatar
Shucai Xiao committed
130
    rnn_variable_seq_lens.cpp
131
    sync_device.cpp
Paul's avatar
Paul committed
132
)
Paul's avatar
Paul committed
133
set_target_properties(migraphx_gpu PROPERTIES EXPORT_NAME gpu)
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function(register_migraphx_gpu_ops PREFIX)
    foreach(OP ${ARGN})
        register_op(migraphx_gpu HEADER migraphx/gpu/${OP}.hpp OPERATORS gpu::${PREFIX}${OP} INCLUDES migraphx/gpu/context.hpp)
    endforeach()
endfunction()
register_migraphx_gpu_ops(hip_
    acosh
    acos
    add
    argmax
    argmin
    asinh
    asin
    atanh
    atan
    ceil
    clip
    concat
    convert
    cosh
    cos
    div
156
    equal
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
    erf
    exp
    floor
    gather
    log
    logsoftmax
    max
    min
    mul
    pad
    pow
    prelu
    recip
    reduce_max
    reduce_mean
    reduce_min
    reduce_prod
    reduce_sum
    relu
    round
    rsqrt
    sigmoid
    sign
    sinh
    sin
    softmax
    sqdiff
    sqrt
    sub
    tanh
    tan
)
register_migraphx_gpu_ops(miopen_
    abs
    batch_norm_inference
    contiguous
    convolution
    deconvolution
    elu
    int8_conv_pack
    leaky_relu
    lrn
    pooling
    quant_convolution
)
register_op(migraphx_gpu 
    HEADER migraphx/gpu/rnn_variable_seq_lens.hpp 
    OPERATORS gpu::hip_rnn_var_sl_shift_sequence gpu::hip_rnn_var_sl_shift_output gpu::hip_rnn_var_sl_last_output
    INCLUDES migraphx/gpu/context.hpp)
register_op(migraphx_gpu 
    HEADER migraphx/gpu/int8_gemm_pack.hpp 
    OPERATORS gpu::hip_int8_gemm_pack_a gpu::hip_int8_gemm_pack_b
    INCLUDES migraphx/gpu/context.hpp)
register_op(migraphx_gpu 
    HEADER migraphx/gpu/gemm.hpp 
    OPERATORS gpu::rocblas_gemm<op::dot> gpu::rocblas_gemm<op::quant_dot>
    INCLUDES migraphx/gpu/context.hpp)
Paul's avatar
Paul committed
214
rocm_set_soversion(migraphx_gpu ${MIGRAPHX_SO_VERSION})
Paul's avatar
Paul committed
215
rocm_clang_tidy_check(migraphx_gpu)
Paul Fultz II's avatar
Paul Fultz II committed
216
217
# Workaround broken rocblas headers
target_compile_definitions(migraphx_gpu PUBLIC -D__HIP_PLATFORM_HCC__=1)
218
target_compile_options(migraphx_gpu PRIVATE -std=c++17)
Paul's avatar
Paul committed
219
220
target_link_libraries(migraphx_gpu PUBLIC migraphx MIOpen roc::rocblas)
target_link_libraries(migraphx_gpu PRIVATE migraphx_device)
mei-ye's avatar
mei-ye committed
221

Paul's avatar
Paul committed
222
rocm_install_targets(
Paul's avatar
Paul committed
223
  TARGETS migraphx_gpu migraphx_device
Paul's avatar
Paul committed
224
225
226
  INCLUDE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
mei-ye's avatar
mei-ye committed
227