2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2021-05-16 20:51:16 +02:00
|
|
|
* Copyright (C) 2018-2021 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2021-09-29 19:10:53 +00:00
|
|
|
#include "shared/source/program/kernel_info.h"
|
2021-12-21 11:53:21 +00:00
|
|
|
#include "shared/test/common/mocks/mock_kernel_info.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-03-20 11:15:25 +01:00
|
|
|
#include "opencl/source/cl_device/cl_device.h"
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/mocks/mock_context.h"
|
|
|
|
#include "opencl/test/unit_test/mocks/mock_program.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
using namespace NEO;
|
2017-12-21 00:45:38 +01:00
|
|
|
using namespace iOpenCL;
|
|
|
|
|
|
|
|
class KernelDataTest : public testing::Test {
|
|
|
|
public:
|
|
|
|
KernelDataTest() {
|
|
|
|
memset(&kernelBinaryHeader, 0x00, sizeof(SKernelBinaryHeaderCommon));
|
|
|
|
pCurPtr = nullptr;
|
|
|
|
pKernelData = nullptr;
|
|
|
|
kernelName = "test";
|
|
|
|
pDsh = nullptr;
|
|
|
|
pGsh = nullptr;
|
|
|
|
pKernelHeap = nullptr;
|
|
|
|
pSsh = nullptr;
|
|
|
|
pPatchList = nullptr;
|
|
|
|
|
|
|
|
kernelDataSize = 0;
|
|
|
|
kernelNameSize = (uint32_t)alignUp(strlen(kernelName.c_str()) + 1, sizeof(uint32_t));
|
|
|
|
dshSize = 0;
|
|
|
|
gshSize = 0;
|
|
|
|
kernelHeapSize = 0;
|
|
|
|
sshSize = 0;
|
|
|
|
patchListSize = 0;
|
|
|
|
|
|
|
|
checkSum = 0;
|
|
|
|
shaderHashCode = 0;
|
|
|
|
kernelUnpaddedSize = 0;
|
|
|
|
|
|
|
|
pKernelInfo = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void buildAndDecode();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SetUp() override {
|
|
|
|
kernelBinaryHeader.KernelNameSize = kernelNameSize;
|
2019-11-19 16:54:47 +01:00
|
|
|
pContext = new MockContext;
|
2020-11-30 17:38:28 +00:00
|
|
|
rootDeviceIndex = pContext->getDevice(0)->getRootDeviceIndex();
|
2020-10-16 15:00:28 +02:00
|
|
|
program = std::make_unique<MockProgram>(pContext, false, toClDeviceVector(*pContext->getDevice(0)));
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override {
|
2018-03-08 11:56:44 +01:00
|
|
|
if (pKernelInfo->kernelAllocation) {
|
2019-11-19 16:54:47 +01:00
|
|
|
pContext->getDevice(0)->getMemoryManager()->freeGraphicsMemory(pKernelInfo->kernelAllocation);
|
2018-03-08 11:56:44 +01:00
|
|
|
const_cast<KernelInfo *>(pKernelInfo)->kernelAllocation = nullptr;
|
|
|
|
}
|
2019-11-19 16:54:47 +01:00
|
|
|
program.reset();
|
|
|
|
delete pContext;
|
2017-12-21 00:45:38 +01:00
|
|
|
alignedFree(pKernelData);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *pCurPtr;
|
|
|
|
char *pKernelData;
|
|
|
|
SKernelBinaryHeaderCommon kernelBinaryHeader;
|
|
|
|
std::string kernelName;
|
|
|
|
void *pDsh;
|
|
|
|
void *pGsh;
|
|
|
|
void *pKernelHeap;
|
|
|
|
void *pSsh;
|
|
|
|
void *pPatchList;
|
|
|
|
|
|
|
|
uint32_t kernelDataSize;
|
|
|
|
uint32_t kernelNameSize;
|
|
|
|
uint32_t dshSize;
|
|
|
|
uint32_t gshSize;
|
|
|
|
uint32_t kernelHeapSize;
|
|
|
|
uint32_t sshSize;
|
|
|
|
uint32_t patchListSize;
|
|
|
|
|
|
|
|
uint32_t checkSum;
|
|
|
|
uint64_t shaderHashCode;
|
|
|
|
uint32_t kernelUnpaddedSize;
|
|
|
|
|
2018-08-09 11:34:50 +02:00
|
|
|
std::unique_ptr<MockProgram> program;
|
2019-11-19 16:54:47 +01:00
|
|
|
MockContext *pContext;
|
2017-12-21 00:45:38 +01:00
|
|
|
const KernelInfo *pKernelInfo;
|
2020-11-30 17:38:28 +00:00
|
|
|
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|