CMakeLists.txt 3.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#####################################################################################
Paul's avatar
Paul committed
24

25
26
include(CheckCXXCompilerFlag)

Paul's avatar
Paul committed
27
add_library(migraphx_cpu
28
    allocate.cpp
29
30
    allocation_model.cpp
    binary.cpp
31
32
33
    concat.cpp
    convolution.cpp
    copy.cpp
34
35
36
37
    deconvolution.cpp
    dnnl.cpp
    eltwise.cpp
    erf.cpp
38
    fmod.cpp
39
    fuse_ops.cpp
40
    gather.cpp
41
    gemm.cpp
42
    layernorm.cpp
43
    logsoftmax.cpp
Shucai Xiao's avatar
Shucai Xiao committed
44
    lowering.cpp
45
    lrn.cpp
46
    mod.cpp
47
    preallocate.cpp
48
49
50
51
52
53
54
    pooling.cpp
    reduction.cpp
    reorder.cpp
    softmax.cpp
    sub.cpp
    target.cpp
    write_literals.cpp
Paul's avatar
Paul committed
55
)
Paul's avatar
Paul committed
56
set_target_properties(migraphx_cpu PROPERTIES EXPORT_NAME cpu)
Paul's avatar
Paul committed
57
rocm_set_soversion(migraphx_cpu ${MIGRAPHX_SO_VERSION})
Paul's avatar
Paul committed
58

59
set(MIGRAPHX_ENABLE_ZENDNN Off CACHE BOOL "")
60

Artur Wojcik's avatar
temp2  
Artur Wojcik committed
61
62
63
64
if(MIGRAPHX_ENABLE_ZENDNN)
    find_path(ZENDNN_INC_PATH zendnn.hpp)
    find_library(ZENDNN_LIB amdZenDNN)
    find_library(BLIS_LIB blis)
65
elseif(NOT WIN32)
Artur Wojcik's avatar
temp2  
Artur Wojcik committed
66
    find_package(dnnl REQUIRED)
67
endif()
Paul's avatar
Paul committed
68

Paul's avatar
Paul committed
69
rocm_clang_tidy_check(migraphx_cpu)
70
71
72
73
74
75
76
if(MIGRAPHX_ENABLE_ZENDNN)
    target_compile_definitions(migraphx_cpu PRIVATE -DMIGRAPHX_ENABLE_ZENDNN)
    target_include_directories(migraphx_cpu PRIVATE ${ZENDNN_INC_PATH})
    message(STATUS "ZENDNN_LIB: ${ZENDNN_LIB}")
    target_link_libraries(migraphx_cpu PRIVATE ${BLIS_LIB})
    target_link_libraries(migraphx_cpu PRIVATE ${ZENDNN_LIB})
else()
Artur Wojcik's avatar
Artur Wojcik committed
77
    target_link_libraries(migraphx_cpu PUBLIC DNNL::dnnl)
78
endif()
79
target_link_libraries(migraphx_cpu PRIVATE migraphx)
80

81
82
migraphx_generate_export_header(migraphx_cpu)

83
find_package(OpenMP)
Artur Wojcik's avatar
Artur Wojcik committed
84
85
86
87
88
89
90
91
92
93
94
95
96
97
if(WIN32)
    target_link_libraries(migraphx_cpu PUBLIC libomp)
    target_include_directories(migraphx_cpu PUBLIC ${OpenMP_CXX_INCLUDE_DIRS})
    target_compile_options(migraphx_cpu PUBLIC ${OpenMP_CXX_FLAGS})
else()
    target_link_libraries(migraphx_cpu PUBLIC OpenMP::OpenMP_CXX)
    # Add library path to rpath to workaround issues with our broken packages
    foreach(LIBRARY ${OpenMP_CXX_LIBRARIES})
        if(LIBRARY MATCHES "libomp")
            get_filename_component(LIBRARY_PATH "${LIBRARY}" PATH)
            target_link_libraries(migraphx_cpu PUBLIC -Wl,-rpath=${LIBRARY_PATH} -Wl,-rpath-link=${LIBRARY_PATH})
        endif()
    endforeach()
endif()
mei-ye's avatar
mei-ye committed
98

Paul's avatar
Paul committed
99
rocm_install_targets(
Paul's avatar
Paul committed
100
  TARGETS migraphx_cpu
Paul's avatar
Paul committed
101
102
103
  INCLUDE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)
mei-ye's avatar
mei-ye committed
104