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 cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ endmacro()

# TODO: Default to ON if CUDA available.
option(TP_USE_CUDA "Enable support for CUDA tensors" OFF)
option(TP_USE_XPU "Enable support for XPU tensors" OFF)

# Optional features
option(TP_BUILD_BENCHMARK "Build benchmarks" OFF)
Expand Down
61 changes: 61 additions & 0 deletions tensorpipe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,67 @@ if(TP_USE_CUDA)

endif()

## XPU

if(TP_USE_XPU)
# TP_SRCS is the list of source files that we need to build libtensorpipe.
set(TP_XPU_SRCS)

# TP_PUBLIC_HDRS is the list of public header files that we need to install.
set(TP_XPU_PUBLIC_HDRS)

# TP_LINK_LIBRARIES is list of dependent libraries to be linked
set(TP_XPU_LINK_LIBRARIES)

# TP_INCLUDE_DIRS is list of include path to be used
set(TP_XPU_INCLUDE_DIRS)

find_package(IntelSYCL REQUIRED)
list(APPEND TP_XPU_LINK_LIBRARIES ${SYCL_LIBRARIES})
list(APPEND TP_XPU_INCLUDE_DIRS ${SYCL_INCLUDE_DIRS})

list(APPEND TP_XPU_SRCS
common/xpu_buffer.cc)
list(APPEND TP_XPU_PUBLIC_HDRS
tensorpipe_xpu.h
common/xpu_buffer.h)

### xpu_basic

list(APPEND TP_XPU_SRCS
channel/xpu_basic/channel_impl.cc
channel/xpu_basic/context_impl.cc
channel/xpu_basic/factory.cc
common/xpu_loop.cc)
list(APPEND TP_XPU_PUBLIC_HDRS
channel/xpu_basic/factory.h)


add_library(tensorpipe_xpu ${TP_STATIC_OR_SHARED} ${TP_XPU_SRCS})

if(BUILD_SHARED_LIBS)
set_target_properties(tensorpipe_xpu PROPERTIES POSITION_INDEPENDENT_CODE 1)
endif()

target_link_libraries(tensorpipe_xpu PUBLIC tensorpipe)
target_link_libraries(tensorpipe_xpu PRIVATE ${TP_XPU_LINK_LIBRARIES})
target_include_directories(tensorpipe_xpu PUBLIC ${TP_XPU_INCLUDE_DIRS})

install(TARGETS tensorpipe_xpu
EXPORT TensorpipeTargets
LIBRARY DESTINATION ${TP_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${TP_INSTALL_LIBDIR})

foreach(_header_file ${TP_XPU_PUBLIC_HDRS})
get_filename_component(_TP_HEADER_SUBDIR "${_header_file}" DIRECTORY)
install(FILES ${_header_file}
DESTINATION ${TP_INSTALL_INCLUDEDIR}/tensorpipe/${_TP_HEADER_SUBDIR})
endforeach()

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
DESTINATION ${TP_INSTALL_INCLUDEDIR}/tensorpipe)

endif()

## Python bindings

Expand Down
12 changes: 12 additions & 0 deletions tensorpipe/benchmark/channel_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ std::shared_ptr<tensorpipe::channel::Context> makeCudaGdrChannel() {
TP_REGISTER_CREATOR(TensorpipeChannelRegistry, cuda_gdr, makeCudaGdrChannel);
#endif // TENSORPIPE_HAS_CUDA_GDR_CHANNEL

// XPU BASIC

std::shared_ptr<tensorpipe::channel::Context> makeXpuBasicChannel() {
return tensorpipe::channel::xpu_basic::create(
tensorpipe::channel::basic::create());
}

TP_REGISTER_CREATOR(
TensorpipeChannelRegistry,
xpu_basic,
makeXpuBasicChannel);

void validateChannelContext(
std::shared_ptr<tensorpipe::channel::Context> context) {
if (!context) {
Expand Down
Loading