[Parallel_libs-commits] [parallel-libs] r280428 - [StreamExecutor] Read dev array directly in test

Jason Henline via Parallel_libs-commits parallel_libs-commits at lists.llvm.org
Thu Sep 1 16:27:39 PDT 2016


Author: jhen
Date: Thu Sep  1 18:27:39 2016
New Revision: 280428

URL: http://llvm.org/viewvc/llvm-project?rev=280428&view=rev
Log:
[StreamExecutor] Read dev array directly in test

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

Use the SimpleHostPlatformDevice allocate methods to create device
arrays for tests, and check for successful copies by dereferncing the
device array handle directly because we know it is really a host
pointer.

Reviewers: jlebar

Subscribers: jprice, parallel_libs-commits

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

Modified:
    parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp
    parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
    parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp

Modified: parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp?rev=280428&r1=280427&r2=280428&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/unittests/DeviceTest.cpp Thu Sep  1 18:27:39 2016
@@ -25,18 +25,28 @@ namespace {
 
 namespace se = ::streamexecutor;
 
+const auto &getDeviceValue =
+    se::test::SimpleHostPlatformDevice::getDeviceValue<int>;
+
 /// Test fixture to hold objects used by tests.
 class DeviceTest : public ::testing::Test {
 public:
   DeviceTest()
-      : HostA5{0, 1, 2, 3, 4}, HostB5{5, 6, 7, 8, 9},
+      : Device(&PDevice), HostA5{0, 1, 2, 3, 4}, HostB5{5, 6, 7, 8, 9},
         HostA7{10, 11, 12, 13, 14, 15, 16}, HostB7{17, 18, 19, 20, 21, 22, 23},
-        DeviceA5(se::GlobalDeviceMemory<int>::makeFromElementCount(HostA5, 5)),
-        DeviceB5(se::GlobalDeviceMemory<int>::makeFromElementCount(HostB5, 5)),
-        DeviceA7(se::GlobalDeviceMemory<int>::makeFromElementCount(HostA7, 7)),
-        DeviceB7(se::GlobalDeviceMemory<int>::makeFromElementCount(HostB7, 7)),
-        Host5{24, 25, 26, 27, 28}, Host7{29, 30, 31, 32, 33, 34, 35},
-        Device(&PDevice) {}
+        DeviceA5(getOrDie(Device.allocateDeviceMemory<int>(5))),
+        DeviceB5(getOrDie(Device.allocateDeviceMemory<int>(5))),
+        DeviceA7(getOrDie(Device.allocateDeviceMemory<int>(7))),
+        DeviceB7(getOrDie(Device.allocateDeviceMemory<int>(7))),
+        Host5{24, 25, 26, 27, 28}, Host7{29, 30, 31, 32, 33, 34, 35} {
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostA5, DeviceA5));
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostB5, DeviceB5));
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostA7, DeviceA7));
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostB7, DeviceB7));
+  }
+
+  se::test::SimpleHostPlatformDevice PDevice;
+  se::Device Device;
 
   // Device memory is backed by host arrays.
   int HostA5[5];
@@ -51,9 +61,6 @@ public:
   // Host memory to be used as actual host memory.
   int Host5[5];
   int Host7[7];
-
-  SimpleHostPlatformDevice PDevice;
-  se::Device Device;
 };
 
 #define EXPECT_NO_ERROR(E) EXPECT_FALSE(static_cast<bool>(E))
