CMakeLists.txt 3.34 KB
Newer Older
gilbertlee-amd's avatar
gilbertlee-amd committed
1
# Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
2

PedramAlizadeh's avatar
PedramAlizadeh committed
3
4
5
6
7
8
if (DEFINED ENV{ROCM_PATH})
    set(ROCM_PATH "$ENV{ROCM_PATH}" CACHE STRING "ROCm install directory")
else()
    set(ROCM_PATH "/opt/rocm" CACHE STRING "ROCm install directory")
endif()
cmake_minimum_required(VERSION 3.5)
9

gilbertlee-amd's avatar
gilbertlee-amd committed
10
project(TransferBench VERSION 1.62.00 LANGUAGES CXX)
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

# Default GPU architectures to build
#==================================================================================================
set(DEFAULT_GPUS
      gfx906
      gfx908
      gfx90a
      gfx942
      gfx1030
      gfx1100
      gfx1101
      gfx1102
      gfx1200
      gfx1201)

# Build only for local GPU architecture
if (BUILD_LOCAL_GPU_TARGET_ONLY)
  message(STATUS "Building only for local GPU target")
  if (COMMAND rocm_local_targets)
    rocm_local_targets(DEFAULT_GPUS)
  else()
    message(WARNING "Unable to determine local GPU targets. Falling back to default GPUs.")
  endif()
endif()

# Determine which GPU architectures to build for
37
set(GPU_TARGETS "${DEFAULT_GPUS}" CACHE STRING "Target default GPUs if GPU_TARGETS is not defined.")
38

39
# Check if clang compiler can offload to GPU_TARGETS
40
if (COMMAND rocm_check_target_ids)
41
42
  message(STATUS "Checking for ROCm support for GPU targets: " "${GPU_TARGETS}")
  rocm_check_target_ids(SUPPORTED_GPUS TARGETS ${GPU_TARGETS})
43
44
45
46
47
else()
  message(WARNING "Unable to check for supported GPU targets. Falling back to default GPUs.")
  set(SUPPORTED_GPUS ${DEFAULT_GPUS})
endif()

48
49
set(COMPILING_TARGETS "${SUPPORTED_GPUS}" CACHE STRING "GPU targets to compile for.")
message(STATUS "Compiling for ${COMPILING_TARGETS}")
50

51
foreach(target ${COMPILING_TARGETS})
52
53
54
 list(APPEND static_link_flags --offload-arch=${target})
endforeach()
list(JOIN static_link_flags " " flags_str)
55
set( CMAKE_CXX_FLAGS "${flags_str} ${CMAKE_CXX_FLAGS}")
56

57
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -L${ROCM_PATH}/lib")
PedramAlizadeh's avatar
PedramAlizadeh committed
58
include_directories(${ROCM_PATH}/include)
gilbertlee-amd's avatar
gilbertlee-amd committed
59
find_library(IBVERBS_LIBRARY ibverbs)
gilbertlee-amd's avatar
gilbertlee-amd committed
60
61
62
63
64
65
66
find_path(IBVERBS_INCLUDE_DIR infiniband/verbs.h)
if (DEFINED ENV{DISABLE_NIC_EXEC})
  message(STATUS "Disabling NIC Executor support")
elseif(IBVERBS_LIBRARY AND IBVERBS_INCLUDE_DIR)
  message(STATUS "Found ibverbs: ${IBVERBS_LIBRARY}. Building with NIC executor support. Can set DISABLE_NIC_EXEC=1 to disable")
  add_definitions(-DNIC_EXEC_ENABLED)
  link_libraries(ibverbs)
gilbertlee-amd's avatar
gilbertlee-amd committed
67
else()
gilbertlee-amd's avatar
gilbertlee-amd committed
68
69
70
71
72
73
  if (NOT IBVERBS_LIBRARY)
    message(WARNING "IBVerbs library not found")
  elseif (NOT IBVERBS_INCLUDE_DIR)
    message(WARNING "infiniband/verbs.h not found")
  endif()
  message(WARNING "Building without NIC executor support. To use the TransferBench RDMA executor, check if your system has NICs, the NIC drivers are installed, and libibverbs-dev is installed")
gilbertlee-amd's avatar
gilbertlee-amd committed
74
endif()
gilbertlee-amd's avatar
gilbertlee-amd committed
75

PedramAlizadeh's avatar
PedramAlizadeh committed
76
link_libraries(numa hsa-runtime64 pthread)
77
78
79
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY .)
add_executable(TransferBench src/client/Client.cpp)
target_include_directories(TransferBench PRIVATE src/header src/client src/client/Presets)
PedramAlizadeh's avatar
PedramAlizadeh committed
80

PedramAlizadeh's avatar
PedramAlizadeh committed
81
82
83
84
85
86
87
88
find_package(ROCM 0.8 REQUIRED PATHS ${ROCM_PATH})
include(ROCMInstallTargets)
include(ROCMCreatePackage)
set(ROCMCHECKS_WARN_TOOLCHAIN_VAR OFF)

set(PACKAGE_NAME TB)
set(LIBRARY_NAME TransferBench)

89
rocm_install(TARGETS TransferBench COMPONENT devel)
PedramAlizadeh's avatar
PedramAlizadeh committed
90

91
rocm_package_add_dependencies(DEPENDS numactl hsa-rocr)
92

PedramAlizadeh's avatar
PedramAlizadeh committed
93
94
95
96
97
rocm_create_package(
    NAME ${LIBRARY_NAME}
    DESCRIPTION "TransferBench package"
    MAINTAINER "RCCL Team <gilbert.lee@amd.com>"
)