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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
################################################################################
#
# Copyright (C) 2019-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.
#
################################################################################
cmake_minimum_required(VERSION 3.13)
if(NOT DEFINED TENSILE_ROOT)
get_filename_component(TENSILE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" DIRECTORY)
endif()
if(NOT DEFINED TENSILE_SCRIPT_ROOT)
set(TENSILE_SCRIPT_ROOT "${TENSILE_ROOT}/Tensile")
endif()
set(tensile_sources ${tensile_sources}
source/AMDGPU.cpp
source/ArithmeticUnitTypes.cpp
source/ContractionProblem.cpp
source/ContractionSolution.cpp
source/DataTypes.cpp
source/Debug.cpp
source/EmbeddedLibrary.cpp
source/KernelArguments.cpp
source/KernelLanguageTypes.cpp
source/MLFeatures.cpp
source/PerformanceMetricTypes.cpp
source/ScalarValueTypes.cpp
source/TensorDescriptor.cpp
source/TensorOps.cpp
source/Tensile.cpp
source/Utils.cpp
)
if(TENSILE_USE_LLVM)
find_package(LLVM REQUIRED CONFIG)
set(tensile_sources ${tensile_sources}
source/llvm/YAML.cpp
source/llvm/Loading.cpp
)
endif()
if(TENSILE_USE_MSGPACK)
set(tensile_sources ${tensile_sources}
source/msgpack/MessagePack.cpp
)
endif()
if(TENSILE_USE_HIP)
set(tensile_sources ${tensile_sources}
source/hip/HipSolutionAdapter.cpp
source/hip/HipHardware.cpp
)
endif()
if(TENSILE_USE_OPENCL)
set(tensile_sources ${tensile_sources}
source/ocl/OclHardware.cpp
source/ocl/OclSolutionAdapter.cpp
source/ocl/OclUtils.cpp
)
endif()
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include")
add_library (TensileHost STATIC ${tensile_sources})
set_target_properties(TensileHost
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
target_include_directories(TensileHost INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include")
if(TENSILE_USE_LLVM OR TENSILE_USE_MSGPACK)
target_compile_definitions(TensileHost PUBLIC TENSILE_DEFAULT_SERIALIZATION)
endif()
if(TENSILE_USE_MSGPACK)
find_package(msgpack REQUIRED NAMES msgpack msgpack-cxx msgpack-c)
target_compile_definitions(TensileHost PUBLIC -DTENSILE_MSGPACK=1)
if(TARGET msgpackc-cxx)
get_target_property(msgpack_inc msgpackc-cxx INTERFACE_INCLUDE_DIRECTORIES)
elseif(TARGET msgpackc)
get_target_property(msgpack_inc msgpackc INTERFACE_INCLUDE_DIRECTORIES)
elseif(TARGET msgpack-cxx)
get_target_property(msgpack_inc msgpack-cxx INTERFACE_INCLUDE_DIRECTORIES)
endif()
if(DEFINED msgpack_inc)
# include C++ headers manually
# External header includes included as system files
target_include_directories(TensileHost
SYSTEM PRIVATE $<BUILD_INTERFACE:${msgpack_inc}>
)
endif()
endif()
if(TENSILE_USE_LLVM)
target_compile_definitions(TensileHost PUBLIC -DTENSILE_YAML=1)
find_library(LLVMObjectYAML_LIBRARY
NAMES LLVMObjectYAML
PATHS ${LLVM_LIBRARY_DIR})
message("LLVMObjectYAML_LIBRARY: ${LLVMObjectYAML_LIBRARY}")
#Use LLVM shared libs if LLVMObjectYAML static lib cannot be found
if(LLVMObjectYAML_LIBRARY)
target_link_libraries(TensileHost PRIVATE LLVMObjectYAML )
else()
target_link_libraries(TensileHost PRIVATE LLVM )
endif()
target_include_directories(TensileHost PRIVATE ${LLVM_INCLUDE_DIRS})
endif()
if(TENSILE_STATIC_ONLY)
target_compile_definitions(TensileHost PUBLIC TENSILE_STATIC_ONLY)
endif()
if(TENSILE_USE_HIP)
target_compile_definitions(TensileHost PUBLIC TENSILE_USE_HIP)
#add_subdirectory(client)
target_link_libraries( TensileHost PUBLIC ${HSA_LIBRARIES} hip::device )
if(WIN32)
target_compile_options( TensileHost PUBLIC -Wno-deprecated-declarations -Wno-ignored-attributes -Wdll-attribute-on-redeclaration -fdelayed-template-parsing )
endif()
endif()
if(TENSILE_USE_OPENCL)
find_package(OpenCL REQUIRED)
target_compile_definitions(TensileHost PUBLIC CL_TARGET_OPENCL_VERSION=200)
target_compile_definitions(TensileHost PUBLIC CL_HPP_TARGET_OPENCL_VERSION=200)
target_compile_definitions(TensileHost PUBLIC CL_HPP_ENABLE_EXCEPTIONS)
target_link_libraries(TensileHost PUBLIC ${OPENCL_LIBRARIES})
target_include_directories(TensileHost PUBLIC ${OPENCL_INCLUDE_DIRS})
endif()
if(false)
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
endif()
|