Skip to content

Conversation

@nieubank
Copy link
Contributor

Add experimental implementation of OrtExternalResourceImporter interface for MIGraphX EP to enable zero-copy import of D3D12 shared resources on Windows via HIP Runtime APIs.

This proof of concept demonstrates:

Memory Import

  • Import D3D12 committed resources (ORT_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE)
  • Import D3D12 heaps (ORT_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP)
  • Map imported resources using hipExternalMemoryGetMappedBuffer
  • Create ORT tensors backed by imported device memory for zero-copy access

Synchronization

  • Import D3D12 timeline fences as HIP external semaphores
  • Implement wait/signal operations on HIP streams
  • Enable GPU-GPU synchronization between D3D12 and HIP workloads

Infrastructure

  • MigraphxExternalMemoryHandle: Wraps hipExternalMemory_t with mapped pointers
  • MigraphxExternalSemaphoreHandle: Wraps hipExternalSemaphore_t for D3D12 fences
  • MigraphxSyncStreamImpl: Wraps hipStream_t for OrtSyncStream interface
  • Factory integration via CreateExternalResourceImporterForDeviceImpl

Key Files

  • onnxruntime/core/providers/migraphx/migraphx_external_resource_importer.h
  • onnxruntime/core/providers/migraphx/migraphx_external_resource_importer.cc
  • onnxruntime/core/providers/migraphx/migraphx_provider_factory.cc (updated)

This enables scenarios like DirectML → MIGraphX model chaining without CPU round-trips, improving performance for hybrid GPU workloads.

… for D3D12-HIP interop

Add experimental implementation of OrtExternalResourceImporter interface
for MIGraphX EP to enable zero-copy import of D3D12 shared resources on
Windows via HIP Runtime APIs.

This proof of concept demonstrates:

**Memory Import**
- Import D3D12 committed resources (ORT_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE)
- Import D3D12 heaps (ORT_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP)
- Map imported resources using hipExternalMemoryGetMappedBuffer
- Create ORT tensors backed by imported device memory for zero-copy access

**Synchronization**
- Import D3D12 timeline fences as HIP external semaphores
- Implement wait/signal operations on HIP streams
- Enable GPU-GPU synchronization between D3D12 and HIP workloads

**Infrastructure**
- MigraphxExternalMemoryHandle: Wraps hipExternalMemory_t with mapped pointers
- MigraphxExternalSemaphoreHandle: Wraps hipExternalSemaphore_t for D3D12 fences
- MigraphxSyncStreamImpl: Wraps hipStream_t for OrtSyncStream interface
- Factory integration via CreateExternalResourceImporterForDeviceImpl

**Key Files**
- onnxruntime/core/providers/migraphx/migraphx_external_resource_importer.h
- onnxruntime/core/providers/migraphx/migraphx_external_resource_importer.cc
- onnxruntime/core/providers/migraphx/migraphx_provider_factory.cc (updated)

This enables scenarios like DirectML → MIGraphX model chaining without
CPU round-trips, improving performance for hybrid GPU workloads.

Windows-only implementation (guarded by #ifdef _WIN32).
@@ -0,0 +1,551 @@
// Copyright (c) Microsoft Corporation. All rights reserved.

Check warning

Code scanning / lintrunner

CLANGFORMAT/format Warning

See https://clang.llvm.org/docs/ClangFormat.html.
Run lintrunner -a to apply this patch.
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can commit the suggested changes from lintrunner.

Comment on lines +297 to +298
impl.device_id_, OrtMemTypeDefault,
&memory_info);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
impl.device_id_, OrtMemTypeDefault,
&memory_info);
impl.device_id_, OrtMemTypeDefault,
&memory_info);

Comment on lines +454 to +456



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants