Skip to content

feat: update dcu adaptor#499

Merged
MC952-arch merged 1 commit into
flagos-ai:mainfrom
wangxshuai:main
Jun 22, 2026
Merged

feat: update dcu adaptor#499
MC952-arch merged 1 commit into
flagos-ai:mainfrom
wangxshuai:main

Conversation

@wangxshuai

Copy link
Copy Markdown
Contributor

PR Category

PAL (Portable Abstraction Layer)

PR Types

New Features

PR Description

This PR updates the DU device adaptor implementation and improves its compatibility with the FlagCX device abstraction layer.

Main changes include:

  • Add DU DMA capability query interfaces:

    • Implement ducudaAdaptorDmaSupport, returning unsupported for DU.
    • Implement ducudaAdaptorMemGetHandleForAddressRange, returning flagcxNotSupported.
  • Implement stream value synchronization support:

    • Add ducudaAdaptorStreamWaitValue64 using cuStreamWaitValue64.
    • Add ducudaAdaptorStreamWriteValue64 using cuStreamWriteValue64.
    • Add argument validation and device error mapping.
  • Implement event elapsed time query:

    • Add ducudaAdaptorEventElapsedTime using cudaEventElapsedTime.
    • Map cudaErrorNotReady to flagcxInProgress.
  • Add symmetric memory VMM support for DU:

    • Implement physical allocation handle retention via cuMemRetainAllocationHandle.
    • Export physical handles as POSIX file descriptors for IPC sharing.
    • Implement flat virtual address mapping across peers with cuMemAddressReserve, cuMemMap, and cuMemSetAccess.
    • Implement flat unmap and physical handle release logic.
  • Improve unsupported multicast handling:

    • Add explicit argument/default output handling for multicast-related APIs.
    • Keep multicast marked as unsupported on DU while making teardown/free paths safely return success.
  • Register the new DMA-related callbacks in ducudaAdaptor.

@CLAassistant

CLAassistant commented Jun 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the DU (DUCUDA) device adaptor to expose additional PAL capabilities expected by the FlagCX device abstraction layer, including DMA capability hooks, stream value synchronization primitives, event elapsed-time queries, and a first pass at symmetric-memory (VMM) support with safer multicast stubs.

Changes:

  • Add DU DMA-buffer capability callbacks (dmaSupport, getHandleForAddressRange) and register them in the adaptor table.
  • Implement stream wait/write value64 and event elapsed-time queries with DUCUDA/CUDA APIs and basic argument validation.
  • Implement symmetric-memory VMM mapping/unmapping and adjust multicast APIs to remain “unsupported” while making teardown/free paths safe.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +304 to +309
flagcxResult_t
ducudaAdaptorMemGetHandleForAddressRange(void *handleOut, void *buffer,
size_t size, unsigned long long flags) {
//unsupportted on dcu
return flagcxNotSupported;
}
@@ -355,36 +393,146 @@ flagcxResult_t ducudaAdaptorHostUnregister(void *ptr) {
}

// Symmetric memory VMM stubs (not supported)
Comment on lines +403 to +426
CUmemGenericAllocationHandle *cuHandle =
(CUmemGenericAllocationHandle *)malloc(
sizeof(CUmemGenericAllocationHandle));
if (cuHandle == NULL)
return flagcxSystemError;

// Retain the physical allocation handle from the VMM-backed pointer
DEVCHECK(cuMemRetainAllocationHandle(cuHandle, ptr));

// Discover actual physical allocation size (already granularity-aligned)
size_t actualAllocSize = 0;
DEVCHECK(cuMemGetAddressRange(NULL, &actualAllocSize, (CUdeviceptr)ptr));
*allocSize = actualAllocSize;

// Export as POSIX fd for IPC sharing
if (*handleSize < sizeof(int)) {
free(cuHandle);
return flagcxInvalidArgument;
}
DEVCHECK(cuMemExportToShareableHandle(
shareableHandle, *cuHandle, CU_MEM_HANDLE_TYPE_POSIX_FILE_DESCRIPTOR, 0));
*handleSize = sizeof(int); // POSIX fd is an int
*physHandle = cuHandle;
return flagcxSuccess;
Comment on lines +409 to +414
// Retain the physical allocation handle from the VMM-backed pointer
DEVCHECK(cuMemRetainAllocationHandle(cuHandle, ptr));

// Discover actual physical allocation size (already granularity-aligned)
size_t actualAllocSize = 0;
DEVCHECK(cuMemGetAddressRange(NULL, &actualAllocSize, (CUdeviceptr)ptr));
Comment on lines 493 to 501
flagcxResult_t ducudaAdaptorSymMulticastSupported(int *supported) {
// not supported on dcu
if (supported == NULL)
return flagcxInvalidArgument;

if (supported)
*supported = 0;
return flagcxSuccess;
}
@MC952-arch MC952-arch merged commit 231e75d into flagos-ai:main Jun 22, 2026
11 checks passed
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.

4 participants