"git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "92063d88f0f70f1d6e4d2ed8e036516e3ff93379"
Unverified Commit 0d9a09df authored by pyynb's avatar pyynb Committed by GitHub
Browse files

[graphbolt] Disable liburing (#7366)

parent 658b2086
...@@ -20,6 +20,7 @@ dgl_option(BUILD_TYPE "Type of the build: dev, dogfood or release" "dev") ...@@ -20,6 +20,7 @@ dgl_option(BUILD_TYPE "Type of the build: dev, dogfood or release" "dev")
message(STATUS "Build for ${BUILD_TYPE}") message(STATUS "Build for ${BUILD_TYPE}")
dgl_option(USE_CUDA "Build with CUDA" OFF) dgl_option(USE_CUDA "Build with CUDA" OFF)
dgl_option(USE_LIBURING "Build with liburing" OFF)
dgl_option(TORCH_PYTHON_INTERPS "Python interpreter for building sub-components" python3) dgl_option(TORCH_PYTHON_INTERPS "Python interpreter for building sub-components" python3)
# Conda build related options. # Conda build related options.
...@@ -349,7 +350,9 @@ endif(EXTERNAL_PHMAP_PATH) ...@@ -349,7 +350,9 @@ endif(EXTERNAL_PHMAP_PATH)
target_include_directories(dgl PRIVATE "tensoradapter/include") target_include_directories(dgl PRIVATE "tensoradapter/include")
target_include_directories(dgl PRIVATE "third_party/pcg/include") target_include_directories(dgl PRIVATE "third_party/pcg/include")
if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(USE_LIBURING)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions(-DHAVE_LIBRARY_LIBURING)
include(ExternalProject) include(ExternalProject)
set(LIBURING_INSTALL_DIR ${CMAKE_BINARY_DIR}/third_party/liburing) set(LIBURING_INSTALL_DIR ${CMAKE_BINARY_DIR}/third_party/liburing)
ExternalProject_Add( ExternalProject_Add(
...@@ -365,7 +368,8 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux") ...@@ -365,7 +368,8 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
) )
set(LIBURING_INCLUDE ${LIBURING_INSTALL_DIR}/include) set(LIBURING_INCLUDE ${LIBURING_INSTALL_DIR}/include)
set(LIBURING ${LIBURING_INSTALL_DIR}/lib/liburing.a) set(LIBURING ${LIBURING_INSTALL_DIR}/lib/liburing.a)
endif() endif()
endif(USE_LIBURING)
if(EXTERNAL_NANOFLANN_PATH) if(EXTERNAL_NANOFLANN_PATH)
include_directories(SYSTEM ${EXTERNAL_NANOFLANN_PATH}) include_directories(SYSTEM ${EXTERNAL_NANOFLANN_PATH})
...@@ -588,7 +592,9 @@ if(BUILD_GRAPHBOLT) ...@@ -588,7 +592,9 @@ if(BUILD_GRAPHBOLT)
if(USE_CUDA) if(USE_CUDA)
add_dependencies(graphbolt gpu_cache) add_dependencies(graphbolt gpu_cache)
endif(USE_CUDA) endif(USE_CUDA)
if(USE_LIBURING)
if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "Linux")
add_dependencies(graphbolt liburing) add_dependencies(graphbolt liburing)
endif() endif()
endif(USE_LIBURING)
endif(BUILD_GRAPHBOLT) endif(BUILD_GRAPHBOLT)
...@@ -76,9 +76,11 @@ include_directories(BEFORE ${BOLT_DIR} ...@@ -76,9 +76,11 @@ include_directories(BEFORE ${BOLT_DIR}
"../third_party/pcg/include") "../third_party/pcg/include")
target_link_libraries(${LIB_GRAPHBOLT_NAME} "${TORCH_LIBRARIES}") target_link_libraries(${LIB_GRAPHBOLT_NAME} "${TORCH_LIBRARIES}")
if(CMAKE_SYSTEM_NAME MATCHES "Linux") if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(USE_LIBURING)
target_include_directories(${LIB_GRAPHBOLT_NAME} PRIVATE "../third_party/liburing/src/include") target_include_directories(${LIB_GRAPHBOLT_NAME} PRIVATE "../third_party/liburing/src/include")
get_filename_component(PARENT_DIR "${CMAKE_SOURCE_DIR}" DIRECTORY) get_filename_component(PARENT_DIR "${CMAKE_SOURCE_DIR}" DIRECTORY)
target_link_libraries(${LIB_GRAPHBOLT_NAME} ${PARENT_DIR}/build/third_party/liburing/lib/liburing.a) target_link_libraries(${LIB_GRAPHBOLT_NAME} ${PARENT_DIR}/build/third_party/liburing/lib/liburing.a)
endif(USE_LIBURING)
endif() endif()
if(USE_CUDA) if(USE_CUDA)
......
...@@ -20,7 +20,11 @@ static constexpr int kDiskAlignmentSize = 4096; ...@@ -20,7 +20,11 @@ static constexpr int kDiskAlignmentSize = 4096;
OnDiskNpyArray::OnDiskNpyArray( OnDiskNpyArray::OnDiskNpyArray(
std::string filename, torch::ScalarType dtype, torch::Tensor shape) std::string filename, torch::ScalarType dtype, torch::Tensor shape)
: filename_(filename), dtype_(dtype) { : filename_(filename), dtype_(dtype) {
#ifdef __linux__ #ifndef __linux__
throw std::runtime_error(
"OnDiskNpyArray is not supported on non-Linux systems.");
#endif
#ifdef HAVE_LIBRARY_LIBURING
ParseNumpyHeader(shape); ParseNumpyHeader(shape);
file_description_ = open(filename.c_str(), O_RDONLY | O_DIRECT); file_description_ = open(filename.c_str(), O_RDONLY | O_DIRECT);
if (file_description_ == -1) { if (file_description_ == -1) {
...@@ -35,7 +39,9 @@ OnDiskNpyArray::OnDiskNpyArray( ...@@ -35,7 +39,9 @@ OnDiskNpyArray::OnDiskNpyArray(
for (int64_t t = 0; t < num_thread_; t++) { for (int64_t t = 0; t < num_thread_; t++) {
io_uring_queue_init(group_size_, &io_uring_queue_[t], 0); io_uring_queue_init(group_size_, &io_uring_queue_[t], 0);
} }
#endif // __linux__ #else
throw std::runtime_error("DiskBasedFeature is not available now.");
#endif // HAVE_LIBRARY_LIBURING
} }
c10::intrusive_ptr<OnDiskNpyArray> OnDiskNpyArray::Create( c10::intrusive_ptr<OnDiskNpyArray> OnDiskNpyArray::Create(
...@@ -44,17 +50,17 @@ c10::intrusive_ptr<OnDiskNpyArray> OnDiskNpyArray::Create( ...@@ -44,17 +50,17 @@ c10::intrusive_ptr<OnDiskNpyArray> OnDiskNpyArray::Create(
} }
OnDiskNpyArray::~OnDiskNpyArray() { OnDiskNpyArray::~OnDiskNpyArray() {
#ifdef __linux__ #ifdef HAVE_LIBRARY_LIBURING
// IO queue exit. // IO queue exit.
for (int64_t t = 0; t < num_thread_; t++) { for (int64_t t = 0; t < num_thread_; t++) {
io_uring_queue_exit(&io_uring_queue_[t]); io_uring_queue_exit(&io_uring_queue_[t]);
} }
close(file_description_); close(file_description_);
#endif // __linux__ #endif // HAVE_LIBRARY_LIBURING
} }
void OnDiskNpyArray::ParseNumpyHeader(torch::Tensor shape) { void OnDiskNpyArray::ParseNumpyHeader(torch::Tensor shape) {
#ifdef __linux__ #ifdef HAVE_LIBRARY_LIBURING
// Parse numpy file header to get basic info of feature. // Parse numpy file header to get basic info of feature.
size_t word_size = c10::elementSize(dtype_); size_t word_size = c10::elementSize(dtype_);
int64_t num_dim = shape.numel(); int64_t num_dim = shape.numel();
...@@ -80,19 +86,19 @@ void OnDiskNpyArray::ParseNumpyHeader(torch::Tensor shape) { ...@@ -80,19 +86,19 @@ void OnDiskNpyArray::ParseNumpyHeader(torch::Tensor shape) {
// Get prefix length for computing feature offset, // Get prefix length for computing feature offset,
// add one for new-line character. // add one for new-line character.
prefix_len_ = header.size() + 1; prefix_len_ = header.size() + 1;
#endif // __linux__ #endif // HAVE_LIBRARY_LIBURING
} }
torch::Tensor OnDiskNpyArray::IndexSelect(torch::Tensor index) { torch::Tensor OnDiskNpyArray::IndexSelect(torch::Tensor index) {
#ifdef __linux__ #ifdef HAVE_LIBRARY_LIBURING
return IndexSelectIOUring(index); return IndexSelectIOUring(index);
#else #else
TORCH_CHECK(false, "OnDiskNpyArray is not supported on non-Linux systems."); TORCH_CHECK(false, "OnDiskNpyArray is not supported on non-Linux systems.");
return torch::empty({0}); return torch::empty({0});
#endif // __linux__ #endif // HAVE_LIBRARY_LIBURING
} }
#ifdef __linux__ #ifdef HAVE_LIBRARY_LIBURING
torch::Tensor OnDiskNpyArray::IndexSelectIOUring(torch::Tensor index) { torch::Tensor OnDiskNpyArray::IndexSelectIOUring(torch::Tensor index) {
index = index.to(torch::kLong); index = index.to(torch::kLong);
// The minimum page size to contain one feature. // The minimum page size to contain one feature.
...@@ -215,7 +221,6 @@ torch::Tensor OnDiskNpyArray::IndexSelectIOUring(torch::Tensor index) { ...@@ -215,7 +221,6 @@ torch::Tensor OnDiskNpyArray::IndexSelectIOUring(torch::Tensor index) {
return result; return result;
} }
#endif // __linux__ #endif // HAVE_LIBRARY_LIBURING
} // namespace storage } // namespace storage
} // namespace graphbolt } // namespace graphbolt
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <torch/script.h> #include <torch/script.h>
#ifdef __linux__ #ifdef HAVE_LIBRARY_LIBURING
#include <liburing.h> #include <liburing.h>
#include <unistd.h> #include <unistd.h>
#endif #endif // HAVE_LIBRARY_LIBURING
#include <cassert> #include <cassert>
#include <cstdio> #include <cstdio>
...@@ -60,7 +60,7 @@ class OnDiskNpyArray : public torch::CustomClassHolder { ...@@ -60,7 +60,7 @@ class OnDiskNpyArray : public torch::CustomClassHolder {
*/ */
torch::Tensor IndexSelect(torch::Tensor index); torch::Tensor IndexSelect(torch::Tensor index);
#ifdef __linux__ #ifdef HAVE_LIBRARY_LIBURING
/** /**
* @brief Index-select operation on an on-disk numpy array using IO Uring for * @brief Index-select operation on an on-disk numpy array using IO Uring for
* asynchronous I/O. * asynchronous I/O.
...@@ -76,8 +76,7 @@ class OnDiskNpyArray : public torch::CustomClassHolder { ...@@ -76,8 +76,7 @@ class OnDiskNpyArray : public torch::CustomClassHolder {
* @throws std::runtime_error If index is out of range. * @throws std::runtime_error If index is out of range.
*/ */
torch::Tensor IndexSelectIOUring(torch::Tensor index); torch::Tensor IndexSelectIOUring(torch::Tensor index);
#endif // __linux__ #endif // HAVE_LIBRARY_LIBURING
private: private:
std::string filename_; // Path to numpy file. std::string filename_; // Path to numpy file.
int file_description_; // File description. int file_description_; // File description.
...@@ -88,9 +87,9 @@ class OnDiskNpyArray : public torch::CustomClassHolder { ...@@ -88,9 +87,9 @@ class OnDiskNpyArray : public torch::CustomClassHolder {
int num_thread_; // Default thread number. int num_thread_; // Default thread number.
int64_t group_size_ = 512; // Default group size. int64_t group_size_ = 512; // Default group size.
#ifdef __linux__ #ifdef HAVE_LIBRARY_LIBURING
io_uring* io_uring_queue_; // io_uring queue. io_uring* io_uring_queue_; // io_uring queue.
#endif #endif // HAVE_LIBRARY_LIBURING
}; };
} // namespace storage } // namespace storage
......
...@@ -18,9 +18,8 @@ def to_on_disk_numpy(test_dir, name, t): ...@@ -18,9 +18,8 @@ def to_on_disk_numpy(test_dir, name, t):
@unittest.skipIf( @unittest.skipIf(
sys.platform.startswith("win"), True,
reason="Tests for disk dataset can only deployed on Linux," reason="DiskBasedFeature is not available now.",
"because the io_uring is only supportted by Linux kernel.",
) )
def test_disk_based_feature(): def test_disk_based_feature():
with tempfile.TemporaryDirectory() as test_dir: with tempfile.TemporaryDirectory() as test_dir:
...@@ -85,6 +84,10 @@ def test_disk_based_feature(): ...@@ -85,6 +84,10 @@ def test_disk_based_feature():
reason="Tests for disk dataset can only deployed on Linux," reason="Tests for disk dataset can only deployed on Linux,"
"because the io_uring is only supportted by Linux kernel.", "because the io_uring is only supportted by Linux kernel.",
) )
@unittest.skipIf(
True,
reason="DiskBasedFeature is not available now.",
)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"dtype", "dtype",
[ [
...@@ -129,6 +132,10 @@ def test_more_disk_based_feature(dtype, idtype, shape, index): ...@@ -129,6 +132,10 @@ def test_more_disk_based_feature(dtype, idtype, shape, index):
reason="Tests for large disk dataset can only deployed on Linux," reason="Tests for large disk dataset can only deployed on Linux,"
"because the io_uring is only supportted by Linux kernel.", "because the io_uring is only supportted by Linux kernel.",
) )
@unittest.skipIf(
True,
reason="DiskBasedFeature is not available now.",
)
def test_disk_based_feature_repr(): def test_disk_based_feature_repr():
with tempfile.TemporaryDirectory() as test_dir: with tempfile.TemporaryDirectory() as test_dir:
a = torch.tensor([[1, 2, 3], [4, 5, 6]]) a = torch.tensor([[1, 2, 3], [4, 5, 6]])
......
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