Commit b0d4b866 authored by Artur Wojcik's avatar Artur Wojcik
Browse files

cmakes

parent f4a34657
...@@ -47,6 +47,8 @@ set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "") ...@@ -47,6 +47,8 @@ set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "")
set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/lib") set(CMAKE_BUILD_RPATH "${CMAKE_BINARY_DIR}/lib")
list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/llvm $ENV{ROCM_PATH} $ENV{HIP_PATH})
project(migraphx LANGUAGES C CXX) project(migraphx LANGUAGES C CXX)
include(CTest) include(CTest)
...@@ -56,12 +58,16 @@ find_package(Threads REQUIRED) ...@@ -56,12 +58,16 @@ find_package(Threads REQUIRED)
# By default build shared libraries # By default build shared libraries
option(BUILD_SHARED_LIBS "Create shared libraries" ON) option(BUILD_SHARED_LIBS "Create shared libraries" ON)
find_path(HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half) if(WIN32)
if (NOT HALF_INCLUDE_DIR) add_compile_definitions($<$<COMPILE_LANGUAGE:C,CXX>:_CRT_SECURE_NO_WARNINGS>)
message(FATAL_ERROR "Could not find half.hpp - Please check that the install path of half.hpp has been added to CMAKE_PREFIX_PATH") add_subdirectory(extern)
else() else()
message(STATUS "half.hpp is at ${HALF_INCLUDE_DIR}") find_path(HALF_INCLUDE_DIR half.hpp PATH_SUFFIXES half)
if (NOT HALF_INCLUDE_DIR)
message(FATAL_ERROR "Could not find half.hpp - Please check that the install path of half.hpp has been added to CMAKE_PREFIX_PATH")
endif()
endif() endif()
message(STATUS "half.hpp is at ${HALF_INCLUDE_DIR}")
include(CheckTypeSize) include(CheckTypeSize)
set(CMAKE_REQUIRED_INCLUDES ${HALF_INCLUDE_DIR}) set(CMAKE_REQUIRED_INCLUDES ${HALF_INCLUDE_DIR})
...@@ -94,13 +100,14 @@ set(MIGRAPHX_ENABLE_CPU Off CACHE BOOL "") ...@@ -94,13 +100,14 @@ set(MIGRAPHX_ENABLE_CPU Off CACHE BOOL "")
# Disable fpga backend by default # Disable fpga backend by default
set(MIGRAPHX_ENABLE_FPGA Off CACHE BOOL "") set(MIGRAPHX_ENABLE_FPGA Off CACHE BOOL "")
set(CMAKE_CXX_STANDARD_DEFAULT "") set(CMAKE_CXX_STANDARD 17)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=c++17>) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(EnableCompilerWarnings) include(EnableCompilerWarnings)
include(ROCMClangTidy) include(ROCMClangTidy)
if(CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+") if(CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+.*")
set(MIGRAPHX_TIDY_ERRORS ERRORS * -readability-inconsistent-declaration-parameter-name) set(MIGRAPHX_TIDY_ERRORS ERRORS * -readability-inconsistent-declaration-parameter-name)
# Enable tidy on hip # Enable tidy on hip
elseif(MIGRAPHX_ENABLE_GPU) elseif(MIGRAPHX_ENABLE_GPU)
......
...@@ -22,16 +22,14 @@ ...@@ -22,16 +22,14 @@
# THE SOFTWARE. # THE SOFTWARE.
# #################################################################################### # ####################################################################################
list(APPEND CMAKE_PREFIX_PATH /opt/rocm) list(APPEND CMAKE_PREFIX_PATH /opt/rocm $ENV{ROCM_PATH})
find_package(miopen)
# rocblas find_package(miopen REQUIRED)
find_package(rocblas REQUIRED PATHS /opt/rocm) message(STATUS "MIGraphX is using MIOpen")
message(STATUS "Build with rocblas")
if(NOT TARGET MIOpen) # rocblas
message(SEND_ERROR "Cant find miopen") find_package(rocblas REQUIRED)
endif() message(STATUS "MIGraphX build with rocBLAS")
if(NOT WIN32) if(NOT WIN32)
# TODO: re-enable when CK is ported to Windows # TODO: re-enable when CK is ported to Windows
...@@ -60,12 +58,11 @@ if(NOT WIN32) ...@@ -60,12 +58,11 @@ if(NOT WIN32)
endif() endif()
configure_file(device/targets.hpp.in include/migraphx/gpu/device/targets.hpp) configure_file(device/targets.hpp.in include/migraphx/gpu/device/targets.hpp)
file(GLOB DEVICE_GPU_SRCS CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/device/*.cpp)
add_library(migraphx_device ${DEVICE_GPU_SRCS})
add_library(compile_for_gpu INTERFACE) add_library(compile_for_gpu INTERFACE)
target_compile_options(compile_for_gpu INTERFACE -std=c++17 -fno-gpu-rdc -Wno-cuda-compat -Wno-unused-command-line-argument -Xclang -fallow-half-arguments-and-returns) target_compile_features(compile_for_gpu INTERFACE cxx_std_17)
target_link_libraries(compile_for_gpu INTERFACE hip::device -fno-gpu-rdc -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Wno-option-ignored) target_compile_options(compile_for_gpu INTERFACE -fno-gpu-rdc -Wno-cuda-compat -Wno-unused-command-line-argument -Xclang -fallow-half-arguments-and-returns)
target_link_options(compile_for_gpu INTERFACE -fno-gpu-rdc -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Wno-option-ignored)
target_link_libraries(compile_for_gpu INTERFACE hip::device)
check_cxx_compiler_flag("--cuda-host-only -fhip-lambda-host-device -x hip" HAS_HIP_LAMBDA_HOST_DEVICE) check_cxx_compiler_flag("--cuda-host-only -fhip-lambda-host-device -x hip" HAS_HIP_LAMBDA_HOST_DEVICE)
if(HAS_HIP_LAMBDA_HOST_DEVICE) if(HAS_HIP_LAMBDA_HOST_DEVICE)
...@@ -73,6 +70,23 @@ if(HAS_HIP_LAMBDA_HOST_DEVICE) ...@@ -73,6 +70,23 @@ if(HAS_HIP_LAMBDA_HOST_DEVICE)
target_compile_options(compile_for_gpu INTERFACE -fhip-lambda-host-device) target_compile_options(compile_for_gpu INTERFACE -fhip-lambda-host-device)
endif() endif()
add_library(migraphx_device
device/argmax.cpp
device/argmin.cpp
device/contiguous.cpp
device/fill.cpp
device/gather.cpp
device/int8_gemm_pack.cpp
device/logsoftmax.cpp
device/multinomial.cpp
device/nonzero.cpp
device/pad.cpp
device/prefix_scan_sum.cpp
device/reverse.cpp
device/rnn_variable_seq_lens.cpp
device/scatter.cpp
device/topk.cpp)
set_target_properties(migraphx_device PROPERTIES EXPORT_NAME device) set_target_properties(migraphx_device PROPERTIES EXPORT_NAME device)
rocm_set_soversion(migraphx_device ${MIGRAPHX_SO_VERSION}) rocm_set_soversion(migraphx_device ${MIGRAPHX_SO_VERSION})
rocm_clang_tidy_check(migraphx_device) rocm_clang_tidy_check(migraphx_device)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment