Skip to content

Commit

Permalink
Merge branch 'main' into nicolaloi/feature_select_by_index
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminum authored Nov 27, 2024
2 parents 2870c69 + b65896f commit abbf8fd
Show file tree
Hide file tree
Showing 46 changed files with 2,190 additions and 618 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/cmake/FindPytorch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro(translate_arch_string input output)
string(REGEX REPLACE "([1-9])([0-9])-real" "\\1.\\2" version "${input}")
elseif("${input}" MATCHES "([0-9]+)")
string(REGEX REPLACE "([1-9])([0-9])" "\\1.\\2+PTX" version "${input}")
elseif(input STREQUAL "native")
elseif("${input}" STREQUAL "native")
set(version "Auto")
else()
message(FATAL_ERROR "Invalid architecture string: ${input}")
Expand Down
13 changes: 12 additions & 1 deletion 3rdparty/embree/embree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ else()
endif()


if(BUILD_SYCL_MODULE)
set(ISA_ARGS ${ISA_ARGS} -DCMAKE_CXX_COMPILER=icpx)
set(ISA_ARGS ${ISA_ARGS} -DCMAKE_C_COMPILER=icx)
set(ISA_ARGS ${ISA_ARGS} -DEMBREE_SYCL_SUPPORT=ON)
list(APPEND ISA_LIBS embree4_sycl ze_wrapper)
list(APPEND ISA_BUILD_BYPRODUCTS "<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree4_sycl${CMAKE_STATIC_LIBRARY_SUFFIX}"
"<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ze_wrapper${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()


ExternalProject_Add(
ext_embree
PREFIX embree
Expand Down Expand Up @@ -92,10 +102,11 @@ ExternalProject_Add(
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}sys${CMAKE_STATIC_LIBRARY_SUFFIX}
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}math${CMAKE_STATIC_LIBRARY_SUFFIX}
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}tasking${CMAKE_STATIC_LIBRARY_SUFFIX}
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}ze_wrapper${CMAKE_STATIC_LIBRARY_SUFFIX}
${ISA_BUILD_BYPRODUCTS}
)

