diff --git a/cpp/open3d/core/SYCLContext.cpp b/cpp/open3d/core/SYCLContext.cpp index b7ac71d1045..30c5f6f6afc 100644 --- a/cpp/open3d/core/SYCLContext.cpp +++ b/cpp/open3d/core/SYCLContext.cpp @@ -54,22 +54,22 @@ SYCLContext::SYCLContext() { } 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 sycl::device &sycl_device = - sycl::device(sycl::cpu_selector_v); - const Device open3d_device = Device("SYCL: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 { + if (devices_.size() == 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] = sycl::queue(sycl_device); - } catch (const sycl::exception &e) { } + const sycl::device &sycl_device = sycl::device(sycl::cpu_selector_v); + const Device open3d_device = + Device("SYCL:" + std::to_string(devices_.size())); + devices_.push_back(open3d_device); + device_to_sycl_device_[open3d_device] = sycl_device; + device_to_default_queue_[open3d_device] = sycl::queue(sycl_device); + } catch (const sycl::exception &e) { } if (devices_.size() == 0) { diff --git a/cpp/open3d/core/SYCLUtils.cpp b/cpp/open3d/core/SYCLUtils.cpp index d92e44fe509..011ee5eb653 100644 --- a/cpp/open3d/core/SYCLUtils.cpp +++ b/cpp/open3d/core/SYCLUtils.cpp @@ -118,14 +118,32 @@ static std::string SYCLDeviceToString(const sycl::device &device) { void PrintSYCLDevices(bool print_all) { #ifdef BUILD_SYCL_MODULE - const char *filter = std::getenv("SYCL_DEVICE_FILTER"); + const char *filter = std::getenv("ONEAPI_DEVICE_SELECTOR"); if (filter) { utility::LogWarning( - "SYCL_DEVICE_FILTER environment variable is set to {}. To see " - "the correct device id, please unset SYCL_DEVICE_FILTER.", + "ONEAPI_DEVICE_SELECTOR environment variable is set to {}. To " + "see the correct device id, please unset " + "ONEAPI_DEVICE_SELECTOR.", filter); } + int nd = 0; + utility::LogInfo("# Open3D SYCL device"); + try { + utility::LogInfo( + "- Device(\"SYCL:{}\"): {}", nd, + SYCLDeviceToString(sycl::device(sycl::gpu_selector_v))); + ++nd; + } catch (const sycl::exception &e) { + } + try { + utility::LogInfo("# Open3D SYCL device (CPU fallback)"); + utility::LogInfo( + "- Device(\"SYCL:{}\"): {}", nd, + SYCLDeviceToString(sycl::device(sycl::cpu_selector_v))); + } catch (const sycl::exception &e) { + if (nd == 0) utility::LogInfo("- Device(\"SYCL:0\"): N/A"); + } if (print_all) { utility::LogInfo("# All SYCL devices"); const std::vector &platforms = @@ -168,24 +186,6 @@ void PrintSYCLDevices(bool print_all) { } catch (const sycl::exception &e) { utility::LogInfo("- sycl::accelerator_selector_v: N/A"); } - - utility::LogInfo("# Open3D SYCL device"); - try { - const sycl::device &device = sycl::device(sycl::gpu_selector_v); - utility::LogInfo("- Device(\"SYCL:0\"): {}", - SYCLDeviceToString(device)); - } catch (const sycl::exception &e) { - utility::LogInfo("- Device(\"SYCL:0\"): N/A"); - } - } else { - utility::LogInfo("# Open3D SYCL device"); - try { - const sycl::device &device = sycl::device(sycl::gpu_selector_v); - utility::LogInfo("- Device(\"SYCL:0\"): {}", - SYCLDeviceToString(device)); - } catch (const sycl::exception &e) { - utility::LogInfo("- Device(\"SYCL:0\"): N/A"); - } } #else diff --git a/cpp/tests/core/CoreTest.cpp b/cpp/tests/core/CoreTest.cpp index babfc30a0e3..3c06295ae7e 100644 --- a/cpp/tests/core/CoreTest.cpp +++ b/cpp/tests/core/CoreTest.cpp @@ -105,7 +105,8 @@ PermuteDevicePairsWithSYCL::TestCases() { std::vector devices; devices.insert(devices.end(), cpu_devices.begin(), cpu_devices.end()); devices.insert(devices.end(), cuda_devices.begin(), cuda_devices.end()); - devices.insert(devices.end(), sycl_devices.begin(), sycl_devices.end()); + // Skip the last SYCL device - this is the CPU fallback + devices.insert(devices.end(), sycl_devices.begin(), sycl_devices.end() - 1); // Self-pairs and cross pairs (bidirectional). std::vector> device_pairs; diff --git a/python/test/t/geometry/test_raycasting_scene.py b/python/test/t/geometry/test_raycasting_scene.py index 4907a84e5ea..c94c66071d9 100755 --- a/python/test/t/geometry/test_raycasting_scene.py +++ b/python/test/t/geometry/test_raycasting_scene.py @@ -15,17 +15,10 @@ sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../..") from open3d_test import list_devices -# RayCastingScene SYCL tests require a GPU with HW raytracing support. We don't -# detect this automatically. -# Do not enable SYCL devices on GIthub - GPU is not available and we don't -# distinguish between SYCL CPU and SYCL GPU. -enable_sycl = os.environ.get("GITHUB_ACTION", "") == "" - - # test intersection with a single triangle @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_cast_rays(device): vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]], dtype=o3d.core.float32, @@ -58,7 +51,7 @@ def test_cast_rays(device): # we expect no errors for this test @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_cast_lots_of_rays(device): vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]], dtype=o3d.core.float32, @@ -80,7 +73,7 @@ def test_cast_lots_of_rays(device): # test occlusion with a single triangle @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_test_occlusions(device): vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]], dtype=o3d.core.float32, @@ -118,7 +111,7 @@ def test_test_occlusions(device): # we expect no errors for this test @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_test_lots_of_occlusions(device): vertices = o3d.core.Tensor([[0, 0, 0], [1, 0, 0], [1, 1, 0]], dtype=o3d.core.float32, @@ -139,7 +132,7 @@ def test_test_lots_of_occlusions(device): @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_add_triangle_mesh(device): cube = o3d.t.geometry.TriangleMesh.create_box() cube = cube.to(device) @@ -160,7 +153,7 @@ def test_add_triangle_mesh(device): @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_count_intersections(device): cube = o3d.t.geometry.TriangleMesh.create_box() vertex_positions = cube.vertex.positions @@ -187,7 +180,7 @@ def test_count_intersections(device): # we expect no errors for this test @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_count_lots_of_intersections(device): cube = o3d.t.geometry.TriangleMesh.create_box() vertex_positions = cube.vertex.positions @@ -208,7 +201,7 @@ def test_count_lots_of_intersections(device): @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_list_intersections(device): cube = o3d.t.geometry.TriangleMesh.create_box() vertex_positions = cube.vertex.positions @@ -238,7 +231,7 @@ def test_list_intersections(device): # we expect no errors for this test @pytest.mark.parametrize("device", list_devices(enable_cuda=False, - enable_sycl=enable_sycl)) + enable_sycl=True)) def test_list_lots_of_intersections(device): cube = o3d.t.geometry.TriangleMesh.create_box() vertex_positions = cube.vertex.positions