Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ slime_option(USE_MACA "USE in MACA Platform" OFF)

slime_option(BUILD_NVLINK "Build NVLINK" OFF)
slime_option(BUILD_ASCEND_DIRECT "Build Ascend direct transport" OFF)
slime_option(BUILD_TCP "Build TCP transport" ON)

# Slime options for custom python wrapper
slime_option(BUILD_PYTHON "Build python wrapper" OFF)
Expand Down
4 changes: 4 additions & 0 deletions dlslime/csrc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ if(BUILD_RDMA)
target_link_libraries(dlslime INTERFACE _slime_rdma)
endif()

if(BUILD_TCP)
target_link_libraries(dlslime INTERFACE _slime_tcp)
endif()

# rpc/ has no independent C++ consumers (the session API is all
# pybind11). It is compiled straight into _slime_c.so by the python
# subdirectory below. Keep the source files here as a marker so future
Expand Down
4 changes: 4 additions & 0 deletions dlslime/csrc/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ endif()
if (BUILD_RDMA)
add_subdirectory(rdma)
endif()

if (BUILD_TCP)
add_subdirectory(tcp)
endif()
40 changes: 40 additions & 0 deletions dlslime/csrc/engine/tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# asio is header-only. Try find_package, fall back to manual detection.
find_package(asio QUIET)
if(NOT asio_FOUND)
if(EXISTS /usr/include/asio.hpp)
add_library(asio::asio INTERFACE IMPORTED)
target_include_directories(asio::asio INTERFACE /usr/include)
elseif(EXISTS /usr/include/boost/asio.hpp)
add_library(asio::asio INTERFACE IMPORTED)
target_include_directories(asio::asio INTERFACE /usr/include/boost)
target_compile_definitions(asio::asio INTERFACE ASIO_STANDALONE)
else()
message(FATAL_ERROR "asio not found. Install libasio-dev or boost.")
endif()
endif()

add_library(_slime_tcp SHARED
tcp_memory_pool.cpp
tcp_connection_pool.cpp
tcp_context.cpp
tcp_session.cpp
tcp_endpoint.cpp
)

target_compile_definitions(_slime_tcp PRIVATE ASIO_STANDALONE)

target_link_libraries(_slime_tcp PUBLIC
asio::asio
_slime_device
_slime_engine
)

set_target_properties(_slime_tcp PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH "${ORIGIN}"
)

install(TARGETS _slime_tcp
EXPORT dlslimeTargets
LIBRARY DESTINATION ${DLSLIME_INSTALL_PATH}
)
54 changes: 54 additions & 0 deletions dlslime/csrc/engine/tcp/build_and_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
BUILD_DIR="$REPO_ROOT/build_tcp"
MODE="${1:-all}"

header() { echo; echo -e "\033[1;36m==>\033[m \033[1m$*\033[m"; }
ok() { echo -e " \033[1;32mOK\033[m $*"; }

do_build() {
header "Configuring (BUILD_TCP=ON, BUILD_RDMA=OFF)"
cmake -S "$REPO_ROOT" -B "$BUILD_DIR" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DDLSLIME_INSTALL_PATH=dlslime \
-DBUILD_PYTHON=ON \
-DBUILD_RDMA=OFF \
-DBUILD_TCP=ON \
-DBUILD_NVLINK=OFF \
-DBUILD_ASCEND_DIRECT=OFF \
-DSKBUILD_PROJECT_NAME=dlslime 2>&1 | tail -3
ok "CMake configure"

header "Building _slime_c"
cmake --build "$BUILD_DIR" --target _slime_c -j"$(nproc)" 2>&1 | tail -8
ok "Build complete"

cp "$BUILD_DIR/lib/"*.so "$REPO_ROOT/dlslime/"
ok "Copied .so files to dlslime/"
}

do_test() {
header "Running TcpEndpoint v3 tests"
export DLSLIME_LOG_LEVEL=0
export LD_LIBRARY_PATH="$REPO_ROOT/dlslime"
export PYTHONPATH="$REPO_ROOT"
python3 "$SCRIPT_DIR/test_tcp_endpoint.py" 2>&1 | while IFS= read -r line; do
if [[ "$line" == *"PASSED"* ]]; then echo -e " \033[1;32m✓\033[m $line"
elif [[ "$line" == *"FAIL"* ]]; then echo -e " \033[1;91m✗\033[m $line"
else echo " $line"
fi
done
ok "All tests passed"
}

case "$MODE" in
all) do_build; do_test ;;
build) do_build ;;
test) do_test ;;
clean) rm -rf "$BUILD_DIR" "$REPO_ROOT/dlslime/_slime_c"*.so "$REPO_ROOT/dlslime/lib_slime_"*.so
ok "Cleaned" ;;
*) echo "Usage: $0 {all|build|test|clean}" >&2; exit 1 ;;
esac
Loading
Loading