Skip to content

Add UnifiedBuffer!T for CUDA Unified Memory (Managed Memory)#94

Open
badnikhil wants to merge 3 commits intolibmir:masterfrom
badnikhil:unified_memory_CUDA
Open

Add UnifiedBuffer!T for CUDA Unified Memory (Managed Memory)#94
badnikhil wants to merge 3 commits intolibmir:masterfrom
badnikhil:unified_memory_CUDA

Conversation

@badnikhil
Copy link
Copy Markdown
Contributor

Summary

Adds UnifiedBuffer!T to the CUDA driver, enabling allocation of Unified Memory (Managed Memory) via cuMemAllocManaged. A unified buffer is accessible from both the host (CPU) and device (GPU) through the same pointer, so explicit copy!(Copy.hostToDevice) / copy!(Copy.deviceToHost) calls are not needed.

Requires CUDA Compute Capability >= 3.0 (Device.supportsUnifiedMemory == true).


tests/main.d

  • Added a unified memory correctness test block, guarded by a runtime dev.supportsUnifiedMemory check
  • Runs saxpy kernel via UnifiedBuffer, verifies result via hostSlice with no explicit copy calls, synchronized with Context.sync()

Notes

  • prefetch() is a stub with a doc comment explaining the limitation.
  • A follow-up to migrate from derelict-cuda to a bindbc-based CUDA binding is being tracked separately.

@badnikhil badnikhil force-pushed the unified_memory_CUDA branch from 863a20d to 53adb79 Compare May 7, 2026 13:19
@badnikhil
Copy link
Copy Markdown
Contributor Author

i tried to document everything precisely in comments. still i would request you to read everything and provide feedback!

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.

1 participant