|
1 | | -# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
3 | 3 |
|
4 | 4 | import multiprocessing |
@@ -133,6 +133,21 @@ def _device_id_from_resource_options(device, args, kwargs): |
133 | 133 | return 0 |
134 | 134 |
|
135 | 135 |
|
| 136 | +def _require_ipc_mempool_devices(devices): |
| 137 | + """Return devices if they all support IPC-enabled mempools, otherwise skip.""" |
| 138 | + from helpers import IS_WSL, supports_ipc_mempool |
| 139 | + |
| 140 | + checked_devices = tuple(devices) |
| 141 | + |
| 142 | + if not all(device.properties.handle_type_posix_file_descriptor_supported for device in checked_devices): |
| 143 | + pytest.skip("Device does not support IPC") |
| 144 | + |
| 145 | + if IS_WSL or not all(supports_ipc_mempool(device) for device in checked_devices): |
| 146 | + pytest.skip("Driver rejects IPC-enabled mempool creation on this platform") |
| 147 | + |
| 148 | + return devices |
| 149 | + |
| 150 | + |
136 | 151 | @pytest.fixture(scope="session", autouse=True) |
137 | 152 | def session_setup(): |
138 | 153 | # Always init CUDA. |
@@ -199,25 +214,13 @@ def pop_all_contexts(): |
199 | 214 | @pytest.fixture |
200 | 215 | def ipc_device(): |
201 | 216 | """Obtains a device suitable for IPC-enabled mempool tests, or skips.""" |
202 | | - # Check if IPC is supported on this platform/device |
203 | 217 | device = Device(0) |
204 | 218 | device.set_current() |
205 | 219 |
|
206 | 220 | if not device.properties.memory_pools_supported: |
207 | 221 | pytest.skip("Device does not support mempool operations") |
208 | 222 |
|
209 | | - # Note: Linux specific. Once Windows support for IPC is implemented, this |
210 | | - # test should be updated. |
211 | | - if not device.properties.handle_type_posix_file_descriptor_supported: |
212 | | - pytest.skip("Device does not support IPC") |
213 | | - |
214 | | - # Skip on WSL or if driver rejects IPC-enabled mempool creation on this platform/device |
215 | | - from helpers import IS_WSL, supports_ipc_mempool |
216 | | - |
217 | | - if IS_WSL or not supports_ipc_mempool(device): |
218 | | - pytest.skip("Driver rejects IPC-enabled mempool creation on this platform") |
219 | | - |
220 | | - return device |
| 223 | + return _require_ipc_mempool_devices((device,))[0] |
221 | 224 |
|
222 | 225 |
|
223 | 226 | @pytest.fixture( |
@@ -286,6 +289,12 @@ def mempool_device_x3(): |
286 | 289 | return _mempool_device_impl(3) |
287 | 290 |
|
288 | 291 |
|
| 292 | +@pytest.fixture |
| 293 | +def ipc_mempool_device_x2(mempool_device_x2): |
| 294 | + """Fixture that provides two IPC-capable mempool devices, or skips.""" |
| 295 | + return _require_ipc_mempool_devices(mempool_device_x2) |
| 296 | + |
| 297 | + |
289 | 298 | @pytest.fixture( |
290 | 299 | params=[ |
291 | 300 | pytest.param((DeviceMemoryResource, DeviceMemoryResourceOptions), id="DeviceMR"), |
|
0 commit comments