mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Set Context in program when using builtins
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
402082182c
commit
722f693e0f
@ -2172,30 +2172,43 @@ using BuiltInOwnershipWrapperTests = BuiltInTests;
|
||||
|
||||
TEST_F(BuiltInOwnershipWrapperTests, givenBuiltinWhenConstructedThenLockAndUnlockOnDestruction) {
|
||||
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pClDevice);
|
||||
MockContext context(pClDevice);
|
||||
{
|
||||
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp);
|
||||
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
|
||||
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp, &context);
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
|
||||
EXPECT_EQ(&context, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
|
||||
}
|
||||
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
|
||||
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
|
||||
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
|
||||
}
|
||||
|
||||
TEST_F(BuiltInOwnershipWrapperTests, givenLockWithoutParametersWhenConstructingThenLockOnlyWhenRequested) {
|
||||
MockAuxBuilInOp mockAuxBuiltInOp(*pBuiltIns, *pClDevice);
|
||||
MockContext context(pClDevice);
|
||||
{
|
||||
BuiltInOwnershipWrapper lock;
|
||||
lock.takeOwnership(mockAuxBuiltInOp);
|
||||
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
|
||||
lock.takeOwnership(mockAuxBuiltInOp, &context);
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
|
||||
EXPECT_TRUE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
|
||||
EXPECT_EQ(&context, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
|
||||
}
|
||||
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getMultiDeviceKernel()->hasOwnership());
|
||||
EXPECT_FALSE(mockAuxBuiltInOp.baseKernel->getProgram()->hasOwnership());
|
||||
EXPECT_EQ(nullptr, mockAuxBuiltInOp.baseKernel->getProgram()->getContextPtr());
|
||||
}
|
||||
|
||||
TEST_F(BuiltInOwnershipWrapperTests, givenLockWithAcquiredOwnershipWhenTakeOwnershipCalledThenAbort) {
|
||||
MockAuxBuilInOp mockAuxBuiltInOp1(*pBuiltIns, *pClDevice);
|
||||
MockAuxBuilInOp mockAuxBuiltInOp2(*pBuiltIns, *pClDevice);
|
||||
MockContext context(pClDevice);
|
||||
|
||||
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp1);
|
||||
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp1), std::exception);
|
||||
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp2), std::exception);
|
||||
BuiltInOwnershipWrapper lock(mockAuxBuiltInOp1, &context);
|
||||
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp1, &context), std::exception);
|
||||
EXPECT_THROW(lock.takeOwnership(mockAuxBuiltInOp2, &context), std::exception);
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInOwnershipWrapperTests, givenBuiltInOwnershipWrapperWhenAskedForTypeTraitsThenDisableCopyConstructorAndOperator) {
|
||||
|
Reference in New Issue
Block a user