CMakeLists.txt 5.67 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/greater.cpp
41
    device/int8_gemm_pack.cpp
kahmed10's avatar
kahmed10 committed
42
    device/layernorm.cpp
43
    device/less.cpp
44
45
46
47
48
49
50
51
52
    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
53
    device/prelu.cpp
kahmed10's avatar
kahmed10 committed
54
    device/recip.cpp
55
    device/reduce_max.cpp
56
    device/reduce_mean.cpp
Shucai Xiao's avatar
Shucai Xiao committed
57
    device/reduce_min.cpp
58
    device/reduce_sum.cpp
Shucai Xiao's avatar
Shucai Xiao committed
59
    device/reduce_prod.cpp
60
61
62
63
    device/relu.cpp
    device/round.cpp
    device/rsqrt.cpp
    device/sigmoid.cpp
Shucai Xiao's avatar
Shucai Xiao committed
64
    device/sign.cpp
65
66
67
68
69
70
71
72
    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
73
    device/rnn_variable_seq_lens.cpp
74
    device/equal.cpp
75
)
Paul's avatar
Paul committed
76
set_target_properties(migraphx_device PROPERTIES EXPORT_NAME device)
Paul's avatar
Paul committed
77
rocm_set_soversion(migraphx_device ${MIGRAPHX_SO_VERSION})
Paul's avatar
Paul committed
78
rocm_clang_tidy_check(migraphx_device)
Paul's avatar
Paul committed
79
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
80
81
82
83
84
85
86
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
87
88
else()
    target_compile_options(migraphx_device PRIVATE -Wno-cuda-compat)
Paul Fultz II's avatar
Paul Fultz II committed
89
endif()
90
91
92
93
94
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
95
96
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>)
97

Paul's avatar
Paul committed
98
add_library(migraphx_gpu
99
    analyze_streams.cpp
Shucai Xiao's avatar
Shucai Xiao committed
100
101
    argmax.cpp
    argmin.cpp
102
    eliminate_workspace.cpp
Paul's avatar
Paul committed
103
    fuse_ops.cpp
Paul's avatar
Paul committed
104
    hip.cpp
Paul's avatar
Paul committed
105
    target.cpp
Paul's avatar
Paul committed
106
    lowering.cpp
wsttiger's avatar
wsttiger committed
107
108
    pooling.cpp
    convolution.cpp
kahmed10's avatar
kahmed10 committed
109
    deconvolution.cpp
110
    quant_convolution.cpp
111
    softmax.cpp
112
    logsoftmax.cpp
113
    concat.cpp
Khalique's avatar
Khalique committed
114
    leaky_relu.cpp
115
    batch_norm_inference.cpp
Paul's avatar
Paul committed
116
    write_literals.cpp
117
    rocblas.cpp
Khalique's avatar
Khalique committed
118
    abs.cpp
Khalique's avatar
Khalique committed
119
    elu.cpp
120
    pad.cpp
121
    gather.cpp
Shucai Xiao's avatar
Shucai Xiao committed
122
    convert.cpp
Khalique's avatar
Khalique committed
123
    lrn.cpp
Paul's avatar
Paul committed
124
    schedule_model.cpp
125
    adjust_allocation.cpp
126
    pack_int8_args.cpp
Khalique's avatar
Khalique committed
127
    clip.cpp
128
129
    int8_gemm_pack.cpp
    int8_conv_pack.cpp
130
    gemm_impl.cpp
131
    preallocate_param.cpp
Shucai Xiao's avatar
Shucai Xiao committed
132
    rnn_variable_seq_lens.cpp
133
    sync_device.cpp
Paul's avatar
Paul committed
134
)
Paul's avatar
Paul committed
135
set_target_properties(migraphx_gpu PROPERTIES EXPORT_NAME gpu)
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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
158
    equal
159
160
161
162
    erf
    exp
    floor
    gather
163
164
    greater
    less
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
214
215
216
217
    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
218
rocm_set_soversion(migraphx_gpu ${MIGRAPHX_SO_VERSION})
Paul's avatar
Paul committed
219
rocm_clang_tidy_check(migraphx_gpu)
Paul Fultz II's avatar
Paul Fultz II committed
220
221
# Workaround broken rocblas headers
target_compile_definitions(migraphx_gpu PUBLIC -D__HIP_PLATFORM_HCC__=1)
222
target_compile_options(migraphx_gpu PRIVATE -std=c++17)
Paul's avatar
Paul committed
223
224
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
225

Paul's avatar
Paul committed
226
rocm_install_targets(
Paul's avatar
Paul committed
227
  TARGETS migraphx_gpu migraphx_device
Paul's avatar
Paul committed
228
229
230
  INCLUDE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
mei-ye's avatar
mei-ye committed
231