Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Embree build with SYCL support and OneAPI 2024.1.0 #6808

Merged
merged 36 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cd841a8
Build Embree with SYCL support and OneAPI 2024.1.0
lumurillo May 31, 2024
97402f9
Add correct compiler for embree SYCL
lumurillo Jun 24, 2024
5d90e33
Add embree dependency change
lumurillo Jul 2, 2024
c799893
Fix embree linking error
ssheorey Jul 12, 2024
f3bde48
Fix SYCL demo typo
lumurillo Jul 26, 2024
d37e8c1
Fix ubuntu CI
lumurillo Jul 26, 2024
667dc18
Fix code style
lumurillo Jul 26, 2024
94c0f0f
Fix python virtualenv in Dockerfile
lumurillo Aug 2, 2024
f1515e2
Update oneAPI version to SYCL shared process
lumurillo Aug 2, 2024
bd02607
Add initial SYCL support to RayCastingScene class
lumurillo Aug 17, 2024
2557482
Add SYCL support to CountIntersections function
lumurillo Aug 19, 2024
2689d45
Provide SYCL support to list intersections functions WIP
lumurillo Sep 21, 2024
048008c
Remove open3d python virtualenv from Dockerfile
lumurillo Oct 4, 2024
84f0ef9
Merge branch 'main' of github.com:isl-org/Open3D into lumurillo/use-o…
ssheorey Oct 4, 2024
e25a9b7
Fix no tbb target with BUILD_SYCL_MODULE
ssheorey Oct 9, 2024
d3e68ea
Add array utils functions
lumurillo Oct 12, 2024
09860d0
Set the SYCL ArrayPartialSum as a sequential implementation
lumurillo Oct 13, 2024
487596f
Make the ListIntersections function work on SYCL
lumurillo Oct 20, 2024
975e7f0
Fix ListInteractions SYCL kernel
lumurillo Oct 25, 2024
c0c2aea
Add list intersections test
lumurillo Oct 26, 2024
278295c
Prepare ComputeClosestPoints for SYCL implementation
lumurillo Nov 2, 2024
aa437b6
Add SYCL enable parameter to list_devices
lumurillo Nov 5, 2024
1eec474
Fix SYCL version of CountIntersections function
lumurillo Nov 5, 2024
2c98133
Fix Dockerfile
lumurillo Nov 9, 2024
7b34720
Fix code style
lumurillo Nov 9, 2024
6284e3d
Simplify RayCastingScene constructor
lumurillo Nov 9, 2024
460e3f7
Move enable JIT cache function to SYCL utils
lumurillo Nov 14, 2024
8da0afc
Do not change the SYCL cache dir
lumurillo Nov 14, 2024
8dbb6fa
test RaycastingScene.add_triangles with TriangleMesh
benjaminum Nov 17, 2024
23b8c7d
create objects for testing with tensor TriangleMesh
benjaminum Nov 18, 2024
4b81b70
Fix possible memory leak in SYCL implementation of RayCastingScene
lumurillo Nov 19, 2024
5b6a6de
Fix code style
lumurillo Nov 19, 2024
b2689cb
Use STL functions in CPU array operations for RayCastingScene
lumurillo Nov 19, 2024
239ccf8
Move comment
lumurillo Nov 19, 2024
9ef538a
Do not include CUDA devices in raycast tests.
ssheorey Nov 19, 2024
e3baed6
Convert deprecated SYCL 1.2 code to SYCL 2020
ssheorey Nov 20, 2024
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
12 changes: 11 additions & 1 deletion 3rdparty/embree/embree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ 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)
endif()


ExternalProject_Add(
ext_embree
PREFIX embree
Expand Down Expand Up @@ -92,10 +100,12 @@ 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}
<INSTALL_DIR>/${Open3D_INSTALL_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}embree_rthwif${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_sycl embree4 simd lexers sys math tasking ze_wrapper embree_rthwif ${ISA_LIBS})
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
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());
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::host_selector());
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
Loading