Skip to content

Commit

Permalink
Convert deprecated SYCL 1.2 code to SYCL 2020
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheorey committed Nov 20, 2024
1 parent 9ef538a commit e3baed6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
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
4 changes: 2 additions & 2 deletions cpp/open3d/core/SYCLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ SYCLContext::SYCLContext() {
// SYCL GPU.
// TODO: Currently we only support one GPU device.
try {
const sycl::device &sycl_device = sycl::device(sycl::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;
Expand All @@ -60,7 +60,7 @@ SYCLContext::SYCLContext() {
// your CPU does not have integrated GPU.
try {
const sycl::device &sycl_device =
sycl::device(sycl::host_selector());
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 "
Expand Down
43 changes: 18 additions & 25 deletions cpp/open3d/core/SYCLUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int SYCLDemo() {
#ifdef BUILD_SYCL_MODULE
// Ref: https://intel.github.io/llvm-docs/GetStartedGuide.html
// Creating buffer of 4 ints to be used inside the kernel code.
sycl::buffer<sycl::cl_int, 1> buffer(4);
sycl::buffer<int, 1> buffer(4);

// Creating SYCL queue.
sycl::queue q;
Expand All @@ -51,13 +51,13 @@ int SYCLDemo() {
cgh.parallel_for<class FillBuffer>(
num_workloads, [=](sycl::id<1> WIid) {
// Fill buffer with indexes.
accessor[WIid] = (sycl::cl_int)WIid.get(0);
accessor[WIid] = (int)WIid.get(0);
});
});

// Getting read only access to the buffer on the host.
// Getting access to the buffer on the host.
// Implicit barrier waiting for q to complete the work.
const auto host_accessor = buffer.get_access<sycl::access::mode::read>();
const auto host_accessor = buffer.get_host_access();

// Check the results.
bool mismatch_found = false;
Expand Down Expand Up @@ -140,45 +140,38 @@ void PrintSYCLDevices(bool print_all) {

utility::LogInfo("# Default SYCL selectors");
try {
const sycl::device &device = sycl::device(sycl::default_selector());
utility::LogInfo("- sycl::default_selector() : {}",
const sycl::device &device = sycl::device(sycl::default_selector_v);
utility::LogInfo("- sycl::default_selector_v : {}",
SYCLDeviceToString(device));
} catch (const sycl::exception &e) {
utility::LogInfo("- sycl::default_selector() : N/A");
utility::LogInfo("- sycl::default_selector_v : N/A");
}
try {
const sycl::device &device = sycl::device(sycl::host_selector());
utility::LogInfo("- sycl::host_selector() : {}",
const sycl::device &device = sycl::device(sycl::cpu_selector_v);
utility::LogInfo("- sycl::cpu_selector_v : {}",
SYCLDeviceToString(device));
} catch (const sycl::exception &e) {
utility::LogInfo("- sycl::host_selector() : N/A");
utility::LogInfo("- sycl::cpu_selector_v : N/A");
}
try {
const sycl::device &device = sycl::device(sycl::cpu_selector());
utility::LogInfo("- sycl::cpu_selector() : {}",
const sycl::device &device = sycl::device(sycl::gpu_selector_v);
utility::LogInfo("- sycl::gpu_selector_v : {}",
SYCLDeviceToString(device));
} catch (const sycl::exception &e) {
utility::LogInfo("- sycl::cpu_selector() : N/A");
}
try {
const sycl::device &device = sycl::device(sycl::gpu_selector());
utility::LogInfo("- sycl::gpu_selector() : {}",
SYCLDeviceToString(device));
} catch (const sycl::exception &e) {
utility::LogInfo("- sycl::gpu_selector() : N/A");
utility::LogInfo("- sycl::gpu_selector_v : N/A");
}
try {
const sycl::device &device =
sycl::device(sycl::accelerator_selector());
utility::LogInfo("- sycl::accelerator_selector(): {}",
sycl::device(sycl::accelerator_selector_v);
utility::LogInfo("- sycl::accelerator_selector_v: {}",
SYCLDeviceToString(device));
} catch (const sycl::exception &e) {
utility::LogInfo("- sycl::accelerator_selector(): N/A");
utility::LogInfo("- sycl::accelerator_selector_v: N/A");
}

utility::LogInfo("# Open3D SYCL device");
try {
const sycl::device &device = sycl::device(sycl::gpu_selector());
const sycl::device &device = sycl::device(sycl::gpu_selector_v);
utility::LogInfo("- Device(\"SYCL:0\"): {}",
SYCLDeviceToString(device));
} catch (const sycl::exception &e) {
Expand All @@ -187,7 +180,7 @@ void PrintSYCLDevices(bool print_all) {
} else {
utility::LogInfo("# Open3D SYCL device");
try {
const sycl::device &device = sycl::device(sycl::gpu_selector());
const sycl::device &device = sycl::device(sycl::gpu_selector_v);
utility::LogInfo("- Device(\"SYCL:0\"): {}",
SYCLDeviceToString(device));
} catch (const sycl::exception &e) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/pybind/t/geometry/raycasting_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ or compute the closest point on the surface of a mesh with respect to one
or more query points.
It builds an internal acceleration structure to speed up those queries.
This class supports only the CPU device.
This class supports the CPU device and SYCL GPU device.
The following shows how to create a scene and compute ray intersections::
Expand Down Expand Up @@ -64,7 +64,7 @@ Create a RaycastingScene.
Args:
nthreads (int): The number of threads to use for building the scene. Set to 0 for automatic.
device (open3d.core.Device): The device to use.
device (open3d.core.Device): The device to use. Currently CPU and SYCL devices are supported.
)doc");

raycasting_scene.def(
Expand Down

0 comments on commit e3baed6

Please sign in to comment.