mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Move surface allocations from Program to BuildInfo
Related-To: NEO-5001 Change-Id: Icf011698fc166285d049b052d59c709c7419e105 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
394e626db9
commit
1f240862ce
@@ -288,21 +288,21 @@ cl_int Kernel::initialize() {
|
||||
const auto &patch = patchInfo.pAllocateStatelessPrivateSurface;
|
||||
patchWithImplicitSurface(reinterpret_cast<void *>(privateSurface->getGpuAddressToPatch()), *privateSurface, *patch);
|
||||
}
|
||||
|
||||
auto rootDeviceIndex = device.getRootDeviceIndex();
|
||||
if (patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization) {
|
||||
DEBUG_BREAK_IF(program->getConstantSurface() == nullptr);
|
||||
uintptr_t constMemory = isBuiltIn ? (uintptr_t)program->getConstantSurface()->getUnderlyingBuffer() : (uintptr_t)program->getConstantSurface()->getGpuAddressToPatch();
|
||||
DEBUG_BREAK_IF(program->getConstantSurface(rootDeviceIndex) == nullptr);
|
||||
uintptr_t constMemory = isBuiltIn ? (uintptr_t)program->getConstantSurface(rootDeviceIndex)->getUnderlyingBuffer() : (uintptr_t)program->getConstantSurface(rootDeviceIndex)->getGpuAddressToPatch();
|
||||
|
||||
const auto &patch = patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization;
|
||||
patchWithImplicitSurface(reinterpret_cast<void *>(constMemory), *program->getConstantSurface(), *patch);
|
||||
patchWithImplicitSurface(reinterpret_cast<void *>(constMemory), *program->getConstantSurface(rootDeviceIndex), *patch);
|
||||
}
|
||||
|
||||
if (patchInfo.pAllocateStatelessGlobalMemorySurfaceWithInitialization) {
|
||||
DEBUG_BREAK_IF(program->getGlobalSurface() == nullptr);
|
||||
uintptr_t globalMemory = isBuiltIn ? (uintptr_t)program->getGlobalSurface()->getUnderlyingBuffer() : (uintptr_t)program->getGlobalSurface()->getGpuAddressToPatch();
|
||||
DEBUG_BREAK_IF(program->getGlobalSurface(rootDeviceIndex) == nullptr);
|
||||
uintptr_t globalMemory = isBuiltIn ? (uintptr_t)program->getGlobalSurface(rootDeviceIndex)->getUnderlyingBuffer() : (uintptr_t)program->getGlobalSurface(rootDeviceIndex)->getGpuAddressToPatch();
|
||||
|
||||
const auto &patch = patchInfo.pAllocateStatelessGlobalMemorySurfaceWithInitialization;
|
||||
patchWithImplicitSurface(reinterpret_cast<void *>(globalMemory), *program->getGlobalSurface(), *patch);
|
||||
patchWithImplicitSurface(reinterpret_cast<void *>(globalMemory), *program->getGlobalSurface(rootDeviceIndex), *patch);
|
||||
}
|
||||
|
||||
if (patchInfo.pAllocateStatelessEventPoolSurface) {
|
||||
@@ -1111,20 +1111,21 @@ inline void Kernel::makeArgsResident(CommandStreamReceiver &commandStreamReceive
|
||||
}
|
||||
|
||||
void Kernel::makeResident(CommandStreamReceiver &commandStreamReceiver) {
|
||||
auto rootDeviceIndex = device.getRootDeviceIndex();
|
||||
if (privateSurface) {
|
||||
commandStreamReceiver.makeResident(*privateSurface);
|
||||
}
|
||||
|
||||
if (program->getConstantSurface()) {
|
||||
commandStreamReceiver.makeResident(*(program->getConstantSurface()));
|
||||
if (program->getConstantSurface(rootDeviceIndex)) {
|
||||
commandStreamReceiver.makeResident(*(program->getConstantSurface(rootDeviceIndex)));
|
||||
}
|
||||
|
||||
if (program->getGlobalSurface()) {
|
||||
commandStreamReceiver.makeResident(*(program->getGlobalSurface()));
|
||||
if (program->getGlobalSurface(rootDeviceIndex)) {
|
||||
commandStreamReceiver.makeResident(*(program->getGlobalSurface(rootDeviceIndex)));
|
||||
}
|
||||
|
||||
if (program->getExportedFunctionsSurface()) {
|
||||
commandStreamReceiver.makeResident(*(program->getExportedFunctionsSurface()));
|
||||
if (program->getExportedFunctionsSurface(rootDeviceIndex)) {
|
||||
commandStreamReceiver.makeResident(*(program->getExportedFunctionsSurface(rootDeviceIndex)));
|
||||
}
|
||||
|
||||
for (auto gfxAlloc : kernelSvmGfxAllocations) {
|
||||
@@ -1160,23 +1161,24 @@ void Kernel::makeResident(CommandStreamReceiver &commandStreamReceiver) {
|
||||
}
|
||||
|
||||
void Kernel::getResidency(std::vector<Surface *> &dst) {
|
||||
auto rootDeviceIndex = device.getRootDeviceIndex();
|
||||
if (privateSurface) {
|
||||
GeneralSurface *surface = new GeneralSurface(privateSurface);
|
||||
dst.push_back(surface);
|
||||
}
|
||||
|
||||
if (program->getConstantSurface()) {
|
||||
GeneralSurface *surface = new GeneralSurface(program->getConstantSurface());
|
||||
if (program->getConstantSurface(rootDeviceIndex)) {
|
||||
GeneralSurface *surface = new GeneralSurface(program->getConstantSurface(rootDeviceIndex));
|
||||
dst.push_back(surface);
|
||||
}
|
||||
|
||||
if (program->getGlobalSurface()) {
|
||||
GeneralSurface *surface = new GeneralSurface(program->getGlobalSurface());
|
||||
if (program->getGlobalSurface(rootDeviceIndex)) {
|
||||
GeneralSurface *surface = new GeneralSurface(program->getGlobalSurface(rootDeviceIndex));
|
||||
dst.push_back(surface);
|
||||
}
|
||||
|
||||
if (program->getExportedFunctionsSurface()) {
|
||||
GeneralSurface *surface = new GeneralSurface(program->getExportedFunctionsSurface());
|
||||
if (program->getExportedFunctionsSurface(rootDeviceIndex)) {
|
||||
GeneralSurface *surface = new GeneralSurface(program->getExportedFunctionsSurface(rootDeviceIndex));
|
||||
dst.push_back(surface);
|
||||
}
|
||||
|
||||
@@ -1825,12 +1827,12 @@ size_t Kernel::getInstructionHeapSizeForExecutionModel() const {
|
||||
}
|
||||
|
||||
void Kernel::patchBlocksCurbeWithConstantValues() {
|
||||
|
||||
auto rootDeviceIndex = device.getRootDeviceIndex();
|
||||
BlockKernelManager *blockManager = program->getBlockKernelManager();
|
||||
uint32_t blockCount = static_cast<uint32_t>(blockManager->getCount());
|
||||
|
||||
uint64_t globalMemoryGpuAddress = program->getGlobalSurface() != nullptr ? program->getGlobalSurface()->getGpuAddressToPatch() : 0;
|
||||
uint64_t constantMemoryGpuAddress = program->getConstantSurface() != nullptr ? program->getConstantSurface()->getGpuAddressToPatch() : 0;
|
||||
uint64_t globalMemoryGpuAddress = program->getGlobalSurface(rootDeviceIndex) != nullptr ? program->getGlobalSurface(rootDeviceIndex)->getGpuAddressToPatch() : 0;
|
||||
uint64_t constantMemoryGpuAddress = program->getConstantSurface(rootDeviceIndex) != nullptr ? program->getConstantSurface(rootDeviceIndex)->getGpuAddressToPatch() : 0;
|
||||
|
||||
for (uint32_t blockID = 0; blockID < blockCount; blockID++) {
|
||||
const KernelInfo *pBlockInfo = blockManager->getBlockKernelInfo(blockID);
|
||||
@@ -2398,7 +2400,7 @@ void Kernel::getAllocationsForCacheFlush(CacheFlushAllocationsVec &out) const {
|
||||
out.push_back(alloc);
|
||||
}
|
||||
|
||||
auto global = getProgram()->getGlobalSurface();
|
||||
auto global = getProgram()->getGlobalSurface(device.getRootDeviceIndex());
|
||||
if (global != nullptr) {
|
||||
out.push_back(global);
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ cl_int Program::getBuildInfo(cl_device_id device, cl_program_build_info paramNam
|
||||
}
|
||||
|
||||
auto pClDev = castToObject<ClDevice>(device);
|
||||
auto rootDeviceIndex = pClDev->getRootDeviceIndex();
|
||||
|
||||
switch (paramName) {
|
||||
case CL_PROGRAM_BUILD_STATUS:
|
||||
@@ -196,7 +197,7 @@ cl_int Program::getBuildInfo(cl_device_id device, cl_program_build_info paramNam
|
||||
break;
|
||||
|
||||
case CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE:
|
||||
pSrc = &globalVarTotalSize;
|
||||
pSrc = &buildInfos[rootDeviceIndex].globalVarTotalSize;
|
||||
retSize = srcSize = sizeof(size_t);
|
||||
break;
|
||||
|
||||
|
||||
@@ -56,12 +56,13 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, const
|
||||
if (linkerInput == nullptr) {
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
auto rootDeviceIndex = pDevice->getRootDeviceIndex();
|
||||
Linker linker(*linkerInput);
|
||||
Linker::SegmentInfo globals;
|
||||
Linker::SegmentInfo constants;
|
||||
Linker::SegmentInfo exportedFunctions;
|
||||
GraphicsAllocation *globalsForPatching = this->globalSurface;
|
||||
GraphicsAllocation *constantsForPatching = this->constantSurface;
|
||||
GraphicsAllocation *globalsForPatching = getGlobalSurface(rootDeviceIndex);
|
||||
GraphicsAllocation *constantsForPatching = getConstantSurface(rootDeviceIndex);
|
||||
if (globalsForPatching != nullptr) {
|
||||
globals.gpuAddress = static_cast<uintptr_t>(globalsForPatching->getGpuAddress());
|
||||
globals.segmentSize = globalsForPatching->getUnderlyingBufferSize();
|
||||
@@ -73,9 +74,9 @@ cl_int Program::linkBinary(Device *pDevice, const void *constantsInitData, const
|
||||
if (linkerInput->getExportedFunctionsSegmentId() >= 0) {
|
||||
// Exported functions reside in instruction heap of one of kernels
|
||||
auto exportedFunctionHeapId = linkerInput->getExportedFunctionsSegmentId();
|
||||
this->exportedFunctionsSurface = this->kernelInfoArray[exportedFunctionHeapId]->getGraphicsAllocation();
|
||||
exportedFunctions.gpuAddress = static_cast<uintptr_t>(exportedFunctionsSurface->getGpuAddressToPatch());
|
||||
exportedFunctions.segmentSize = exportedFunctionsSurface->getUnderlyingBufferSize();
|
||||
buildInfos[rootDeviceIndex].exportedFunctionsSurface = this->kernelInfoArray[exportedFunctionHeapId]->getGraphicsAllocation();
|
||||
exportedFunctions.gpuAddress = static_cast<uintptr_t>(buildInfos[rootDeviceIndex].exportedFunctionsSurface->getGpuAddressToPatch());
|
||||
exportedFunctions.segmentSize = buildInfos[rootDeviceIndex].exportedFunctionsSurface->getUnderlyingBufferSize();
|
||||
}
|
||||
Linker::PatchableSegments isaSegmentsForPatching;
|
||||
std::vector<std::vector<char>> patchedIsaTempStorage;
|
||||
@@ -125,11 +126,13 @@ cl_int Program::processGenBinary() {
|
||||
}
|
||||
|
||||
cleanCurrentKernelInfo();
|
||||
if (this->constantSurface || this->globalSurface) {
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(this->constantSurface);
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(this->globalSurface);
|
||||
this->constantSurface = nullptr;
|
||||
this->globalSurface = nullptr;
|
||||
for (auto &buildInfo : buildInfos) {
|
||||
if (buildInfo.constantSurface || buildInfo.globalSurface) {
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(buildInfo.constantSurface);
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(buildInfo.globalSurface);
|
||||
buildInfo.constantSurface = nullptr;
|
||||
buildInfo.globalSurface = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ProgramInfo programInfo;
|
||||
@@ -176,18 +179,19 @@ cl_int Program::processProgramInfo(ProgramInfo &src) {
|
||||
|
||||
this->kernelInfoArray = std::move(src.kernelInfos);
|
||||
auto svmAllocsManager = context ? context->getSVMAllocsManager() : nullptr;
|
||||
auto rootDeviceIndex = pDevice ? pDevice->getRootDeviceIndex() : 0u;
|
||||
if (src.globalConstants.size != 0) {
|
||||
UNRECOVERABLE_IF(nullptr == pDevice);
|
||||
this->constantSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalConstants.size, true, linkerInput, src.globalConstants.initData);
|
||||
buildInfos[rootDeviceIndex].constantSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalConstants.size, true, linkerInput, src.globalConstants.initData);
|
||||
}
|
||||
|
||||
this->globalVarTotalSize = src.globalVariables.size;
|
||||
buildInfos[rootDeviceIndex].globalVarTotalSize = src.globalVariables.size;
|
||||
|
||||
if (src.globalVariables.size != 0) {
|
||||
UNRECOVERABLE_IF(nullptr == pDevice);
|
||||
this->globalSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalVariables.size, false, linkerInput, src.globalVariables.initData);
|
||||
buildInfos[rootDeviceIndex].globalSurface = allocateGlobalsSurface(svmAllocsManager, *pDevice, src.globalVariables.size, false, linkerInput, src.globalVariables.initData);
|
||||
if (pDevice->getSpecializedDevice<ClDevice>()->areOcl21FeaturesEnabled() == false) {
|
||||
this->globalVarTotalSize = 0u;
|
||||
buildInfos[rootDeviceIndex].globalVarTotalSize = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,23 +123,22 @@ Program::~Program() {
|
||||
freeBlockResources();
|
||||
|
||||
delete blockKernelManager;
|
||||
|
||||
if (constantSurface) {
|
||||
if ((nullptr != context) && (nullptr != context->getSVMAllocsManager()) && (context->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(constantSurface->getGpuAddress())))) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(reinterpret_cast<void *>(constantSurface->getGpuAddress()));
|
||||
} else {
|
||||
this->executionEnvironment.memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(constantSurface);
|
||||
for (const auto &buildInfo : buildInfos) {
|
||||
if (buildInfo.constantSurface) {
|
||||
if ((nullptr != context) && (nullptr != context->getSVMAllocsManager()) && (context->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(buildInfo.constantSurface->getGpuAddress())))) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(reinterpret_cast<void *>(buildInfo.constantSurface->getGpuAddress()));
|
||||
} else {
|
||||
this->executionEnvironment.memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(buildInfo.constantSurface);
|
||||
}
|
||||
}
|
||||
constantSurface = nullptr;
|
||||
}
|
||||
|
||||
if (globalSurface) {
|
||||
if ((nullptr != context) && (nullptr != context->getSVMAllocsManager()) && (context->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(globalSurface->getGpuAddress())))) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(reinterpret_cast<void *>(globalSurface->getGpuAddress()));
|
||||
} else {
|
||||
this->executionEnvironment.memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(globalSurface);
|
||||
if (buildInfo.globalSurface) {
|
||||
if ((nullptr != context) && (nullptr != context->getSVMAllocsManager()) && (context->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(buildInfo.globalSurface->getGpuAddress())))) {
|
||||
context->getSVMAllocsManager()->freeSVMAlloc(reinterpret_cast<void *>(buildInfo.globalSurface->getGpuAddress()));
|
||||
} else {
|
||||
this->executionEnvironment.memoryManager->checkGpuUsageAndDestroyGraphicsAllocations(buildInfo.globalSurface);
|
||||
}
|
||||
}
|
||||
globalSurface = nullptr;
|
||||
}
|
||||
|
||||
if (context && !isBuiltIn) {
|
||||
|
||||
@@ -205,16 +205,16 @@ class Program : public BaseObject<_cl_program> {
|
||||
return isSpirV;
|
||||
}
|
||||
|
||||
GraphicsAllocation *getConstantSurface() const {
|
||||
return constantSurface;
|
||||
GraphicsAllocation *getConstantSurface(uint32_t rootDeviceIndex) const {
|
||||
return buildInfos[rootDeviceIndex].constantSurface;
|
||||
}
|
||||
|
||||
GraphicsAllocation *getGlobalSurface() const {
|
||||
return globalSurface;
|
||||
GraphicsAllocation *getGlobalSurface(uint32_t rootDeviceIndex) const {
|
||||
return buildInfos[rootDeviceIndex].globalSurface;
|
||||
}
|
||||
|
||||
GraphicsAllocation *getExportedFunctionsSurface() const {
|
||||
return exportedFunctionsSurface;
|
||||
GraphicsAllocation *getExportedFunctionsSurface(uint32_t rootDeviceIndex) const {
|
||||
return buildInfos[rootDeviceIndex].exportedFunctionsSurface;
|
||||
}
|
||||
|
||||
BlockKernelManager *getBlockKernelManager() const {
|
||||
@@ -315,12 +315,6 @@ class Program : public BaseObject<_cl_program> {
|
||||
std::vector<KernelInfo *> parentKernelInfoArray;
|
||||
std::vector<KernelInfo *> subgroupKernelInfoArray;
|
||||
|
||||
GraphicsAllocation *constantSurface = nullptr;
|
||||
GraphicsAllocation *globalSurface = nullptr;
|
||||
GraphicsAllocation *exportedFunctionsSurface = nullptr;
|
||||
|
||||
size_t globalVarTotalSize = 0U;
|
||||
|
||||
cl_build_status buildStatus = CL_BUILD_NONE;
|
||||
bool isCreatedFromBinary = false;
|
||||
|
||||
@@ -333,6 +327,10 @@ class Program : public BaseObject<_cl_program> {
|
||||
bool allowNonUniform = false;
|
||||
|
||||
struct BuildInfo : public NonCopyableClass {
|
||||
GraphicsAllocation *constantSurface = nullptr;
|
||||
GraphicsAllocation *globalSurface = nullptr;
|
||||
GraphicsAllocation *exportedFunctionsSurface = nullptr;
|
||||
size_t globalVarTotalSize = 0U;
|
||||
std::unique_ptr<LinkerInput> linkerInput;
|
||||
Linker::RelocatedSymbolsMap symbols{};
|
||||
std::string buildLog{};
|
||||
|
||||
@@ -2007,8 +2007,8 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithGlobalMemoryAn
|
||||
MockContext context(pClDevice);
|
||||
MockParentKernel *parentKernel = MockParentKernel::create(context, false, true, false);
|
||||
|
||||
if (parentKernel->mockProgram->getGlobalSurface()) {
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getGlobalSurface());
|
||||
if (parentKernel->mockProgram->getGlobalSurface(pClDevice->getRootDeviceIndex())) {
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getGlobalSurface(pClDevice->getRootDeviceIndex()));
|
||||
parentKernel->mockProgram->setGlobalSurface(nullptr);
|
||||
}
|
||||
|
||||
@@ -2083,8 +2083,8 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithConstantMemory
|
||||
MockContext context(pClDevice);
|
||||
MockParentKernel *parentKernel = MockParentKernel::create(context, false, false, true);
|
||||
|
||||
if (parentKernel->mockProgram->getConstantSurface()) {
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getConstantSurface());
|
||||
if (parentKernel->mockProgram->getConstantSurface(pClDevice->getRootDeviceIndex())) {
|
||||
pDevice->getMemoryManager()->freeGraphicsMemory(parentKernel->mockProgram->getConstantSurface(pClDevice->getRootDeviceIndex()));
|
||||
parentKernel->mockProgram->setConstantSurface(nullptr);
|
||||
}
|
||||
|
||||
@@ -2127,7 +2127,7 @@ using KernelReflectionMultiDeviceTest = MultiRootDeviceFixture;
|
||||
TEST_F(KernelReflectionMultiDeviceTest, GivenNoKernelArgsWhenObtainingKernelReflectionSurfaceThenParamsAreCorrect) {
|
||||
REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device.get());
|
||||
|
||||
MockProgram program(*device->getExecutionEnvironment());
|
||||
MockProgram program(*device->getExecutionEnvironment(), context.get(), false, &device->getDevice());
|
||||
KernelInfo *blockInfo = new KernelInfo;
|
||||
KernelInfo &info = *blockInfo;
|
||||
cl_queue_properties properties[1] = {0};
|
||||
@@ -2176,7 +2176,7 @@ TEST_F(KernelReflectionMultiDeviceTest, GivenNoKernelArgsWhenObtainingKernelRefl
|
||||
TEST_F(KernelReflectionMultiDeviceTest, GivenDeviceQueueKernelArgWhenObtainingKernelReflectionSurfaceThenParamsAreCorrect) {
|
||||
REQUIRE_DEVICE_ENQUEUE_OR_SKIP(device.get());
|
||||
|
||||
MockProgram program(*device->getExecutionEnvironment());
|
||||
MockProgram program(*device->getExecutionEnvironment(), context.get(), false, &device->getDevice());
|
||||
|
||||
KernelInfo *blockInfo = new KernelInfo;
|
||||
KernelInfo &info = *blockInfo;
|
||||
|
||||
@@ -1681,7 +1681,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenExportedFun
|
||||
|
||||
MockProgram program(*pDevice->getExecutionEnvironment());
|
||||
auto exportedFunctionsSurface = std::make_unique<MockGraphicsAllocation>();
|
||||
program.exportedFunctionsSurface = exportedFunctionsSurface.get();
|
||||
program.buildInfos[pDevice->getRootDeviceIndex()].exportedFunctionsSurface = exportedFunctionsSurface.get();
|
||||
MockContext ctx;
|
||||
program.setContext(&ctx);
|
||||
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
|
||||
@@ -1689,7 +1689,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenExportedFun
|
||||
|
||||
EXPECT_EQ(0u, commandStreamReceiver.makeResidentAllocations.size());
|
||||
pKernel->makeResident(pDevice->getGpgpuCommandStreamReceiver());
|
||||
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.exportedFunctionsSurface));
|
||||
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.buildInfos[pDevice->getRootDeviceIndex()].exportedFunctionsSurface));
|
||||
|
||||
// check getResidency as well
|
||||
std::vector<NEO::Surface *> residencySurfaces;
|
||||
@@ -1720,13 +1720,13 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenGlobalBuffe
|
||||
MockProgram program(*pDevice->getExecutionEnvironment());
|
||||
MockContext ctx;
|
||||
program.setContext(&ctx);
|
||||
program.globalSurface = new MockGraphicsAllocation();
|
||||
program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation();
|
||||
std::unique_ptr<MockKernel> pKernel(new MockKernel(&program, *pKernelInfo, *pClDevice));
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
|
||||
EXPECT_EQ(0u, commandStreamReceiver.makeResidentAllocations.size());
|
||||
pKernel->makeResident(pDevice->getGpgpuCommandStreamReceiver());
|
||||
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.globalSurface));
|
||||
EXPECT_TRUE(commandStreamReceiver.isMadeResident(program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface));
|
||||
|
||||
std::vector<NEO::Surface *> residencySurfaces;
|
||||
pKernel->getResidency(residencySurfaces);
|
||||
@@ -1738,7 +1738,7 @@ HWTEST_F(KernelResidencyTest, givenKernelWhenMakeResidentIsCalledThenGlobalBuffe
|
||||
s->makeResident(csrMock);
|
||||
delete s;
|
||||
}
|
||||
EXPECT_EQ(1U, csrMock.residency.count(program.globalSurface->getUnderlyingBuffer()));
|
||||
EXPECT_EQ(1U, csrMock.residency.count(program.buildInfos[pDevice->getRootDeviceIndex()].globalSurface->getUnderlyingBuffer()));
|
||||
mockCsrExecEnv = std::move(csrMock.mockExecutionEnvironment);
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ class MockKernelWithInternals {
|
||||
mockContext = context;
|
||||
}
|
||||
|
||||
mockProgram = new MockProgram(*deviceArg.getExecutionEnvironment(), context, false, nullptr);
|
||||
mockProgram = new MockProgram(*deviceArg.getExecutionEnvironment(), context, false, &deviceArg.getDevice());
|
||||
mockKernel = new MockKernel(mockProgram, kernelInfo, deviceArg);
|
||||
mockKernel->setCrossThreadData(&crossThreadData, sizeof(crossThreadData));
|
||||
mockKernel->setSshLocal(&sshLocal, sizeof(sshLocal));
|
||||
|
||||
@@ -38,15 +38,12 @@ class MockProgram : public Program {
|
||||
using Program::areSpecializationConstantsInitialized;
|
||||
using Program::blockKernelManager;
|
||||
using Program::buildInfos;
|
||||
using Program::constantSurface;
|
||||
using Program::context;
|
||||
using Program::createdFrom;
|
||||
using Program::debugData;
|
||||
using Program::debugDataSize;
|
||||
using Program::exportedFunctionsSurface;
|
||||
using Program::extractInternalOptions;
|
||||
using Program::getKernelInfo;
|
||||
using Program::globalSurface;
|
||||
using Program::irBinary;
|
||||
using Program::irBinarySize;
|
||||
using Program::isSpirV;
|
||||
@@ -77,10 +74,22 @@ class MockProgram : public Program {
|
||||
}
|
||||
std::string &getInternalOptions() { return internalOptions; };
|
||||
void setConstantSurface(GraphicsAllocation *gfxAllocation) {
|
||||
constantSurface = gfxAllocation;
|
||||
if (gfxAllocation) {
|
||||
buildInfos[gfxAllocation->getRootDeviceIndex()].constantSurface = gfxAllocation;
|
||||
} else {
|
||||
for (auto &buildInfo : buildInfos) {
|
||||
buildInfo.constantSurface = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
void setGlobalSurface(GraphicsAllocation *gfxAllocation) {
|
||||
globalSurface = gfxAllocation;
|
||||
if (gfxAllocation) {
|
||||
buildInfos[gfxAllocation->getRootDeviceIndex()].globalSurface = gfxAllocation;
|
||||
} else {
|
||||
for (auto &buildInfo : buildInfos) {
|
||||
buildInfo.globalSurface = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
void setDevice(Device *device) {
|
||||
this->pDevice = device;
|
||||
|
||||
@@ -70,7 +70,7 @@ class ProgramDataTestBase : public testing::Test,
|
||||
size_t setupConstantAllocation() {
|
||||
size_t constSize = strlen(constValue) + 1;
|
||||
|
||||
EXPECT_EQ(nullptr, pProgram->getConstantSurface());
|
||||
EXPECT_EQ(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
|
||||
SPatchAllocateConstantMemorySurfaceProgramBinaryInfo allocateConstMemorySurface;
|
||||
allocateConstMemorySurface.Token = PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
|
||||
@@ -96,7 +96,7 @@ class ProgramDataTestBase : public testing::Test,
|
||||
size_t setupGlobalAllocation() {
|
||||
size_t globalSize = strlen(globalValue) + 1;
|
||||
|
||||
EXPECT_EQ(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_EQ(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
|
||||
SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface;
|
||||
allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
|
||||
@@ -178,8 +178,8 @@ TEST_F(ProgramDataTest, WhenAllocatingConstantMemorySurfaceThenUnderlyingBufferI
|
||||
|
||||
buildAndDecodeProgramPatchList();
|
||||
|
||||
EXPECT_NE(nullptr, pProgram->getConstantSurface());
|
||||
EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface()->getUnderlyingBuffer(), constSize));
|
||||
EXPECT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer(), constSize));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, givenProgramWhenAllocatingConstantMemorySurfaceThenProperDeviceBitfieldIsPassed) {
|
||||
@@ -191,7 +191,7 @@ TEST_F(ProgramDataTest, givenProgramWhenAllocatingConstantMemorySurfaceThenPrope
|
||||
EXPECT_NE(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
|
||||
setupConstantAllocation();
|
||||
buildAndDecodeProgramPatchList();
|
||||
EXPECT_NE(nullptr, pProgram->getConstantSurface());
|
||||
EXPECT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
|
||||
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
|
||||
}
|
||||
@@ -210,8 +210,8 @@ TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedThenAllocateSurfacesAsSvm)
|
||||
programInfo.linkerInput = std::move(mockLinkerInput);
|
||||
this->pProgram->processProgramInfo(programInfo);
|
||||
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface());
|
||||
EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getConstantSurface()->getGpuAddress())));
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress())));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, whenGlobalConstantsAreNotExportedThenAllocateSurfacesAsNonSvm) {
|
||||
@@ -228,8 +228,9 @@ TEST_F(ProgramDataTest, whenGlobalConstantsAreNotExportedThenAllocateSurfacesAsN
|
||||
programInfo.linkerInput = std::move(mockLinkerInput);
|
||||
this->pProgram->processProgramInfo(programInfo);
|
||||
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface());
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getConstantSurface()->getGpuAddress())));
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(
|
||||
pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress())));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedButContextUnavailableThenAllocateSurfacesAsNonSvm) {
|
||||
@@ -251,8 +252,9 @@ TEST_F(ProgramDataTest, whenGlobalConstantsAreExportedButContextUnavailableThenA
|
||||
|
||||
pProgram->context = pContext;
|
||||
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface());
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getConstantSurface()->getGpuAddress())));
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(
|
||||
pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress())));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedThenAllocateSurfacesAsSvm) {
|
||||
@@ -268,8 +270,8 @@ TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedThenAllocateSurfacesAsSvm)
|
||||
programInfo.linkerInput = std::move(mockLinkerInput);
|
||||
this->pProgram->processProgramInfo(programInfo);
|
||||
|
||||
ASSERT_NE(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface()->getGpuAddress())));
|
||||
ASSERT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_NE(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress())));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedButContextUnavailableThenAllocateSurfacesAsNonSvm) {
|
||||
@@ -291,8 +293,8 @@ TEST_F(ProgramDataTest, whenGlobalVariablesAreExportedButContextUnavailableThenA
|
||||
|
||||
pProgram->context = pContext;
|
||||
|
||||
ASSERT_NE(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface()->getGpuAddress())));
|
||||
ASSERT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress())));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, whenGlobalVariablesAreNotExportedThenAllocateSurfacesAsNonSvm) {
|
||||
@@ -309,8 +311,8 @@ TEST_F(ProgramDataTest, whenGlobalVariablesAreNotExportedThenAllocateSurfacesAsN
|
||||
programInfo.linkerInput = std::move(mockLinkerInput);
|
||||
this->pProgram->processProgramInfo(programInfo);
|
||||
|
||||
ASSERT_NE(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface()->getGpuAddress())));
|
||||
ASSERT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(nullptr, this->pContext->getSVMAllocsManager()->getSVMAlloc(reinterpret_cast<const void *>(pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddress())));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, givenConstantAllocationThatIsInUseByGpuWhenProgramIsBeingDestroyedThenItIsAddedToTemporaryAllocationList) {
|
||||
@@ -321,7 +323,7 @@ TEST_F(ProgramDataTest, givenConstantAllocationThatIsInUseByGpuWhenProgramIsBein
|
||||
|
||||
auto &csr = *pPlatform->getClDevice(0)->getDefaultEngine().commandStreamReceiver;
|
||||
auto tagAddress = csr.getTagAddress();
|
||||
auto constantSurface = pProgram->getConstantSurface();
|
||||
auto constantSurface = pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex());
|
||||
constantSurface->updateTaskCount(*tagAddress + 1, csr.getOsContext().getContextId());
|
||||
|
||||
EXPECT_TRUE(csr.getTemporaryAllocations().peekIsEmpty());
|
||||
@@ -338,7 +340,7 @@ TEST_F(ProgramDataTest, givenGlobalAllocationThatIsInUseByGpuWhenProgramIsBeingD
|
||||
|
||||
auto &csr = *pPlatform->getClDevice(0)->getDefaultEngine().commandStreamReceiver;
|
||||
auto tagAddress = csr.getTagAddress();
|
||||
auto globalSurface = pProgram->getGlobalSurface();
|
||||
auto globalSurface = pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex());
|
||||
globalSurface->updateTaskCount(*tagAddress + 1, csr.getOsContext().getContextId());
|
||||
|
||||
EXPECT_TRUE(csr.getTemporaryAllocations().peekIsEmpty());
|
||||
@@ -354,19 +356,19 @@ TEST_F(ProgramDataTest, GivenDeviceForcing32BitMessagesWhenConstAllocationIsPres
|
||||
|
||||
buildAndDecodeProgramPatchList();
|
||||
|
||||
EXPECT_NE(nullptr, pProgram->getConstantSurface());
|
||||
EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface()->getUnderlyingBuffer(), constSize));
|
||||
EXPECT_NE(nullptr, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer(), constSize));
|
||||
|
||||
if (is64bit) {
|
||||
EXPECT_TRUE(pProgram->getConstantSurface()->is32BitAllocation());
|
||||
EXPECT_TRUE(pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->is32BitAllocation());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, WhenAllocatingGlobalMemorySurfaceThenUnderlyingBufferIsSetCorrectly) {
|
||||
auto globalSize = setupGlobalAllocation();
|
||||
buildAndDecodeProgramPatchList();
|
||||
EXPECT_NE(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface()->getUnderlyingBuffer(), globalSize));
|
||||
EXPECT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer(), globalSize));
|
||||
}
|
||||
TEST_F(ProgramDataTest, givenProgramWhenAllocatingGlobalMemorySurfaceThenProperDeviceBitfieldIsPassed) {
|
||||
auto executionEnvironment = pProgram->getDevice().getExecutionEnvironment();
|
||||
@@ -378,7 +380,7 @@ TEST_F(ProgramDataTest, givenProgramWhenAllocatingGlobalMemorySurfaceThenProperD
|
||||
|
||||
setupGlobalAllocation();
|
||||
buildAndDecodeProgramPatchList();
|
||||
EXPECT_NE(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(pProgram->getDevice().getDeviceBitfield(), memoryManager->recentlyPassedDeviceBitfield);
|
||||
std::swap(memoryManagerBackup, executionEnvironment->memoryManager);
|
||||
}
|
||||
@@ -387,7 +389,7 @@ TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHa
|
||||
char globalValue[] = "55667788";
|
||||
size_t globalSize = strlen(globalValue) + 1;
|
||||
this->pContext->getDevice(0)->getMemoryManager()->setForce32BitAllocations(true);
|
||||
EXPECT_EQ(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_EQ(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
|
||||
SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface;
|
||||
allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
|
||||
@@ -410,10 +412,10 @@ TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHa
|
||||
|
||||
buildAndDecodeProgramPatchList();
|
||||
|
||||
EXPECT_NE(nullptr, pProgram->getGlobalSurface());
|
||||
EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface()->getUnderlyingBuffer(), globalSize));
|
||||
EXPECT_NE(nullptr, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer(), globalSize));
|
||||
if (is64bit) {
|
||||
EXPECT_TRUE(pProgram->getGlobalSurface()->is32BitAllocation());
|
||||
EXPECT_TRUE(pProgram->getGlobalSurface(pContext->getDevice(0)->getRootDeviceIndex())->is32BitAllocation());
|
||||
}
|
||||
|
||||
delete[] pAllocateGlobalMemorySurface;
|
||||
@@ -433,12 +435,13 @@ TEST(ProgramScopeMetadataTest, WhenPatchingGlobalSurfaceThenPickProperSourceBuff
|
||||
program.pDevice = &device.getDevice();
|
||||
NEO::populateProgramInfo(programInfo, decodedProgram);
|
||||
program.processProgramInfo(programInfo);
|
||||
ASSERT_NE(nullptr, program.globalSurface);
|
||||
ASSERT_NE(nullptr, program.constantSurface);
|
||||
ASSERT_NE(nullptr, program.globalSurface->getUnderlyingBuffer());
|
||||
ASSERT_NE(nullptr, program.constantSurface->getUnderlyingBuffer());
|
||||
EXPECT_EQ(static_cast<uintptr_t>(program.globalSurface->getGpuAddressToPatch()), *reinterpret_cast<uintptr_t *>(program.constantSurface->getUnderlyingBuffer()));
|
||||
EXPECT_EQ(static_cast<uintptr_t>(program.constantSurface->getGpuAddressToPatch()), *reinterpret_cast<uintptr_t *>(program.globalSurface->getUnderlyingBuffer()));
|
||||
auto &buildInfo = program.buildInfos[device.getRootDeviceIndex()];
|
||||
ASSERT_NE(nullptr, buildInfo.globalSurface);
|
||||
ASSERT_NE(nullptr, buildInfo.constantSurface);
|
||||
ASSERT_NE(nullptr, buildInfo.globalSurface->getUnderlyingBuffer());
|
||||
ASSERT_NE(nullptr, buildInfo.constantSurface->getUnderlyingBuffer());
|
||||
EXPECT_EQ(static_cast<uintptr_t>(buildInfo.globalSurface->getGpuAddressToPatch()), *reinterpret_cast<uintptr_t *>(buildInfo.constantSurface->getUnderlyingBuffer()));
|
||||
EXPECT_EQ(static_cast<uintptr_t>(buildInfo.constantSurface->getGpuAddressToPatch()), *reinterpret_cast<uintptr_t *>(buildInfo.globalSurface->getUnderlyingBuffer()));
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeConstantBufferPatchTokensAreReadThenConstantPointerOffsetIsPatchedWith32bitPointer) {
|
||||
@@ -449,7 +452,7 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeConstantB
|
||||
MockProgram *prog = pProgram;
|
||||
|
||||
// simulate case when constant surface was not allocated
|
||||
EXPECT_EQ(nullptr, prog->getConstantSurface());
|
||||
EXPECT_EQ(nullptr, prog->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
ProgramInfo programInfo;
|
||||
programInfo.prepareLinkerInputStorage();
|
||||
NEO::LinkerInput::RelocationInfo relocInfo;
|
||||
@@ -486,7 +489,7 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeGlobalPoi
|
||||
MockProgram *prog = pProgram;
|
||||
|
||||
// simulate case when constant surface was not allocated
|
||||
EXPECT_EQ(nullptr, prog->getConstantSurface());
|
||||
EXPECT_EQ(nullptr, prog->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex()));
|
||||
|
||||
ProgramInfo programInfo;
|
||||
programInfo.prepareLinkerInputStorage();
|
||||
@@ -584,6 +587,7 @@ TEST_F(ProgramDataTest, whenLinkerInputValidThenIsaIsProperlyPatched) {
|
||||
linkerInput->exportedFunctionsSegmentId = 0;
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
||||
MockProgram program{*device->getExecutionEnvironment(), nullptr, false, device.get()};
|
||||
auto &buildInfo = program.buildInfos[device->getRootDeviceIndex()];
|
||||
KernelInfo kernelInfo = {};
|
||||
kernelInfo.name = "onlyKernel";
|
||||
std::vector<char> kernelHeap;
|
||||
@@ -595,35 +599,35 @@ TEST_F(ProgramDataTest, whenLinkerInputValidThenIsaIsProperlyPatched) {
|
||||
program.getKernelInfoArray().push_back(&kernelInfo);
|
||||
program.setLinkerInput(device->getRootDeviceIndex(), std::move(linkerInput));
|
||||
|
||||
program.exportedFunctionsSurface = kernelInfo.kernelAllocation;
|
||||
buildInfo.exportedFunctionsSurface = kernelInfo.kernelAllocation;
|
||||
std::vector<char> globalVariablesBuffer;
|
||||
globalVariablesBuffer.resize(32, 7);
|
||||
std::vector<char> globalConstantsBuffer;
|
||||
globalConstantsBuffer.resize(32, 7);
|
||||
std::vector<char> globalVariablesInitData{32, 0};
|
||||
std::vector<char> globalConstantsInitData{32, 0};
|
||||
program.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size());
|
||||
program.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size());
|
||||
buildInfo.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size());
|
||||
buildInfo.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size());
|
||||
|
||||
program.pDevice = &this->pContext->getDevice(0)->getDevice();
|
||||
|
||||
auto ret = program.linkBinary(pProgram->pDevice, globalConstantsInitData.data(), globalVariablesInitData.data());
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
|
||||
linkerInput.reset(static_cast<WhiteBox<LinkerInput> *>(program.buildInfos[program.pDevice->getRootDeviceIndex()].linkerInput.release()));
|
||||
linkerInput.reset(static_cast<WhiteBox<LinkerInput> *>(buildInfo.linkerInput.release()));
|
||||
|
||||
for (size_t i = 0; i < linkerInput->relocations.size(); ++i) {
|
||||
auto expectedPatch = program.globalSurface->getGpuAddress() + linkerInput->symbols[linkerInput->relocations[0][0].symbolName].offset;
|
||||
auto expectedPatch = buildInfo.globalSurface->getGpuAddress() + linkerInput->symbols[linkerInput->relocations[0][0].symbolName].offset;
|
||||
auto relocationAddress = kernelHeap.data() + linkerInput->relocations[0][0].offset;
|
||||
|
||||
EXPECT_EQ(static_cast<uintptr_t>(expectedPatch), *reinterpret_cast<uintptr_t *>(relocationAddress)) << i;
|
||||
}
|
||||
|
||||
program.getKernelInfoArray().clear();
|
||||
delete program.globalSurface;
|
||||
program.globalSurface = nullptr;
|
||||
delete program.constantSurface;
|
||||
program.constantSurface = nullptr;
|
||||
delete buildInfo.globalSurface;
|
||||
buildInfo.globalSurface = nullptr;
|
||||
delete buildInfo.constantSurface;
|
||||
buildInfo.constantSurface = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(ProgramDataTest, whenRelocationsAreNotNeededThenIsaIsPreserved) {
|
||||
@@ -633,6 +637,7 @@ TEST_F(ProgramDataTest, whenRelocationsAreNotNeededThenIsaIsPreserved) {
|
||||
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
||||
MockProgram program{*device->getExecutionEnvironment(), nullptr, false, device.get()};
|
||||
auto &buildInfo = program.buildInfos[device->getRootDeviceIndex()];
|
||||
KernelInfo kernelInfo = {};
|
||||
kernelInfo.name = "onlyKernel";
|
||||
std::vector<char> kernelHeapData;
|
||||
@@ -651,8 +656,8 @@ TEST_F(ProgramDataTest, whenRelocationsAreNotNeededThenIsaIsPreserved) {
|
||||
globalConstantsBuffer.resize(32, 7);
|
||||
std::vector<char> globalVariablesInitData{32, 0};
|
||||
std::vector<char> globalConstantsInitData{32, 0};
|
||||
program.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size());
|
||||
program.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size());
|
||||
buildInfo.globalSurface = new MockGraphicsAllocation(globalVariablesBuffer.data(), globalVariablesBuffer.size());
|
||||
buildInfo.constantSurface = new MockGraphicsAllocation(globalConstantsBuffer.data(), globalConstantsBuffer.size());
|
||||
|
||||
program.pDevice = &this->pContext->getDevice(0)->getDevice();
|
||||
|
||||
@@ -661,8 +666,8 @@ TEST_F(ProgramDataTest, whenRelocationsAreNotNeededThenIsaIsPreserved) {
|
||||
EXPECT_EQ(kernelHeapData, kernelHeap);
|
||||
|
||||
program.getKernelInfoArray().clear();
|
||||
delete program.globalSurface;
|
||||
program.globalSurface = nullptr;
|
||||
delete program.constantSurface;
|
||||
program.constantSurface = nullptr;
|
||||
delete buildInfo.globalSurface;
|
||||
buildInfo.globalSurface = nullptr;
|
||||
delete buildInfo.constantSurface;
|
||||
buildInfo.constantSurface = nullptr;
|
||||
}
|
||||
|
||||
@@ -659,18 +659,18 @@ TEST_P(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi
|
||||
TEST_P(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffersAreFreed) {
|
||||
cl_device_id device = pClDevice;
|
||||
pProgram->build(1, &device, nullptr, nullptr, nullptr, true);
|
||||
EXPECT_EQ(nullptr, pProgram->constantSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->globalSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface);
|
||||
|
||||
pProgram->constantSurface = new MockGraphicsAllocation();
|
||||
pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface = new MockGraphicsAllocation();
|
||||
pProgram->processGenBinary();
|
||||
EXPECT_EQ(nullptr, pProgram->constantSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->globalSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface);
|
||||
|
||||
pProgram->globalSurface = new MockGraphicsAllocation();
|
||||
pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface = new MockGraphicsAllocation();
|
||||
pProgram->processGenBinary();
|
||||
EXPECT_EQ(nullptr, pProgram->constantSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->globalSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].constantSurface);
|
||||
EXPECT_EQ(nullptr, pProgram->buildInfos[pClDevice->getRootDeviceIndex()].globalSurface);
|
||||
}
|
||||
|
||||
TEST_P(ProgramFromBinaryTest, givenProgramWhenCleanKernelInfoIsCalledThenKernelAllocationIsFreed) {
|
||||
@@ -1384,10 +1384,10 @@ HWTEST_F(PatchTokenTests, givenKernelRequiringConstantAllocationWhenMakeResident
|
||||
auto pKernelInfo = pProgram->getKernelInfo("test");
|
||||
|
||||
EXPECT_NE(nullptr, pKernelInfo->patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization);
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface());
|
||||
ASSERT_NE(nullptr, pProgram->getConstantSurface(pClDevice->getRootDeviceIndex()));
|
||||
|
||||
uint32_t expected_values[] = {0xabcd5432u, 0xaabb5533u};
|
||||
uint32_t *constBuff = reinterpret_cast<uint32_t *>(pProgram->getConstantSurface()->getUnderlyingBuffer());
|
||||
uint32_t *constBuff = reinterpret_cast<uint32_t *>(pProgram->getConstantSurface(pClDevice->getRootDeviceIndex())->getUnderlyingBuffer());
|
||||
EXPECT_EQ(expected_values[0], constBuff[0]);
|
||||
EXPECT_EQ(expected_values[1], constBuff[1]);
|
||||
|
||||
@@ -1409,7 +1409,7 @@ HWTEST_F(PatchTokenTests, givenKernelRequiringConstantAllocationWhenMakeResident
|
||||
|
||||
//we expect kernel ISA here and constant allocation
|
||||
auto kernelIsa = pKernel->getKernelInfo().getGraphicsAllocation();
|
||||
auto constantAllocation = pProgram->getConstantSurface();
|
||||
auto constantAllocation = pProgram->getConstantSurface(pDevice->getRootDeviceIndex());
|
||||
|
||||
auto element = std::find(residencyVector.begin(), residencyVector.end(), kernelIsa);
|
||||
EXPECT_NE(residencyVector.end(), element);
|
||||
@@ -1417,7 +1417,7 @@ HWTEST_F(PatchTokenTests, givenKernelRequiringConstantAllocationWhenMakeResident
|
||||
EXPECT_NE(residencyVector.end(), element);
|
||||
|
||||
auto crossThreadData = pKernel->getCrossThreadData();
|
||||
uint32_t *constBuffGpuAddr = reinterpret_cast<uint32_t *>(pProgram->getConstantSurface()->getGpuAddressToPatch());
|
||||
uint32_t *constBuffGpuAddr = reinterpret_cast<uint32_t *>(pProgram->getConstantSurface(pContext->getDevice(0)->getRootDeviceIndex())->getGpuAddressToPatch());
|
||||
uintptr_t *pDst = reinterpret_cast<uintptr_t *>(crossThreadData + pKernelInfo->patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization->DataParamOffset);
|
||||
|
||||
EXPECT_EQ(*pDst, reinterpret_cast<uintptr_t>(constBuffGpuAddr));
|
||||
|
||||
Reference in New Issue
Block a user