for (int i = 0; i < mem.size(); ++i) {
EXPECT_EQ((reinterpret_cast<char*>(cpu_data))[i], 1);
}
+ // do another round
+ cpu_data = mem.mutable_cpu_data();
+ EXPECT_EQ(mem.head(), SyncedMemory::HEAD_AT_CPU);
+ memset(cpu_data, 2, mem.size());
+ for (int i = 0; i < mem.size(); ++i) {
+ EXPECT_EQ((reinterpret_cast<char*>(cpu_data))[i], 2);
+ }
+}
+
+TEST_F(SyncedMemoryTest, TestGPURead) {
+ SyncedMemory mem(10);
+ void* cpu_data = mem.mutable_cpu_data();
+ EXPECT_EQ(mem.head(), SyncedMemory::HEAD_AT_CPU);
+ memset(cpu_data, 1, mem.size());
const void* gpu_data = mem.gpu_data();
EXPECT_EQ(mem.head(), SyncedMemory::SYNCED);
// check if values are the same
cpu_data = mem.mutable_cpu_data();
EXPECT_EQ(mem.head(), SyncedMemory::HEAD_AT_CPU);
memset(cpu_data, 2, mem.size());
- for (int i = 0; i < mem.size(); ++i) {
- EXPECT_EQ((reinterpret_cast<char*>(cpu_data))[i], 2);
- }
gpu_data = mem.gpu_data();
EXPECT_EQ(mem.head(), SyncedMemory::SYNCED);
// check if values are the same