diff --git a/cuda_core/tests/conftest.py b/cuda_core/tests/conftest.py index a176de5479d..0a8c9d44786 100644 --- a/cuda_core/tests/conftest.py +++ b/cuda_core/tests/conftest.py @@ -529,50 +529,64 @@ def _close_memory_resource(mr): close() -@pytest.fixture( - params=[ - pytest.param("device", id="DeviceMR"), - pytest.param("pinned", id="PinnedMR"), - pytest.param("vmm", id="VirtualMR"), - ] -) -def ipc_memory_resource(request, ipc_device): - """Provides an IPC-enabled memory resource: a device pool, a pinned pool, or a VirtualMemoryResource. +_DEVICE_MR = pytest.param("device", id="DeviceMR") +_PINNED_MR = pytest.param("pinned", id="PinnedMR") +_VIRTUAL_MR = pytest.param("vmm", id="VirtualMR") - The VMM parameter needs VMM support and POSIX file descriptor handles on - top of what :func:`ipc_device` requires; it skips otherwise. Tests that - use the pool-only half of the IPC protocol (``allocation_handle``, - ``from_allocation_handle``, the registry, ``uuid``, ``is_mapped`` on the - resource) guard or skip for it. - """ - mr = _make_ipc_memory_resource(request.param, ipc_device) + +def _ipc_memory_resource(kind, device): + mr = _make_ipc_memory_resource(kind, device) assert mr.is_ipc_enabled yield mr _close_memory_resource(mr) # TODO(seberg): Make sure the `mr` and it's buffers are fully torn down. # May be unnecessary as `mr.close()` is not parallel with other work. - ipc_device.sync() + device.sync() -@pytest.fixture( - params=[ - pytest.param("device", id="DeviceMR"), - pytest.param("vmm", id="VirtualMR"), - ] -) -def ipc_memory_resource_factory(request, ipc_device): - """Provides a callable that creates fresh IPC-enabled resources of one kind; all are closed at teardown.""" +def _ipc_memory_resource_factory(kind, device): created = [] def make(): - mr = _make_ipc_memory_resource(request.param, ipc_device) + mr = _make_ipc_memory_resource(kind, device) created.append(mr) return mr yield make for mr in created: _close_memory_resource(mr) - ipc_device.sync() + device.sync() + + +@pytest.fixture(params=[_DEVICE_MR, _PINNED_MR, _VIRTUAL_MR]) +def ipc_memory_resource(request, ipc_device): + """Provides an IPC-enabled memory resource: a device pool, a pinned pool, or a VirtualMemoryResource. + + The VMM parameter needs VMM support and POSIX file descriptor handles on + top of what :func:`ipc_device` requires; it skips otherwise. Tests that + use the pool-only half of the IPC protocol (``allocation_handle``, + ``from_allocation_handle``, the registry, ``uuid``, ``is_mapped`` on the + resource) use :func:`ipc_pool_memory_resource` instead. + """ + yield from _ipc_memory_resource(request.param, ipc_device) + + +@pytest.fixture(params=[_DEVICE_MR, _PINNED_MR]) +def ipc_pool_memory_resource(request, ipc_device): + """Provides an IPC-enabled memory pool: a device pool or a pinned pool.""" + yield from _ipc_memory_resource(request.param, ipc_device) + + +@pytest.fixture(params=[_DEVICE_MR, _VIRTUAL_MR]) +def ipc_memory_resource_factory(request, ipc_device): + """Provides a callable that creates fresh IPC-enabled resources of one kind; all are closed at teardown.""" + yield from _ipc_memory_resource_factory(request.param, ipc_device) + + +@pytest.fixture(params=[_DEVICE_MR]) +def ipc_pool_memory_resource_factory(request, ipc_device): + """Like :func:`ipc_memory_resource_factory`, for tests that use the pool-only half of the IPC protocol.""" + yield from _ipc_memory_resource_factory(request.param, ipc_device) @pytest.fixture diff --git a/cuda_core/tests/memory_ipc/test_errors.py b/cuda_core/tests/memory_ipc/test_errors.py index 84cbb5c3047..c84aa9e694e 100644 --- a/cuda_core/tests/memory_ipc/test_errors.py +++ b/cuda_core/tests/memory_ipc/test_errors.py @@ -102,10 +102,8 @@ def test_registry_rejects_a_key_that_is_not_a_uuid(mempool_device, key): DeviceMemoryResource.from_registry(key) -# For the VirtualMR parameter case: -# This test is not currently run in any CI job @pytest.mark.human_authored -def test_register_rejects_mismatched_uuid(ipc_memory_resource): +def test_register_rejects_mismatched_uuid(ipc_pool_memory_resource): """register() rejects a UUID that does not match the resource's own. The check is an explicit ValueError (not a bare ``assert``) so it remains @@ -113,9 +111,7 @@ def test_register_rejects_mismatched_uuid(ipc_memory_resource): (see #2697). Registering under a foreign key would otherwise rewrite the resource's UUID and silently corrupt the IPC registry. """ - mr = ipc_memory_resource - if not is_pool_resource(mr): - pytest.skip("allocation handles and the registry are pool-only") + mr = ipc_pool_memory_resource assert mr.is_ipc_enabled # The resource must already carry its own UUID (assigned on creation). @@ -136,7 +132,7 @@ def test_register_rejects_mismatched_uuid(ipc_memory_resource): @pytest.mark.agent_authored(model="claude-fable-5-2") -def test_register_keeps_the_uuid_object_the_resource_already_has(ipc_memory_resource_factory): +def test_register_keeps_the_uuid_object_the_resource_already_has(ipc_pool_memory_resource_factory): """register() under an equal UUID keeps the UUID object the resource already has. The UUID of an allocation handle is read without a lock. Replacing the @@ -145,9 +141,7 @@ def test_register_keeps_the_uuid_object_the_resource_already_has(ipc_memory_reso """ # A resource of its own: pytest-run-parallel shares fixtures between its # threads, and another thread could register a shared resource first. - mr = ipc_memory_resource_factory() - if not is_pool_resource(mr): - pytest.skip("allocation handles and the registry are pool-only") + mr = ipc_pool_memory_resource_factory() original = mr.uuid assert original is not None @@ -180,13 +174,9 @@ def test_ipc_allocation_handle_state_tracks_close(): os.close(write_fd) -# For the VirtualMR parameter case: -# This test is not currently run in any CI job @pytest.mark.agent_authored(model="gpt-5.6") -def test_closed_ipc_allocation_handle_rejected_before_registry_hit(ipc_device, ipc_memory_resource): - mr = ipc_memory_resource - if not is_pool_resource(mr): - pytest.skip("allocation handles and the registry are pool-only") +def test_closed_ipc_allocation_handle_rejected_before_registry_hit(ipc_device, ipc_pool_memory_resource): + mr = ipc_pool_memory_resource handle = IPCAllocationHandle._init(os.dup(int(mr.allocation_handle)), mr.uuid) assert mr.register(mr.uuid) is mr handle.close() @@ -202,9 +192,8 @@ def test_closed_ipc_allocation_handle_rejected_before_registry_hit(ipc_device, i class ChildErrorHarness: """Test harness for checking errors in child processes. Subclasses override PARENT_ACTION, CHILD_ACTION, and ASSERT (see below for examples). A subclass - that exercises the pool half of the protocol sets POOL_ONLY.""" - - POOL_ONLY = False + that exercises the pool half of the protocol overrides ``ipc_memory_resource`` + with ``ipc_pool_memory_resource``.""" @pytest.mark.thread_unsafe( reason=( @@ -220,8 +209,6 @@ def test_main(self, ipc_device, ipc_memory_resource): self.device = ipc_device self.mr = ipc_memory_resource self._extra_mrs = [] - if self.POOL_ONLY and not is_pool_resource(self.mr): - pytest.skip("this scenario needs the pool half of the IPC protocol") # Clear stale 'buffer' left by a previous flaky-rerun attempt. # Its backing DeviceMemoryResource may already be closed, which causes # process.start() to fail when pickling self for spawn-mode IPC. @@ -377,15 +364,16 @@ def ASSERT(self, exc_type, exc_msg): assert exc_msg.startswith("Argument 'ipc_descriptor' has incorrect type") -# For the inherited test_main[VirtualMR] case: -# This test is not currently run in any CI job class TestDanglingBuffer(ChildErrorHarness): """ Error when importing a buffer object without registering its memory resource. """ - POOL_ONLY = True # plain pickle of a VMM buffer is refused (fds), and VMM has no registry + @pytest.fixture + def ipc_memory_resource(self, ipc_pool_memory_resource): + # Plain pickle of a VMM buffer is refused (fds), and VMM has no registry. + return ipc_pool_memory_resource def PARENT_ACTION(self, queue): options = DeviceMemoryResourceOptions(max_size=POOL_SIZE, ipc_enabled=True) diff --git a/cuda_core/tests/memory_ipc/test_ipc_pool_duplicate_import.py b/cuda_core/tests/memory_ipc/test_ipc_pool_duplicate_import.py index 1e8c7c4c6e5..498fc87df52 100644 --- a/cuda_core/tests/memory_ipc/test_ipc_pool_duplicate_import.py +++ b/cuda_core/tests/memory_ipc/test_ipc_pool_duplicate_import.py @@ -31,7 +31,6 @@ drain_on_exit, enter_imported_pool, import_pool_resource, - is_pool_resource, pool_access_flags, pool_supported_devices, ) @@ -606,96 +605,113 @@ def _set_start_method(self): mp.set_start_method("spawn", force=True) @pytest.fixture - def pool_resource(self, ipc_memory_resource): - if not is_pool_resource(ipc_memory_resource): - pytest.skip("a VirtualMemoryResource has no memory pool to import") - return ipc_memory_resource - - @pytest.fixture - def exported_buffer(self, ipc_device, pool_resource): + def exported_buffer(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() stream = ipc_device.default_stream - buffer = pool_resource.allocate(NBYTES, stream=stream) + buffer = ipc_pool_memory_resource.allocate(NBYTES, stream=stream) stream.sync() yield buffer buffer.close(stream) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_closing_one_import_keeps_the_other_usable(self, pool_resource, exported_buffer): + def test_closing_one_import_keeps_the_other_usable(self, ipc_pool_memory_resource, exported_buffer): run_child( - child_close_one_import, type(pool_resource), pool_resource.allocation_handle, exported_buffer.ipc_descriptor + child_close_one_import, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, + exported_buffer.ipc_descriptor, ) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_closing_both_imports_with_an_outstanding_buffer(self, pool_resource, exported_buffer): + def test_closing_both_imports_with_an_outstanding_buffer(self, ipc_pool_memory_resource, exported_buffer): run_child( child_close_both_imports_with_outstanding_buffer, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, exported_buffer.ipc_descriptor, ) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_reimport_racing_the_last_release_keeps_access(self, pool_resource, exported_buffer): + def test_reimport_racing_the_last_release_keeps_access(self, ipc_pool_memory_resource, exported_buffer): run_child( child_reimport_races_last_release, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, exported_buffer.ipc_descriptor, ) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_registration_reentered_from_garbage_collection(self, ipc_device, pool_resource): + def test_registration_reentered_from_garbage_collection(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() - run_child(child_register_reentered_by_gc, type(pool_resource), pool_resource.allocation_handle) + run_child( + child_register_reentered_by_gc, type(ipc_pool_memory_resource), ipc_pool_memory_resource.allocation_handle + ) @pytest.mark.skipif(sys.version_info[:2] != (3, 11), reason="requires CPython 3.11's allocation-triggered GC") @pytest.mark.agent_authored(model="gpt-6.2-sol") - def test_gc_during_registration_allows_registry_lookup(self, ipc_device, pool_resource): + def test_gc_during_registration_allows_registry_lookup(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() run_child( - child_gc_during_registration_allows_registry_lookup, type(pool_resource), pool_resource.allocation_handle + child_gc_during_registration_allows_registry_lookup, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, ) @pytest.mark.agent_authored(model="claude-opus-5-5") @pytest.mark.parametrize("shared_handle", [False, True], ids=["separate_handles", "shared_handle"]) @pytest.mark.parametrize("case", ["keep", "close", "fail"]) - def test_registration_interrupted_at_every_use_of_its_key(self, ipc_device, pool_resource, case, shared_handle): + def test_registration_interrupted_at_every_use_of_its_key( + self, ipc_device, ipc_pool_memory_resource, case, shared_handle + ): ipc_device.set_current() run_child( child_register_interrupted_at_every_key_use, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, case, shared_handle, ) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_registry_entry_of_a_dropped_resource_is_removed(self, ipc_device, pool_resource): + def test_registry_entry_of_a_dropped_resource_is_removed(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() - run_child(child_dead_registry_entry_is_removed, type(pool_resource), pool_resource.allocation_handle) + run_child( + child_dead_registry_entry_is_removed, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, + ) @pytest.mark.agent_authored(model="claude-fable-5-2") - def test_shared_handle_keeps_its_uuid_object_after_its_first_owner(self, ipc_device, pool_resource): + def test_shared_handle_keeps_its_uuid_object_after_its_first_owner(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() - run_child(child_shared_handle_keeps_its_uuid_object, type(pool_resource), pool_resource.allocation_handle) + run_child( + child_shared_handle_keeps_its_uuid_object, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, + ) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_lookups_racing_registrations_find_registered_resources(self, ipc_device, pool_resource): + def test_lookups_racing_registrations_find_registered_resources(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() - run_child(child_lookups_race_registrations, type(pool_resource), pool_resource.allocation_handle) + run_child( + child_lookups_race_registrations, type(ipc_pool_memory_resource), ipc_pool_memory_resource.allocation_handle + ) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_concurrent_imports_of_one_uuid_share_a_resource(self, ipc_device, pool_resource): + def test_concurrent_imports_of_one_uuid_share_a_resource(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() - run_child(child_concurrent_uuid_imports, type(pool_resource), pool_resource.allocation_handle) + run_child( + child_concurrent_uuid_imports, type(ipc_pool_memory_resource), ipc_pool_memory_resource.allocation_handle + ) # Releasing the last import of a pool with unsynchronized frees pending # leaves the driver holding the pool (#3514); the next import must still # grant device access. @pytest.mark.parametrize("import_path", ["single", "raw_handle", "concurrent_uuid"]) @pytest.mark.agent_authored(model="claude-sonnet-5-5") - def test_reimport_after_release_with_pending_free(self, ipc_device, pool_resource, exported_buffer, import_path): + def test_reimport_after_release_with_pending_free( + self, ipc_device, ipc_pool_memory_resource, exported_buffer, import_path + ): # The child holds the free with a LatchKernel. Check what it needs here: # a skip raised in the child would surface as a child failure. if helpers.CUDA_INCLUDE_PATH is None: @@ -704,8 +720,8 @@ def test_reimport_after_release_with_pending_free(self, ipc_device, pool_resourc pytest.skip("__nanosleep is only available starting Volta (sm70)") run_child( child_reimport_after_release_with_pending_free, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, exported_buffer.ipc_descriptor, import_path, ) diff --git a/cuda_core/tests/memory_ipc/test_ipc_pool_kind.py b/cuda_core/tests/memory_ipc/test_ipc_pool_kind.py index b7edc019226..b3c14f7c65f 100644 --- a/cuda_core/tests/memory_ipc/test_ipc_pool_kind.py +++ b/cuda_core/tests/memory_ipc/test_ipc_pool_kind.py @@ -22,7 +22,6 @@ drain_on_exit, enter_imported_pool, import_pool_resource, - is_pool_resource, pool_access_flags, skip_if_host_numa_pinned_memory_unsupported, skip_if_pool_location_query_unsupported, @@ -181,16 +180,10 @@ def _set_start_method(self): mp.set_start_method("spawn", force=True) @pytest.fixture - def pool_resource(self, ipc_memory_resource): - if not is_pool_resource(ipc_memory_resource): - pytest.skip("a VirtualMemoryResource has no memory pool to import") - return ipc_memory_resource - - @pytest.fixture - def exported_buffer(self, ipc_device, pool_resource): + def exported_buffer(self, ipc_device, ipc_pool_memory_resource): ipc_device.set_current() stream = ipc_device.default_stream - buffer = pool_resource.allocate(NBYTES, stream=stream) + buffer = ipc_pool_memory_resource.allocate(NBYTES, stream=stream) stream.sync() yield buffer buffer.close(stream) @@ -200,11 +193,11 @@ class TestIpcPoolMatchingImport(_IpcPoolFixtures): """Importing a pool with the exporter's class works whether or not the pool's kind can be checked.""" @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_matching_import_works(self, pool_resource, exported_buffer): + def test_matching_import_works(self, ipc_pool_memory_resource, exported_buffer): run_child( child_matching_import, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, exported_buffer.ipc_descriptor, ) @@ -213,11 +206,11 @@ class TestIpcPoolImportWithoutLocationQuery(_IpcPoolFixtures): """With a driver before 13.2, importing with the exporter's class works without the pool kind check.""" @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_import_without_location_query(self, pool_resource, exported_buffer): + def test_import_without_location_query(self, ipc_pool_memory_resource, exported_buffer): run_child( child_import_without_location_query, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, exported_buffer.ipc_descriptor, ) @@ -230,20 +223,20 @@ def _require_pool_location_query(self): skip_if_pool_location_query_unsupported() @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_mismatched_import_raises(self, pool_resource, exported_buffer): + def test_mismatched_import_raises(self, ipc_pool_memory_resource, exported_buffer): run_child( child_mismatched_import_raises, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, exported_buffer.ipc_descriptor, ) @pytest.mark.agent_authored(model="claude-opus-5-5") - def test_rejected_import_keeps_existing_import(self, pool_resource, exported_buffer): + def test_rejected_import_keeps_existing_import(self, ipc_pool_memory_resource, exported_buffer): run_child( child_rejected_import_keeps_existing_import, - type(pool_resource), - pool_resource.allocation_handle, + type(ipc_pool_memory_resource), + ipc_pool_memory_resource.allocation_handle, exported_buffer.ipc_descriptor, ) diff --git a/cuda_core/tests/memory_ipc/test_leaks.py b/cuda_core/tests/memory_ipc/test_leaks.py index 92023b8dc19..d9d589e703e 100644 --- a/cuda_core/tests/memory_ipc/test_leaks.py +++ b/cuda_core/tests/memory_ipc/test_leaks.py @@ -26,15 +26,11 @@ pytestmark = pytest.mark.thread_unsafe(reason="Tests number of fds which is shared.") -# For the VirtualMR parameter case: -# This test is not currently run in any CI job @pytest.mark.flaky(reruns=2) @skip_if_unrunnable -def test_alloc_handle(ipc_memory_resource): +def test_alloc_handle(ipc_pool_memory_resource): """Check for fd leaks in allocation_handle.""" - mr = ipc_memory_resource - if not hasattr(mr, "allocation_handle"): - pytest.skip("allocation handles are pool-only") + mr = ipc_pool_memory_resource with CheckFDLeaks(): [mr.allocation_handle for _ in range(10)] @@ -81,12 +77,6 @@ def __reduce__(self): raise RuntimeError("Irreducible") -def _get_alloc_handle(mr, _stream): - if not hasattr(mr, "allocation_handle"): - pytest.skip("allocation handles are pool-only") - return mr.allocation_handle - - def _get_mr(mr, _stream): return mr @@ -99,20 +89,11 @@ def _get_buffer_desc(mr, stream): return mr.allocate(NBYTES, stream=stream).ipc_descriptor -# For VirtualMR with getobject=alloc_handle (all launchers): -# This test is not currently run in any CI job -@pytest.mark.flaky(reruns=2) -@skip_if_unrunnable -@pytest.mark.parametrize( - "getobject", - [_get_alloc_handle, _get_mr, _get_buffer, _get_buffer_desc], - ids=["alloc_handle", "mr", "buffer", "buffer_desc"], -) -@pytest.mark.parametrize("launcher", [exec_success, exec_launch_failure, exec_reduce_failure]) -def test_pass_object(ipc_device, ipc_memory_resource, launcher, getobject): - """Check for fd leaks when an object is sent as a subprocess argument.""" - mr = ipc_memory_resource - stream = ipc_device.default_stream +LAUNCHERS = [exec_success, exec_launch_failure, exec_reduce_failure] + + +def _check_pass_object(device, mr, launcher, getobject): + stream = device.default_stream with CheckFDLeaks(): obj = getobject(mr, stream) stream.sync() @@ -122,6 +103,27 @@ def test_pass_object(ipc_device, ipc_memory_resource, launcher, getobject): del obj +@pytest.mark.flaky(reruns=2) +@skip_if_unrunnable +@pytest.mark.parametrize( + "getobject", + [_get_mr, _get_buffer, _get_buffer_desc], + ids=["mr", "buffer", "buffer_desc"], +) +@pytest.mark.parametrize("launcher", LAUNCHERS) +def test_pass_object(ipc_device, ipc_memory_resource, launcher, getobject): + """Check for fd leaks when an object is sent as a subprocess argument.""" + _check_pass_object(ipc_device, ipc_memory_resource, launcher, getobject) + + +@pytest.mark.flaky(reruns=2) +@skip_if_unrunnable +@pytest.mark.parametrize("launcher", LAUNCHERS) +def test_pass_alloc_handle(ipc_device, ipc_pool_memory_resource, launcher): + """Check for fd leaks when an allocation handle is sent as a subprocess argument.""" + _check_pass_object(ipc_device, ipc_pool_memory_resource, launcher, lambda mr, _stream: mr.allocation_handle) + + class CheckFDLeaks: """ Context manager to check for file descriptor leaks. diff --git a/cuda_core/tests/memory_ipc/test_send_buffers.py b/cuda_core/tests/memory_ipc/test_send_buffers.py index 17103245c51..acdddc53ced 100644 --- a/cuda_core/tests/memory_ipc/test_send_buffers.py +++ b/cuda_core/tests/memory_ipc/test_send_buffers.py @@ -10,7 +10,7 @@ from helpers.child_processes import child_timeout_sec, kill_subprocesses from helpers.memory import drain_on_exit -from cuda.core import Device, VirtualMemoryResource +from cuda.core import Device CHILD_TIMEOUT_SEC = child_timeout_sec() NBYTES = 64 @@ -89,21 +89,17 @@ class TestIpcReexport: re-exported from B to C. """ - # For the VirtualMR parameter case: - # This test is not currently run in any CI job + # An imported VirtualMemoryBuffer cannot be exported again: the driver does + # not export imported allocations. test_vmm_ipc.py::TestReexport checks + # that this raises a clear error. @pytest.mark.flaky(reruns=2) - def test_main(self, ipc_device, ipc_memory_resource): + def test_main(self, ipc_device, ipc_pool_memory_resource): # Set up the device. device = ipc_device device.set_current() # Allocate, fill a buffer. - mr = ipc_memory_resource - if isinstance(mr, VirtualMemoryResource): - pytest.skip( - "an imported VirtualMemoryBuffer cannot be exported again: the driver does not export " - "imported allocations, and cuda.core does not forward the original descriptor" - ) + mr = ipc_pool_memory_resource stream = device.default_stream pgen = PatternGen(device, NBYTES, stream=stream) buffer = mr.allocate(NBYTES, stream=stream) diff --git a/cuda_core/tests/memory_ipc/test_workerpool.py b/cuda_core/tests/memory_ipc/test_workerpool.py index 701ba8cf082..75cb465c29c 100644 --- a/cuda_core/tests/memory_ipc/test_workerpool.py +++ b/cuda_core/tests/memory_ipc/test_workerpool.py @@ -10,7 +10,7 @@ from helpers.buffers import PatternGen from helpers.memory import drain_on_exit -from cuda.core import Buffer, Device, VirtualMemoryResource +from cuda.core import Buffer, Device NBYTES = 64 NWORKERS = 2 @@ -133,15 +133,13 @@ def init_worker(mrs): # Passing mrs implicitly registers them. pass - # For VirtualMR with nmrs=1 or nmrs=3: - # This test is not currently run in any CI job + # Pool-only: plain pickle cannot carry the file descriptors of a + # VirtualMemoryResource buffer, and VMM has no registry. @pytest.mark.flaky(reruns=2) @pytest.mark.parametrize("nmrs", (1, NMRS)) - def test_main(self, ipc_device, ipc_memory_resource_factory, nmrs): + def test_main(self, ipc_device, ipc_pool_memory_resource_factory, nmrs): device = ipc_device - mrs = [ipc_memory_resource_factory() for _ in range(nmrs)] - if isinstance(mrs[0], VirtualMemoryResource): - pytest.skip("plain pickle cannot carry the file descriptors of a VirtualMemoryResource buffer") + mrs = [ipc_pool_memory_resource_factory() for _ in range(nmrs)] buffers = [] stream = device.default_stream