Skip to content

Commit a531751

Browse files
Remove ULT code from runtime
Change-Id: I2faf52070f980d031788fc6946df8534d96c639b Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent 41e77d2 commit a531751

File tree

12 files changed

+50
-80
lines changed

12 files changed

+50
-80
lines changed

runtime/command_stream/command_stream_receiver.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,6 @@ void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer &alloc
9797
this->processEviction(osContext);
9898
}
9999

100-
GraphicsAllocation *CommandStreamReceiver::createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferedDeleteList) {
101-
GraphicsAllocation *graphicsAllocation = getMemoryManager()->allocateGraphicsMemory(size, address);
102-
makeResident(*graphicsAllocation);
103-
if (addToDefferedDeleteList) {
104-
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(graphicsAllocation), TEMPORARY_ALLOCATION);
105-
}
106-
if (!graphicsAllocation->isL3Capable()) {
107-
disableL3Cache = true;
108-
}
109-
110-
return graphicsAllocation;
111-
}
112-
113100
void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation) {
114101
makeResident(*gfxAllocation);
115102
if (!gfxAllocation->isL3Capable()) {

runtime/command_stream/command_stream_receiver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ class CommandStreamReceiver {
8181

8282
virtual GmmPageTableMngr *createPageTableManager() { return nullptr; }
8383

84-
GraphicsAllocation *createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferFreeList = true);
8584
MOCKABLE_VIRTUAL void waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType);
8685

8786
LinearStream &getCS(size_t minRequiredSize = 1024u);

unit_tests/aub_tests/command_queue/enqueue_kernel_aub_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ struct AUBSimpleArgNonUniformFixture : public KernelAUBFixture<SimpleArgNonUnifo
382382

383383
kernel->setArgSvm(1, sizeUserMemory, destMemory);
384384

385-
outBuffer = csr->createAllocationAndHandleResidency(destMemory, sizeUserMemory);
385+
outBuffer = csr->getMemoryManager()->allocateGraphicsMemory(sizeUserMemory, destMemory);
386+
csr->makeResidentHostPtrAllocation(outBuffer);
387+
csr->getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(outBuffer), TEMPORARY_ALLOCATION);
386388
ASSERT_NE(nullptr, outBuffer);
387389
outBuffer->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
388390
outBuffer->setMemObjectsAllocationWithWritableFlags(true);

unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ HWTEST_P(AUBReadBuffer, simple) {
5858
cl_event *eventWaitList = nullptr;
5959
cl_event *event = nullptr;
6060

61-
GraphicsAllocation *allocation = pCommandStreamReceiver->createAllocationAndHandleResidency(pDestMemory, sizeof(destMemory));
61+
GraphicsAllocation *allocation = createResidentAllocationAndStoreItInCsr(pDestMemory, sizeof(destMemory));
6262

6363
srcBuffer->forceDisallowCPUCopy = true;
6464
retVal = pCmdQ->enqueueReadBuffer(
@@ -138,7 +138,7 @@ HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) {
138138
nullptr);
139139
EXPECT_EQ(CL_SUCCESS, retVal);
140140

141-
GraphicsAllocation *dstAllocation = pCommandStreamReceiver->createAllocationAndHandleResidency(dstMemory, sizeof(dstMemory));
141+
GraphicsAllocation *dstAllocation = createResidentAllocationAndStoreItInCsr(dstMemory, sizeof(dstMemory));
142142
cl_float *dstGpuAddress = reinterpret_cast<cl_float *>(dstAllocation->getGpuAddress());
143143

144144
AUBCommandStreamFixture::expectMemory<FamilyType>(dstGpuAddress, srcMemory, sizeof(dstMemory));

unit_tests/aub_tests/command_queue/enqueue_read_buffer_rect_aub_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ HWTEST_P(AUBReadBufferRect, simple3D) {
6767

6868
cl_bool blockingRead = CL_TRUE;
6969

70-
pCommandStreamReceiver->createAllocationAndHandleResidency(destMemory, bufferSize);
70+
createResidentAllocationAndStoreItInCsr(destMemory, bufferSize);
7171

7272
size_t bufferOrigin[] = {0, 0, zBuffOffs};
7373
size_t hostOrigin[] = {0, 0, zHostOffs};

unit_tests/aub_tests/command_queue/enqueue_read_image_aub_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ HWTEST_P(AUBReadImage, simpleUnalignedMemory) {
135135

136136
// Since we're testing for overwrite, we need to ensure
137137
// the complete memory is made resident for AUB testing.
138-
auto graphicsAllocation = pCommandStreamReceiver->createAllocationAndHandleResidency(dstMemoryUnaligned, (numPixels * elementSize));
138+
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(dstMemoryUnaligned, (numPixels * elementSize));
139139
pCommandStreamReceiver->makeNonResident(*graphicsAllocation);
140140
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
141141
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat);

unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ class AUBCommandStreamFixture : public CommandStreamFixture {
7272
aubCsr->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified);
7373
}
7474

75+
GraphicsAllocation *createResidentAllocationAndStoreItInCsr(const void *address, size_t size) {
76+
GraphicsAllocation *graphicsAllocation = pCommandStreamReceiver->getMemoryManager()->allocateGraphicsMemory(size, address);
77+
pCommandStreamReceiver->makeResidentHostPtrAllocation(graphicsAllocation);
78+
pCommandStreamReceiver->getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(graphicsAllocation), TEMPORARY_ALLOCATION);
79+
return graphicsAllocation;
80+
}
7581
CommandStreamReceiver *pCommandStreamReceiver = nullptr;
7682
volatile uint32_t *pTagMemory = nullptr;
7783

