Fix max root device index in Program's ctor

Related-To: NEO-5001
Change-Id: If3b86a51df478222f47a30c9254466dea0710ec4
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2020-10-20 15:41:32 +02:00
committed by sys_ocldev
parent 52feced02b
commit 4122554b71
2 changed files with 30 additions and 1 deletions

View File

@ -48,7 +48,13 @@ Program::Program(Context *context, bool isBuiltIn, const ClDeviceVector &clDevic
numDevices = static_cast<uint32_t>(clDevicesIn.size());
bool force32BitAddressess = false;
uint32_t maxRootDeviceIndex = pDevice->getRootDeviceIndex();
uint32_t maxRootDeviceIndex = 0;
for (const auto &device : clDevicesIn) {
if (device->getRootDeviceIndex() > maxRootDeviceIndex) {
maxRootDeviceIndex = device->getRootDeviceIndex();
}
}
buildInfos.resize(maxRootDeviceIndex + 1);

View File

@ -3053,6 +3053,29 @@ TEST_F(ProgramMultiRootDeviceTests, WhenPrivateSurfaceIsCreatedThenItHasCorrectR
EXPECT_EQ(expectedRootDeviceIndex, privateSurface->getRootDeviceIndex());
}
TEST_F(ProgramMultiRootDeviceTests, WhenProgramIsCreatedThenBuildInfosVectorIsProperlyResized) {
{
ClDeviceVector deviceVector;
deviceVector.push_back(device.get());
deviceVector.push_back(device2.get());
EXPECT_EQ(1u, deviceVector[0]->getRootDeviceIndex());
auto program = std::make_unique<MockProgram>(context.get(), false, deviceVector);
EXPECT_EQ(3u, program->buildInfos.size());
}
{
ClDeviceVector deviceVector;
deviceVector.push_back(device2.get());
deviceVector.push_back(device.get());
EXPECT_EQ(2u, deviceVector[0]->getRootDeviceIndex());
auto program = std::make_unique<MockProgram>(context.get(), false, deviceVector);
EXPECT_EQ(3u, program->buildInfos.size());
}
}
class MockCompilerInterfaceWithGtpinParam : public CompilerInterface {
public:
TranslationOutput::ErrorCode link(