machichima commented on code in PR #708:
URL: https://github.com/apache/mahout/pull/708#discussion_r2616208522


##########
qdp/qdp-core/src/gpu/memory.rs:
##########
@@ -263,3 +266,79 @@ impl GpuStateVector {
         }
     }
 }
+
+// === Pinned Memory Implementation ===
+
+/// Pinned Host Memory Buffer (Page-Locked)
+///
+/// Enables DMA for H2D copies, doubling bandwidth and reducing CPU usage.
+#[cfg(target_os = "linux")]
+pub struct PinnedBuffer {
+    ptr: *mut f64,
+    size_elements: usize,
+}
+
+#[cfg(target_os = "linux")]
+impl PinnedBuffer {
+    /// Allocate pinned memory
+    pub fn new(elements: usize) -> Result<Self> {
+        unsafe {
+            let bytes = elements * std::mem::size_of::<f64>();
+            let mut ptr: *mut c_void = std::ptr::null_mut();
+
+            unsafe extern "C" {
+                fn cudaHostAlloc(pHost: *mut *mut c_void, size: usize, flags: 
u32) -> i32;
+            }

Review Comment:
   Do we want to fix this? Seeing plenty of extern "C" blocks in different 
places, I think gathering them is a good idea. May have a clean up follow-up 
for this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to