@@ -186,12 +193,12 @@ TEST_F(DeviceTest, SyncCopyD2HSliceToPoi
 TEST_F(DeviceTest, SyncCopyH2DToArrayRefByCount) {
   EXPECT_NO_ERROR(Device.synchronousCopyH2D(ArrayRef<int>(Host5), DeviceA5, 5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   EXPECT_NO_ERROR(Device.synchronousCopyH2D(ArrayRef<int>(Host5), DeviceB5, 2));
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostB5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]);
   }
 
   EXPECT_ERROR(Device.synchronousCopyH2D(ArrayRef<int>(Host7), DeviceA5, 7));
@@ -204,7 +211,7 @@ TEST_F(DeviceTest, SyncCopyH2DToArrayRef
 TEST_F(DeviceTest, SyncCopyH2DToArrayRef) {
   EXPECT_NO_ERROR(Device.synchronousCopyH2D(ArrayRef<int>(Host5), DeviceA5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   EXPECT_ERROR(Device.synchronousCopyH2D(ArrayRef<int>(Host5), DeviceA7));
@@ -215,7 +222,7 @@ TEST_F(DeviceTest, SyncCopyH2DToArrayRef
 TEST_F(DeviceTest, SyncCopyH2DToPointer) {
   EXPECT_NO_ERROR(Device.synchronousCopyH2D(Host5, DeviceA5, 5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   EXPECT_ERROR(Device.synchronousCopyH2D(Host7, DeviceA5, 7));
@@ -225,13 +232,13 @@ TEST_F(DeviceTest, SyncCopyH2DSliceToArr
   EXPECT_NO_ERROR(Device.synchronousCopyH2D(
       ArrayRef<int>(Host5 + 1, 4), DeviceA5.asSlice().drop_front(1), 4));
   for (int I = 1; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   EXPECT_NO_ERROR(Device.synchronousCopyH2D(
       ArrayRef<int>(Host5), DeviceB5.asSlice().drop_back(1), 2));
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostB5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]);
   }
 
   EXPECT_ERROR(
@@ -248,7 +255,7 @@ TEST_F(DeviceTest, SyncCopyH2DSliceToArr
   EXPECT_NO_ERROR(
       Device.synchronousCopyH2D(ArrayRef<int>(Host5), DeviceA5.asSlice()));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   EXPECT_ERROR(
@@ -261,7 +268,7 @@ TEST_F(DeviceTest, SyncCopyH2DSliceToArr
 TEST_F(DeviceTest, SyncCopyH2DSliceToPointer) {
   EXPECT_NO_ERROR(Device.synchronousCopyH2D(Host5, DeviceA5.asSlice(), 5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   EXPECT_ERROR(Device.synchronousCopyH2D(Host7, DeviceA5.asSlice(), 7));
@@ -272,12 +279,12 @@ TEST_F(DeviceTest, SyncCopyH2DSliceToPoi
 TEST_F(DeviceTest, SyncCopyD2DByCount) {
   EXPECT_NO_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5, 5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   EXPECT_NO_ERROR(Device.synchronousCopyD2D(DeviceA7, DeviceB7, 2));
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5, 7));
@@ -290,7 +297,7 @@ TEST_F(DeviceTest, SyncCopyD2DByCount) {
 TEST_F(DeviceTest, SyncCopyD2D) {
   EXPECT_NO_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA7, DeviceB5));
@@ -302,13 +309,13 @@ TEST_F(DeviceTest, SyncCopySliceD2DByCou
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA5.asSlice().drop_front(1), DeviceB5, 4));
   for (int I = 0; I < 4; ++I) {
-    EXPECT_EQ(HostA5[I + 1], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I + 1), getDeviceValue(DeviceB5, I));
   }
 
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA7.asSlice().drop_back(1), DeviceB7, 2));
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA5.asSlice(), DeviceB5, 7));
@@ -322,7 +329,7 @@ TEST_F(DeviceTest, SyncCopySliceD2D) {
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA7.asSlice().drop_back(2), DeviceB5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA7[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB5, I));
   }
 
   EXPECT_ERROR(
@@ -336,13 +343,13 @@ TEST_F(DeviceTest, SyncCopyD2DSliceByCou
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA5, DeviceB7.asSlice().drop_front(2), 5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB7[I + 2]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I + 2));
   }
 
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA7, DeviceB7.asSlice().drop_back(3), 2));
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA5, DeviceB5.asSlice(), 7));
@@ -356,7 +363,7 @@ TEST_F(DeviceTest, SyncCopyD2DSlice) {
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA5, DeviceB7.asSlice().drop_back(2)));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I));
   }
 
   EXPECT_ERROR(Device.synchronousCopyD2D(DeviceA7, DeviceB5.asSlice()));
