[Parallel_libs-commits] [parallel-libs] r280439 - [StreamExecutor] Pass device memory by ref

Jason Henline via Parallel_libs-commits parallel_libs-commits at lists.llvm.org
Thu Sep 1 17:25:52 PDT 2016


Author: jhen
Date: Thu Sep  1 19:25:52 2016
New Revision: 280439

URL: http://llvm.org/viewvc/llvm-project?rev=280439&view=rev
Log:
[StreamExecutor] Pass device memory by ref

Summary:
Step 3 of getting GlobalDeviceMemory to own its handle.

Since GlobalDeviceMemory will no longer by copy-constructible, we must
pass instances by reference rather than by value.

Reviewers: jlebar

Subscribers: jprice, parallel_libs-commits

Differential Revision: https://reviews.llvm.org/D24172

Modified:
    parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h
    parallel-libs/trunk/streamexecutor/include/streamexecutor/DeviceMemory.h
    parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h

Modified: parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h?rev=280439&r1=280438&r2=280439&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h (original)
+++ parallel-libs/trunk/streamexecutor/include/streamexecutor/Device.h Thu Sep  1 19:25:52 2016
@@ -161,19 +161,19 @@ public:
   }
 
   template <typename T>
-  Error synchronousCopyD2H(GlobalDeviceMemory<T> Src,
+  Error synchronousCopyD2H(const GlobalDeviceMemory<T> &Src,
                            llvm::MutableArrayRef<T> Dst, size_t ElementCount) {
     return synchronousCopyD2H(Src.asSlice(), Dst, ElementCount);
   }
 
   template <typename T>
-  Error synchronousCopyD2H(GlobalDeviceMemory<T> Src,
+  Error synchronousCopyD2H(const GlobalDeviceMemory<T> &Src,
                            llvm::MutableArrayRef<T> Dst) {
     return synchronousCopyD2H(Src.asSlice(), Dst);
   }
 
   template <typename T>
-  Error synchronousCopyD2H(GlobalDeviceMemory<T> Src, T *Dst,
+  Error synchronousCopyD2H(const GlobalDeviceMemory<T> &Src, T *Dst,
                            size_t ElementCount) {
     return synchronousCopyD2H(Src.asSlice(), Dst, ElementCount);
   }
@@ -216,18 +216,18 @@ public:
   }
 
   template <typename T>
-  Error synchronousCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> Dst,
+  Error synchronousCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> &Dst,
                            size_t ElementCount) {
     return synchronousCopyH2D(Src, Dst.asSlice(), ElementCount);
   }
 
   template <typename T>
-  Error synchronousCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> Dst) {
+  Error synchronousCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> &Dst) {
     return synchronousCopyH2D(Src, Dst.asSlice());
   }
 
   template <typename T>
-  Error synchronousCopyH2D(T *Src, GlobalDeviceMemory<T> Dst,
+  Error synchronousCopyH2D(T *Src, GlobalDeviceMemory<T> &Dst,
                            size_t ElementCount) {
     return synchronousCopyH2D(Src, Dst.asSlice(), ElementCount);
   }
@@ -265,39 +265,39 @@ public:
   }
 
   template <typename T>
