Simplify Semaphore programming

Change-Id: I3322be137bbc1fe6f63baada26cf65baf821b4c1
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
Dunajski, Bartosz
2018-09-11 10:15:54 +02:00
committed by sys_ocldev
parent c3be3d9ef3
commit 2366c41154
5 changed files with 35 additions and 10 deletions

View File

@ -664,11 +664,7 @@ inline void GpgpuWalkerHelper<GfxFamily>::dispatchOnDeviceWaitlistSemaphores(Lin
auto compareAddress = timestampPacket->pickAddressForDataWrite(TimestampPacket::DataIndex::ContextEnd);
auto miSemaphoreCmd = commandStream->getSpaceForCmd<MI_SEMAPHORE_WAIT>();
*miSemaphoreCmd = MI_SEMAPHORE_WAIT::sInit();
miSemaphoreCmd->setCompareOperation(MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD);
miSemaphoreCmd->setSemaphoreDataDword(1);
miSemaphoreCmd->setSemaphoreGraphicsAddress(compareAddress);
KernelCommandsHelper<GfxFamily>::programMiSemaphoreWait(*commandStream, compareAddress, 1);
}
}

View File

@ -797,11 +797,7 @@ void CommandStreamReceiverHw<GfxFamily>::programOutOfDeviceWaitlistSemaphores(Li
auto compareAddress = timestampPacket->pickAddressForDataWrite(TimestampPacket::DataIndex::ContextEnd);
auto miSemaphoreCmd = commandStream.getSpaceForCmd<MI_SEMAPHORE_WAIT>();
*miSemaphoreCmd = MI_SEMAPHORE_WAIT::sInit();
miSemaphoreCmd->setCompareOperation(MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD);
miSemaphoreCmd->setSemaphoreDataDword(1);
miSemaphoreCmd->setSemaphoreGraphicsAddress(compareAddress);
KernelCommandsHelper<GfxFamily>::programMiSemaphoreWait(csr, compareAddress, 1);
}
}
} // namespace OCLRT

View File

@ -160,6 +160,8 @@ struct KernelCommandsHelper : public PerThreadDataHelper {
return totalSize;
}
static void programMiSemaphoreWait(LinearStream &commandStream, uint64_t compareAddress, uint32_t compareData);
static const size_t alignInterfaceDescriptorData = 64 * sizeof(uint8_t);
static const uint32_t alignIndirectStatePointer = 64 * sizeof(uint8_t);
};

View File

@ -420,4 +420,15 @@ size_t KernelCommandsHelper<GfxFamily>::sendIndirectState(
return offsetCrossThreadData;
}
template <typename GfxFamily>
void KernelCommandsHelper<GfxFamily>::programMiSemaphoreWait(LinearStream &commandStream, uint64_t compareAddress, uint32_t compareData) {
using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;
auto miSemaphoreCmd = commandStream.getSpaceForCmd<MI_SEMAPHORE_WAIT>();
*miSemaphoreCmd = MI_SEMAPHORE_WAIT::sInit();
miSemaphoreCmd->setCompareOperation(MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD);
miSemaphoreCmd->setSemaphoreDataDword(compareData);
miSemaphoreCmd->setSemaphoreGraphicsAddress(compareAddress);
}
} // namespace OCLRT

View File

@ -1011,6 +1011,26 @@ HWCMDTEST_F(IGFX_GEN8_CORE, KernelCommandsTest, GivenKernelWithSamplersWhenIndir
delete[] mockDsh;
}
using KernelCommandsHelperTests = ::testing::Test;
HWTEST_F(KernelCommandsHelperTests, givenCompareAddressAndDataWhenProgrammingSemaphoreWaitThenSetupAllFields) {
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
uint64_t compareAddress = 0x10000;
uint32_t compareData = 1234;
uint8_t buffer[1024] = {};
LinearStream cmdStream(buffer, 1024);
MI_SEMAPHORE_WAIT referenceCommand = MI_SEMAPHORE_WAIT::sInit();
referenceCommand.setCompareOperation(MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_NOT_EQUAL_SDD);
referenceCommand.setSemaphoreDataDword(compareData);
referenceCommand.setSemaphoreGraphicsAddress(compareAddress);
KernelCommandsHelper<FamilyType>::programMiSemaphoreWait(cmdStream, compareAddress, compareData);
EXPECT_EQ(sizeof(MI_SEMAPHORE_WAIT), cmdStream.getUsed());
EXPECT_EQ(0, memcmp(&referenceCommand, buffer, sizeof(MI_SEMAPHORE_WAIT)));
}
typedef ExecutionModelKernelFixture ParentKernelCommandsFromBinaryTest;
HWTEST_P(ParentKernelCommandsFromBinaryTest, getSizeRequiredForExecutionModelForSurfaceStatesReturnsSizeOfBlocksPlusMaxBindingTableSizeForAllIDTEntriesAndSchedulerSSHSize) {