From aa437b62482021cde879505e7a3b95244392fd99 Mon Sep 17 00:00:00 2001
From: "Murillo Rojas, Luis" <luis.murillo.rojas@intel.com>
Date: Mon, 4 Nov 2024 16:56:37 -0800
Subject: [PATCH] Add SYCL enable parameter to list_devices

---
 python/test/open3d_test.py                     |  4 ++--
 .../test/t/geometry/test_raycasting_scene.py   | 18 +++++++++---------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/python/test/open3d_test.py b/python/test/open3d_test.py
index 271cdadf3a1..013df23f36a 100755
--- a/python/test/open3d_test.py
+++ b/python/test/open3d_test.py
@@ -23,7 +23,7 @@ def torch_available():
     return True
 
 
-def list_devices():
+def list_devices(enable_sycl=False):
     """
     If Open3D is built with CUDA support:
     - If cuda device is available, returns [Device("CPU:0"), Device("CUDA:0")].
@@ -39,7 +39,7 @@ def list_devices():
     import open3d as o3d
     if o3d.core.cuda.device_count() > 0:
         return [o3d.core.Device("CPU:0"), o3d.core.Device("CUDA:0")]
-    elif o3d.core.sycl.is_available():
+    elif enable_sycl and o3d.core.sycl.is_available():
         return [o3d.core.Device("CPU:0"), o3d.core.Device("SYCL:0")]
     else:
         return [o3d.core.Device("CPU:0")]
diff --git a/python/test/t/geometry/test_raycasting_scene.py b/python/test/t/geometry/test_raycasting_scene.py
index 294c5af33a5..ec8ae54acea 100755
--- a/python/test/t/geometry/test_raycasting_scene.py
+++ b/python/test/t/geometry/test_raycasting_scene.py
@@ -16,7 +16,7 @@
 
 
 # test intersection with a single triangle
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(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,
@@ -45,7 +45,7 @@ def test_cast_rays(device):
 
 # cast lots of random rays to test the internal batching
 # we expect no errors for this test
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(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,
@@ -65,7 +65,7 @@ def test_cast_lots_of_rays(device):
 
 
 # test occlusion with a single triangle
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(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,
@@ -99,7 +99,7 @@ def test_test_occlusions(device):
 
 # test lots of random rays for occlusions to test the internal batching
 # we expect no errors for this test
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(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,
@@ -118,7 +118,7 @@ def test_test_lots_of_occlusions(device):
     _ = scene.test_occlusions(rays)
 
 
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
 def test_add_triangle_mesh(device):
     cube = o3d.t.geometry.TriangleMesh.from_legacy(
         o3d.geometry.TriangleMesh.create_box())
@@ -140,7 +140,7 @@ def test_add_triangle_mesh(device):
     np.testing.assert_equal(ans.cpu().numpy(), [2, 1, 0])
 
 
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
 def test_count_intersections(device):
     cube = o3d.t.geometry.TriangleMesh.from_legacy(
         o3d.geometry.TriangleMesh.create_box())
@@ -164,7 +164,7 @@ def test_count_intersections(device):
 
 # count lots of random ray intersections to test the internal batching
 # we expect no errors for this test
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
 def test_count_lots_of_intersections(device):
     cube = o3d.t.geometry.TriangleMesh.from_legacy(
         o3d.geometry.TriangleMesh.create_box())
@@ -184,7 +184,7 @@ def test_count_lots_of_intersections(device):
     _ = scene.count_intersections(rays)
 
 
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
 def test_list_intersections(device):
     cube = o3d.t.geometry.TriangleMesh.from_legacy(
         o3d.geometry.TriangleMesh.create_box())
@@ -211,7 +211,7 @@ def test_list_intersections(device):
 
 # list lots of random ray intersections to test the internal batching
 # we expect no errors for this test
-@pytest.mark.parametrize("device", list_devices())
+@pytest.mark.parametrize("device", list_devices(enable_sycl=True))
 def test_list_lots_of_intersections(device):
     cube = o3d.t.geometry.TriangleMesh.from_legacy(
         o3d.geometry.TriangleMesh.create_box())