@@ -368,13 +375,13 @@ TEST_F(DeviceTest, SyncCopySliceD2DSlice
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice(), 5));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA7.asSlice(), DeviceB7.asSlice(), 2));
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   EXPECT_ERROR(
@@ -391,7 +398,7 @@ TEST_F(DeviceTest, SyncCopySliceD2DSlice
   EXPECT_NO_ERROR(
       Device.synchronousCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice()));
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   EXPECT_ERROR(

Modified: parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h?rev=280428&r1=280427&r2=280428&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h (original)
+++ parallel-libs/trunk/streamexecutor/lib/unittests/SimpleHostPlatformDevice.h Thu Sep  1 18:27:39 2016
@@ -22,12 +22,16 @@
 
 #include "streamexecutor/PlatformInterfaces.h"
 
+namespace streamexecutor {
+namespace test {
+
 /// A streamexecutor::PlatformDevice that simply forwards all operations to the
 /// host platform.
 ///
 /// The allocate and copy methods are simple wrappers for std::malloc and
 /// std::memcpy.
 class SimpleHostPlatformDevice : public streamexecutor::PlatformDevice {
+public:
   std::string getName() const override { return "SimpleHostPlatformDevice"; }
 
   streamexecutor::Expected<
@@ -130,6 +134,17 @@ class SimpleHostPlatformDevice : public
                 ByteCount);
     return streamexecutor::Error::success();
   }
+
+  /// Gets the value at the given index from a GlobalDeviceMemory<T> instance
+  /// created by this class.
+  template <typename T>
+  static T getDeviceValue(const streamexecutor::GlobalDeviceMemory<T> &Memory,
+                          size_t Index) {
+    return static_cast<const T *>(Memory.getHandle())[Index];
+  }
 };
 
+} // namespace test
+} // namespace streamexecutor
+
 #endif // STREAMEXECUTOR_LIB_UNITTESTS_SIMPLEHOSTPLATFORMDEVICE_H

Modified: parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp
URL: http://llvm.org/viewvc/llvm-project/parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp?rev=280428&r1=280427&r2=280428&view=diff
==============================================================================
--- parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp (original)
+++ parallel-libs/trunk/streamexecutor/lib/unittests/StreamTest.cpp Thu Sep  1 18:27:39 2016
@@ -27,36 +27,48 @@ namespace {
 
 namespace se = ::streamexecutor;
 
+const auto &getDeviceValue =
+    se::test::SimpleHostPlatformDevice::getDeviceValue<int>;
+
 /// Test fixture to hold objects used by tests.
 class StreamTest : public ::testing::Test {
 public:
   StreamTest()
-      : HostA5{0, 1, 2, 3, 4}, HostB5{5, 6, 7, 8, 9},
+      : Device(&PDevice),
+        Stream(llvm::make_unique<se::PlatformStreamHandle>(&PDevice)),
+        HostA5{0, 1, 2, 3, 4}, HostB5{5, 6, 7, 8, 9},
         HostA7{10, 11, 12, 13, 14, 15, 16}, HostB7{17, 18, 19, 20, 21, 22, 23},
-        DeviceA5(se::GlobalDeviceMemory<int>::makeFromElementCount(HostA5, 5)),
-        DeviceB5(se::GlobalDeviceMemory<int>::makeFromElementCount(HostB5, 5)),
-        DeviceA7(se::GlobalDeviceMemory<int>::makeFromElementCount(HostA7, 7)),
-        DeviceB7(se::GlobalDeviceMemory<int>::makeFromElementCount(HostB7, 7)),
         Host5{24, 25, 26, 27, 28}, Host7{29, 30, 31, 32, 33, 34, 35},
-        Stream(llvm::make_unique<se::PlatformStreamHandle>(&PDevice)) {}
+        DeviceA5(getOrDie(Device.allocateDeviceMemory<int>(5))),
+        DeviceB5(getOrDie(Device.allocateDeviceMemory<int>(5))),
+        DeviceA7(getOrDie(Device.allocateDeviceMemory<int>(7))),
+        DeviceB7(getOrDie(Device.allocateDeviceMemory<int>(7))) {
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostA5, DeviceA5));
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostB5, DeviceB5));
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostA7, DeviceA7));
+    se::dieIfError(Device.synchronousCopyH2D<int>(HostB7, DeviceB7));
+  }
 
 protected:
-  // Device memory is backed by host arrays.
+  se::test::SimpleHostPlatformDevice PDevice;
+  se::Device Device;
+  se::Stream Stream;
+
+  // Device memory is matched by host arrays.
   int HostA5[5];
   int HostB5[5];
   int HostA7[7];
   int HostB7[7];
-  se::GlobalDeviceMemory<int> DeviceA5;
-  se::GlobalDeviceMemory<int> DeviceB5;
-  se::GlobalDeviceMemory<int> DeviceA7;
-  se::GlobalDeviceMemory<int> DeviceB7;
 
   // Host memory to be used as actual host memory.
   int Host5[5];
   int Host7[7];
 
-  SimpleHostPlatformDevice PDevice;
-  se::Stream Stream;
+  // Device memory.
+  se::GlobalDeviceMemory<int> DeviceA5;
+  se::GlobalDeviceMemory<int> DeviceB5;
+  se::GlobalDeviceMemory<int> DeviceA7;
+  se::GlobalDeviceMemory<int> DeviceB7;
 };
 
 using llvm::ArrayRef;
