Skip to content

Commit

Permalink
Skip last SYCL device (CPU fallback) in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheorey committed Dec 11, 2024
1 parent d9ae308 commit e0ee30c
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 40 deletions.
5 changes: 4 additions & 1 deletion cpp/tests/core/CoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ PermuteDevicePairsWithSYCL::TestCases() {
devices.insert(devices.end(), cpu_devices.begin(), cpu_devices.end());
devices.insert(devices.end(), cuda_devices.begin(), cuda_devices.end());
// Skip the last SYCL device - this is the CPU fallback
devices.insert(devices.end(), sycl_devices.begin(), sycl_devices.end() - 1);
if (sycl_devices.size() > 1) {
devices.insert(devices.end(), sycl_devices.begin(),
sycl_devices.end() - 1);
}

// Self-pairs and cross pairs (bidirectional).
std::vector<std::pair<core::Device, core::Device>> device_pairs;
Expand Down
5 changes: 3 additions & 2 deletions python/test/open3d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ def list_devices(enable_cuda=True, enable_sycl=False):
Returns a list of devices that are available for Open3D to use:
- Device("CPU:0")
- Device("CUDA:0") if built with CUDA support and a CUDA device is available.
- Device("SYCL:0") if built with SYCL support and a SYCL device is available.
- Device("SYCL:0") if built with SYCL support and a SYCL GPU device is available.
"""
import open3d as o3d

devices = [o3d.core.Device("CPU:0")]
if enable_cuda and o3d.core.cuda.device_count() > 0:
devices.append(o3d.core.Device("CUDA:0"))
if enable_sycl and o3d.core.sycl.is_available():
# Ignore fallback SYCL CPU device
if enable_sycl and len(o3d.core.sycl.get_available_devices()) > 1:
devices.append(o3d.core.Device("SYCL:0"))
return devices

Expand Down
99 changes: 62 additions & 37 deletions python/test/t/geometry/test_raycasting_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../..")
from open3d_test import list_devices


# test intersection with a single triangle
@pytest.mark.parametrize("device",
list_devices(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, 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,
Expand Down Expand Up @@ -50,8 +50,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(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, 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,
Expand All @@ -72,8 +71,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=True))
list_devices(enable_cuda=False, 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,
Expand Down Expand Up @@ -110,8 +108,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(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, 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,
Expand All @@ -131,8 +128,7 @@ def test_test_lots_of_occlusions(device):


@pytest.mark.parametrize("device",
list_devices(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, enable_sycl=True))
def test_add_triangle_mesh(device):
cube = o3d.t.geometry.TriangleMesh.create_box()
cube = cube.to(device)
Expand All @@ -152,8 +148,7 @@ def test_add_triangle_mesh(device):


@pytest.mark.parametrize("device",
list_devices(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, enable_sycl=True))
def test_count_intersections(device):
cube = o3d.t.geometry.TriangleMesh.create_box()
vertex_positions = cube.vertex.positions
Expand All @@ -179,8 +174,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(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, enable_sycl=True))
def test_count_lots_of_intersections(device):
cube = o3d.t.geometry.TriangleMesh.create_box()
vertex_positions = cube.vertex.positions
Expand All @@ -200,8 +194,7 @@ def test_count_lots_of_intersections(device):


@pytest.mark.parametrize("device",
list_devices(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, enable_sycl=True))
def test_list_intersections(device):
cube = o3d.t.geometry.TriangleMesh.create_box()
vertex_positions = cube.vertex.positions
Expand Down Expand Up @@ -230,8 +223,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(enable_cuda=False,
enable_sycl=True))
list_devices(enable_cuda=False, enable_sycl=True))
def test_list_lots_of_intersections(device):
cube = o3d.t.geometry.TriangleMesh.create_box()
vertex_positions = cube.vertex.positions
Expand Down Expand Up @@ -411,25 +403,58 @@ def test_sphere_wrong_occupancy():

occupancy = scene.compute_occupancy(query_points)
expected = np.array(
[[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]],
[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 1.0, 0.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0], [0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 0.0, 1.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]],
[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], [0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, 1.0, 0.0],
[0.0, 0.0, 1.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
],
[
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
],
[
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
],
[
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 1.0, 0.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 1.0, 1.0, 1.0, 1.0, 0.0],
[0.0, 0.0, 1.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
],
[
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
],
],
dtype=np.float32,
)
np.testing.assert_equal(occupancy.numpy(), expected)

# we should get the same result with more samples
Expand Down

0 comments on commit e0ee30c

Please sign in to comment.