[TE] Improve AMD HIP support with hipify-perl (#1154)

* Improve AMD HIP support with hipify-perl

This commit improves AMD GPU support by migrating to hipify-perl
for automatic CUDA-to-HIP code conversion at build time, and extends HIP
compatibility to the NVLink transport layer.

* [TE] Add HIP support to nvlink-allocator with hipcc compilation

* Add USE_HIP to the documentation

* [TE/NVLINK] Check CU_DEVICE_ATTRIBUTE_HANDLE_TYPE_FABRIC_SUPPORTED only if USE_CUDA

* [TE/EXAMPLE] Fix compiler error if USE_MNNVL and USE_HIP

* Address review  comments
This commit is contained in:
Anatolii Rozanov 2025-12-05 14:01:42 +01:00 committed by GitHub
parent 73fe0b954f
commit 1373d5875f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 188 additions and 128 deletions

View File

@ -152,6 +152,7 @@ cd /Mooncake-main/build/mooncake-transfer-engine/example
## Advanced Compile Options
The following options can be used during `cmake ..` to specify whether to compile certain components of Mooncake.
- `-DUSE_CUDA=[ON|OFF]`: Enable GPU Direct RDMA and NVMe-of support
- `-DUSE_HIP=[ON|OFF]`: Enable AMD GPU support via HIP/ROCm
- `-DUSE_CXL=[ON|OFF]`: Enable CXL support
- `-DWITH_STORE=[ON|OFF]`: Build Mooncake Store component
- `-DWITH_P2P_STORE=[ON|OFF]`: Enable Golang support and build P2P Store component, require go 1.23+

View File

@ -144,6 +144,7 @@ cd /Mooncake-main/build/mooncake-transfer-engine/example
## Advanced Compile Options
The following options can be used during `cmake ..` to specify whether to compile certain components of Mooncake.
- `-DUSE_CUDA=[ON|OFF]`: Enable GPU Direct RDMA and NVMe-of support
- `-DUSE_HIP=[ON|OFF]`: Enable AMD GPU support via HIP/ROCm
- `-DUSE_CXL=[ON|OFF]`: Enable CXL support
- `-DWITH_STORE=[ON|OFF]`: Build Mooncake Store component
- `-DWITH_P2P_STORE=[ON|OFF]`: Enable Golang support and build P2P Store component, require go 1.23+

View File

@ -99,7 +99,9 @@ if (USE_NVMEOF)
endif()
if (USE_MNNVL)
set(USE_CUDA ON)
if(NOT USE_HIP)
set(USE_CUDA ON)
endif()
add_compile_definitions(USE_MNNVL)
message(STATUS "Multi-Node NVLink support is enabled")
endif()
@ -124,24 +126,46 @@ if (USE_MUSA)
endif()
if (USE_HIP)
if (NOT EXISTS $ENV{ROCM_PATH})
if (NOT EXISTS /opt/rocm)
set(ROCM_PATH /usr)
else()
set(ROCM_PATH /opt/rocm)
endif()
else()
set(ROCM_PATH $ENV{ROCM_PATH})
endif()
add_definitions(-D__HIP_PLATFORM_AMD__)
add_compile_definitions(USE_HIP)
list(APPEND CMAKE_PREFIX_PATH "/opt/rocm/lib/cmake")
find_package(HIP REQUIRED)
include_directories(${HIP_INCLUDE_DIRS})
add_compile_definitions(USE_HIP __HIP_PLATFORM_AMD__)
message(STATUS "HIP support is enabled")
include_directories("${ROCM_PATH}/include")
link_directories(
"${ROCM_PATH}/lib"
)
find_program(HIPIFY_PERL_EXECUTABLE hipify-perl)
if(NOT HIPIFY_PERL_EXECUTABLE)
message(FATAL_ERROR
"hipify-perl not found.\n"
"Please ensure the ROCm or HIP SDK is installed and in your PATH.")
endif()
endif()
# This function converts given CUDA source files into HIP-compatible
# files using hipify-perl, placing the outputs in the build directory for use in
# project compilation. The file path changes to a new location after hipify.
function(hipify_files input_var_name)
set(result_files)
foreach(input_file IN LISTS ${input_var_name})
file(RELATIVE_PATH rel_path ${CMAKE_SOURCE_DIR} ${input_file})
set(output_file "${CMAKE_BINARY_DIR}/${rel_path}")
get_filename_component(output_dir ${output_file} DIRECTORY)
file(MAKE_DIRECTORY ${output_dir})
add_custom_command(
OUTPUT ${output_file}
COMMAND ${HIPIFY_PERL_EXECUTABLE} ${input_file} > ${output_file}
DEPENDS ${input_file}
COMMENT "HIPifying ${input_file} ${output_file}"
)
list(APPEND result_files ${output_file})
endforeach()
set(${input_var_name} ${result_files} PARENT_SCOPE)
endfunction()
if (USE_CXL)
add_compile_definitions(USE_CXL)
message(STATUS "CXL support is enabled")

View File

@ -39,6 +39,10 @@ if [ -d "/usr/local/cuda/lib64" ]; then
EXT_LDFLAGS+=" -L/usr/local/cuda/lib64 -lcudart"
fi
if [ -d "/opt/rocm/lib" ]; then
EXT_LDFLAGS+=" -L/opt/rocm/lib64 -L/opt/rocm/lib -lamdhip64"
fi
if [ -d "/usr/local/musa/lib" ]; then
EXT_LDFLAGS+=" -L/usr/local/musa/lib -lmusart"
fi

View File

@ -1,29 +1,39 @@
add_executable(transfer_engine_bench transfer_engine_bench.cpp)
set(WORKSPACE "${CMAKE_CURRENT_SOURCE_DIR}")
if (USE_HIP)
file(GLOB EXAMPLE_SOURCES "*.cpp")
hipify_files(EXAMPLE_SOURCES)
file(RELATIVE_PATH EXAMPLE_REL_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
set(WORKSPACE "${CMAKE_BINARY_DIR}/${EXAMPLE_REL_PATH}")
endif()
add_executable(transfer_engine_bench ${WORKSPACE}/transfer_engine_bench.cpp)
target_link_libraries(transfer_engine_bench PUBLIC transfer_engine)
add_executable(transfer_engine_validator transfer_engine_validator.cpp)
add_executable(transfer_engine_validator ${WORKSPACE}/transfer_engine_validator.cpp)
target_link_libraries(transfer_engine_validator PUBLIC transfer_engine)
add_executable(transfer_engine_bench_with_notify transfer_engine_bench_with_notify.cpp)
add_executable(transfer_engine_bench_with_notify ${WORKSPACE}/transfer_engine_bench_with_notify.cpp)
target_link_libraries(transfer_engine_bench_with_notify PUBLIC transfer_engine)
add_executable(memory_pool memory_pool.cpp)
add_executable(memory_pool ${WORKSPACE}/memory_pool.cpp)
target_link_libraries(memory_pool PUBLIC transfer_engine)
if (USE_ASCEND)
add_executable(transfer_engine_ascend_one_sided transfer_engine_ascend_one_sided.cpp)
add_executable(transfer_engine_ascend_one_sided ${WORKSPACE}/transfer_engine_ascend_one_sided.cpp)
target_link_libraries(transfer_engine_ascend_one_sided PUBLIC transfer_engine)
add_executable(transfer_engine_ascend_perf transfer_engine_ascend_perf.cpp)
add_executable(transfer_engine_ascend_perf ${WORKSPACE}/transfer_engine_ascend_perf.cpp)
target_link_libraries(transfer_engine_ascend_perf PUBLIC transfer_engine)
endif()
if (USE_ASCEND_DIRECT)
add_executable(transfer_engine_ascend_direct_perf transfer_engine_ascend_direct_perf.cpp)
add_executable(transfer_engine_ascend_direct_perf ${WORKSPACE}/transfer_engine_ascend_direct_perf.cpp)
target_link_libraries(transfer_engine_ascend_direct_perf PUBLIC ascendcl transfer_engine)
endif()
if (USE_ASCEND_HETEROGENEOUS)
add_executable(transfer_engine_heterogeneous_ascend_perf_initiator transfer_engine_heterogeneous_ascend_perf_initiator.cpp)
add_executable(transfer_engine_heterogeneous_ascend_perf_initiator ${WORKSPACE}/transfer_engine_heterogeneous_ascend_perf_initiator.cpp)
target_link_libraries(transfer_engine_heterogeneous_ascend_perf_initiator PUBLIC transfer_engine)
endif()

View File

@ -35,15 +35,15 @@
#ifdef USE_NVMEOF
#include <cufile.h>
#endif
#ifdef USE_MNNVL
#include <transport/nvlink_transport/nvlink_transport.h>
#endif
#endif
#if defined(USE_CUDA) || defined(USE_MUSA) || defined(USE_HIP)
#include <cassert>
#ifdef USE_MNNVL
#include <transport/nvlink_transport/nvlink_transport.h>
#endif
static void checkCudaError(cudaError_t result, const char *message) {
if (result != cudaSuccess) {
LOG(ERROR) << message << " (Error code: " << result << " - "

View File

@ -35,15 +35,15 @@
#ifdef USE_NVMEOF
#include <cufile.h>
#endif
#ifdef USE_NVLINK
#include <transport/nvlink_transport/nvlink_transport.h>
#endif
#endif
#if defined(USE_CUDA) || defined(USE_MUSA) || defined(USE_HIP)
#include <cassert>
#ifdef USE_MNNVL
#include <transport/nvlink_transport/nvlink_transport.h>
#endif
static void checkCudaError(cudaError_t result, const char *message) {
if (result != cudaSuccess) {
LOG(ERROR) << message << " (Error code: " << result << " - "
@ -99,7 +99,7 @@ static void *allocateMemoryPool(size_t size, int socket_id,
int gpu_id = FLAGS_gpu_id;
void *d_buf;
checkCudaError(cudaSetDevice(gpu_id), "Failed to set device");
#ifdef USE_NVLINK
#ifdef USE_MNNVL
d_buf = mooncake::NvlinkTransport::allocatePinnedLocalMemory(size);
#else
checkCudaError(cudaMalloc(&d_buf, size),
@ -113,7 +113,7 @@ static void *allocateMemoryPool(size_t size, int socket_id,
static void freeMemoryPool(void *addr, size_t size) {
#if defined(USE_CUDA) || defined(USE_MUSA) || defined(USE_HIP)
#ifdef USE_NVLINK
#ifdef USE_MNNVL
CUmemGenericAllocationHandle handle;
auto result = cuMemRetainAllocationHandle(&handle, addr);
if (result == CUDA_SUCCESS) {
@ -440,7 +440,7 @@ int target() {
}
for (int i = 0; i < buffer_num; ++i) {
engine->unregisterLocalMemory(addr[i]);
#ifdef USE_NVLINK
#ifdef USE_MNNVL
mooncake::NvlinkTransport::freePinnedLocalMemory(addr[i]);
#else
freeMemoryPool(addr[i], FLAGS_buffer_size);

View File

@ -35,15 +35,14 @@
#ifdef USE_NVMEOF
#include <cufile.h>
#endif
#endif
#if defined(USE_CUDA) || defined(USE_MUSA) || defined(USE_HIP)
#include <cassert>
#ifdef USE_MNNVL
#include <transport/nvlink_transport/nvlink_transport.h>
#endif
#endif
#if defined(USE_CUDA) || defined(USE_MUSA) || defined(USE_HIP)
#include <cassert>
static void checkCudaError(cudaError_t result, const char *message) {
if (result != cudaSuccess) {

View File

@ -11,5 +11,6 @@
#endif
#if !defined(USE_HIP) && !defined(USE_MUSA)
#include <string>
const static std::string GPU_PREFIX = "cuda:";
#endif

View File

@ -1,70 +1,22 @@
#include <hip/hip_runtime.h>
#include <string>
const static std::string GPU_PREFIX = "hip:";
#define CU_MEM_ACCESS_FLAGS_PROT_READWRITE hipMemAccessFlagsProtReadWrite
#define CU_MEM_ALLOCATION_TYPE_PINNED hipMemAllocationTypePinned
#define CU_MEM_LOCATION_TYPE_DEVICE hipMemLocationTypeDevice
#define CU_MEM_RANGE_HANDLE_TYPE_DMA_BUF_FD hipMemRangeHandleTypeDmaBufFd
#define CU_MEMORYTYPE_DEVICE hipMemoryTypeDevice
#define CU_MEMORYTYPE_HOST hipMemoryTypeHost
#define CU_POINTER_ATTRIBUTE_MEMORY_TYPE HIP_POINTER_ATTRIBUTE_MEMORY_TYPE
#define CU_POINTER_ATTRIBUTE_RANGE_SIZE HIP_POINTER_ATTRIBUTE_RANGE_SIZE
// hipify-perl warning: unsupported HIP identifier: cudaMemoryTypeUnregistered
#define cudaMemoryTypeUnregistered hipMemoryTypeUnregistered
#define CUdevice hipDevice_t
#define CUdeviceptr hipDeviceptr_t
#define CUmemAccessDesc hipMemAccessDesc
#define CUmemAllocationProp hipMemAllocationProp
#define CUmemGenericAllocationHandle hipMemGenericAllocationHandle_t
#define CUmemorytype hipMemoryType
#define CUresult hipError_t
#define cuDeviceGet hipDeviceGet
#define cuDeviceGetAttribute hipDeviceGetAttribute
#define cuGetErrorString hipDrvGetErrorString
#define cuMemAddressFree hipMemAddressFree
#define cuMemAddressReserve hipMemAddressReserve
#define cuMemCreate hipMemCreate
#define cuMemGetAllocationGranularity hipMemGetAllocationGranularity
#define cuMemGetHandleForAddressRange hipMemGetHandleForAddressRange
#define cuMemMap hipMemMap
#define cuMemRelease hipMemRelease
#define cuMemSetAccess hipMemSetAccess
#define cuMemUnmap hipMemUnmap
#define cuPointerGetAttribute hipPointerGetAttribute
// hipify-perl warning: unsupported HIP identifier: CU_MEM_HANDLE_TYPE_FABRIC
// Note: HIP does not currently support multi-node (fabric-based) transfers.
// Use POSIX file descriptor handle type for now, which only supports
// intra-node (same-machine) memory sharing between processes.
// TODO: Change to appropriate handle type when HIP adds multi-node support.
#define CU_MEM_HANDLE_TYPE_FABRIC hipMemHandleTypePosixFileDescriptor
#define CUDA_SUCCESS hipSuccess
#define cudaDeviceCanAccessPeer hipDeviceCanAccessPeer
#define cudaDeviceEnablePeerAccess hipDeviceEnablePeerAccess
#define cudaDeviceGetPCIBusId hipDeviceGetPCIBusId
#define cudaError_t hipError_t
#define cudaFree hipFree
#define cudaFreeHost hipHostFree
#define cudaGetDevice hipGetDevice
#define cudaGetDeviceCount hipGetDeviceCount
#define cudaGetErrorString hipGetErrorString
#define cudaGetLastError hipGetLastError
#define cudaHostRegister hipHostRegister
#define cudaHostRegisterPortable hipHostRegisterPortable
#define cudaHostUnregister hipHostUnregister
#define cudaMalloc hipMalloc
#define cudaMallocHost(ptr, size) hipHostMalloc(ptr, size, hipHostMallocDefault)
#define cudaMemcpy hipMemcpy
#define cudaMemcpyAsync hipMemcpyAsync
#define cudaMemcpyDefault hipMemcpyDefault
#define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost
#define cudaMemcpyHostToDevice hipMemcpyHostToDevice
#define cudaMemset hipMemset
#define cudaMemsetAsync hipMemsetAsync
#define cudaMemoryTypeDevice hipMemoryTypeDevice
#define cudaMemoryTypeHost hipMemoryTypeHost
// cudaMemoryTypeUnregistered is currently not supported as hipMemoryType enum,
// due to HIP functionality backward compatibility.
#define cudaMemoryTypeUnregistered 99
#define cudaPointerAttributes hipPointerAttribute_t
#define cudaPointerGetAttributes hipPointerGetAttributes
#define cudaSetDevice hipSetDevice
#define cudaStreamCreate hipStreamCreate
#define cudaStreamDestroy hipStreamDestroy
#define cudaStreamSynchronize hipStreamSynchronize
#define cudaStream_t hipStream_t
#define cudaSuccess hipSuccess
// hipify-perl warning: unsupported HIP identifier:
// CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED
#define CU_DEVICE_ATTRIBUTE_GPU_DIRECT_RDMA_WITH_CUDA_VMM_SUPPORTED \
hipDeviceAttributeVirtualMemoryManagementSupported
// hipify-perl warning: unsupported HIP identifier: CUmemFabricHandle
#define CUmemFabricHandle void*

View File

@ -3,7 +3,7 @@
#ifndef NVLINK_TRANSPORT_H_
#define NVLINK_TRANSPORT_H_
#include <cuda_runtime.h>
#include "cuda_alike.h"
#include <functional>
#include <iostream>

View File

@ -1,10 +1,28 @@
# Build nvlink allocator and output to build directory
add_custom_target(build_nvlink_allocator DEPENDS transfer_engine)
get_target_property(INCLUDE_DIRS build_nvlink_allocator INCLUDE_DIRECTORIES)
string(REPLACE ";" " " INCLUDE_DIRS_STR "${INCLUDE_DIRS}")
if (USE_CUDA)
add_custom_command(
TARGET build_nvlink_allocator
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}
COMMAND bash build.sh ${CMAKE_CURRENT_BINARY_DIR}
COMMAND bash build.sh ${CMAKE_CURRENT_BINARY_DIR} "${INCLUDE_DIRS_STR}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building nvlink allocator to ${CMAKE_CURRENT_BINARY_DIR}"
)
endif()
if (USE_HIP)
add_custom_command(
TARGET build_nvlink_allocator
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}
COMMAND bash build.sh --use-hipcc ${CMAKE_CURRENT_BINARY_DIR} "${INCLUDE_DIRS_STR}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building nvlink allocator to ${CMAKE_CURRENT_BINARY_DIR}"
)
endif()
set_property(TARGET build_nvlink_allocator PROPERTY EXCLUDE_FROM_ALL FALSE)

View File

@ -4,11 +4,15 @@ set -e
# Check for flags
USE_NVCC=false
USE_HIPCC=false
CI_BUILD=false
if [[ "$1" == "--use-nvcc" ]]; then
USE_NVCC=true
shift
elif [[ "$1" == "--use-hipcc" ]]; then
USE_HIPCC=true
shift
elif [[ "$1" == "--ci-build" ]]; then
CI_BUILD=true
shift
@ -17,6 +21,18 @@ fi
# Get output directory from command line argument, default to current directory
OUTPUT_DIR=${1:-.}
# Get include directories from second argument (if provided)
INCLUDE_LIST=""
if [ $# -ge 2 ]; then
INCLUDE_LIST=${2}
fi
# Process include directories into flags
INCLUDE_FLAGS=""
if [ -n "$INCLUDE_LIST" ]; then
INCLUDE_FLAGS=$(echo "$INCLUDE_LIST" | tr ' ' '\n' | sed 's/^/-I/' | paste -sd' ' -)
fi
echo "Building nvlink allocator to: $OUTPUT_DIR"
# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"
@ -26,13 +42,19 @@ CPP_FILE=$(dirname $(readlink -f $0))/nvlink_allocator.cpp # get cpp file path,
# Choose build command based on flags
if [ "$CI_BUILD" = true ]; then
# CI build: use nvcc without linking cuda
nvcc "$CPP_FILE" -o "$OUTPUT_DIR/nvlink_allocator.so" -shared -Xcompiler -fPIC -I/usr/local/cuda/include -L/usr/local/cuda-12.8/targets/x86_64-linux/lib -lcuda
nvcc "$CPP_FILE" -o "$OUTPUT_DIR/nvlink_allocator.so" -shared -Xcompiler -fPIC -I/usr/local/cuda/include ${INCLUDE_FLAGS} -L/usr/local/cuda-12.8/targets/x86_64-linux/lib -lcuda -DUSE_CUDA=1
elif [ "$USE_NVCC" = true ]; then
# Regular nvcc build with cuda linking
nvcc "$CPP_FILE" -o "$OUTPUT_DIR/nvlink_allocator.so" -shared -Xcompiler -fPIC -lcuda -I/usr/local/cuda/include
nvcc "$CPP_FILE" -o "$OUTPUT_DIR/nvlink_allocator.so" -shared -Xcompiler -fPIC -lcuda -I/usr/local/cuda/include ${INCLUDE_FLAGS} -DUSE_CUDA=1
elif [ "$USE_HIPCC" = true ]; then
hipify-perl "$CPP_FILE" > "${OUTPUT_DIR}/nvlink_allocator.cpp"
hipcc "$OUTPUT_DIR/nvlink_allocator.cpp" -o "$OUTPUT_DIR/nvlink_allocator.so" -shared -fPIC -lamdhip64 -I/opt/rocm/include ${INCLUDE_FLAGS} -DUSE_HIP=1
else
# Default g++ build
g++ "$CPP_FILE" -o "$OUTPUT_DIR/nvlink_allocator.so" --shared -fPIC -lcuda -I/usr/local/cuda/include
# Add include directory for cuda_alike.h (relative to build.sh location)
SCRIPT_DIR=$(dirname $(readlink -f $0))
DEFAULT_INCLUDE_DIR="${SCRIPT_DIR}/../include"
g++ "$CPP_FILE" -o "$OUTPUT_DIR/nvlink_allocator.so" --shared -fPIC -lcuda -I/usr/local/cuda/include -I${DEFAULT_INCLUDE_DIR} ${INCLUDE_FLAGS} -DUSE_CUDA=1
fi
if [ $? -eq 0 ]; then

View File

@ -1,5 +1,4 @@
#include <cuda.h>
#include <cuda_runtime_api.h>
#include "cuda_alike.h"
#include <sys/types.h>
#include <iostream>

View File

@ -4,6 +4,10 @@ add_subdirectory(transport)
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if (USE_HIP)
hipify_files(ENGINE_SOURCES)
endif()
add_library(transfer_engine ${ENGINE_SOURCES} $<TARGET_OBJECTS:transport>)
if (BUILD_SHARED_LIBS)
install(TARGETS transfer_engine DESTINATION lib)
@ -57,8 +61,8 @@ if (USE_MUSA)
endif()
if (USE_HIP)
target_include_directories(transfer_engine PRIVATE "${ROCM_PATH}/include")
target_link_libraries(transfer_engine PUBLIC amdhip64 rt)
target_include_directories(transfer_engine PRIVATE ${HIP_INCLUDE_DIRS})
target_link_libraries(transfer_engine PUBLIC hip::host rt)
endif()
if (USE_ASCEND)

View File

@ -1,5 +1,15 @@
file(GLOB NVLINK_SOURCES "*.cpp")
if (USE_HIP)
hipify_files(NVLINK_SOURCES)
endif()
add_library(nvlink_transport OBJECT ${NVLINK_SOURCES})
if (USE_CUDA)
target_include_directories(nvlink_transport PUBLIC CUDA::cudart "/usr/local/cuda/include")
endif()
if (USE_HIP)
target_include_directories(nvlink_transport PUBLIC ${HIP_INCLUDE_DIRS})
endif()

View File

@ -15,8 +15,7 @@
#include "transport/nvlink_transport/nvlink_transport.h"
#include <bits/stdint-uintn.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include "cuda_alike.h"
#include <glog/logging.h>
#include <algorithm>
@ -69,6 +68,7 @@ static bool supportFabricMem() {
return false;
}
#ifdef USE_CUDA
for (int device_id = 0; device_id < num_devices; ++device_id) {
int device_support_fabric_mem = 0;
cuDeviceGetAttribute(&device_support_fabric_mem,
@ -78,6 +78,7 @@ static bool supportFabricMem() {
return false;
}
}
#endif
return true;
}

View File

@ -1,4 +1,8 @@
file(GLOB TCP_SOURCES "*.cpp")
if (USE_HIP)
hipify_files(TCP_SOURCES)
endif()
add_library(tcp_transport OBJECT ${TCP_SOURCES})
target_link_libraries(tcp_transport PRIVATE JsonCpp::JsonCpp yalantinglibs::yalantinglibs)

View File

@ -1,55 +1,65 @@
add_executable(rdma_transport_test rdma_transport_test.cpp)
set(WORKSPACE "${CMAKE_CURRENT_SOURCE_DIR}")
if (USE_HIP)
file(GLOB TEST_SOURCES "*.cpp")
hipify_files(TEST_SOURCES)
file(RELATIVE_PATH EXAMPLE_REL_PATH "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
set(WORKSPACE "${CMAKE_BINARY_DIR}/${EXAMPLE_REL_PATH}")
endif()
add_executable(rdma_transport_test ${WORKSPACE}/rdma_transport_test.cpp)
target_link_libraries(rdma_transport_test PUBLIC transfer_engine)
# add_test(NAME rdma_transport_test COMMAND rdma_transport_test)
add_executable(transport_uint_test transport_uint_test.cpp)
add_executable(transport_uint_test ${WORKSPACE}/transport_uint_test.cpp)
target_link_libraries(transport_uint_test PUBLIC transfer_engine gtest gtest_main )
add_test(NAME transport_uint_test COMMAND transport_uint_test)
add_executable(rdma_transport_test2 rdma_transport_test2.cpp)
add_executable(rdma_transport_test2 ${WORKSPACE}/rdma_transport_test2.cpp)
target_link_libraries(rdma_transport_test2 PUBLIC transfer_engine gtest gtest_main )
# add_test(NAME rdma_transport_test2 COMMAND rdma_transport_test2)
add_executable(rdma_loopback_test rdma_loopback_test.cpp)
add_executable(rdma_loopback_test ${WORKSPACE}/rdma_loopback_test.cpp)
target_link_libraries(rdma_loopback_test PUBLIC transfer_engine gtest gtest_main )
# add_test(NAME rdma_loopback_test COMMAND rdma_loopback_test)
if (USE_CXL)
add_executable(cxl_transport_test cxl_transport_test.cpp)
add_executable(cxl_transport_test ${WORKSPACE}/cxl_transport_test.cpp)
target_link_libraries(cxl_transport_test PUBLIC transfer_engine gtest gtest_main )
add_test(NAME cxl_transport_test COMMAND cxl_transport_test)
endif()
if (USE_NVMEOF)
add_executable(nvmeof_transport_test nvmeof_transport_test.cpp)
add_executable(nvmeof_transport_test ${WORKSPACE}/nvmeof_transport_test.cpp)
target_link_libraries(nvmeof_transport_test PUBLIC transfer_engine gtest gtest_main )
# add_test(NAME nvmeof_transport_test COMMAND nvmeof_transport_test)
endif()
if (USE_TCP)
add_executable(tcp_transport_test tcp_transport_test.cpp)
add_executable(tcp_transport_test ${WORKSPACE}/tcp_transport_test.cpp)
target_link_libraries(tcp_transport_test PUBLIC transfer_engine gtest gtest_main )
add_test(NAME tcp_transport_test COMMAND tcp_transport_test)
endif()
if (USE_MNNVL)
add_executable(nvlink_transport_test nvlink_transport_test.cpp)
add_executable(nvlink_transport_test ${WORKSPACE}/nvlink_transport_test.cpp)
target_link_libraries(nvlink_transport_test PUBLIC transfer_engine gtest gtest_main )
add_test(NAME nvlink_transport_test COMMAND nvlink_transport_test)
endif()
add_executable(transfer_metadata_test transfer_metadata_test.cpp)
add_executable(transfer_metadata_test ${WORKSPACE}/transfer_metadata_test.cpp)
target_link_libraries(transfer_metadata_test PUBLIC transfer_engine gtest gtest_main)
add_test(NAME transfer_metadata_test COMMAND transfer_metadata_test)
add_executable(topology_test topology_test.cpp)
add_executable(topology_test ${WORKSPACE}/topology_test.cpp)
target_link_libraries(topology_test PUBLIC transfer_engine gtest gtest_main)
add_test(NAME topology_test COMMAND topology_test)
add_executable(memory_location_test memory_location_test.cpp)
add_executable(memory_location_test ${WORKSPACE}/memory_location_test.cpp)
target_link_libraries(memory_location_test PUBLIC transfer_engine gtest gtest_main)
add_test(NAME memory_location_test COMMAND memory_location_test)
add_executable(common_test common_test.cpp)
add_executable(common_test ${WORKSPACE}/common_test.cpp)
target_link_libraries(common_test PUBLIC transfer_engine gtest gtest_main)
add_test(NAME common_test COMMAND common_test)

View File

@ -1,11 +1,11 @@
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <gtest/gtest.h>
#include <cuda_runtime.h>
#include <thread>
#include <memory>
#include <cstring>
#include "cuda_alike.h"
#include "transfer_engine.h"
#include "transport/transport.h"