summaryrefslogtreecommitdiff
path: root/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp')
-rw-r--r--parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp114
1 files changed, 35 insertions, 79 deletions
diff --git a/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp b/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp
index 65598540d67..34516e2c2da 100644
--- a/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp
+++ b/parallel-libs/streamexecutor/unittests/CoreTests/StreamTest.cpp
@@ -39,6 +39,10 @@ public:
HostB5{5, 6, 7, 8, 9}, HostA7{10, 11, 12, 13, 14, 15, 16},
HostB7{17, 18, 19, 20, 21, 22, 23}, Host5{24, 25, 26, 27, 28},
Host7{29, 30, 31, 32, 33, 34, 35},
+ RegisteredHost5(getOrDie(
+ Device.registerHostMemory(llvm::MutableArrayRef<int>(Host5)))),
+ RegisteredHost7(getOrDie(
+ Device.registerHostMemory(llvm::MutableArrayRef<int>(Host7)))),
DeviceA5(getOrDie(Device.allocateDeviceMemory<int>(5))),
DeviceB5(getOrDie(Device.allocateDeviceMemory<int>(5))),
DeviceA7(getOrDie(Device.allocateDeviceMemory<int>(7))),
@@ -66,6 +70,9 @@ protected:
int Host5[5];
int Host7[7];
+ se::RegisteredHostMemory<int> RegisteredHost5;
+ se::RegisteredHostMemory<int> RegisteredHost7;
+
// Device memory.
se::GlobalDeviceMemory<int> DeviceA5;
se::GlobalDeviceMemory<int> DeviceB5;
@@ -78,166 +85,119 @@ using llvm::MutableArrayRef;
// D2H tests
-TEST_F(StreamTest, CopyD2HToMutableArrayRefByCount) {
- Stream.thenCopyD2H(DeviceA5, MutableArrayRef<int>(Host5), 5);
+TEST_F(StreamTest, CopyD2HToRegisteredRefByCount) {
+ Stream.thenCopyD2H(DeviceA5, RegisteredHost5, 5);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
EXPECT_EQ(HostA5[I], Host5[I]);
}
- Stream.thenCopyD2H(DeviceB5, MutableArrayRef<int>(Host5), 2);
+ Stream.thenCopyD2H(DeviceB5, RegisteredHost5, 2);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 2; ++I) {
EXPECT_EQ(HostB5[I], Host5[I]);
}
- Stream.thenCopyD2H(DeviceA7, MutableArrayRef<int>(Host5), 7);
- EXPECT_FALSE(Stream.isOK());
-}
-
-TEST_F(StreamTest, CopyD2HToMutableArrayRef) {
- Stream.thenCopyD2H(DeviceA5, MutableArrayRef<int>(Host5));
- EXPECT_TRUE(Stream.isOK());
- for (int I = 0; I < 5; ++I) {
- EXPECT_EQ(HostA5[I], Host5[I]);
- }
-
- Stream.thenCopyD2H(DeviceA5, MutableArrayRef<int>(Host7));
+ Stream.thenCopyD2H(DeviceA7, RegisteredHost5, 7);
EXPECT_FALSE(Stream.isOK());
}
-TEST_F(StreamTest, CopyD2HToPointer) {
- Stream.thenCopyD2H(DeviceA5, Host5, 5);
+TEST_F(StreamTest, CopyD2HToRegistered) {
+ Stream.thenCopyD2H(DeviceA5, RegisteredHost5);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
EXPECT_EQ(HostA5[I], Host5[I]);
}
- Stream.thenCopyD2H(DeviceA5, Host7, 7);
+ Stream.thenCopyD2H(DeviceA5, RegisteredHost7);
EXPECT_FALSE(Stream.isOK());
}
-TEST_F(StreamTest, CopyD2HSliceToMutableArrayRefByCount) {
+TEST_F(StreamTest, CopyD2HSliceToRegiseredSliceByCount) {
Stream.thenCopyD2H(DeviceA5.asSlice().drop_front(1),
- MutableArrayRef<int>(Host5 + 1, 4), 4);
+ RegisteredHost5.asSlice().slice(1, 4), 4);
EXPECT_TRUE(Stream.isOK());
for (int I = 1; I < 5; ++I) {
EXPECT_EQ(HostA5[I], Host5[I]);
}
- Stream.thenCopyD2H(DeviceB5.asSlice().drop_back(1),
- MutableArrayRef<int>(Host5), 2);
+ Stream.thenCopyD2H(DeviceB5.asSlice().drop_back(1), RegisteredHost5, 2);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 2; ++I) {
EXPECT_EQ(HostB5[I], Host5[I]);
}
- Stream.thenCopyD2H(DeviceA5.asSlice(), MutableArrayRef<int>(Host7), 7);
+ Stream.thenCopyD2H(DeviceA5.asSlice(), RegisteredHost7, 7);
EXPECT_FALSE(Stream.isOK());
}
-TEST_F(StreamTest, CopyD2HSliceToMutableArrayRef) {
- Stream.thenCopyD2H(DeviceA7.asSlice().slice(1, 5),
- MutableArrayRef<int>(Host5));
+TEST_F(StreamTest, CopyD2HSliceToRegistered) {
+ Stream.thenCopyD2H(DeviceA7.asSlice().slice(1, 5), RegisteredHost5);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
EXPECT_EQ(HostA7[I + 1], Host5[I]);
}
- Stream.thenCopyD2H(DeviceA5.asSlice(), MutableArrayRef<int>(Host7));
- EXPECT_FALSE(Stream.isOK());
-}
-
-TEST_F(StreamTest, CopyD2HSliceToPointer) {
- Stream.thenCopyD2H(DeviceA5.asSlice().drop_front(1), Host5 + 1, 4);
- EXPECT_TRUE(Stream.isOK());
- for (int I = 1; I < 5; ++I) {
- EXPECT_EQ(HostA5[I], Host5[I]);
- }
-
- Stream.thenCopyD2H(DeviceA5.asSlice(), Host7, 7);
+ Stream.thenCopyD2H(DeviceA5.asSlice(), RegisteredHost7);
EXPECT_FALSE(Stream.isOK());
}
// H2D tests
-TEST_F(StreamTest, CopyH2DToArrayRefByCount) {
- Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5, 5);
+TEST_F(StreamTest, CopyH2DFromRegisterdByCount) {
+ Stream.thenCopyH2D(RegisteredHost5, DeviceA5, 5);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
}
- Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceB5, 2);
+ Stream.thenCopyH2D(RegisteredHost5, DeviceB5, 2);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 2; ++I) {
EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]);
}
- Stream.thenCopyH2D(ArrayRef<int>(Host7), DeviceA5, 7);
- EXPECT_FALSE(Stream.isOK());
-}
-
-TEST_F(StreamTest, CopyH2DToArrayRef) {
- Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5);
- EXPECT_TRUE(Stream.isOK());
- for (int I = 0; I < 5; ++I) {
- EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
- }
-
- Stream.thenCopyH2D(ArrayRef<int>(Host7), DeviceA5);
+ Stream.thenCopyH2D(RegisteredHost7, DeviceA5, 7);
EXPECT_FALSE(Stream.isOK());
}
-TEST_F(StreamTest, CopyH2DToPointer) {
- Stream.thenCopyH2D(Host5, DeviceA5, 5);
+TEST_F(StreamTest, CopyH2DFromRegistered) {
+ Stream.thenCopyH2D(RegisteredHost5, DeviceA5);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
}
- Stream.thenCopyH2D(Host7, DeviceA5, 7);
+ Stream.thenCopyH2D(RegisteredHost7, DeviceA5);
EXPECT_FALSE(Stream.isOK());
}
-TEST_F(StreamTest, CopyH2DSliceToArrayRefByCount) {
- Stream.thenCopyH2D(ArrayRef<int>(Host5 + 1, 4),
+TEST_F(StreamTest, CopyH2DFromRegisteredSliceToSlice) {
+ Stream.thenCopyH2D(RegisteredHost5.asSlice().slice(1, 4),
DeviceA5.asSlice().drop_front(1), 4);
EXPECT_TRUE(Stream.isOK());
for (int I = 1; I < 5; ++I) {
EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
}
- Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceB5.asSlice().drop_back(1), 2);
+ Stream.thenCopyH2D(RegisteredHost5, DeviceB5.asSlice().drop_back(1), 2);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 2; ++I) {
EXPECT_EQ(getDeviceValue(DeviceB5, I), Host5[I]);
}
- Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5.asSlice(), 7);
+ Stream.thenCopyH2D(RegisteredHost5, DeviceA5.asSlice(), 7);
EXPECT_FALSE(Stream.isOK());
}
-TEST_F(StreamTest, CopyH2DSliceToArrayRef) {
-
- Stream.thenCopyH2D(ArrayRef<int>(Host5), DeviceA5.asSlice());
+TEST_F(StreamTest, CopyH2DRegisteredToSlice) {
+ Stream.thenCopyH2D(RegisteredHost5, DeviceA5.asSlice());
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
}
- Stream.thenCopyH2D(ArrayRef<int>(Host7), DeviceA5.asSlice());
- EXPECT_FALSE(Stream.isOK());
-}
-
-TEST_F(StreamTest, CopyH2DSliceToPointer) {
- Stream.thenCopyH2D(Host5, DeviceA5.asSlice(), 5);
- EXPECT_TRUE(Stream.isOK());
- for (int I = 0; I < 5; ++I) {
- EXPECT_EQ(getDeviceValue(DeviceA5, I), Host5[I]);
- }
-
- Stream.thenCopyH2D(Host7, DeviceA5.asSlice(), 7);
+ Stream.thenCopyH2D(RegisteredHost7, DeviceA5.asSlice());
EXPECT_FALSE(Stream.isOK());
}
@@ -289,7 +249,6 @@ TEST_F(StreamTest, CopySliceD2DByCount) {
}
TEST_F(StreamTest, CopySliceD2D) {
-
Stream.thenCopyD2D(DeviceA7.asSlice().drop_back(2), DeviceB5);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
@@ -318,7 +277,6 @@ TEST_F(StreamTest, CopyD2DSliceByCount) {
}
TEST_F(StreamTest, CopyD2DSlice) {
-
Stream.thenCopyD2D(DeviceA5, DeviceB7.asSlice().drop_back(2));
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
@@ -330,7 +288,6 @@ TEST_F(StreamTest, CopyD2DSlice) {
}
TEST_F(StreamTest, CopySliceD2DSliceByCount) {
-
Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice(), 5);
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {
@@ -348,7 +305,6 @@ TEST_F(StreamTest, CopySliceD2DSliceByCount) {
}
TEST_F(StreamTest, CopySliceD2DSlice) {
-
Stream.thenCopyD2D(DeviceA5.asSlice(), DeviceB5.asSlice());
EXPECT_TRUE(Stream.isOK());
for (int I = 0; I < 5; ++I) {