unit_tests/aub_tests/command_stream/aub_command_stream_tests.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,17 @@ TEST_F(AUBcommandstreamTests, makeResident) {
9595
uint8_t buffer[0x10000];
9696
size_t size = sizeof(buffer);
9797
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
98-
auto graphicsAllocation = commandStreamReceiver.createAllocationAndHandleResidency(buffer, size);
98+
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, size);
9999
ResidencyContainer allocationsForResidency = {graphicsAllocation};
100100
commandStreamReceiver.processResidency(allocationsForResidency, *pDevice->getOsContext());
101101
}
102102

103103
HWTEST_F(AUBcommandstreamTests, expectMemorySingle) {
104104
uint32_t buffer = 0xdeadbeef;
105105
size_t size = sizeof(buffer);
106-
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
107-
auto graphicsAllocation = commandStreamReceiver.createAllocationAndHandleResidency(&buffer, size);
106+
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(&buffer, size);
108107
ResidencyContainer allocationsForResidency = {graphicsAllocation};
109-
commandStreamReceiver.processResidency(allocationsForResidency, *pDevice->getOsContext());
108+
pCommandStreamReceiver->processResidency(allocationsForResidency, *pDevice->getOsContext());
110109

111110
AUBCommandStreamFixture::expectMemory<FamilyType>(&buffer, &buffer, size);
112111
}
@@ -119,10 +118,9 @@ HWTEST_F(AUBcommandstreamTests, expectMemoryLarge) {
119118
buffer[index] = static_cast<uint8_t>(index);
120119
}
121120

122-
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
123-
auto graphicsAllocation = commandStreamReceiver.createAllocationAndHandleResidency(buffer, sizeBuffer);
121+
auto graphicsAllocation = createResidentAllocationAndStoreItInCsr(buffer, sizeBuffer);
124122
ResidencyContainer allocationsForResidency = {graphicsAllocation};
125-
commandStreamReceiver.processResidency(allocationsForResidency, *pDevice->getOsContext());
123+
pCommandStreamReceiver->processResidency(allocationsForResidency, *pDevice->getOsContext());
126124

127125
AUBCommandStreamFixture::expectMemory<FamilyType>(buffer, buffer, sizeBuffer);
128126
delete[] buffer;

unit_tests/aub_tests/fixtures/simple_arg_fixture.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ struct SimpleArgFixture : public FixtureFactory::IndirectHeapFixture,
7878
pKernel->setArg(0, sizeof(int), &argVal);
7979
pKernel->setArgSvm(1, sizeUserMemory, pDestMemory);
8080