-  Error synchronousCopyD2D(GlobalDeviceMemory<T> Src,
+  Error synchronousCopyD2D(const GlobalDeviceMemory<T> &Src,
                            GlobalDeviceMemorySlice<T> Dst,
                            size_t ElementCount) {
     return synchronousCopyD2D(Src.asSlice(), Dst, ElementCount);
   }
 
   template <typename T>
-  Error synchronousCopyD2D(GlobalDeviceMemory<T> Src,
+  Error synchronousCopyD2D(const GlobalDeviceMemory<T> &Src,
                            GlobalDeviceMemorySlice<T> Dst) {
     return synchronousCopyD2D(Src.asSlice(), Dst);
   }
 
   template <typename T>
   Error synchronousCopyD2D(GlobalDeviceMemorySlice<T> Src,
-                           GlobalDeviceMemory<T> Dst, size_t ElementCount) {
+                           GlobalDeviceMemory<T> &Dst, size_t ElementCount) {
     return synchronousCopyD2D(Src, Dst.asSlice(), ElementCount);
   }
 
   template <typename T>
   Error synchronousCopyD2D(GlobalDeviceMemorySlice<T> Src,
-                           GlobalDeviceMemory<T> Dst) {
+                           GlobalDeviceMemory<T> &Dst) {
     return synchronousCopyD2D(Src, Dst.asSlice());
   }
 
   template <typename T>
-  Error synchronousCopyD2D(GlobalDeviceMemory<T> Src, GlobalDeviceMemory<T> Dst,
-                           size_t ElementCount) {
+  Error synchronousCopyD2D(const GlobalDeviceMemory<T> &Src,
+                           GlobalDeviceMemory<T> &Dst, size_t ElementCount) {
     return synchronousCopyD2D(Src.asSlice(), Dst.asSlice(), ElementCount);
   }
 
   template <typename T>
-  Error synchronousCopyD2D(GlobalDeviceMemory<T> Src,
-                           GlobalDeviceMemory<T> Dst) {
+  Error synchronousCopyD2D(const GlobalDeviceMemory<T> &Src,
+                           GlobalDeviceMemory<T> &Dst) {
     return synchronousCopyD2D(Src.asSlice(), Dst.asSlice());
   }
 

Modified: parallel-libs/trunk/streamexecutor/include/streamexecutor/DeviceMemory.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/include/streamexecutor/DeviceMemory.h?rev=280439&r1=280438&r2=280439&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/include/streamexecutor/DeviceMemory.h (original)
+++ parallel-libs/trunk/streamexecutor/include/streamexecutor/DeviceMemory.h Thu Sep  1 19:25:52 2016
@@ -192,7 +192,7 @@ public:
   size_t getElementCount() const { return getByteCount() / sizeof(ElemT); }
 
   /// Converts this memory object into a slice.
-  GlobalDeviceMemorySlice<ElemT> asSlice() {
+  GlobalDeviceMemorySlice<ElemT> asSlice() const {
     return GlobalDeviceMemorySlice<ElemT>(*this);
   }
 

Modified: parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h?rev=280439&r1=280438&r2=280439&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h (original)
+++ parallel-libs/trunk/streamexecutor/include/streamexecutor/Stream.h Thu Sep  1 19:25:52 2016
@@ -164,20 +164,22 @@ public:
   }
 
   template <typename T>
-  Stream &thenCopyD2H(GlobalDeviceMemory<T> Src, llvm::MutableArrayRef<T> Dst,
-                      size_t ElementCount) {
+  Stream &thenCopyD2H(const GlobalDeviceMemory<T> &Src,
+                      llvm::MutableArrayRef<T> Dst, size_t ElementCount) {
     thenCopyD2H(Src.asSlice(), Dst, ElementCount);
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyD2H(GlobalDeviceMemory<T> Src, llvm::MutableArrayRef<T> Dst) {
+  Stream &thenCopyD2H(const GlobalDeviceMemory<T> &Src,
+                      llvm::MutableArrayRef<T> Dst) {
     thenCopyD2H(Src.asSlice(), Dst);
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyD2H(GlobalDeviceMemory<T> Src, T *Dst, size_t ElementCount) {
+  Stream &thenCopyD2H(const GlobalDeviceMemory<T> &Src, T *Dst,
+                      size_t ElementCount) {
     thenCopyD2H(Src.asSlice(), Dst, ElementCount);
     return *this;
   }
@@ -221,20 +223,20 @@ public:
   }
 
   template <typename T>
-  Stream &thenCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> Dst,
+  Stream &thenCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> &Dst,
                       size_t ElementCount) {
     thenCopyH2D(Src, Dst.asSlice(), ElementCount);
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> Dst) {
+  Stream &thenCopyH2D(llvm::ArrayRef<T> Src, GlobalDeviceMemory<T> &Dst) {
     thenCopyH2D(Src, Dst.asSlice());
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyH2D(T *Src, GlobalDeviceMemory<T> Dst, size_t ElementCount) {
+  Stream &thenCopyH2D(T *Src, GlobalDeviceMemory<T> &Dst, size_t ElementCount) {
     thenCopyH2D(Src, Dst.asSlice(), ElementCount);
     return *this;
   }
@@ -272,42 +274,43 @@ public:
   }
 
   template <typename T>
-  Stream &thenCopyD2D(GlobalDeviceMemory<T> Src, GlobalDeviceMemorySlice<T> Dst,
-                      size_t ElementCount) {
+  Stream &thenCopyD2D(const GlobalDeviceMemory<T> &Src,
+                      GlobalDeviceMemorySlice<T> Dst, size_t ElementCount) {
     thenCopyD2D(Src.asSlice(), Dst, ElementCount);
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyD2D(GlobalDeviceMemory<T> Src,
+  Stream &thenCopyD2D(const GlobalDeviceMemory<T> &Src,
                       GlobalDeviceMemorySlice<T> Dst) {
     thenCopyD2D(Src.asSlice(), Dst);
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyD2D(GlobalDeviceMemorySlice<T> Src, GlobalDeviceMemory<T> Dst,
-                      size_t ElementCount) {
+  Stream &thenCopyD2D(GlobalDeviceMemorySlice<T> Src,
+                      GlobalDeviceMemory<T> &Dst, size_t ElementCount) {
     thenCopyD2D(Src, Dst.asSlice(), ElementCount);
     return *this;
   }
 
   template <typename T>
   Stream &thenCopyD2D(GlobalDeviceMemorySlice<T> Src,
-                      GlobalDeviceMemory<T> Dst) {
+                      GlobalDeviceMemory<T> &Dst) {
     thenCopyD2D(Src, Dst.asSlice());
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyD2D(GlobalDeviceMemory<T> Src, GlobalDeviceMemory<T> Dst,
-                      size_t ElementCount) {
+  Stream &thenCopyD2D(const GlobalDeviceMemory<T> &Src,
+                      GlobalDeviceMemory<T> &Dst, size_t ElementCount) {
     thenCopyD2D(Src.asSlice(), Dst.asSlice(), ElementCount);
     return *this;
   }
 
   template <typename T>
-  Stream &thenCopyD2D(GlobalDeviceMemory<T> Src, GlobalDeviceMemory<T> Dst) {
+  Stream &thenCopyD2D(const GlobalDeviceMemory<T> &Src,
+                      GlobalDeviceMemory<T> &Dst) {
     thenCopyD2D(Src.asSlice(), Dst.asSlice());
     return *this;
   }




More information about the Parallel_libs-commits mailing list