|
1 |
| -//==----------- NoUnifiedHostMemory.cpp --- Scheduler unit tests -----------==// |
| 1 | +//==----------- NoHostUnifiedMemory.cpp --- Scheduler unit tests -----------==// |
2 | 2 | //
|
3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
4 | 4 | // See https://llvm.org/LICENSE.txt for license information.
|
@@ -62,7 +62,7 @@ static pi_result redefinedEnqueueMemBufferWriteRect(
|
62 | 62 |
|
63 | 63 | static pi_result redefinedMemRelease(pi_mem mem) { return PI_SUCCESS; }
|
64 | 64 |
|
65 |
| -TEST_F(SchedulerTest, NoUnifiedHostMemory) { |
| 65 | +TEST_F(SchedulerTest, NoHostUnifiedMemory) { |
66 | 66 | platform Plt{default_selector()};
|
67 | 67 | if (Plt.is_host()) {
|
68 | 68 | std::cout << "Not run due to host-only environment\n";
|
@@ -144,4 +144,26 @@ TEST_F(SchedulerTest, NoUnifiedHostMemory) {
|
144 | 144 | detail::Command *MemoryMove = MS.insertMemoryMove(Record, &Req, QImpl);
|
145 | 145 | EXPECT_EQ(MemoryMove->getType(), detail::Command::COPY_MEMORY);
|
146 | 146 | }
|
| 147 | + // Check that memory movement operations work correctly with/after discard |
| 148 | + // access modes. |
| 149 | + { |
| 150 | + int val; |
| 151 | + buffer<int, 1> Buf(&val, range<1>(1)); |
| 152 | + detail::Requirement Req = getMockRequirement(Buf); |
| 153 | + ExpectedMemObjFlags = PI_MEM_FLAGS_ACCESS_RW | PI_MEM_FLAGS_HOST_PTR_COPY; |
| 154 | + |
| 155 | + detail::Requirement DiscardReq = getMockRequirement(Buf); |
| 156 | + DiscardReq.MAccessMode = access::mode::discard_read_write; |
| 157 | + |
| 158 | + detail::MemObjRecord *Record = MS.getOrInsertMemObjRecord(QImpl, &Req); |
| 159 | + MS.getOrCreateAllocaForReq(Record, &Req, QImpl); |
| 160 | + MS.getOrCreateAllocaForReq(Record, &Req, DefaultHostQueue); |
| 161 | + |
| 162 | + // Memory movement operations should be omitted for discard access modes. |
| 163 | + detail::Command *MemoryMove = |
| 164 | + MS.insertMemoryMove(Record, &DiscardReq, DefaultHostQueue); |
| 165 | + EXPECT_EQ(MemoryMove, nullptr); |
| 166 | + // The current context for the record should still be modified. |
| 167 | + EXPECT_EQ(Record->MCurContext, DefaultHostQueue->getContextImplPtr()); |
| 168 | + } |
147 | 169 | }
|
0 commit comments