81-
auto &commandStreamReceiver = pDevice->getCommandStreamReceiver();
82-
outBuffer = commandStreamReceiver.createAllocationAndHandleResidency(pDestMemory, sizeUserMemory);
81+
outBuffer = AUBCommandStreamFixture::createResidentAllocationAndStoreItInCsr(pDestMemory, sizeUserMemory);
8382
ASSERT_NE(nullptr, outBuffer);
8483
outBuffer->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
8584
outBuffer->setMemObjectsAllocationWithWritableFlags(true);

unit_tests/command_stream/command_stream_receiver_tests.cpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,52 +131,34 @@ TEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenGetCSIsCalledThe
131131
EXPECT_EQ(GraphicsAllocation::AllocationType::LINEAR_STREAM, commandStreamAllocation->getAllocationType());
132132
}
133133

134-
TEST_F(CommandStreamReceiverTest, createAllocationAndHandleResidency) {
135-
void *host_ptr = (void *)0x1212341;
136-
auto size = 17262u;
137-
138-
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(host_ptr, size);
139-
ASSERT_NE(nullptr, graphicsAllocation);
140-
141-
EXPECT_EQ(host_ptr, graphicsAllocation->getUnderlyingBuffer());
142-
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
143-
}
144-
145-
TEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenAllocationIsNotAddedToListThenCallerMustFreeAllocation) {
146-
void *hostPtr = reinterpret_cast<void *>(0x1212341);
147-
auto size = 17262u;
148-
149-
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size, false);
150-
ASSERT_NE(nullptr, graphicsAllocation);
151-
152-
EXPECT_EQ(hostPtr, graphicsAllocation->getUnderlyingBuffer());
153-
EXPECT_EQ(size, graphicsAllocation->getUnderlyingBufferSize());
154-
155-
commandStreamReceiver->getMemoryManager()->freeGraphicsMemory(graphicsAllocation);
156-
}
157-
158-
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenPtrAndSizeMeetL3CriteriaThenCsrEnableL3) {
134+
HWTEST_F(CommandStreamReceiverTest, givenPtrAndSizeThatMeetL3CriteriaWhenMakeResidentHostPtrThenCsrEnableL3) {
159135
void *hostPtr = reinterpret_cast<void *>(0xF000);
160136
auto size = 0x2000u;
161137

162-
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size);
138+
auto memoryManager = commandStreamReceiver->getMemoryManager();
139+
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(size, hostPtr);
163140
ASSERT_NE(nullptr, graphicsAllocation);
141+
commandStreamReceiver->makeResidentHostPtrAllocation(graphicsAllocation);
164142

165143
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
166144

167145
EXPECT_FALSE(csr.disableL3Cache);
146+
memoryManager->freeGraphicsMemory(graphicsAllocation);
168147
}
169148

170-
HWTEST_F(CommandStreamReceiverTest, givenCommandStreamerWhenPtrAndSizeDoNotMeetL3CriteriaThenCsrDisableL3) {
149+
HWTEST_F(CommandStreamReceiverTest, givenPtrAndSizeThatDoNotMeetL3CriteriaWhenMakeResidentHostPtrThenCsrDisableL3) {
171150
void *hostPtr = reinterpret_cast<void *>(0xF001);
172151
auto size = 0x2001u;
173152

174-
GraphicsAllocation *graphicsAllocation = commandStreamReceiver->createAllocationAndHandleResidency(hostPtr, size);
153+
auto memoryManager = commandStreamReceiver->getMemoryManager();
154+
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(size, hostPtr);
175155
ASSERT_NE(nullptr, graphicsAllocation);
156+
commandStreamReceiver->makeResidentHostPtrAllocation(graphicsAllocation);
176157

177158
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
178159

179160
EXPECT_TRUE(csr.disableL3Cache);
161+
memoryManager->freeGraphicsMemory(graphicsAllocation);
180162
}
181163

182164
TEST_F(CommandStreamReceiverTest, memoryManagerHasAccessToCSR) {

0 commit comments

Comments
 (0)