ExternalProject_Get_Property(ext_embree INSTALL_DIR)
set(EMBREE_INCLUDE_DIRS ${INSTALL_DIR}/include/ ${INSTALL_DIR}/src/ext_embree/) # "/" is critical.
set(EMBREE_LIB_DIR ${INSTALL_DIR}/${Open3D_INSTALL_LIB_DIR})
set(EMBREE_LIBRARIES embree4 ${ISA_LIBS} simd lexers sys math tasking)
set(EMBREE_LIBRARIES embree4 simd lexers sys math tasking ${ISA_LIBS})
6 changes: 3 additions & 3 deletions 3rdparty/find_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ if(BUILD_GUI)
${CPP_LIBRARY} ${CPPABI_LIBRARY})
message(STATUS "Filament C++ libraries: ${CPP_LIBRARY} ${CPPABI_LIBRARY}")
if (LIBCPP_VERSION GREATER 11)
message(WARNING "libc++ (LLVM) version ${LIBCPP_VERSION} > 11 includes libunwind that "
message(WARNING "libc++ (LLVM) version ${LIBCPP_VERSION} > 11 includes libunwind that "
"interferes with the system libunwind.so.8 and may crash Python code when exceptions "
"are used. Please consider using libc++ (LLVM) v11.")
endif()
Expand Down Expand Up @@ -1697,7 +1697,7 @@ else(OPEN3D_USE_ONEAPI_PACKAGES)
INCLUDE_DIRS ${STATIC_MKL_INCLUDE_DIR}
LIB_DIR ${STATIC_MKL_LIB_DIR}
LIBRARIES ${STATIC_MKL_LIBRARIES}
DEPENDS ext_tbb ext_mkl_include ext_mkl
DEPENDS Open3D::3rdparty_tbb ext_mkl_include ext_mkl
)
if(UNIX)
target_compile_options(3rdparty_blas INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:-m64>")
Expand All @@ -1719,7 +1719,7 @@ else(OPEN3D_USE_ONEAPI_PACKAGES)
endif()
if(NOT USE_SYSTEM_TBB)
include(${Open3D_3RDPARTY_DIR}/mkl/tbb.cmake)
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM TBB::tbb)
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_CUSTOM Open3D::3rdparty_tbb)
else()
list(APPEND Open3D_3RDPARTY_PRIVATE_TARGETS_FROM_SYSTEM Open3D::3rdparty_tbb)
endif()
Expand Down
1 change: 1 addition & 0 deletions 3rdparty/mkl/tbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ install(TARGETS tbb EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${Open3D_INSTALL_BIN_DIR}
COMPONENT tbb
)
add_library(${PROJECT_NAME}::3rdparty_tbb ALIAS tbb)
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
- Fix tensor EstimatePointWiseNormalsWithFastEigen3x3 (PR #6980)
- Fix alpha shape reconstruction if alpha too small for point scale (PR #6998)
- Fix render to depth image on Apple Retina displays (PR #7001)
- Fix infinite loop in segment_plane if num_points < ransac_n (PR #7032)
- Add select_by_index method to Feature class (PR #7039)

## 0.13
Expand Down
3 changes: 3 additions & 0 deletions cpp/open3d/Macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <cassert>

// https://gcc.gnu.org/wiki/Visibility updated to use C++11 attribute syntax
// In Open3D, we set symbol visibility based on folder / cmake target through
// cmake. e.g. all symbols in kernel folders are hidden. These macros allow fine
// grained control over symbol visibility.
#if defined(_WIN32) || defined(__CYGWIN__)
#define OPEN3D_DLL_IMPORT __declspec(dllimport)
#define OPEN3D_DLL_EXPORT __declspec(dllexport)
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/core/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ std::vector<Device> Device::GetAvailableCUDADevices() {
}

std::vector<Device> Device::GetAvailableSYCLDevices() {
return sycl::GetAvailableSYCLDevices();
return sy::GetAvailableSYCLDevices();
}

void Device::PrintAvailableDevices() {
Expand Down
2 changes: 1 addition & 1 deletion cpp/open3d/core/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Device {
enum class DeviceType {
CPU = 0,
CUDA = 1,
SYCL = 2, // SYCL gpu_selector().
SYCL = 2, // SYCL gpu_selector_v.
};

/// Default constructor -> "CPU:0".
Expand Down
22 changes: 10 additions & 12 deletions cpp/open3d/core/MemoryManagerSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// SPDX-License-Identifier: MIT
// ----------------------------------------------------------------------------

#include <CL/sycl.hpp>
#include <cstdlib>
#include <sycl/sycl.hpp>
#include <unordered_map>

#include "open3d/core/Device.h"
Expand All @@ -18,24 +18,22 @@
namespace open3d {
namespace core {

namespace sy = cl::sycl;

void* MemoryManagerSYCL::Malloc(size_t byte_size, const Device& device) {
const sy::queue& queue =
sycl::SYCLContext::GetInstance().GetDefaultQueue(device);
const sycl::queue& queue =
sy::SYCLContext::GetInstance().GetDefaultQueue(device);

#ifdef ENABLE_SYCL_UNIFIED_SHARED_MEMORY
return static_cast<void*>(sy::malloc_shared(byte_size, queue));
return static_cast<void*>(sycl::malloc_shared(byte_size, queue));
#else
return static_cast<void*>(sy::malloc_device(byte_size, queue));
return static_cast<void*>(sycl::malloc_device(byte_size, queue));
#endif
}

void MemoryManagerSYCL::Free(void* ptr, const Device& device) {
if (ptr) {
const sy::queue& queue =
sycl::SYCLContext::GetInstance().GetDefaultQueue(device);
sy::free(ptr, queue);
const sycl::queue& queue =
sy::SYCLContext::GetInstance().GetDefaultQueue(device);
sycl::free(ptr, queue);
}
}

Expand All @@ -62,8 +60,8 @@ void MemoryManagerSYCL::Memcpy(void* dst_ptr,
dst_device.ToString());
}

sy::queue queue =
sycl::SYCLContext::GetInstance().GetDefaultQueue(device_with_queue);
sycl::queue queue =
sy::SYCLContext::GetInstance().GetDefaultQueue(device_with_queue);
queue.memcpy(dst_ptr, src_ptr, num_bytes).wait_and_throw();
}

Expand Down
21 changes: 11 additions & 10 deletions cpp/open3d/core/SYCLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

#include "open3d/core/SYCLContext.h"

#include <CL/sycl.hpp>
#include <array>
#include <cstdlib>
#include <sstream>
#include <sycl/sycl.hpp>

#include "open3d/core/SYCLUtils.h"
#include "open3d/utility/Logging.h"

namespace open3d {
namespace core {
namespace sycl {
namespace sy {

SYCLContext &SYCLContext::GetInstance() {
static thread_local SYCLContext instance;
Expand All @@ -38,36 +38,37 @@ bool SYCLContext::IsDeviceAvailable(const Device &device) {
}
std::vector<Device> SYCLContext::GetAvailableSYCLDevices() { return devices_; }

sy::queue SYCLContext::GetDefaultQueue(const Device &device) {
sycl::queue SYCLContext::GetDefaultQueue(const Device &device) {
return device_to_default_queue_.at(device);
}

SYCLContext::SYCLContext() {
// SYCL GPU.
// TODO: Currently we only support one GPU device.
try {
const sy::device &sycl_device = sy::device(sy::gpu_selector());
const sycl::device &sycl_device = sycl::device(sycl::gpu_selector_v);
const Device open3d_device = Device("SYCL:0");
devices_.push_back(open3d_device);
device_to_sycl_device_[open3d_device] = sycl_device;
device_to_default_queue_[open3d_device] = sy::queue(sycl_device);
} catch (const sy::exception &e) {
device_to_default_queue_[open3d_device] = sycl::queue(sycl_device);
} catch (const sycl::exception &e) {
}

if (devices_.size() == 0) {
// SYCL CPU fallback.
// This could happen if the Intel GPGPU driver is not installed or if
// your CPU does not have integrated GPU.
try {
const sy::device &sycl_device = sy::device(sy::host_selector());
const sycl::device &sycl_device =
sycl::device(sycl::cpu_selector_v);
const Device open3d_device = Device("SYCL:0");
utility::LogWarning(
"SYCL GPU device is not available, falling back to SYCL "
"host device.");
devices_.push_back(open3d_device);
device_to_sycl_device_[open3d_device] = sycl_device;
device_to_default_queue_[open3d_device] = sy::queue(sycl_device);
} catch (const sy::exception &e) {
device_to_default_queue_[open3d_device] = sycl::queue(sycl_device);
} catch (const sycl::exception &e) {
}
}

Expand All @@ -76,6 +77,6 @@ SYCLContext::SYCLContext() {
}
}

} // namespace sycl
} // namespace sy
} // namespace core
} // namespace open3d
16 changes: 7 additions & 9 deletions cpp/open3d/core/SYCLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@

#pragma once

#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>
#include <unordered_map>

#include "open3d/core/Device.h"

namespace open3d {
namespace core {
namespace sycl {

namespace sy = cl::sycl;
namespace sy {

/// Singleton SYCL context manager. It maintains:
/// - A default queue for each SYCL device
Expand All @@ -45,7 +43,7 @@ class SYCLContext {
std::vector<Device> GetAvailableSYCLDevices();

/// Get the default SYCL queue given an Open3D device.
sy::queue GetDefaultQueue(const Device& device);
sycl::queue GetDefaultQueue(const Device& device);

private:
SYCLContext();
Expand All @@ -54,12 +52,12 @@ class SYCLContext {
std::vector<Device> devices_;

/// Maps core::Device to the corresponding default SYCL queue.
std::unordered_map<Device, sy::queue> device_to_default_queue_;
std::unordered_map<Device, sycl::queue> device_to_default_queue_;

/// Maps core::Device to sy::device. Internal use only for now.
std::unordered_map<Device, sy::device> device_to_sycl_device_;
/// Maps core::Device to sycl::device. Internal use only for now.
std::unordered_map<Device, sycl::device> device_to_sycl_device_;
};

} // namespace sycl
} // namespace sy
} // namespace core
} // namespace open3d
Loading

0 comments on commit abbf8fd

Please sign in to comment.