@@ -151,13 +163,13 @@ TEST_F(StreamTest, CopyH2DToArrayRefByCo
   Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5, 5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceB5, 2);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostB5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(ArrayRef<int>(Host7), DeviceA5, 7);
@@ -168,7 +180,7 @@ TEST_F(StreamTest, CopyH2DToArrayRef) {
   Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(ArrayRef<int>(Host7), DeviceA5);
@@ -179,7 +191,7 @@ TEST_F(StreamTest, CopyH2DToPointer) {
   Stream.thenCopyH2D(Host5, DeviceA5, 5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(Host7, DeviceA5, 7);
@@ -191,13 +203,13 @@ TEST_F(StreamTest, CopyH2DSliceToArrayRe
                      DeviceA5.asSlice().drop_front(1), 4);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 1; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceB5.asSlice().drop_back(1), 2);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostB5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5.asSlice(), 7);
@@ -209,7 +221,7 @@ TEST_F(StreamTest, CopyH2DSliceToArrayRe
   Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5.asSlice());
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(ArrayRef<int>(Host7), DeviceA5.asSlice());
@@ -220,7 +232,7 @@ TEST_F(StreamTest, CopyH2DSliceToPointer
   Stream.thenCopyH2D(Host5, DeviceA5.asSlice(), 5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], Host5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
   }
 
   Stream.thenCopyH2D(Host7, DeviceA5.asSlice(), 7);
@@ -233,13 +245,13 @@ TEST_F(StreamTest, CopyD2DByCount) {
   Stream.thenCopyD2D(DeviceA5, DeviceB5, 5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   Stream.thenCopyD2D(DeviceA7, DeviceB7, 2);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   Stream.thenCopyD2D(DeviceA7, DeviceB5, 7);
@@ -250,7 +262,7 @@ TEST_F(StreamTest, CopyD2D) {
   Stream.thenCopyD2D(DeviceA5, DeviceB5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   Stream.thenCopyD2D(DeviceA7, DeviceB5);
@@ -261,13 +273,13 @@ TEST_F(StreamTest, CopySliceD2DByCount)
   Stream.thenCopyD2D(DeviceA5.asSlice().drop_front(1), DeviceB5, 4);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 4; ++I) {
-    EXPECT_EQ(HostA5[I + 1], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I + 1), getDeviceValue(DeviceB5, I));
   }
 
   Stream.thenCopyD2D(DeviceA7.asSlice().drop_back(1), DeviceB7, 2);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5, 7);
@@ -279,7 +291,7 @@ TEST_F(StreamTest, CopySliceD2D) {
   Stream.thenCopyD2D(DeviceA7.asSlice().drop_back(2), DeviceB5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA7[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB5, I));
   }
 
   Stream.thenCopyD2D(DeviceA5.asSlice().drop_back(1), DeviceB7);
@@ -290,13 +302,13 @@ TEST_F(StreamTest, CopyD2DSliceByCount)
   Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice().drop_front(2), 5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB7[I + 2]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I + 2));
   }
 
   Stream.thenCopyD2D(DeviceA7, DeviceB7.asSlice().drop_back(3), 2);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice(), 7);
@@ -308,7 +320,7 @@ TEST_F(StreamTest, CopyD2DSlice) {
   Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice().drop_back(2));
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB7, I));
   }
 
   Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice());
@@ -320,13 +332,13 @@ TEST_F(StreamTest, CopySliceD2DSliceByCo
   Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice(), 5);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   Stream.thenCopyD2D(DeviceA7.asSlice(), DeviceB7.asSlice(), 2);
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 2; ++I) {
-    EXPECT_EQ(HostA7[I], HostB7[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA7, I), getDeviceValue(DeviceB7, I));
   }
 
   Stream.thenCopyD2D(DeviceA7.asSlice(), DeviceB5.asSlice(), 7);
@@ -338,7 +350,7 @@ TEST_F(StreamTest, CopySliceD2DSlice) {
   Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice());
   EXPECT_TRUE(Stream.isOK());
   for (int I = 0; I < 5; ++I) {
-    EXPECT_EQ(HostA5[I], HostB5[I]);
+    EXPECT_EQ(getDeviceValue(DeviceA5, I), getDeviceValue(DeviceB5, I));
   }
 
   Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB7.asSlice());




More information about the Parallel_libs-commits mailing list