Add private scratch space allocation to scratch space controller

Related-To: NEO-3190

Change-Id: I8100bb1db99700c2aac487e443a872f56c887dd1
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2019-06-27 12:59:27 +02:00 committed by sys_ocldev
parent da09c70e8c
commit 373dd2021b
5 changed files with 12 additions and 2 deletions

View File

@ -224,6 +224,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
if (requiredScratchSize) { if (requiredScratchSize) {
scratchSpaceController->setRequiredScratchSpace(ssh.getCpuBase(), scratchSpaceController->setRequiredScratchSpace(ssh.getCpuBase(),
requiredScratchSize, requiredScratchSize,
0u,
this->taskCount, this->taskCount,
this->osContext->getContextId(), this->osContext->getContextId(),
stateBaseAddressDirty, stateBaseAddressDirty,

View File

@ -28,8 +28,12 @@ class ScratchSpaceController {
GraphicsAllocation *getScratchSpaceAllocation() { GraphicsAllocation *getScratchSpaceAllocation() {
return scratchAllocation; return scratchAllocation;
} }
GraphicsAllocation *getPrivateScratchSpaceAllocation() {
return privateScratchAllocation;
}
virtual void setRequiredScratchSpace(void *sshBaseAddress, virtual void setRequiredScratchSpace(void *sshBaseAddress,
uint32_t requiredPerThreadScratchSize, uint32_t requiredPerThreadScratchSize,
uint32_t requiredPerThreadPrivateScratchSize,
uint32_t currentTaskCount, uint32_t currentTaskCount,
uint32_t deviceIdx, uint32_t deviceIdx,
bool &stateBaseAddressDirty, bool &stateBaseAddressDirty,
@ -44,8 +48,10 @@ class ScratchSpaceController {
ExecutionEnvironment &executionEnvironment; ExecutionEnvironment &executionEnvironment;
GraphicsAllocation *scratchAllocation = nullptr; GraphicsAllocation *scratchAllocation = nullptr;
GraphicsAllocation *privateScratchAllocation = nullptr;
InternalAllocationStorage &csrAllocationStorage; InternalAllocationStorage &csrAllocationStorage;
size_t scratchSizeBytes = 0; size_t scratchSizeBytes = 0;
size_t privateScratchSizeBytes = 0;
bool force32BitAllocation = false; bool force32BitAllocation = false;
uint32_t computeUnitsUsedForScratch = 0; uint32_t computeUnitsUsedForScratch = 0;
}; };

View File

@ -23,6 +23,7 @@ ScratchSpaceControllerBase::ScratchSpaceControllerBase(ExecutionEnvironment &env
void ScratchSpaceControllerBase::setRequiredScratchSpace(void *sshBaseAddress, void ScratchSpaceControllerBase::setRequiredScratchSpace(void *sshBaseAddress,
uint32_t requiredPerThreadScratchSize, uint32_t requiredPerThreadScratchSize,
uint32_t requiredPerThreadPrivateScratchSize,
uint32_t currentTaskCount, uint32_t currentTaskCount,
uint32_t contextId, uint32_t contextId,
bool &stateBaseAddressDirty, bool &stateBaseAddressDirty,

View File

@ -16,6 +16,7 @@ class ScratchSpaceControllerBase : public ScratchSpaceController {
void setRequiredScratchSpace(void *sshBaseAddress, void setRequiredScratchSpace(void *sshBaseAddress,
uint32_t requiredPerThreadScratchSize, uint32_t requiredPerThreadScratchSize,
uint32_t requiredPerThreadPrivateScratchSize,
uint32_t currentTaskCount, uint32_t currentTaskCount,
uint32_t contextId, uint32_t contextId,
bool &stateBaseAddressDirty, bool &stateBaseAddressDirty,

View File

@ -235,10 +235,11 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsNotRequiredThenScratchAl
bool stateBaseAddressDirty = false; bool stateBaseAddressDirty = false;
bool cfeStateDirty = false; bool cfeStateDirty = false;
scratchController->setRequiredScratchSpace(reinterpret_cast<void *>(0x2000), 0u, 0u, 0u, stateBaseAddressDirty, cfeStateDirty); scratchController->setRequiredScratchSpace(reinterpret_cast<void *>(0x2000), 0u, 0u, 0u, 0u, stateBaseAddressDirty, cfeStateDirty);
EXPECT_FALSE(cfeStateDirty); EXPECT_FALSE(cfeStateDirty);
EXPECT_FALSE(stateBaseAddressDirty); EXPECT_FALSE(stateBaseAddressDirty);
EXPECT_EQ(nullptr, scratchController->getScratchSpaceAllocation()); EXPECT_EQ(nullptr, scratchController->getScratchSpaceAllocation());
EXPECT_EQ(nullptr, scratchController->getPrivateScratchSpaceAllocation());
} }
HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsRequiredThenCorrectAddressIsReturned) { HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsRequiredThenCorrectAddressIsReturned) {
@ -249,7 +250,7 @@ HWTEST_F(CommandStreamReceiverHwTest, WhenScratchSpaceIsRequiredThenCorrectAddre
bool stateBaseAddressDirty = false; bool stateBaseAddressDirty = false;
std::unique_ptr<void, std::function<decltype(alignedFree)>> surfaceHeap(alignedMalloc(0x1000, 0x1000), alignedFree); std::unique_ptr<void, std::function<decltype(alignedFree)>> surfaceHeap(alignedMalloc(0x1000, 0x1000), alignedFree);
scratchController->setRequiredScratchSpace(surfaceHeap.get(), 0x1000u, 0u, 0u, stateBaseAddressDirty, cfeStateDirty); scratchController->setRequiredScratchSpace(surfaceHeap.get(), 0x1000u, 0u, 0u, 0u, stateBaseAddressDirty, cfeStateDirty);
uint64_t expectedScratchAddress = 0xAAABBBCCCDDD000ull; uint64_t expectedScratchAddress = 0xAAABBBCCCDDD000ull;
auto scratchAllocation = scratchController->getScratchSpaceAllocation(); auto scratchAllocation = scratchController->getScratchSpaceAllocation();