[1/N] Program refactor - decouple from patchokens

Change-Id: I63bbf6c31a5db9e788124f22b6105e65c16c86d4
This commit is contained in:
Jaroslaw Chodor 2019-10-27 19:48:26 +01:00 committed by sys_ocldev
parent 412c88cf9b
commit 355e8d3e5a
61 changed files with 6159 additions and 1368 deletions

View File

@ -30,6 +30,10 @@ typedef struct tagBINDING_TABLE_STATE {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
inline const uint32_t &getRawData(const uint32_t index) const {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
typedef enum tagSURFACESTATEPOINTER {
SURFACESTATEPOINTER_BIT_SHIFT = 0x6,
SURFACESTATEPOINTER_ALIGN_SIZE = 0x40,

View File

@ -30,6 +30,10 @@ typedef struct tagBINDING_TABLE_STATE {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
inline const uint32_t &getRawData(const uint32_t index) const {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
typedef enum tagSURFACESTATEPOINTER {
SURFACESTATEPOINTER_BIT_SHIFT = 0x6,
SURFACESTATEPOINTER_ALIGN_SIZE = 0x40,

View File

@ -30,6 +30,10 @@ typedef struct tagBINDING_TABLE_STATE {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
inline const uint32_t &getRawData(const uint32_t index) const {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
typedef enum tagSURFACESTATEPOINTER {
SURFACESTATEPOINTER_BIT_SHIFT = 0x6,
SURFACESTATEPOINTER_ALIGN_SIZE = 0x40,

View File

@ -30,6 +30,10 @@ typedef struct tagBINDING_TABLE_STATE {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
inline const uint32_t &getRawData(const uint32_t index) const {
DEBUG_BREAK_IF(index >= 1);
return TheStructure.RawData[index];
}
typedef enum tagSURFACESTATEPOINTER {
SURFACESTATEPOINTER_BIT_SHIFT = 0x6,
SURFACESTATEPOINTER_ALIGN_SIZE = 0x40,

View File

@ -25,7 +25,7 @@ class GmmHelper;
class HwHelper {
public:
static HwHelper &get(GFXCORE_FAMILY gfxCore);
virtual uint32_t getBindingTableStateSurfaceStatePointer(void *pBindingTable, uint32_t index) = 0;
virtual uint32_t getBindingTableStateSurfaceStatePointer(const void *pBindingTable, uint32_t index) = 0;
virtual size_t getBindingTableStateSize() const = 0;
virtual uint32_t getBindingTableStateAlignement() const = 0;
virtual size_t getInterfaceDescriptorDataSize() const = 0;
@ -88,10 +88,10 @@ class HwHelperHw : public HwHelper {
static const aub_stream::EngineType lowPriorityEngineType;
uint32_t getBindingTableStateSurfaceStatePointer(void *pBindingTable, uint32_t index) override {
uint32_t getBindingTableStateSurfaceStatePointer(const void *pBindingTable, uint32_t index) override {
using BINDING_TABLE_STATE = typename GfxFamily::BINDING_TABLE_STATE;
BINDING_TABLE_STATE *bindingTableState = static_cast<BINDING_TABLE_STATE *>(pBindingTable);
const BINDING_TABLE_STATE *bindingTableState = static_cast<const BINDING_TABLE_STATE *>(pBindingTable);
return bindingTableState[index].getRawData(0);
}

View File

@ -47,14 +47,33 @@ inline void *addrToPtr(IntegerAddressType addr) {
return ptrReturn;
}
inline void patchWithRequiredSize(void *memoryToBePatched, uint32_t patchSize, uintptr_t patchValue) {
if (patchSize == sizeof(uint64_t)) {
uint64_t *curbeAddress = (uint64_t *)memoryToBePatched;
*curbeAddress = patchValue;
} else {
uint32_t *curbeAddress = (uint32_t *)memoryToBePatched;
*curbeAddress = (uint32_t)patchValue;
struct PatchStoreOperation {
template <typename T>
void operator()(T *memory, T value) {
*memory = value;
}
};
struct PatchIncrementOperation {
template <typename T>
void operator()(T *memory, T value) {
*memory += value;
}
};
template <typename PatchOperationT = PatchStoreOperation>
inline void patchWithRequiredSize(void *memoryToBePatched, uint32_t patchSize, uint64_t patchValue) {
if (patchSize == sizeof(uint64_t)) {
uint64_t *curbeAddress = reinterpret_cast<uint64_t *>(memoryToBePatched);
PatchOperationT{}(curbeAddress, patchValue);
} else {
uint32_t *curbeAddress = reinterpret_cast<uint32_t *>(memoryToBePatched);
PatchOperationT{}(curbeAddress, static_cast<uint32_t>(patchValue));
}
}
inline void patchIncrement(void *memoryToBePatched, uint32_t patchSize, uint64_t patchIncrementValue) {
patchWithRequiredSize<PatchIncrementOperation>(memoryToBePatched, patchSize, patchIncrementValue);
}
inline uint64_t castToUint64(void *address) {

View File

@ -1417,14 +1417,17 @@ TEST(StackVec, Clear) {
DummyFNode nd2(&destructorCounter);
DummyFNode nd3(&destructorCounter);
StackVec<DummyFNode, 3> v;
EXPECT_TRUE(v.empty());
v.push_back(nd1);
v.push_back(nd2);
v.push_back(nd3);
ASSERT_EQ(0U, destructorCounter);
ASSERT_EQ(3U, v.size());
EXPECT_FALSE(v.empty());
v.clear();
ASSERT_EQ(3U, destructorCounter);
ASSERT_EQ(0U, v.size());
EXPECT_TRUE(v.empty());
StackVec<DummyFNode, 1> v2;
v2.push_back(nd1);
@ -1561,11 +1564,13 @@ TEST(ArrayRef, WrapContainers) {
ASSERT_EQ(35, sum(carray));
ArrayRef<int> ar2;
EXPECT_TRUE(ar2.empty());
ASSERT_EQ(0U, ar2.size());
ASSERT_EQ(nullptr, ar2.begin());
ASSERT_EQ(nullptr, ar2.end());
ar2 = carray;
EXPECT_FALSE(ar2.empty());
ASSERT_EQ(sizeof(carray) / sizeof(carray[0]), ar2.size());
ASSERT_EQ(35, sum(ar2));

View File

@ -45,10 +45,24 @@ class ArrayRef {
ArrayRef() = default;
ArrayRef(const ArrayRef &src)
: begIt(src.begIt), endIt(src.endIt) {
}
ArrayRef &operator=(const ArrayRef &src) {
this->begIt = src.begIt;
this->endIt = src.endIt;
return *this;
}
size_t size() const {
return endIt - begIt;
}
bool empty() const {
return (0U == size());
}
DataType &operator[](std::size_t idx) {
return begIt[idx];
}

View File

@ -133,6 +133,10 @@ class StackVec {
return onStackSize;
}
bool empty() const {
return 0U == size();
}
size_t capacity() const {
if (dynamicMem) {
return dynamicMem->capacity();

View File

@ -13,6 +13,7 @@
#include "core/helpers/string.h"
#include "core/memory_manager/graphics_allocation.h"
#include "runtime/device/device.h"
#include "runtime/program/kernel_info.h"
#include "runtime/program/program.h"
namespace NEO {

View File

@ -9,6 +9,11 @@ set(RUNTIME_SRCS_COMPILER_INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options.cpp
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options.h
${CMAKE_CURRENT_SOURCE_DIR}/default_cl_cache_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_decoder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_decoder.h
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_dumper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_dumper.h
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_validator.inl
)
get_property(NEO_COMPILER_INTERFACE GLOBAL PROPERTY NEO_COMPILER_INTERFACE)

View File

@ -0,0 +1,620 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "patchtokens_decoder.h"
#include "core/helpers/debug_helpers.h"
#include "core/helpers/hash.h"
#include "core/helpers/ptr_math.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include <algorithm>
namespace NEO {
namespace PatchTokenBinary {
struct PatchTokensStreamReader {
const ArrayRef<const uint8_t> data;
PatchTokensStreamReader(ArrayRef<const uint8_t> data) : data(data) {}
template <typename DecodePosT>
bool notEnoughDataLeft(DecodePosT *decodePos, size_t requestedSize) {
return getDataSizeLeft(decodePos) < requestedSize;
}
template <typename T, typename DecodePosT>
constexpr bool notEnoughDataLeft(DecodePosT *decodePos) {
return notEnoughDataLeft(decodePos, sizeof(T));
}
template <typename... ArgsT>
bool enoughDataLeft(ArgsT &&... args) {
return false == notEnoughDataLeft(std::forward<ArgsT>(args)...);
}
template <typename T, typename... ArgsT>
bool enoughDataLeft(ArgsT &&... args) {
return false == notEnoughDataLeft<T>(std::forward<ArgsT>(args)...);
}
template <typename DecodePosT>
size_t getDataSizeLeft(DecodePosT *decodePos) {
auto dataConsumed = ptrDiff(decodePos, data.begin());
UNRECOVERABLE_IF(dataConsumed > data.size());
return data.size() - dataConsumed;
}
};
template <typename T>
inline void assignToken(const T *&dst, const SPatchItemHeader *src) {
dst = reinterpret_cast<const T *>(src);
}
inline KernelArgFromPatchtokens &getKernelArg(KernelFromPatchtokens &kernel, size_t argNum, ArgObjectType type = ArgObjectType::None, ArgObjectTypeSpecialized typeSpecialized = ArgObjectTypeSpecialized::None) {
if (kernel.tokens.kernelArgs.size() < argNum + 1) {
kernel.tokens.kernelArgs.resize(argNum + 1);
}
auto &arg = kernel.tokens.kernelArgs[argNum];
if (arg.objectType == ArgObjectType::None) {
arg.objectType = type;
} else if ((arg.objectType != type) && (type != ArgObjectType::None)) {
kernel.decodeStatus = DecoderError::InvalidBinary;
DBG_LOG(LogPatchTokens, "\n Mismatched metadata for kernel arg :", argNum);
DEBUG_BREAK_IF(true);
}
if (arg.objectTypeSpecialized == ArgObjectTypeSpecialized::None) {
arg.objectTypeSpecialized = typeSpecialized;
} else if (typeSpecialized != ArgObjectTypeSpecialized::None) {
UNRECOVERABLE_IF(arg.objectTypeSpecialized != typeSpecialized);
}
return arg;
}
inline void assignArgInfo(KernelFromPatchtokens &kernel, const SPatchItemHeader *src) {
auto argInfoToken = reinterpret_cast<const SPatchKernelArgumentInfo *>(src);
getKernelArg(kernel, argInfoToken->ArgumentNumber, ArgObjectType::None).argInfo = argInfoToken;
}
template <typename T>
inline uint32_t getArgNum(const SPatchItemHeader *argToken) {
return reinterpret_cast<const T *>(argToken)->ArgumentNumber;
}
inline void assignArg(KernelFromPatchtokens &kernel, const SPatchItemHeader *src) {
uint32_t argNum = 0;
ArgObjectType type = ArgObjectType::Buffer;
switch (src->Token) {
default:
UNRECOVERABLE_IF(src->Token != PATCH_TOKEN_SAMPLER_KERNEL_ARGUMENT);
argNum = getArgNum<SPatchSamplerKernelArgument>(src);
type = ArgObjectType::Sampler;
break;
case PATCH_TOKEN_IMAGE_MEMORY_OBJECT_KERNEL_ARGUMENT:
argNum = getArgNum<SPatchImageMemoryObjectKernelArgument>(src);
type = ArgObjectType::Image;
break;
case PATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
argNum = getArgNum<SPatchGlobalMemoryObjectKernelArgument>(src);
break;
case PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
argNum = getArgNum<SPatchStatelessGlobalMemoryObjectKernelArgument>(src);
break;
case PATCH_TOKEN_STATELESS_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT:
argNum = getArgNum<SPatchStatelessConstantMemoryObjectKernelArgument>(src);
break;
case PATCH_TOKEN_STATELESS_DEVICE_QUEUE_KERNEL_ARGUMENT:
argNum = getArgNum<SPatchStatelessDeviceQueueKernelArgument>(src);
break;
}
getKernelArg(kernel, argNum, type).objectArg = src;
}
inline void assignToken(StackVecStrings &stringVec, const SPatchItemHeader *src) {
auto stringToken = reinterpret_cast<const SPatchString *>(src);
if (stringVec.size() < stringToken->Index + 1) {
stringVec.resize(stringToken->Index + 1);
}
stringVec[stringToken->Index] = stringToken;
}
template <size_t S>
inline void assignTokenInArray(const SPatchDataParameterBuffer *(&tokensArray)[S], const SPatchDataParameterBuffer *src, StackVecUnhandledTokens &unhandledTokens) {
auto sourceIndex = src->SourceOffset >> 2;
if (sourceIndex >= S) {
DBG_LOG(LogPatchTokens, "\n .Type", "Unhandled sourceIndex ", sourceIndex);
DEBUG_BREAK_IF(true);
unhandledTokens.push_back(src);
return;
}
assignToken(tokensArray[sourceIndex], src);
}
template <typename PatchT, size_t NumInlineEl>
inline void addTok(StackVec<const PatchT *, NumInlineEl> &tokensVec, const SPatchItemHeader *src) {
tokensVec.push_back(reinterpret_cast<const PatchT *>(src));
}
inline void decodeKernelDataParameterToken(const SPatchDataParameterBuffer *token, KernelFromPatchtokens &out) {
auto &crossthread = out.tokens.crossThreadPayloadArgs;
auto sourceIndex = token->SourceOffset >> 2;
auto argNum = token->ArgumentNumber;
switch (token->Type) {
default:
DBG_LOG(LogPatchTokens, "\n .Type", "Unhandled SPatchDataParameterBuffer ", token->Type);
DEBUG_BREAK_IF(true);
out.unhandledTokens.push_back(token);
break;
case DATA_PARAMETER_KERNEL_ARGUMENT:
getKernelArg(out, argNum, ArgObjectType::None).byValMap.push_back(token);
break;
case DATA_PARAMETER_LOCAL_WORK_SIZE: {
if (sourceIndex >= 3) {
DBG_LOG(LogPatchTokens, "\n .Type", "Unhandled sourceIndex ", sourceIndex);
DEBUG_BREAK_IF(true);
out.unhandledTokens.push_back(token);
return;
}
auto localWorkSizeArray = (crossthread.localWorkSize[sourceIndex] == nullptr)
? crossthread.localWorkSize
: crossthread.localWorkSize2;
localWorkSizeArray[sourceIndex] = token;
break;
}
case DATA_PARAMETER_GLOBAL_WORK_OFFSET:
assignTokenInArray(crossthread.globalWorkOffset, token, out.unhandledTokens);
break;
case DATA_PARAMETER_ENQUEUED_LOCAL_WORK_SIZE:
assignTokenInArray(crossthread.enqueuedLocalWorkSize, token, out.unhandledTokens);
break;
case DATA_PARAMETER_GLOBAL_WORK_SIZE:
assignTokenInArray(crossthread.globalWorkSize, token, out.unhandledTokens);
break;
case DATA_PARAMETER_NUM_WORK_GROUPS:
assignTokenInArray(crossthread.numWorkGroups, token, out.unhandledTokens);
break;
case DATA_PARAMETER_MAX_WORKGROUP_SIZE:
crossthread.maxWorkGroupSize = token;
break;
case DATA_PARAMETER_WORK_DIMENSIONS:
crossthread.workDimensions = token;
break;
case DATA_PARAMETER_SIMD_SIZE:
crossthread.simdSize = token;
break;
case DATA_PARAMETER_PRIVATE_MEMORY_STATELESS_SIZE:
crossthread.privateMemoryStatelessSize = token;
break;
case DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_SIZE:
crossthread.localMemoryStatelessWindowSize = token;
break;
case DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS:
crossthread.localMemoryStatelessWindowStartAddress = token;
break;
case DATA_PARAMETER_OBJECT_ID:
getKernelArg(out, argNum, ArgObjectType::None).objectId = token;
break;
case DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES: {
auto &kernelArg = getKernelArg(out, argNum, ArgObjectType::Slm);
kernelArg.byValMap.push_back(token);
kernelArg.metadata.slm.token = token;
} break;
case DATA_PARAMETER_BUFFER_OFFSET:
getKernelArg(out, argNum, ArgObjectType::Buffer).metadata.buffer.bufferOffset = token;
break;
case DATA_PARAMETER_BUFFER_STATEFUL:
getKernelArg(out, argNum, ArgObjectType::Buffer).metadata.buffer.pureStateful = token;
break;
case DATA_PARAMETER_IMAGE_WIDTH:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.width = token;
break;
case DATA_PARAMETER_IMAGE_HEIGHT:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.height = token;
break;
case DATA_PARAMETER_IMAGE_DEPTH:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.depth = token;
break;
case DATA_PARAMETER_IMAGE_CHANNEL_DATA_TYPE:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.channelDataType = token;
break;
case DATA_PARAMETER_IMAGE_CHANNEL_ORDER:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.channelOrder = token;
break;
case DATA_PARAMETER_IMAGE_ARRAY_SIZE:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.arraySize = token;
break;
case DATA_PARAMETER_IMAGE_NUM_SAMPLES:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.numSamples = token;
break;
case DATA_PARAMETER_IMAGE_NUM_MIP_LEVELS:
getKernelArg(out, argNum, ArgObjectType::Image).metadata.image.numMipLevels = token;
break;
case DATA_PARAMETER_SAMPLER_COORDINATE_SNAP_WA_REQUIRED:
getKernelArg(out, argNum, ArgObjectType::Sampler).metadata.sampler.coordinateSnapWaRequired = token;
break;
case DATA_PARAMETER_SAMPLER_ADDRESS_MODE:
getKernelArg(out, argNum, ArgObjectType::Sampler).metadata.sampler.addressMode = token;
break;
case DATA_PARAMETER_SAMPLER_NORMALIZED_COORDS:
getKernelArg(out, argNum, ArgObjectType::Sampler).metadata.sampler.normalizedCoords = token;
break;
case DATA_PARAMETER_VME_MB_BLOCK_TYPE:
getKernelArg(out, argNum, ArgObjectType::None, ArgObjectTypeSpecialized::Vme).metadataSpecialized.vme.mbBlockType = token;
break;
case DATA_PARAMETER_VME_SUBPIXEL_MODE:
getKernelArg(out, argNum, ArgObjectType::None, ArgObjectTypeSpecialized::Vme).metadataSpecialized.vme.subpixelMode = token;
break;
case DATA_PARAMETER_VME_SAD_ADJUST_MODE:
getKernelArg(out, argNum, ArgObjectType::None, ArgObjectTypeSpecialized::Vme).metadataSpecialized.vme.sadAdjustMode = token;
break;
case DATA_PARAMETER_VME_SEARCH_PATH_TYPE:
getKernelArg(out, argNum, ArgObjectType::None, ArgObjectTypeSpecialized::Vme).metadataSpecialized.vme.searchPathType = token;
break;
case DATA_PARAMETER_PARENT_EVENT:
crossthread.parentEvent = token;
break;
case DATA_PARAMETER_CHILD_BLOCK_SIMD_SIZE:
crossthread.childBlockSimdSize.push_back(token);
break;
case DATA_PARAMETER_PREFERRED_WORKGROUP_MULTIPLE:
crossthread.preferredWorkgroupMultiple = token;
break;
case DATA_PARAMETER_NUM_HARDWARE_THREADS:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_PRINTF_SURFACE_SIZE:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_IMAGE_SRGB_CHANNEL_ORDER:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_STAGE_IN_GRID_ORIGIN:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_STAGE_IN_GRID_SIZE:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_LOCAL_ID:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_EXECUTION_MASK:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_VME_IMAGE_TYPE:
CPP_ATTRIBUTE_FALLTHROUGH;
case DATA_PARAMETER_VME_MB_SKIP_BLOCK_TYPE:
// ignored intentionally
break;
}
}
inline bool decodeToken(const SPatchItemHeader *token, KernelFromPatchtokens &out) {
switch (token->Token) {
default: {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "Unknown kernel-scope Patch Token: %d\n", token->Token);
DEBUG_BREAK_IF(true);
out.unhandledTokens.push_back(token);
break;
}
case PATCH_TOKEN_SAMPLER_STATE_ARRAY:
assignToken(out.tokens.samplerStateArray, token);
break;
case PATCH_TOKEN_BINDING_TABLE_STATE:
assignToken(out.tokens.bindingTableState, token);
break;
case PATCH_TOKEN_ALLOCATE_LOCAL_SURFACE:
assignToken(out.tokens.allocateLocalSurface, token);
break;
case PATCH_TOKEN_MEDIA_VFE_STATE:
assignToken(out.tokens.mediaVfeState[0], token);
break;
case PATCH_TOKEN_MEDIA_VFE_STATE_SLOT1:
assignToken(out.tokens.mediaVfeState[1], token);
break;
case PATCH_TOKEN_MEDIA_INTERFACE_DESCRIPTOR_LOAD:
assignToken(out.tokens.mediaInterfaceDescriptorLoad, token);
break;
case PATCH_TOKEN_INTERFACE_DESCRIPTOR_DATA:
assignToken(out.tokens.interfaceDescriptorData, token);
break;
case PATCH_TOKEN_THREAD_PAYLOAD:
assignToken(out.tokens.threadPayload, token);
break;
case PATCH_TOKEN_EXECUTION_ENVIRONMENT:
assignToken(out.tokens.executionEnvironment, token);
break;
case PATCH_TOKEN_KERNEL_ATTRIBUTES_INFO:
assignToken(out.tokens.kernelAttributesInfo, token);
break;
case PATCH_TOKEN_ALLOCATE_STATELESS_PRIVATE_MEMORY:
assignToken(out.tokens.allocateStatelessPrivateSurface, token);
break;
case PATCH_TOKEN_ALLOCATE_STATELESS_CONSTANT_MEMORY_SURFACE_WITH_INITIALIZATION:
assignToken(out.tokens.allocateStatelessConstantMemorySurfaceWithInitialization, token);
break;
case PATCH_TOKEN_ALLOCATE_STATELESS_GLOBAL_MEMORY_SURFACE_WITH_INITIALIZATION:
assignToken(out.tokens.allocateStatelessGlobalMemorySurfaceWithInitialization, token);
break;
case PATCH_TOKEN_ALLOCATE_STATELESS_PRINTF_SURFACE:
assignToken(out.tokens.allocateStatelessPrintfSurface, token);
break;
case PATCH_TOKEN_ALLOCATE_STATELESS_EVENT_POOL_SURFACE:
assignToken(out.tokens.allocateStatelessEventPoolSurface, token);
break;
case PATCH_TOKEN_ALLOCATE_STATELESS_DEFAULT_DEVICE_QUEUE_SURFACE:
assignToken(out.tokens.allocateStatelessDefaultDeviceQueueSurface, token);
break;
case PATCH_TOKEN_STRING:
assignToken(out.tokens.strings, token);
break;
case PATCH_TOKEN_INLINE_VME_SAMPLER_INFO:
assignToken(out.tokens.inlineVmeSamplerInfo, token);
break;
case PATCH_TOKEN_GTPIN_FREE_GRF_INFO:
assignToken(out.tokens.gtpinFreeGrfInfo, token);
break;
case PATCH_TOKEN_GTPIN_INFO:
assignToken(out.tokens.gtpinInfo, token);
break;
case PATCH_TOKEN_STATE_SIP:
assignToken(out.tokens.stateSip, token);
break;
case PATCH_TOKEN_ALLOCATE_SIP_SURFACE:
assignToken(out.tokens.allocateSystemThreadSurface, token);
break;
case PATCH_TOKEN_PROGRAM_SYMBOL_TABLE:
assignToken(out.tokens.programSymbolTable, token);
break;
case PATCH_TOKEN_PROGRAM_RELOCATION_TABLE:
assignToken(out.tokens.programRelocationTable, token);
break;
case PATCH_TOKEN_KERNEL_ARGUMENT_INFO:
assignArgInfo(out, token);
break;
case PATCH_TOKEN_SAMPLER_KERNEL_ARGUMENT:
CPP_ATTRIBUTE_FALLTHROUGH;
case PATCH_TOKEN_IMAGE_MEMORY_OBJECT_KERNEL_ARGUMENT:
CPP_ATTRIBUTE_FALLTHROUGH;
case PATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
CPP_ATTRIBUTE_FALLTHROUGH;
case PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
CPP_ATTRIBUTE_FALLTHROUGH;
case PATCH_TOKEN_STATELESS_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT:
CPP_ATTRIBUTE_FALLTHROUGH;
case PATCH_TOKEN_STATELESS_DEVICE_QUEUE_KERNEL_ARGUMENT:
assignArg(out, token);
break;
case PATCH_TOKEN_DATA_PARAMETER_STREAM:
assignToken(out.tokens.dataParameterStream, token);
break;
case PATCH_TOKEN_DATA_PARAMETER_BUFFER: {
auto tokDataP = reinterpret_cast<const SPatchDataParameterBuffer *>(token);
decodeKernelDataParameterToken(tokDataP, out);
} break;
}
return out.decodeStatus != DecoderError::InvalidBinary;
}
inline bool decodeToken(const SPatchItemHeader *token, ProgramFromPatchtokens &out) {
auto &progTok = out.programScopeTokens;
switch (token->Token) {
default: {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "Unknown program-scope Patch Token: %d\n", token->Token);
DEBUG_BREAK_IF(true);
out.unhandledTokens.push_back(token);
break;
}
case PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO:
addTok(progTok.allocateConstantMemorySurface, token);
break;
case PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO:
addTok(progTok.allocateGlobalMemorySurface, token);
break;
case PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO:
addTok(progTok.globalPointer, token);
break;
case PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO:
addTok(progTok.constantPointer, token);
break;
case PATCH_TOKEN_PROGRAM_SYMBOL_TABLE:
assignToken(progTok.symbolTable, token);
break;
}
return true;
}
template <typename DecodeContext>
inline size_t getPatchTokenTotalSize(PatchTokensStreamReader stream, const SPatchItemHeader *token);
template <>
inline size_t getPatchTokenTotalSize<KernelFromPatchtokens>(PatchTokensStreamReader stream, const SPatchItemHeader *token) {
return token->Size;
}
template <>
inline size_t getPatchTokenTotalSize<ProgramFromPatchtokens>(PatchTokensStreamReader stream, const SPatchItemHeader *token) {
size_t tokSize = token->Size;
switch (token->Token) {
default:
return tokSize;
case PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO:
return stream.enoughDataLeft<SPatchAllocateConstantMemorySurfaceProgramBinaryInfo>(token)
? tokSize + reinterpret_cast<const SPatchAllocateConstantMemorySurfaceProgramBinaryInfo *>(token)->InlineDataSize
: std::numeric_limits<size_t>::max();
case PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO:
return stream.enoughDataLeft<SPatchAllocateConstantMemorySurfaceProgramBinaryInfo>(token)
? tokSize + reinterpret_cast<const SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo *>(token)->InlineDataSize
: std::numeric_limits<size_t>::max();
}
}
template <typename OutT>
inline bool decodePatchList(PatchTokensStreamReader patchListStream, OutT &out) {
auto decodePos = patchListStream.data.begin();
auto decodeEnd = patchListStream.data.end();
bool decodeSuccess = true;
while ((decodePos + sizeof(SPatchItemHeader) <= decodeEnd) && decodeSuccess) {
auto token = reinterpret_cast<const SPatchItemHeader *>(decodePos);
size_t tokenTotalSize = getPatchTokenTotalSize<OutT>(patchListStream, token);
decodeSuccess = patchListStream.enoughDataLeft(decodePos, tokenTotalSize);
decodeSuccess = decodeSuccess && (tokenTotalSize > 0U);
decodeSuccess = decodeSuccess && decodeToken(token, out);
decodePos = ptrOffset(decodePos, tokenTotalSize);
}
return decodeSuccess;
}
bool decodeKernelFromPatchtokensBlob(ArrayRef<const uint8_t> data, KernelFromPatchtokens &out) {
PatchTokensStreamReader stream{data};
auto decodePos = stream.data.begin();
out.decodeStatus = DecoderError::Undefined;
if (stream.notEnoughDataLeft<SKernelBinaryHeaderCommon>(decodePos)) {
out.decodeStatus = DecoderError::InvalidBinary;
return false;
}
out.header = reinterpret_cast<const SKernelBinaryHeaderCommon *>(decodePos);
auto kernelInfoBlobSize = sizeof(SKernelBinaryHeaderCommon) + out.header->KernelNameSize + out.header->KernelHeapSize + out.header->GeneralStateHeapSize + out.header->DynamicStateHeapSize + out.header->SurfaceStateHeapSize + out.header->PatchListSize;
if (stream.notEnoughDataLeft(decodePos, kernelInfoBlobSize)) {
out.decodeStatus = DecoderError::InvalidBinary;
return false;
}
out.blobs.kernelInfo = ArrayRef<const uint8_t>(stream.data.begin(), kernelInfoBlobSize);
decodePos = ptrOffset(decodePos, sizeof(SKernelBinaryHeaderCommon));
auto kernelName = reinterpret_cast<const char *>(decodePos);
out.name = ArrayRef<const char>(kernelName, out.header->KernelNameSize);
decodePos = ptrOffset(decodePos, out.name.size());
out.isa = ArrayRef<const uint8_t>(decodePos, out.header->KernelHeapSize);
decodePos = ptrOffset(decodePos, out.isa.size());
out.heaps.generalState = ArrayRef<const uint8_t>(decodePos, out.header->GeneralStateHeapSize);
decodePos = ptrOffset(decodePos, out.heaps.generalState.size());
out.heaps.dynamicState = ArrayRef<const uint8_t>(decodePos, out.header->DynamicStateHeapSize);
decodePos = ptrOffset(decodePos, out.heaps.dynamicState.size());
out.heaps.surfaceState = ArrayRef<const uint8_t>(decodePos, out.header->SurfaceStateHeapSize);
decodePos = ptrOffset(decodePos, out.heaps.surfaceState.size());
out.blobs.patchList = ArrayRef<const uint8_t>(decodePos, out.header->PatchListSize);
if (false == decodePatchList(out.blobs.patchList, out)) {
out.decodeStatus = DecoderError::InvalidBinary;
return false;
}
out.decodeStatus = DecoderError::Success;
return true;
}
inline bool decodeProgramHeader(ProgramFromPatchtokens &decodedProgram) {
auto decodePos = decodedProgram.blobs.programInfo.begin();
PatchTokensStreamReader stream{decodedProgram.blobs.programInfo};
if (stream.notEnoughDataLeft<SProgramBinaryHeader>(decodePos)) {
return false;
}
decodedProgram.header = reinterpret_cast<const SProgramBinaryHeader *>(decodePos);
if (decodedProgram.header->Magic != MAGIC_CL) {
return false;
}
decodePos = ptrOffset(decodePos, sizeof(SProgramBinaryHeader));
if (stream.notEnoughDataLeft(decodePos, decodedProgram.header->PatchListSize)) {
return false;
}
decodedProgram.blobs.patchList = ArrayRef<const uint8_t>(decodePos, decodedProgram.header->PatchListSize);
decodePos = ptrOffset(decodePos, decodedProgram.blobs.patchList.size());
decodedProgram.blobs.kernelsInfo = ArrayRef<const uint8_t>(decodePos, stream.getDataSizeLeft(decodePos));
return true;
}
inline bool decodeKernels(ProgramFromPatchtokens &decodedProgram) {
auto numKernels = decodedProgram.header->NumberOfKernels;
decodedProgram.kernels.reserve(decodedProgram.header->NumberOfKernels);
const uint8_t *decodePos = decodedProgram.blobs.kernelsInfo.begin();
bool decodeSuccess = true;
PatchTokensStreamReader stream{decodedProgram.blobs.kernelsInfo};
for (uint32_t i = 0; (i < numKernels) && decodeSuccess; i++) {
decodedProgram.kernels.resize(decodedProgram.kernels.size() + 1);
auto &currKernelInfo = *decodedProgram.kernels.rbegin();
auto kernelDataLeft = ArrayRef<const uint8_t>(decodePos, stream.getDataSizeLeft(decodePos));
decodeSuccess = decodeKernelFromPatchtokensBlob(kernelDataLeft, currKernelInfo);
decodePos = ptrOffset(decodePos, currKernelInfo.blobs.kernelInfo.size());
}
return decodeSuccess;
}
bool decodeProgramFromPatchtokensBlob(ArrayRef<const uint8_t> blob, ProgramFromPatchtokens &out) {
out.blobs.programInfo = blob;
bool decodeSuccess = decodeProgramHeader(out);
decodeSuccess = decodeSuccess && decodeKernels(out);
decodeSuccess = decodeSuccess && decodePatchList(out.blobs.patchList, out);
out.decodeStatus = decodeSuccess ? DecoderError::Success : DecoderError::InvalidBinary;
return decodeSuccess;
}
uint32_t calcKernelChecksum(const ArrayRef<const uint8_t> kernelBlob) {
UNRECOVERABLE_IF(kernelBlob.size() <= sizeof(SKernelBinaryHeaderCommon));
auto dataToHash = ArrayRef<const uint8_t>(ptrOffset(kernelBlob.begin(), sizeof(SKernelBinaryHeaderCommon)), kernelBlob.end());
uint64_t hashValue = Hash::hash(reinterpret_cast<const char *>(dataToHash.begin()), dataToHash.size());
uint32_t checksum = hashValue & 0xFFFFFFFF;
return checksum;
}
bool hasInvalidChecksum(const KernelFromPatchtokens &decodedKernel) {
uint32_t decodedChecksum = decodedKernel.header->CheckSum;
uint32_t calculatedChecksum = NEO::PatchTokenBinary::calcKernelChecksum(decodedKernel.blobs.kernelInfo);
return decodedChecksum != calculatedChecksum;
}
const KernelArgAttributesFromPatchtokens getInlineData(const SPatchKernelArgumentInfo *ptr) {
KernelArgAttributesFromPatchtokens ret = {};
UNRECOVERABLE_IF(ptr == nullptr);
auto decodePos = reinterpret_cast<const char *>(ptr + 1);
auto bounds = reinterpret_cast<const char *>(ptr) + ptr->Size;
ret.addressQualifier = ArrayRef<const char>(decodePos, std::min(decodePos + ptr->AddressQualifierSize, bounds));
decodePos += ret.addressQualifier.size();
ret.accessQualifier = ArrayRef<const char>(decodePos, std::min(decodePos + ptr->AccessQualifierSize, bounds));
decodePos += ret.accessQualifier.size();
ret.argName = ArrayRef<const char>(decodePos, std::min(decodePos + ptr->ArgumentNameSize, bounds));
decodePos += ret.argName.size();
ret.typeName = ArrayRef<const char>(decodePos, std::min(decodePos + ptr->TypeNameSize, bounds));
decodePos += ret.typeName.size();
ret.typeQualifiers = ArrayRef<const char>(decodePos, std::min(decodePos + ptr->TypeQualifierSize, bounds));
return ret;
}
} // namespace PatchTokenBinary
} // namespace NEO

View File

@ -0,0 +1,213 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/helpers/ptr_math.h"
#include "core/utilities/arrayref.h"
#include "core/utilities/stackvec.h"
#include "patch_g7.h"
#include "patch_list.h"
#include "patch_shared.h"
#include "program_debug_data.h"
#include <limits>
#include <memory>
namespace NEO {
namespace PatchTokenBinary {
using namespace iOpenCL;
enum class DecoderError {
Success = 0,
Undefined = 1,
InvalidBinary = 2,
};
enum class ArgObjectType : uint32_t {
None = 0,
Buffer,
Image,
Sampler,
Slm
};
enum class ArgObjectTypeSpecialized : uint32_t {
None = 0,
Vme
};
using StackVecUnhandledTokens = StackVec<const SPatchItemHeader *, 4>;
using StackVecByValMap = StackVec<const SPatchDataParameterBuffer *, 8>;
using StackVecStrings = StackVec<const SPatchString *, 4>;
struct KernelArgFromPatchtokens {
const SPatchKernelArgumentInfo *argInfo = nullptr;
const SPatchItemHeader *objectArg = nullptr;
const SPatchDataParameterBuffer *objectId = nullptr;
ArgObjectType objectType = ArgObjectType::None;
ArgObjectTypeSpecialized objectTypeSpecialized = ArgObjectTypeSpecialized::None;
StackVecByValMap byValMap;
union {
struct {
const SPatchDataParameterBuffer *width;
const SPatchDataParameterBuffer *height;
const SPatchDataParameterBuffer *depth;
const SPatchDataParameterBuffer *channelDataType;
const SPatchDataParameterBuffer *channelOrder;
const SPatchDataParameterBuffer *arraySize;
const SPatchDataParameterBuffer *numSamples;
const SPatchDataParameterBuffer *numMipLevels;
} image;
struct {
const SPatchDataParameterBuffer *bufferOffset;
const SPatchDataParameterBuffer *pureStateful;
} buffer;
struct {
const SPatchDataParameterBuffer *coordinateSnapWaRequired;
const SPatchDataParameterBuffer *addressMode;
const SPatchDataParameterBuffer *normalizedCoords;
} sampler;
struct {
const SPatchDataParameterBuffer *token;
} slm;
static_assert((sizeof(image) > sizeof(buffer)) && (sizeof(image) > sizeof(sampler)) && (sizeof(image) > sizeof(slm)),
"Union initialization based on image wont' initialize whole struct");
} metadata = {};
union {
struct {
const SPatchDataParameterBuffer *mbBlockType;
const SPatchDataParameterBuffer *subpixelMode;
const SPatchDataParameterBuffer *sadAdjustMode;
const SPatchDataParameterBuffer *searchPathType;
} vme;
} metadataSpecialized = {};
};
using StackVecKernelArgs = StackVec<KernelArgFromPatchtokens, 12>;
struct KernelFromPatchtokens {
DecoderError decodeStatus = DecoderError::Undefined;
const SKernelBinaryHeaderCommon *header = nullptr;
ArrayRef<const char> name;
ArrayRef<const uint8_t> isa;
struct {
ArrayRef<const uint8_t> generalState;
ArrayRef<const uint8_t> dynamicState;
ArrayRef<const uint8_t> surfaceState;
} heaps;
struct {
ArrayRef<const uint8_t> kernelInfo;
ArrayRef<const uint8_t> patchList;
} blobs;
struct {
const SPatchSamplerStateArray *samplerStateArray = nullptr;
const SPatchBindingTableState *bindingTableState = nullptr;
const SPatchAllocateLocalSurface *allocateLocalSurface = nullptr;
const SPatchMediaVFEState *mediaVfeState[2] = {nullptr, nullptr};
const SPatchMediaInterfaceDescriptorLoad *mediaInterfaceDescriptorLoad = nullptr;
const SPatchInterfaceDescriptorData *interfaceDescriptorData = nullptr;
const SPatchThreadPayload *threadPayload = nullptr;
const SPatchExecutionEnvironment *executionEnvironment = nullptr;
const SPatchDataParameterStream *dataParameterStream = nullptr;
const SPatchKernelAttributesInfo *kernelAttributesInfo = nullptr;
const SPatchAllocateStatelessPrivateSurface *allocateStatelessPrivateSurface = nullptr;
const SPatchAllocateStatelessConstantMemorySurfaceWithInitialization *allocateStatelessConstantMemorySurfaceWithInitialization = nullptr;
const SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization *allocateStatelessGlobalMemorySurfaceWithInitialization = nullptr;
const SPatchAllocateStatelessPrintfSurface *allocateStatelessPrintfSurface = nullptr;
const SPatchAllocateStatelessEventPoolSurface *allocateStatelessEventPoolSurface = nullptr;
const SPatchAllocateStatelessDefaultDeviceQueueSurface *allocateStatelessDefaultDeviceQueueSurface = nullptr;
const SPatchItemHeader *inlineVmeSamplerInfo = nullptr;
const SPatchGtpinFreeGRFInfo *gtpinFreeGrfInfo = nullptr;
const SPatchStateSIP *stateSip = nullptr;
const SPatchAllocateSystemThreadSurface *allocateSystemThreadSurface = nullptr;
const SPatchItemHeader *gtpinInfo = nullptr;
const SPatchFunctionTableInfo *programSymbolTable = nullptr;
const SPatchFunctionTableInfo *programRelocationTable = nullptr;
StackVecKernelArgs kernelArgs;
StackVecStrings strings;
struct {
const SPatchDataParameterBuffer *localWorkSize[3] = {};
const SPatchDataParameterBuffer *localWorkSize2[3] = {};
const SPatchDataParameterBuffer *enqueuedLocalWorkSize[3] = {};
const SPatchDataParameterBuffer *numWorkGroups[3] = {};
const SPatchDataParameterBuffer *globalWorkOffset[3] = {};
const SPatchDataParameterBuffer *globalWorkSize[3] = {};
const SPatchDataParameterBuffer *maxWorkGroupSize = nullptr;
const SPatchDataParameterBuffer *workDimensions = nullptr;
const SPatchDataParameterBuffer *simdSize = nullptr;
const SPatchDataParameterBuffer *parentEvent = nullptr;
const SPatchDataParameterBuffer *privateMemoryStatelessSize = nullptr;
const SPatchDataParameterBuffer *localMemoryStatelessWindowSize = nullptr;
const SPatchDataParameterBuffer *localMemoryStatelessWindowStartAddress = nullptr;
const SPatchDataParameterBuffer *preferredWorkgroupMultiple = nullptr;
StackVec<const SPatchDataParameterBuffer *, 4> childBlockSimdSize;
} crossThreadPayloadArgs;
} tokens;
StackVecUnhandledTokens unhandledTokens;
};
struct ProgramFromPatchtokens {
DecoderError decodeStatus = DecoderError::Undefined;
const SProgramBinaryHeader *header = nullptr;
struct {
ArrayRef<const uint8_t> programInfo;
ArrayRef<const uint8_t> patchList;
ArrayRef<const uint8_t> kernelsInfo;
} blobs;
struct {
StackVec<const SPatchAllocateConstantMemorySurfaceProgramBinaryInfo *, 2> allocateConstantMemorySurface;
StackVec<const SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo *, 2> allocateGlobalMemorySurface;
StackVec<const SPatchConstantPointerProgramBinaryInfo *, 4> constantPointer;
StackVec<const SPatchGlobalPointerProgramBinaryInfo *, 4> globalPointer;
const SPatchFunctionTableInfo *symbolTable = nullptr;
} programScopeTokens;
StackVec<KernelFromPatchtokens, 2> kernels;
StackVec<const SPatchItemHeader *, 4> unhandledTokens;
};
struct KernelArgAttributesFromPatchtokens {
ArrayRef<const char> addressQualifier;
ArrayRef<const char> accessQualifier;
ArrayRef<const char> argName;
ArrayRef<const char> typeName;
ArrayRef<const char> typeQualifiers;
};
bool decodeKernelFromPatchtokensBlob(ArrayRef<const uint8_t> blob, KernelFromPatchtokens &out);
bool decodeProgramFromPatchtokensBlob(ArrayRef<const uint8_t> blob, ProgramFromPatchtokens &out);
uint32_t calcKernelChecksum(const ArrayRef<const uint8_t> kernelBlob);
bool hasInvalidChecksum(const KernelFromPatchtokens &decodedKernel);
inline const uint8_t *getInlineData(const SPatchAllocateConstantMemorySurfaceProgramBinaryInfo *ptr) {
return ptrOffset(reinterpret_cast<const uint8_t *>(ptr), sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo));
}
inline const uint8_t *getInlineData(const SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo *ptr) {
return ptrOffset(reinterpret_cast<const uint8_t *>(ptr), sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo));
}
inline const uint8_t *getInlineData(const SPatchString *ptr) {
return ptrOffset(reinterpret_cast<const uint8_t *>(ptr), sizeof(SPatchString));
}
const KernelArgAttributesFromPatchtokens getInlineData(const SPatchKernelArgumentInfo *ptr);
} // namespace PatchTokenBinary
} // namespace NEO

View File

@ -0,0 +1,889 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "patchtokens_dumper.h"
#include "patchtokens_decoder.h"
#include <sstream>
namespace NEO {
namespace PatchTokenBinary {
#define CASE_TOK_STR(TOK) \
case TOK: \
return std::to_string(TOK) + "(" + #TOK + ")"; \
break;
std::string asString(PATCH_TOKEN token) {
switch (token) {
default:
return std::to_string(token);
CASE_TOK_STR(PATCH_TOKEN_UNKNOWN);
CASE_TOK_STR(PATCH_TOKEN_MEDIA_STATE_POINTERS);
CASE_TOK_STR(PATCH_TOKEN_STATE_SIP);
CASE_TOK_STR(PATCH_TOKEN_CS_URB_STATE);
CASE_TOK_STR(PATCH_TOKEN_CONSTANT_BUFFER);
CASE_TOK_STR(PATCH_TOKEN_SAMPLER_STATE_ARRAY);
CASE_TOK_STR(PATCH_TOKEN_INTERFACE_DESCRIPTOR);
CASE_TOK_STR(PATCH_TOKEN_VFE_STATE);
CASE_TOK_STR(PATCH_TOKEN_BINDING_TABLE_STATE);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_SCRATCH_SURFACE);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_SIP_SURFACE);
CASE_TOK_STR(PATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT);
CASE_TOK_STR(PATCH_TOKEN_IMAGE_MEMORY_OBJECT_KERNEL_ARGUMENT);
CASE_TOK_STR(PATCH_TOKEN_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_SURFACE_WITH_INITIALIZATION);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_LOCAL_SURFACE);
CASE_TOK_STR(PATCH_TOKEN_SAMPLER_KERNEL_ARGUMENT);
CASE_TOK_STR(PATCH_TOKEN_DATA_PARAMETER_BUFFER);
CASE_TOK_STR(PATCH_TOKEN_MEDIA_VFE_STATE);
CASE_TOK_STR(PATCH_TOKEN_MEDIA_INTERFACE_DESCRIPTOR_LOAD);
CASE_TOK_STR(PATCH_TOKEN_MEDIA_CURBE_LOAD);
CASE_TOK_STR(PATCH_TOKEN_INTERFACE_DESCRIPTOR_DATA);
CASE_TOK_STR(PATCH_TOKEN_THREAD_PAYLOAD);
CASE_TOK_STR(PATCH_TOKEN_EXECUTION_ENVIRONMENT);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_PRIVATE_MEMORY);
CASE_TOK_STR(PATCH_TOKEN_DATA_PARAMETER_STREAM);
CASE_TOK_STR(PATCH_TOKEN_KERNEL_ARGUMENT_INFO);
CASE_TOK_STR(PATCH_TOKEN_KERNEL_ATTRIBUTES_INFO);
CASE_TOK_STR(PATCH_TOKEN_STRING);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_PRINTF_SURFACE);
CASE_TOK_STR(PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT);
CASE_TOK_STR(PATCH_TOKEN_STATELESS_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_SURFACE_WITH_INITIALIZATION);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_PRINTF_SURFACE);
CASE_TOK_STR(PATCH_TOKEN_CB_MAPPING);
CASE_TOK_STR(PATCH_TOKEN_CB2CR_GATHER_TABLE);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_EVENT_POOL_SURFACE);
CASE_TOK_STR(PATCH_TOKEN_NULL_SURFACE_LOCATION);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_PRIVATE_MEMORY);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_WITH_INITIALIZATION);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_WITH_INITIALIZATION);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_GLOBAL_MEMORY_SURFACE_WITH_INITIALIZATION);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_CONSTANT_MEMORY_SURFACE_WITH_INITIALIZATION);
CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_DEFAULT_DEVICE_QUEUE_SURFACE);
CASE_TOK_STR(PATCH_TOKEN_STATELESS_DEVICE_QUEUE_KERNEL_ARGUMENT);
CASE_TOK_STR(PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO);
CASE_TOK_STR(PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO);
CASE_TOK_STR(PATCH_TOKEN_CONSTRUCTOR_DESTRUCTOR_KERNEL_PROGRAM_BINARY_INFO);
CASE_TOK_STR(PATCH_TOKEN_INLINE_VME_SAMPLER_INFO);
CASE_TOK_STR(PATCH_TOKEN_GTPIN_FREE_GRF_INFO);
CASE_TOK_STR(PATCH_TOKEN_GTPIN_INFO);
CASE_TOK_STR(PATCH_TOKEN_PROGRAM_SYMBOL_TABLE);
CASE_TOK_STR(PATCH_TOKEN_PROGRAM_RELOCATION_TABLE);
CASE_TOK_STR(PATCH_TOKEN_MEDIA_VFE_STATE_SLOT1);
}
}
std::string asString(DATA_PARAMETER_TOKEN dataParameter) {
switch (dataParameter) {
default:
return std::to_string(dataParameter);
CASE_TOK_STR(DATA_PARAMETER_TOKEN_UNKNOWN);
CASE_TOK_STR(DATA_PARAMETER_KERNEL_ARGUMENT);
CASE_TOK_STR(DATA_PARAMETER_LOCAL_WORK_SIZE);
CASE_TOK_STR(DATA_PARAMETER_GLOBAL_WORK_SIZE);
CASE_TOK_STR(DATA_PARAMETER_NUM_WORK_GROUPS);
CASE_TOK_STR(DATA_PARAMETER_WORK_DIMENSIONS);
CASE_TOK_STR(DATA_PARAMETER_LOCAL_ID);
CASE_TOK_STR(DATA_PARAMETER_EXECUTION_MASK);
CASE_TOK_STR(DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_WIDTH);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_HEIGHT);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_DEPTH);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_CHANNEL_DATA_TYPE);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_CHANNEL_ORDER);
CASE_TOK_STR(DATA_PARAMETER_SAMPLER_ADDRESS_MODE);
CASE_TOK_STR(DATA_PARAMETER_SAMPLER_NORMALIZED_COORDS);
CASE_TOK_STR(DATA_PARAMETER_GLOBAL_WORK_OFFSET);
CASE_TOK_STR(DATA_PARAMETER_NUM_HARDWARE_THREADS);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_ARRAY_SIZE);
CASE_TOK_STR(DATA_PARAMETER_PRINTF_SURFACE_SIZE);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_NUM_SAMPLES);
CASE_TOK_STR(DATA_PARAMETER_SAMPLER_COORDINATE_SNAP_WA_REQUIRED);
CASE_TOK_STR(DATA_PARAMETER_PARENT_EVENT);
CASE_TOK_STR(DATA_PARAMETER_VME_MB_BLOCK_TYPE);
CASE_TOK_STR(DATA_PARAMETER_VME_SUBPIXEL_MODE);
CASE_TOK_STR(DATA_PARAMETER_VME_SAD_ADJUST_MODE);
CASE_TOK_STR(DATA_PARAMETER_VME_SEARCH_PATH_TYPE);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_NUM_MIP_LEVELS);
CASE_TOK_STR(DATA_PARAMETER_ENQUEUED_LOCAL_WORK_SIZE);
CASE_TOK_STR(DATA_PARAMETER_MAX_WORKGROUP_SIZE);
CASE_TOK_STR(DATA_PARAMETER_PREFERRED_WORKGROUP_MULTIPLE);
CASE_TOK_STR(DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS);
CASE_TOK_STR(DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_SIZE);
CASE_TOK_STR(DATA_PARAMETER_PRIVATE_MEMORY_STATELESS_SIZE);
CASE_TOK_STR(DATA_PARAMETER_SIMD_SIZE);
CASE_TOK_STR(DATA_PARAMETER_OBJECT_ID);
CASE_TOK_STR(DATA_PARAMETER_VME_IMAGE_TYPE);
CASE_TOK_STR(DATA_PARAMETER_VME_MB_SKIP_BLOCK_TYPE);
CASE_TOK_STR(DATA_PARAMETER_CHILD_BLOCK_SIMD_SIZE);
CASE_TOK_STR(DATA_PARAMETER_IMAGE_SRGB_CHANNEL_ORDER);
CASE_TOK_STR(DATA_PARAMETER_STAGE_IN_GRID_ORIGIN);
CASE_TOK_STR(DATA_PARAMETER_STAGE_IN_GRID_SIZE);
CASE_TOK_STR(DATA_PARAMETER_BUFFER_OFFSET);
CASE_TOK_STR(DATA_PARAMETER_BUFFER_STATEFUL);
}
}
#undef CASE_TOK_STR
void dump(const SProgramBinaryHeader &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SProgramBinaryHeader {\n";
out << indent << " uint32_t Magic; // = " << value.Magic << "\n";
out << indent << " uint32_t Version; // = " << value.Version << "\n";
out << indent << "\n";
out << indent << " uint32_t Device; // = " << value.Device << "\n";
out << indent << " uint32_t GPUPointerSizeInBytes; // = " << value.GPUPointerSizeInBytes << "\n";
out << indent << "\n";
out << indent << " uint32_t NumberOfKernels; // = " << value.NumberOfKernels << "\n";
out << indent << "\n";
out << indent << " uint32_t SteppingId; // = " << value.SteppingId << "\n";
out << indent << "\n";
out << indent << " uint32_t PatchListSize; // = " << value.PatchListSize << "\n";
out << indent << "};\n";
}
void dump(const SKernelBinaryHeader &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SKernelBinaryHeader {\n";
out << indent << " uint32_t CheckSum;// = " << value.CheckSum << "\n";
out << indent << " uint64_t ShaderHashCode;// = " << value.ShaderHashCode << "\n";
out << indent << " uint32_t KernelNameSize;// = " << value.KernelNameSize << "\n";
out << indent << " uint32_t PatchListSize;// = " << value.PatchListSize << "\n";
out << indent << "};\n";
}
void dump(const SPatchDataParameterBuffer &value, std::stringstream &out, const std::string &indent);
void dump(const SPatchItemHeader &value, std::stringstream &out, const std::string &indent) {
if (value.Token == iOpenCL::PATCH_TOKEN_DATA_PARAMETER_BUFFER) {
dump(static_cast<const SPatchDataParameterBuffer &>(value), out, indent);
return;
}
out << indent << "struct SPatchItemHeader {\n";
out << indent << " uint32_t Token;// = " << asString(static_cast<PATCH_TOKEN>(value.Token)) << "\n";
out << indent << " uint32_t Size;// = " << value.Size << "\n";
out << indent << "};\n";
}
void dumpPatchItemHeaderInline(const SPatchItemHeader &value, std::stringstream &out, const std::string &indent) {
out << "Token=" << asString(static_cast<PATCH_TOKEN>(value.Token)) << ", Size=" << value.Size;
}
void dump(const SPatchGlobalMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchGlobalMemoryObjectKernelArgument :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t LocationIndex;// = " << value.LocationIndex << "\n";
out << indent << " uint32_t LocationIndex2;// = " << value.LocationIndex2 << "\n";
out << indent << " uint32_t IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
out << indent << "}\n";
}
void dump(const SPatchImageMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchImageMemoryObjectKernelArgument :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t Type;// = " << value.Type << "\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t LocationIndex;// = " << value.LocationIndex << "\n";
out << indent << " uint32_t LocationIndex2;// = " << value.LocationIndex2 << "\n";
out << indent << " uint32_t Writeable;// = " << value.Writeable << "\n";
out << indent << " uint32_t Transformable;// = " << value.Transformable << "\n";
out << indent << " uint32_t needBindlessHandle;// = " << value.needBindlessHandle << "\n";
out << indent << " uint32_t IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
out << indent << " uint32_t btiOffset;// = " << value.btiOffset << "\n";
out << indent << "}\n";
}
void dump(const SPatchSamplerKernelArgument &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchSamplerKernelArgument :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t Type;// = " << value.Type << "\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t LocationIndex;// = " << value.LocationIndex << "\n";
out << indent << " uint32_t LocationIndex2;// = " << value.LocationIndex2 << "\n";
out << indent << " uint32_t needBindlessHandle;// = " << value.needBindlessHandle << "\n";
out << indent << " uint32_t TextureMask;// = " << value.TextureMask << "\n";
out << indent << " uint32_t IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
out << indent << " uint32_t btiOffset;// = " << value.btiOffset << "\n";
out << indent << "}\n";
}
void dump(const SPatchDataParameterBuffer &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchDataParameterBuffer :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Type;// = " << asString(static_cast<DATA_PARAMETER_TOKEN>(value.Type)) << "\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t DataSize;// = " << value.DataSize << "\n";
out << indent << " uint32_t SourceOffset;// = " << value.SourceOffset << "\n";
out << indent << " uint32_t LocationIndex;// = " << value.LocationIndex << "\n";
out << indent << " uint32_t LocationIndex2;// = " << value.LocationIndex2 << "\n";
out << indent << " uint32_t IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
out << indent << "}\n";
}
void dump(const SPatchKernelArgumentInfo &value, std::stringstream &out, const std::string &indent) {
auto toStr = [](ArrayRef<const char> &src) { return std::string(src.begin(), src.end()); };
auto inlineData = getInlineData(&value);
out << indent << "struct SPatchKernelArgumentInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t AddressQualifierSize;// = " << value.AddressQualifierSize << " : [" << toStr(inlineData.addressQualifier) << "]\n";
out << indent << " uint32_t AccessQualifierSize;// = " << value.AccessQualifierSize << " : [" << toStr(inlineData.accessQualifier) << "]\n";
out << indent << " uint32_t ArgumentNameSize;// = " << value.ArgumentNameSize << " : [" << toStr(inlineData.argName) << "]\n";
out << indent << " uint32_t TypeNameSize;// = " << value.TypeNameSize << " : [" << toStr(inlineData.typeName) << "]\n";
out << indent << " uint32_t TypeQualifierSize;// = " << value.TypeQualifierSize << " : [" << toStr(inlineData.typeQualifiers) << "]\n";
out << indent << "}\n";
}
void dump(const SPatchKernelAttributesInfo &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchKernelAttributesInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t AttributesSize;// = " << value.AttributesSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchMediaInterfaceDescriptorLoad &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchMediaInterfaceDescriptorLoad :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t InterfaceDescriptorDataOffset;// = " << value.InterfaceDescriptorDataOffset << "\n";
out << indent << "}\n";
}
void dump(const SPatchInterfaceDescriptorData &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchInterfaceDescriptorData :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t SamplerStateOffset;// = " << value.SamplerStateOffset << "\n";
out << indent << " uint32_t KernelOffset;// = " << value.KernelOffset << "\n";
out << indent << " uint32_t BindingTableOffset;// = " << value.BindingTableOffset << "\n";
out << indent << "}\n";
}
void dump(const SPatchDataParameterStream &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchDataParameterStream :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t DataParameterStreamSize;// = " << value.DataParameterStreamSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchStateSIP &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchStateSIP :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t SystemKernelOffset;// = " << value.SystemKernelOffset << "\n";
out << indent << "}\n";
}
void dump(const SPatchSamplerStateArray &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchSamplerStateArray :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t Count;// = " << value.Count << "\n";
out << indent << " uint32_t BorderColorOffset;// = " << value.BorderColorOffset << "\n";
out << indent << "}\n";
}
void dump(const SPatchBindingTableState &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchBindingTableState :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t Count;// = " << value.Count << "\n";
out << indent << " uint32_t SurfaceStateOffset;// = " << value.SurfaceStateOffset << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateSystemThreadSurface &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateSystemThreadSurface :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t PerThreadSystemThreadSurfaceSize;// = " << value.PerThreadSystemThreadSurfaceSize << "\n";
out << indent << " uint32_t BTI;// = " << value.BTI << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateLocalSurface &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateLocalSurface :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Offset;// = " << value.Offset << "\n";
out << indent << " uint32_t TotalInlineLocalMemorySize;// = " << value.TotalInlineLocalMemorySize << "\n";
out << indent << "}\n";
}
void dump(const SPatchThreadPayload &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchThreadPayload :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t HeaderPresent;// = " << value.HeaderPresent << "\n";
out << indent << " uint32_t LocalIDXPresent;// = " << value.LocalIDXPresent << "\n";
out << indent << " uint32_t LocalIDYPresent;// = " << value.LocalIDYPresent << "\n";
out << indent << " uint32_t LocalIDZPresent;// = " << value.LocalIDZPresent << "\n";
out << indent << " uint32_t LocalIDFlattenedPresent;// = " << value.LocalIDFlattenedPresent << "\n";
out << indent << " uint32_t IndirectPayloadStorage;// = " << value.IndirectPayloadStorage << "\n";
out << indent << " uint32_t UnusedPerThreadConstantPresent;// = " << value.UnusedPerThreadConstantPresent << "\n";
out << indent << " uint32_t GetLocalIDPresent;// = " << value.GetLocalIDPresent << "\n";
out << indent << " uint32_t GetGroupIDPresent;// = " << value.GetGroupIDPresent << "\n";
out << indent << " uint32_t GetGlobalOffsetPresent;// = " << value.GetGlobalOffsetPresent << "\n";
out << indent << " uint32_t StageInGridOriginPresent;// = " << value.StageInGridOriginPresent << "\n";
out << indent << " uint32_t StageInGridSizePresent;// = " << value.StageInGridSizePresent << "\n";
out << indent << " uint32_t OffsetToSkipPerThreadDataLoad;// = " << value.OffsetToSkipPerThreadDataLoad << "\n";
out << indent << " uint32_t OffsetToSkipSetFFIDGP;// = " << value.OffsetToSkipSetFFIDGP << "\n";
out << indent << " uint32_t PassInlineData;// = " << value.PassInlineData << "\n";
out << indent << "}\n";
}
void dump(const SPatchExecutionEnvironment &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchExecutionEnvironment :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t RequiredWorkGroupSizeX;// = " << value.RequiredWorkGroupSizeX << "\n";
out << indent << " uint32_t RequiredWorkGroupSizeY;// = " << value.RequiredWorkGroupSizeY << "\n";
out << indent << " uint32_t RequiredWorkGroupSizeZ;// = " << value.RequiredWorkGroupSizeZ << "\n";
out << indent << " uint32_t LargestCompiledSIMDSize;// = " << value.LargestCompiledSIMDSize << "\n";
out << indent << " uint32_t CompiledSubGroupsNumber;// = " << value.CompiledSubGroupsNumber << "\n";
out << indent << " uint32_t HasBarriers;// = " << value.HasBarriers << "\n";
out << indent << " uint32_t DisableMidThreadPreemption;// = " << value.DisableMidThreadPreemption << "\n";
out << indent << " uint32_t CompiledSIMD8;// = " << value.CompiledSIMD8 << "\n";
out << indent << " uint32_t CompiledSIMD16;// = " << value.CompiledSIMD16 << "\n";
out << indent << " uint32_t CompiledSIMD32;// = " << value.CompiledSIMD32 << "\n";
out << indent << " uint32_t HasDeviceEnqueue;// = " << value.HasDeviceEnqueue << "\n";
out << indent << " uint32_t MayAccessUndeclaredResource;// = " << value.MayAccessUndeclaredResource << "\n";
out << indent << " uint32_t UsesFencesForReadWriteImages;// = " << value.UsesFencesForReadWriteImages << "\n";
out << indent << " uint32_t UsesStatelessSpillFill;// = " << value.UsesStatelessSpillFill << "\n";
out << indent << " uint32_t UsesMultiScratchSpaces;// = " << value.UsesMultiScratchSpaces << "\n";
out << indent << " uint32_t IsCoherent;// = " << value.IsCoherent << "\n";
out << indent << " uint32_t IsInitializer;// = " << value.IsInitializer << "\n";
out << indent << " uint32_t IsFinalizer;// = " << value.IsFinalizer << "\n";
out << indent << " uint32_t SubgroupIndependentForwardProgressRequired;// = " << value.SubgroupIndependentForwardProgressRequired << "\n";
out << indent << " uint32_t CompiledForGreaterThan4GBBuffers;// = " << value.CompiledForGreaterThan4GBBuffers << "\n";
out << indent << " uint32_t NumGRFRequired;// = " << value.NumGRFRequired << "\n";
out << indent << " uint32_t WorkgroupWalkOrderDims;// = " << value.WorkgroupWalkOrderDims << "\n";
out << indent << " uint32_t HasGlobalAtomics;// = " << value.HasGlobalAtomics << "\n";
out << indent << "}\n";
}
void dump(const SPatchString &value, std::stringstream &out, const std::string &indent) {
const char *strBeg = reinterpret_cast<const char *>((&value) + 1);
std::string strValue = std::string(strBeg, strBeg + value.StringSize);
out << indent << "struct SPatchString :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Index;// = " << value.Index << "\n";
out << indent << " uint32_t StringSize;// = " << value.StringSize << " : [" << strValue << "]"
<< "\n";
out << indent << "}\n";
}
void dump(const SPatchStatelessGlobalMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchStatelessGlobalMemoryObjectKernelArgument :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << " uint32_t LocationIndex;// = " << value.LocationIndex << "\n";
out << indent << " uint32_t LocationIndex2;// = " << value.LocationIndex2 << "\n";
out << indent << " uint32_t IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
out << indent << "}\n";
}
void dump(const SPatchStatelessConstantMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchStatelessConstantMemoryObjectKernelArgument :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << " uint32_t LocationIndex;// = " << value.LocationIndex << "\n";
out << indent << " uint32_t LocationIndex2;// = " << value.LocationIndex2 << "\n";
out << indent << " uint32_t IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t GlobalBufferIndex;// = " << value.GlobalBufferIndex << "\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateStatelessConstantMemorySurfaceWithInitialization &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateStatelessConstantMemorySurfaceWithInitialization :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ConstantBufferIndex;// = " << value.ConstantBufferIndex << "\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t Type;// = " << value.Type << "\n";
out << indent << " uint32_t GlobalBufferIndex;// = " << value.GlobalBufferIndex << "\n";
out << indent << " uint32_t InlineDataSize;// = " << value.InlineDataSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateConstantMemorySurfaceProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateConstantMemorySurfaceProgramBinaryInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ConstantBufferIndex;// = " << value.ConstantBufferIndex << "\n";
out << indent << " uint32_t InlineDataSize;// = " << value.InlineDataSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchGlobalPointerProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchGlobalPointerProgramBinaryInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t GlobalBufferIndex;// = " << value.GlobalBufferIndex << "\n";
out << indent << " uint64_t GlobalPointerOffset;// = " << value.GlobalPointerOffset << "\n";
out << indent << " uint32_t BufferType;// = " << value.BufferType << "\n";
out << indent << " uint32_t BufferIndex;// = " << value.BufferIndex << "\n";
out << indent << "}\n";
}
void dump(const SPatchConstantPointerProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchConstantPointerProgramBinaryInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ConstantBufferIndex;// = " << value.ConstantBufferIndex << "\n";
out << indent << " uint64_t ConstantPointerOffset;// = " << value.ConstantPointerOffset << "\n";
out << indent << " uint32_t BufferType;// = " << value.BufferType << "\n";
out << indent << " uint32_t BufferIndex;// = " << value.BufferIndex << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateStatelessPrintfSurface &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateStatelessPrintfSurface :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t PrintfSurfaceIndex;// = " << value.PrintfSurfaceIndex << "\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateStatelessPrivateSurface &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateStatelessPrivateSurface :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << " uint32_t PerThreadPrivateMemorySize;// = " << value.PerThreadPrivateMemorySize << "\n";
out << indent << "}\n";
}
void dump(const SPatchMediaVFEState &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchMediaVFEState :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ScratchSpaceOffset;// = " << value.ScratchSpaceOffset << "\n";
out << indent << " uint32_t PerThreadScratchSpace;// = " << value.PerThreadScratchSpace << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateStatelessEventPoolSurface &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateStatelessEventPoolSurface :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t EventPoolSurfaceIndex;// = " << value.EventPoolSurfaceIndex << "\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchAllocateStatelessDefaultDeviceQueueSurface &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchAllocateStatelessDefaultDeviceQueueSurface :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchStatelessDeviceQueueKernelArgument &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchStatelessDeviceQueueKernelArgument :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
out << indent << " uint32_t SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
out << indent << " uint32_t DataParamOffset;// = " << value.DataParamOffset << "\n";
out << indent << " uint32_t DataParamSize;// = " << value.DataParamSize << "\n";
out << indent << " uint32_t LocationIndex;// = " << value.LocationIndex << "\n";
out << indent << " uint32_t LocationIndex2;// = " << value.LocationIndex2 << "\n";
out << indent << " uint32_t IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
out << indent << "}\n";
}
void dump(const SPatchGtpinFreeGRFInfo &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchGtpinFreeGRFInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t BufferSize;// = " << value.BufferSize << "\n";
out << indent << "}\n";
}
void dump(const SPatchFunctionTableInfo &value, std::stringstream &out, const std::string &indent) {
out << indent << "struct SPatchFunctionTableInfo :\n";
out << indent << " SPatchItemHeader (";
dumpPatchItemHeaderInline(value, out, "");
out << ")\n"
<< indent << "{\n";
out << indent << " uint32_t NumEntries;// = " << value.NumEntries << "\n";
out << indent << "}\n";
}
template <typename T>
void dumpOrNull(const T *value, const std::string &messageIfNull, std::stringstream &out, const std::string &indent) {
if (value == nullptr) {
if (messageIfNull.empty() == false) {
out << indent << messageIfNull;
}
return;
}
dump(*value, out, indent);
}
template <typename T>
void dumpOrNullObjArg(const T *value, std::stringstream &out, const std::string &indent) {
if (value == nullptr) {
return;
}
switch (value->Token) {
default:
UNRECOVERABLE_IF(value->Token != PATCH_TOKEN_SAMPLER_KERNEL_ARGUMENT);
dumpOrNull(reinterpret_cast<const SPatchSamplerKernelArgument *>(value), "", out, indent);
break;
case PATCH_TOKEN_IMAGE_MEMORY_OBJECT_KERNEL_ARGUMENT:
dumpOrNull(reinterpret_cast<const SPatchImageMemoryObjectKernelArgument *>(value), "", out, indent);
break;
case PATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
dumpOrNull(reinterpret_cast<const SPatchGlobalMemoryObjectKernelArgument *>(value), "", out, indent);
break;
case PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
dumpOrNull(reinterpret_cast<const SPatchStatelessGlobalMemoryObjectKernelArgument *>(value), "", out, indent);
break;
case PATCH_TOKEN_STATELESS_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT:
dumpOrNull(reinterpret_cast<const SPatchStatelessConstantMemoryObjectKernelArgument *>(value), "", out, indent);
break;
case PATCH_TOKEN_STATELESS_DEVICE_QUEUE_KERNEL_ARGUMENT:
dumpOrNull(reinterpret_cast<const SPatchStatelessDeviceQueueKernelArgument *>(value), "", out, indent);
break;
}
}
template <typename T, size_t Size>
void dumpOrNullArrayIfNotEmpty(T (&value)[Size], const std::string &arrayName, std::stringstream &out, const std::string &indent) {
bool allEmpty = true;
for (size_t i = 0; i < Size; ++i) {
allEmpty = allEmpty && (value[i] == nullptr);
}
if (allEmpty) {
return;
}
out << indent << arrayName << " [" << Size << "] :\n";
for (size_t i = 0; i < Size; ++i) {
if (value[i] == nullptr) {
continue;
}
out << indent << " + [" << i << "]:\n";
dump(*value[i], out, indent + " | ");
}
}
template <typename T>
void dumpVecIfNotEmpty(const T &vector, const std::string &vectorName, std::stringstream &out, const std::string &indent) {
if (vector.size() == 0) {
return;
}
out << indent << vectorName << " [" << vector.size() << "] :\n";
for (size_t i = 0; i < vector.size(); ++i) {
out << indent << " + [" << i << "]:\n";
dumpOrNull(vector[i], "DECODER INTERNAL ERROR\n", out, indent + " | ");
}
}
const char *asString(DecoderError err) {
switch (err) {
default:
DEBUG_BREAK_IF(err != DecoderError::InvalidBinary);
return "with invalid binary";
break;
case DecoderError::Success:
return "decoded successfully";
break;
case DecoderError::Undefined:
return "in undefined status";
break;
}
}
std::string asString(const ProgramFromPatchtokens &prog) {
std::stringstream stream;
stream << "Program of size : " << prog.blobs.programInfo.size()
<< " " << asString(prog.decodeStatus) << "\n";
dumpOrNull(prog.header, "WARNING : Program header is missing\n", stream, "");
stream << "Program-scope tokens section size : " << prog.blobs.patchList.size() << "\n";
dumpVecIfNotEmpty(prog.unhandledTokens, "WARNING : Unhandled program-scope tokens detected", stream, " ");
dumpVecIfNotEmpty(prog.programScopeTokens.allocateConstantMemorySurface, "Inline Costant Surface(s)", stream, " ");
dumpVecIfNotEmpty(prog.programScopeTokens.constantPointer, "Inline Costant Surface - self relocations", stream, " ");
dumpVecIfNotEmpty(prog.programScopeTokens.allocateGlobalMemorySurface, "Inline Global Variable Surface(s)", stream, " ");
dumpVecIfNotEmpty(prog.programScopeTokens.globalPointer, "Inline Global Variable Surface - self relocations", stream, " ");
dumpOrNull(prog.programScopeTokens.symbolTable, "", stream, " ");
stream << "Kernels section size : " << prog.blobs.kernelsInfo.size() << "\n";
for (size_t i = 0; i < prog.kernels.size(); ++i) {
stream << "kernel[" << i << "] " << (prog.kernels[i].name.size() > 0 ? std::string(prog.kernels[i].name.begin(), prog.kernels[i].name.end()).c_str() : "<UNNAMED>") << ":\n";
stream << asString(prog.kernels[i]);
}
return stream.str();
}
std::string asString(const KernelFromPatchtokens &kern) {
std::stringstream stream;
std::string indentLevel1 = " ";
stream << "Kernel of size : " << kern.blobs.kernelInfo.size() << " "
<< " " << asString(kern.decodeStatus) << "\n";
dumpOrNull(kern.header, "WARNING : Kernel header is missing\n", stream, "");
stream << "Kernel-scope tokens section size : " << kern.blobs.patchList.size() << "\n";
dumpVecIfNotEmpty(kern.unhandledTokens, "WARNING : Unhandled kernel-scope tokens detected", stream, indentLevel1);
dumpOrNull(kern.tokens.executionEnvironment, "", stream, indentLevel1);
dumpOrNull(kern.tokens.threadPayload, "", stream, indentLevel1);
dumpOrNull(kern.tokens.samplerStateArray, "", stream, indentLevel1);
dumpOrNull(kern.tokens.bindingTableState, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateLocalSurface, "", stream, indentLevel1);
dumpOrNullArrayIfNotEmpty(kern.tokens.mediaVfeState, "mediaVfeState", stream, indentLevel1);
dumpOrNull(kern.tokens.mediaInterfaceDescriptorLoad, "", stream, indentLevel1);
dumpOrNull(kern.tokens.interfaceDescriptorData, "", stream, indentLevel1);
dumpOrNull(kern.tokens.kernelAttributesInfo, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateStatelessPrivateSurface, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateStatelessConstantMemorySurfaceWithInitialization, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateStatelessGlobalMemorySurfaceWithInitialization, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateStatelessPrintfSurface, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateStatelessEventPoolSurface, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateStatelessDefaultDeviceQueueSurface, "", stream, indentLevel1);
dumpOrNull(kern.tokens.inlineVmeSamplerInfo, "", stream, indentLevel1);
dumpOrNull(kern.tokens.gtpinFreeGrfInfo, "", stream, indentLevel1);
dumpOrNull(kern.tokens.stateSip, "", stream, indentLevel1);
dumpOrNull(kern.tokens.allocateSystemThreadSurface, "", stream, indentLevel1);
dumpOrNull(kern.tokens.gtpinInfo, "", stream, indentLevel1);
dumpOrNull(kern.tokens.programSymbolTable, "", stream, indentLevel1);
dumpOrNull(kern.tokens.programRelocationTable, "", stream, indentLevel1);
dumpOrNull(kern.tokens.dataParameterStream, "", stream, indentLevel1);
dumpVecIfNotEmpty(kern.tokens.strings, "String literals", stream, indentLevel1);
dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.localWorkSize, "localWorkSize", stream, indentLevel1);
dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.localWorkSize2, "localWorkSize2", stream, indentLevel1);
dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.enqueuedLocalWorkSize, "enqueuedLocalWorkSize", stream, indentLevel1);
dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.numWorkGroups, "numWorkGroups", stream, indentLevel1);
dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.globalWorkOffset, "globalWorkOffset", stream, indentLevel1);
dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.globalWorkSize, "globalWorkSize", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.maxWorkGroupSize, "", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.workDimensions, "", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.simdSize, "", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.parentEvent, "", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.privateMemoryStatelessSize, "", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.localMemoryStatelessWindowSize, "", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.localMemoryStatelessWindowStartAddress, "", stream, indentLevel1);
dumpOrNull(kern.tokens.crossThreadPayloadArgs.preferredWorkgroupMultiple, "", stream, indentLevel1);
dumpVecIfNotEmpty(kern.tokens.crossThreadPayloadArgs.childBlockSimdSize, "Child block simd size(s)", stream, indentLevel1);
if (kern.tokens.kernelArgs.size() != 0) {
stream << "Kernel arguments [" << kern.tokens.kernelArgs.size() << "] :\n";
for (size_t i = 0; i < kern.tokens.kernelArgs.size(); ++i) {
stream << " + kernelArg[" << i << "]:\n";
stream << asString(kern.tokens.kernelArgs[i], indentLevel1 + "| ");
}
}
return stream.str();
}
std::string asString(ArgObjectType type, ArgObjectTypeSpecialized typeSpecialized) {
std::string typeAsStr;
switch (type) {
default:
UNRECOVERABLE_IF(ArgObjectType::None != type);
return "unspecified";
case ArgObjectType::Buffer:
typeAsStr = "BUFFER";
break;
case ArgObjectType::Image:
typeAsStr = "IMAGE";
break;
case ArgObjectType::Sampler:
typeAsStr = "SAMPLER";
break;
case ArgObjectType::Slm:
typeAsStr = "SLM";
break;
}
switch (typeSpecialized) {
default:
UNRECOVERABLE_IF(ArgObjectTypeSpecialized::None != typeSpecialized);
break;
case ArgObjectTypeSpecialized::Vme:
typeAsStr += " [ VME ]";
}
return typeAsStr;
}
std::string asString(const KernelArgFromPatchtokens &arg, const std::string &indent) {
std::stringstream stream;
stream << indent << "Kernel argument of type " << asString(arg.objectType, arg.objectTypeSpecialized) << "\n";
std::string indentLevel1 = indent + " ";
std::string indentLevel2 = indentLevel1 + " ";
dumpOrNull(arg.argInfo, "", stream, indentLevel1);
dumpOrNullObjArg(arg.objectArg, stream, indentLevel1);
dumpOrNull(arg.objectId, "", stream, indentLevel1);
switch (arg.objectType) {
default:
break;
case ArgObjectType::Buffer:
stream << indentLevel1 << "Buffer Metadata:\n";
dumpOrNull(arg.metadata.buffer.bufferOffset, "", stream, indentLevel2);
dumpOrNull(arg.metadata.buffer.pureStateful, "", stream, indentLevel2);
break;
case ArgObjectType::Image:
stream << indentLevel1 << "Image Metadata:\n";
dumpOrNull(arg.metadata.image.width, "", stream, indentLevel2);
dumpOrNull(arg.metadata.image.height, "", stream, indentLevel2);
dumpOrNull(arg.metadata.image.depth, "", stream, indentLevel2);
dumpOrNull(arg.metadata.image.channelDataType, "", stream, indentLevel2);
dumpOrNull(arg.metadata.image.channelOrder, "", stream, indentLevel2);
dumpOrNull(arg.metadata.image.arraySize, "", stream, indentLevel2);
dumpOrNull(arg.metadata.image.numSamples, "", stream, indentLevel2);
dumpOrNull(arg.metadata.image.numMipLevels, "", stream, indentLevel2);
break;
case ArgObjectType::Sampler:
stream << indentLevel1 << "Sampler Metadata:\n";
dumpOrNull(arg.metadata.sampler.addressMode, "", stream, indentLevel2);
dumpOrNull(arg.metadata.sampler.coordinateSnapWaRequired, "", stream, indentLevel2);
dumpOrNull(arg.metadata.sampler.normalizedCoords, "", stream, indentLevel2);
break;
case ArgObjectType::Slm:
stream << indentLevel1 << "Slm Metadata:\n";
dumpOrNull(arg.metadata.slm.token, "", stream, indentLevel2);
break;
}
switch (arg.objectTypeSpecialized) {
default:
break;
case ArgObjectTypeSpecialized::Vme:
stream << indentLevel1 << "Vme Metadata:\n";
dumpOrNull(arg.metadataSpecialized.vme.mbBlockType, "", stream, indentLevel2);
dumpOrNull(arg.metadataSpecialized.vme.sadAdjustMode, "", stream, indentLevel2);
dumpOrNull(arg.metadataSpecialized.vme.searchPathType, "", stream, indentLevel2);
dumpOrNull(arg.metadataSpecialized.vme.subpixelMode, "", stream, indentLevel2);
break;
}
dumpVecIfNotEmpty(arg.byValMap, " Data passed by value ", stream, indentLevel1);
return stream.str();
}
} // namespace PatchTokenBinary
} // namespace NEO

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <string>
namespace NEO {
namespace PatchTokenBinary {
struct ProgramFromPatchtokens;
struct KernelFromPatchtokens;
struct KernelArgFromPatchtokens;
std::string asString(const ProgramFromPatchtokens &prog);
std::string asString(const KernelFromPatchtokens &kern);
std::string asString(const KernelArgFromPatchtokens &arg, const std::string &indent);
} // namespace PatchTokenBinary
} // namespace NEO

View File

@ -0,0 +1,130 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/helpers/hw_info.h"
#include "igfxfmid.h"
#include <string>
namespace NEO {
namespace PatchTokenBinary {
enum class ValidatorError {
Success = 0,
Undefined = 1,
InvalidBinary = 2,
NotEnoughSlm = 3,
};
constexpr bool isDeviceSupported(GFXCORE_FAMILY device) {
return (device < (sizeof(familyEnabled) / sizeof(familyEnabled[0]))) && familyEnabled[device];
}
template <typename UknownTokenValidatorT>
inline ValidatorError validate(const ProgramFromPatchtokens &decodedProgram,
size_t sharedLocalMemorySize,
const UknownTokenValidatorT &tokenValidator,
std::string &outErrReason, std::string &outWarnings) {
if (decodedProgram.decodeStatus != PatchTokenBinary::DecoderError::Success) {
outErrReason = "ProgramFromPatchtokens wasn't successfully decoded";
return ValidatorError::InvalidBinary;
}
if (decodedProgram.programScopeTokens.allocateConstantMemorySurface.size() > 1) {
outErrReason = "Unhandled number of global constants surfaces > 1";
return ValidatorError::InvalidBinary;
}
if (decodedProgram.programScopeTokens.allocateGlobalMemorySurface.size() > 1) {
outErrReason = "Unhandled number of global variables surfaces > 1";
return ValidatorError::InvalidBinary;
}
for (const auto &globalConstantPointerToken : decodedProgram.programScopeTokens.constantPointer) {
bool isUnhandled = (globalConstantPointerToken->ConstantBufferIndex != 0);
isUnhandled |= (globalConstantPointerToken->BufferIndex != 0);
isUnhandled |= (globalConstantPointerToken->BufferType != PROGRAM_SCOPE_CONSTANT_BUFFER);
isUnhandled |= (0 == decodedProgram.programScopeTokens.allocateConstantMemorySurface.size()) || decodedProgram.programScopeTokens.allocateConstantMemorySurface[0]->InlineDataSize < globalConstantPointerToken->ConstantPointerOffset + sizeof(uint32_t);
if (isUnhandled) {
outErrReason = "Unhandled SPatchConstantPointerProgramBinaryInfo";
return ValidatorError::InvalidBinary;
}
}
for (const auto &globalVariablePointerToken : decodedProgram.programScopeTokens.globalPointer) {
bool isUnhandled = (globalVariablePointerToken->GlobalBufferIndex != 0);
isUnhandled |= (globalVariablePointerToken->BufferIndex != 0);
isUnhandled |= (globalVariablePointerToken->BufferType != PROGRAM_SCOPE_GLOBAL_BUFFER);
isUnhandled |= (0 == decodedProgram.programScopeTokens.allocateGlobalMemorySurface.size()) || decodedProgram.programScopeTokens.allocateGlobalMemorySurface[0]->InlineDataSize < globalVariablePointerToken->GlobalPointerOffset + sizeof(uint32_t);
if (isUnhandled) {
outErrReason = "Unhandled SPatchGlobalPointerProgramBinaryInfo";
return ValidatorError::InvalidBinary;
}
}
for (const auto &unhandledToken : decodedProgram.unhandledTokens) {
if (false == tokenValidator.isSafeToSkipUnhandledToken(unhandledToken->Token)) {
outErrReason = "Unhandled required program-scope Patch Token : " + std::to_string(unhandledToken->Token);
return ValidatorError::InvalidBinary;
} else {
outWarnings = "Unknown program-scope Patch Token : " + std::to_string(unhandledToken->Token);
}
}
UNRECOVERABLE_IF(nullptr == decodedProgram.header);
if (decodedProgram.header->Version != CURRENT_ICBE_VERSION) {
outErrReason = "Unhandled Version of Patchtokens: expected: " + std::to_string(CURRENT_ICBE_VERSION) + ", got: " + std::to_string(decodedProgram.header->Version);
return ValidatorError::InvalidBinary;
}
if (false == isDeviceSupported(static_cast<GFXCORE_FAMILY>(decodedProgram.header->Device))) {
outErrReason = "Unsupported device binary, device GFXCORE_FAMILY : " + std::to_string(decodedProgram.header->Device);
return ValidatorError::InvalidBinary;
}
for (const auto &decodedKernel : decodedProgram.kernels) {
if (decodedKernel.decodeStatus != PatchTokenBinary::DecoderError::Success) {
outErrReason = "KernelFromPatchtokens wasn't successfully decoded";
return ValidatorError::InvalidBinary;
}
UNRECOVERABLE_IF(nullptr == decodedKernel.header);
if (hasInvalidChecksum(decodedKernel)) {
outErrReason = "KernelFromPatchtokens has invalid checksum";
return ValidatorError::InvalidBinary;
}
if (decodedKernel.tokens.allocateLocalSurface) {
if (sharedLocalMemorySize < decodedKernel.tokens.allocateLocalSurface->TotalInlineLocalMemorySize) {
outErrReason = "KernelFromPatchtokens requires too much SLM";
return ValidatorError::NotEnoughSlm;
}
}
for (const auto &unhandledToken : decodedKernel.unhandledTokens) {
if (false == tokenValidator.isSafeToSkipUnhandledToken(unhandledToken->Token)) {
outErrReason = "Unhandled required kernel-scope Patch Token : " + std::to_string(unhandledToken->Token);
return ValidatorError::InvalidBinary;
} else {
outWarnings = "Unknown kernel-scope Patch Token : " + std::to_string(unhandledToken->Token);
}
}
}
return ValidatorError::Success;
}
} // namespace PatchTokenBinary
} // namespace NEO

View File

@ -6,6 +6,7 @@
*/
#include "runtime/device_queue/device_queue_hw_base.inl"
#include "runtime/program/block_kernel_manager.h"
namespace NEO {

View File

@ -164,42 +164,7 @@ struct HardwareCommandsHelper : public PerThreadDataHelper {
static size_t getTotalSizeRequiredSSH(
const MultiDispatchInfo &multiDispatchInfo);
static size_t getSizeRequiredForExecutionModel(IndirectHeap::Type heapType, const Kernel &kernel) {
typedef typename GfxFamily::BINDING_TABLE_STATE BINDING_TABLE_STATE;
size_t totalSize = 0;
BlockKernelManager *blockManager = kernel.getProgram()->getBlockKernelManager();
uint32_t blockCount = static_cast<uint32_t>(blockManager->getCount());
uint32_t maxBindingTableCount = 0;
if (heapType == IndirectHeap::SURFACE_STATE) {
totalSize = BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE - 1;
for (uint32_t i = 0; i < blockCount; i++) {
const KernelInfo *pBlockInfo = blockManager->getBlockKernelInfo(i);
totalSize += pBlockInfo->heapInfo.pKernelHeader->SurfaceStateHeapSize;
totalSize = alignUp(totalSize, BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE);
maxBindingTableCount = std::max(maxBindingTableCount, pBlockInfo->patchInfo.bindingTableState->Count);
}
}
if (heapType == IndirectHeap::INDIRECT_OBJECT || heapType == IndirectHeap::SURFACE_STATE) {
BuiltIns &builtIns = *kernel.getDevice().getExecutionEnvironment()->getBuiltIns();
SchedulerKernel &scheduler = builtIns.getSchedulerKernel(kernel.getContext());
if (heapType == IndirectHeap::INDIRECT_OBJECT) {
totalSize += getSizeRequiredIOH(scheduler);
} else {
totalSize += getSizeRequiredSSH(scheduler);
totalSize += maxBindingTableCount * sizeof(BINDING_TABLE_STATE) * DeviceQueue::interfaceDescriptorEntries;
totalSize = alignUp(totalSize, BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE);
}
}
return totalSize;
}
static size_t getSizeRequiredForExecutionModel(IndirectHeap::Type heapType, const Kernel &kernel);
static void setInterfaceDescriptorOffset(
WALKER_TYPE<GfxFamily> *walkerCmd,
uint32_t &interfaceDescriptorIndex);

View File

@ -17,6 +17,7 @@
#include "runtime/indirect_heap/indirect_heap.h"
#include "runtime/kernel/kernel.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/program/block_kernel_manager.h"
#include <cstring>
@ -131,6 +132,43 @@ size_t HardwareCommandsHelper<GfxFamily>::getTotalSizeRequiredSSH(
return getSizeRequired(multiDispatchInfo, [](const DispatchInfo &dispatchInfo) { return getSizeRequiredSSH(*dispatchInfo.getKernel()); });
}
template <typename GfxFamily>
size_t HardwareCommandsHelper<GfxFamily>::getSizeRequiredForExecutionModel(IndirectHeap::Type heapType, const Kernel &kernel) {
typedef typename GfxFamily::BINDING_TABLE_STATE BINDING_TABLE_STATE;
size_t totalSize = 0;
BlockKernelManager *blockManager = kernel.getProgram()->getBlockKernelManager();
uint32_t blockCount = static_cast<uint32_t>(blockManager->getCount());
uint32_t maxBindingTableCount = 0;
if (heapType == IndirectHeap::SURFACE_STATE) {
totalSize = BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE - 1;
for (uint32_t i = 0; i < blockCount; i++) {
const KernelInfo *pBlockInfo = blockManager->getBlockKernelInfo(i);
totalSize += pBlockInfo->heapInfo.pKernelHeader->SurfaceStateHeapSize;
totalSize = alignUp(totalSize, BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE);
maxBindingTableCount = std::max(maxBindingTableCount, pBlockInfo->patchInfo.bindingTableState->Count);
}
}
if (heapType == IndirectHeap::INDIRECT_OBJECT || heapType == IndirectHeap::SURFACE_STATE) {
BuiltIns &builtIns = *kernel.getDevice().getExecutionEnvironment()->getBuiltIns();
SchedulerKernel &scheduler = builtIns.getSchedulerKernel(kernel.getContext());
if (heapType == IndirectHeap::INDIRECT_OBJECT) {
totalSize += getSizeRequiredIOH(scheduler);
} else {
totalSize += getSizeRequiredSSH(scheduler);
totalSize += maxBindingTableCount * sizeof(BINDING_TABLE_STATE) * DeviceQueue::interfaceDescriptorEntries;
totalSize = alignUp(totalSize, BINDING_TABLE_STATE::SURFACESTATEPOINTER_ALIGN_SIZE);
}
}
return totalSize;
}
template <typename GfxFamily>
size_t HardwareCommandsHelper<GfxFamily>::sendInterfaceDescriptorData(
const IndirectHeap &indirectHeap,

View File

@ -38,6 +38,7 @@
#include "runtime/memory_manager/surface.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/platform/platform.h"
#include "runtime/program/block_kernel_manager.h"
#include "runtime/program/kernel_info.h"
#include "runtime/sampler/sampler.h"
@ -1823,7 +1824,7 @@ void Kernel::ReflectionSurfaceHelper::getCurbeParams(std::vector<IGIL_KernelCurb
if (kernelInfo.patchInfo.bindingTableState) {
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
void *ssh = static_cast<char *>(kernelInfo.heapInfo.pSsh) + kernelInfo.patchInfo.bindingTableState->Offset;
const void *ssh = static_cast<const char *>(kernelInfo.heapInfo.pSsh) + kernelInfo.patchInfo.bindingTableState->Offset;
for (uint32_t i = 0; i < kernelInfo.patchInfo.bindingTableState->Count; i++) {
@ -1869,11 +1870,9 @@ void Kernel::ReflectionSurfaceHelper::getCurbeParams(std::vector<IGIL_KernelCurb
}
}
for (auto param : kernelInfo.patchInfo.dataParameterBuffers) {
if (param->Type == DATA_PARAMETER_KERNEL_ARGUMENT) {
curbeParamsOut.emplace_back(IGIL_KernelCurbeParams{DATA_PARAMETER_KERNEL_ARGUMENT, param->DataSize, param->Offset, param->ArgumentNumber});
tokenMask |= ((uint64_t)1 << DATA_PARAMETER_KERNEL_ARGUMENT);
}
for (auto param : kernelInfo.patchInfo.dataParameterBuffersKernelArgs) {
curbeParamsOut.emplace_back(IGIL_KernelCurbeParams{DATA_PARAMETER_KERNEL_ARGUMENT, param->DataSize, param->Offset, param->ArgumentNumber});
tokenMask |= ((uint64_t)1 << DATA_PARAMETER_KERNEL_ARGUMENT);
}
for (uint32_t i = 0; i < 3; i++) {
@ -2319,4 +2318,13 @@ void Kernel::addAllocationToCacheFlushVector(uint32_t argIndex, GraphicsAllocati
}
}
void Kernel::setReflectionSurfaceBlockBtOffset(uint32_t blockID, uint32_t offset) {
DEBUG_BREAK_IF(blockID >= program->getBlockKernelManager()->getCount());
ReflectionSurfaceHelper::setKernelAddressDataBtOffset(getKernelReflectionSurface()->getUnderlyingBuffer(), blockID, offset);
}
bool Kernel::checkIfIsParentKernelAndBlocksUsesPrintf() {
return isParentKernel && getProgram()->getBlockKernelManager()->getIfBlockUsesPrintf();
}
} // namespace NEO

View File

@ -8,6 +8,7 @@
#pragma once
#include "core/helpers/preamble.h"
#include "core/unified_memory/unified_memory.h"
#include "core/utilities/stackvec.h"
#include "runtime/api/cl_types.h"
#include "runtime/command_stream/thread_arbitration_policy.h"
#include "runtime/device_queue/device_queue.h"
@ -23,6 +24,7 @@
namespace NEO {
struct CompletionStamp;
class Buffer;
class CommandStreamReceiver;
class GraphicsAllocation;
class ImageTransformer;
class Surface;
@ -294,10 +296,7 @@ class Kernel : public BaseObject<_cl_kernel> {
bool hasPrintfOutput() const;
void setReflectionSurfaceBlockBtOffset(uint32_t blockID, uint32_t offset) {
DEBUG_BREAK_IF(blockID >= program->getBlockKernelManager()->getCount());
ReflectionSurfaceHelper::setKernelAddressDataBtOffset(getKernelReflectionSurface()->getUnderlyingBuffer(), blockID, offset);
}
void setReflectionSurfaceBlockBtOffset(uint32_t blockID, uint32_t offset);
cl_int checkCorrectImageAccessQualifier(cl_uint argIndex,
size_t argSize,
@ -353,9 +352,7 @@ class Kernel : public BaseObject<_cl_kernel> {
return ThreadArbitrationPolicy::AgeBased;
}
}
bool checkIfIsParentKernelAndBlocksUsesPrintf() {
return isParentKernel && getProgram()->getBlockKernelManager()->getIfBlockUsesPrintf();
}
bool checkIfIsParentKernelAndBlocksUsesPrintf();
bool is32Bit() const {
return kernelInfo.gpuPointerSize == 4;

View File

@ -6,6 +6,7 @@
*/
#include "runtime/kernel/kernel.h"
#include "runtime/program/block_kernel_manager.h"
#include "runtime/program/printf_handler.h"
namespace NEO {

View File

@ -19,6 +19,8 @@ set(RUNTIME_SRCS_PROGRAM
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_info.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_info.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_info_from_patchtokens.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_info_from_patchtokens.h
${CMAKE_CURRENT_SOURCE_DIR}/link.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patch_info.h
${CMAKE_CURRENT_SOURCE_DIR}/print_formatter.cpp

View File

@ -13,6 +13,7 @@
#include "runtime/helpers/validators.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/platform/platform.h"
#include "runtime/program/kernel_info.h"
#include "runtime/program/program.h"
#include "runtime/source_level_debugger/source_level_debugger.h"
@ -197,15 +198,6 @@ cl_int Program::build(const cl_device_id device, const char *buildOptions, bool
return ret;
}
cl_int Program::build(
const char *pKernelData,
size_t kernelDataSize) {
cl_int retVal = CL_SUCCESS;
processKernel(pKernelData, 0U, retVal);
return retVal;
}
void Program::extractInternalOptions(std::string &options) {
for (auto &optionString : internalOptionsToExtract) {
size_t pos = options.find(optionString);

View File

@ -7,6 +7,7 @@
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/helpers/string_helpers.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/program/program.h"

View File

@ -13,25 +13,11 @@
namespace NEO {
struct HeapInfo {
const SKernelBinaryHeaderCommon *pKernelHeader;
const void *pKernelHeap;
const void *pGsh;
const void *pDsh;
void *pSsh;
const void *pPatchList;
const void *pBlob;
size_t blobSize;
HeapInfo() {
pKernelHeader = nullptr;
pKernelHeap = nullptr;
pGsh = nullptr;
pDsh = nullptr;
pSsh = nullptr;
pPatchList = nullptr;
pBlob = nullptr;
blobSize = 0;
}
const SKernelBinaryHeaderCommon *pKernelHeader = nullptr;
const void *pKernelHeap = nullptr;
const void *pGsh = nullptr;
const void *pDsh = nullptr;
const void *pSsh = nullptr;
};
} // namespace NEO

View File

@ -8,6 +8,7 @@
#include "core/helpers/aligned_memory.h"
#include "core/helpers/ptr_math.h"
#include "core/helpers/string.h"
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/device/device.h"
#include "runtime/gen_common/hw_cmds.h"
#include "runtime/helpers/dispatch_info.h"
@ -202,44 +203,57 @@ KernelInfo::~KernelInfo() {
delete[] crossThreadData;
}
cl_int KernelInfo::storeArgInfo(const SPatchKernelArgumentInfo *pkernelArgInfo) {
cl_int retVal = CL_SUCCESS;
if (pkernelArgInfo == nullptr) {
retVal = CL_INVALID_BINARY;
} else {
uint32_t argNum = pkernelArgInfo->ArgumentNumber;
auto pCurArgAttrib = ptrOffset(
reinterpret_cast<const char *>(pkernelArgInfo),
sizeof(SPatchKernelArgumentInfo));
resizeKernelArgInfoAndRegisterParameter(argNum);
kernelArgInfo[argNum].addressQualifierStr = pCurArgAttrib;
pCurArgAttrib += pkernelArgInfo->AddressQualifierSize;
kernelArgInfo[argNum].accessQualifierStr = pCurArgAttrib;
pCurArgAttrib += pkernelArgInfo->AccessQualifierSize;
kernelArgInfo[argNum].name = pCurArgAttrib;
pCurArgAttrib += pkernelArgInfo->ArgumentNameSize;
{
auto argType = strchr(pCurArgAttrib, ';');
DEBUG_BREAK_IF(argType == nullptr);
kernelArgInfo[argNum].typeStr.assign(pCurArgAttrib, argType - pCurArgAttrib);
pCurArgAttrib += pkernelArgInfo->TypeNameSize;
++argType;
}
kernelArgInfo[argNum].typeQualifierStr = pCurArgAttrib;
patchInfo.kernelArgumentInfo.push_back(pkernelArgInfo);
void KernelInfo::storePatchToken(const SPatchExecutionEnvironment *execEnv) {
this->patchInfo.executionEnvironment = execEnv;
if (execEnv->RequiredWorkGroupSizeX != 0) {
this->reqdWorkGroupSize[0] = execEnv->RequiredWorkGroupSizeX;
this->reqdWorkGroupSize[1] = execEnv->RequiredWorkGroupSizeY;
this->reqdWorkGroupSize[2] = execEnv->RequiredWorkGroupSizeZ;
DEBUG_BREAK_IF(!(execEnv->RequiredWorkGroupSizeY > 0));
DEBUG_BREAK_IF(!(execEnv->RequiredWorkGroupSizeZ > 0));
}
this->workgroupWalkOrder[0] = 0;
this->workgroupWalkOrder[1] = 1;
this->workgroupWalkOrder[2] = 2;
if (execEnv->WorkgroupWalkOrderDims) {
constexpr auto dimensionMask = 0b11;
constexpr auto dimensionSize = 2;
this->workgroupWalkOrder[0] = execEnv->WorkgroupWalkOrderDims & dimensionMask;
this->workgroupWalkOrder[1] = (execEnv->WorkgroupWalkOrderDims >> dimensionSize) & dimensionMask;
this->workgroupWalkOrder[2] = (execEnv->WorkgroupWalkOrderDims >> dimensionSize * 2) & dimensionMask;
this->requiresWorkGroupOrder = true;
}
return retVal;
for (uint32_t i = 0; i < 3; ++i) {
// inverts the walk order mapping (from ORDER_ID->DIM_ID to DIM_ID->ORDER_ID)
this->workgroupDimensionsOrder[this->workgroupWalkOrder[i]] = i;
}
if (execEnv->CompiledForGreaterThan4GBBuffers == false) {
this->requiresSshForBuffers = true;
}
}
void KernelInfo::storeArgInfo(const SPatchKernelArgumentInfo *pkernelArgInfo) {
if (pkernelArgInfo == nullptr) {
return;
}
uint32_t argNum = pkernelArgInfo->ArgumentNumber;
resizeKernelArgInfoAndRegisterParameter(argNum);
auto inlineData = PatchTokenBinary::getInlineData(pkernelArgInfo);
kernelArgInfo[argNum].addressQualifierStr = std::string(inlineData.addressQualifier.begin(), inlineData.addressQualifier.end()).c_str();
kernelArgInfo[argNum].accessQualifierStr = std::string(inlineData.accessQualifier.begin(), inlineData.accessQualifier.end()).c_str();
kernelArgInfo[argNum].name = std::string(inlineData.argName.begin(), inlineData.argName.end()).c_str();
auto argTypeDelim = strchr(inlineData.typeName.begin(), ';');
DEBUG_BREAK_IF(argTypeDelim == nullptr);
kernelArgInfo[argNum].typeStr = std::string(inlineData.typeName.begin(), ptrDiff(argTypeDelim, inlineData.typeName.begin())).c_str();
kernelArgInfo[argNum].typeQualifierStr = std::string(inlineData.typeQualifiers.begin(), inlineData.typeQualifiers.end()).c_str();
patchInfo.kernelArgumentInfo.push_back(pkernelArgInfo);
}
void KernelInfo::storeKernelArgument(
@ -380,6 +394,7 @@ void KernelInfo::storePatchToken(const SPatchString *pStringArg) {
}
void KernelInfo::storePatchToken(const SPatchKernelAttributesInfo *pKernelAttributesInfo) {
this->patchInfo.pKernelAttributesInfo = pKernelAttributesInfo;
attributes = reinterpret_cast<const char *>(pKernelAttributesInfo) + sizeof(SPatchKernelAttributesInfo);
auto start = attributes.find("intel_reqd_sub_group_size(");

View File

@ -38,47 +38,24 @@ extern std::unordered_map<std::string, uint32_t> addressQualifierMap;
extern std::map<std::string, size_t> typeSizeMap;
struct WorkloadInfo {
uint32_t globalWorkOffsetOffsets[3];
uint32_t globalWorkSizeOffsets[3];
uint32_t localWorkSizeOffsets[3];
uint32_t localWorkSizeOffsets2[3];
uint32_t enqueuedLocalWorkSizeOffsets[3];
uint32_t numWorkGroupsOffset[3];
uint32_t maxWorkGroupSizeOffset;
uint32_t workDimOffset;
uint32_t slmStaticSize = 0;
uint32_t simdSizeOffset;
uint32_t parentEventOffset;
uint32_t preferredWkgMultipleOffset;
static const uint32_t undefinedOffset;
static const uint32_t invalidParentEvent;
WorkloadInfo() {
globalWorkOffsetOffsets[0] = undefinedOffset;
globalWorkOffsetOffsets[1] = undefinedOffset;
globalWorkOffsetOffsets[2] = undefinedOffset;
globalWorkSizeOffsets[0] = undefinedOffset;
globalWorkSizeOffsets[1] = undefinedOffset;
globalWorkSizeOffsets[2] = undefinedOffset;
localWorkSizeOffsets[0] = undefinedOffset;
localWorkSizeOffsets[1] = undefinedOffset;
localWorkSizeOffsets[2] = undefinedOffset;
localWorkSizeOffsets2[0] = undefinedOffset;
localWorkSizeOffsets2[1] = undefinedOffset;
localWorkSizeOffsets2[2] = undefinedOffset;
enqueuedLocalWorkSizeOffsets[0] = undefinedOffset;
enqueuedLocalWorkSizeOffsets[1] = undefinedOffset;
enqueuedLocalWorkSizeOffsets[2] = undefinedOffset;
numWorkGroupsOffset[0] = undefinedOffset;
numWorkGroupsOffset[1] = undefinedOffset;
numWorkGroupsOffset[2] = undefinedOffset;
maxWorkGroupSizeOffset = undefinedOffset;
workDimOffset = undefinedOffset;
simdSizeOffset = undefinedOffset;
parentEventOffset = undefinedOffset;
preferredWkgMultipleOffset = undefinedOffset;
}
uint32_t globalWorkOffsetOffsets[3] = {undefinedOffset, undefinedOffset, undefinedOffset};
uint32_t globalWorkSizeOffsets[3] = {undefinedOffset, undefinedOffset, undefinedOffset};
uint32_t localWorkSizeOffsets[3] = {undefinedOffset, undefinedOffset, undefinedOffset};
uint32_t localWorkSizeOffsets2[3] = {undefinedOffset, undefinedOffset, undefinedOffset};
uint32_t enqueuedLocalWorkSizeOffsets[3] = {undefinedOffset, undefinedOffset, undefinedOffset};
uint32_t numWorkGroupsOffset[3] = {undefinedOffset, undefinedOffset, undefinedOffset};
uint32_t maxWorkGroupSizeOffset = undefinedOffset;
uint32_t workDimOffset = undefinedOffset;
uint32_t slmStaticSize = 0;
uint32_t simdSizeOffset = undefinedOffset;
uint32_t parentEventOffset = undefinedOffset;
uint32_t preferredWkgMultipleOffset = undefinedOffset;
uint32_t privateMemoryStatelessSizeOffset = undefinedOffset;
uint32_t localMemoryStatelessWindowSizeOffset = undefinedOffset;
uint32_t localMemoryStatelessWindowStartAddressOffset = undefinedOffset;
};
static const float YTilingRatioValue = 1.3862943611198906188344642429164f;
@ -115,24 +92,12 @@ struct DebugData {
struct KernelInfo {
public:
KernelInfo() {
heapInfo = {};
patchInfo = {};
workloadInfo = {};
kernelArgInfo = {};
kernelNonArgInfo = {};
childrenKernelsIdOffset = {};
reqdWorkGroupSize[0] = WorkloadInfo::undefinedOffset;
reqdWorkGroupSize[1] = WorkloadInfo::undefinedOffset;
reqdWorkGroupSize[2] = WorkloadInfo::undefinedOffset;
}
KernelInfo() = default;
KernelInfo(const KernelInfo &) = delete;
KernelInfo &operator=(const KernelInfo &) = delete;
~KernelInfo();
cl_int storeArgInfo(const SPatchKernelArgumentInfo *pkernelArgInfo);
void storeArgInfo(const SPatchKernelArgumentInfo *pkernelArgInfo);
void storeKernelArgument(const SPatchDataParameterBuffer *pDataParameterKernelArg);
void storeKernelArgument(const SPatchStatelessGlobalMemoryObjectKernelArgument *pStatelessGlobalKernelArg);
void storeKernelArgument(const SPatchImageMemoryObjectKernelArgument *pImageMemObjKernelArg);
@ -140,6 +105,7 @@ struct KernelInfo {
void storeKernelArgument(const SPatchStatelessConstantMemoryObjectKernelArgument *pStatelessConstMemObjKernelArg);
void storeKernelArgument(const SPatchStatelessDeviceQueueKernelArgument *pStatelessDeviceQueueKernelArg);
void storeKernelArgument(const SPatchSamplerKernelArgument *pSamplerKernelArg);
void storePatchToken(const SPatchExecutionEnvironment *execEnv);
void storePatchToken(const SPatchAllocateStatelessPrivateSurface *pStatelessPrivateSurfaceArg);
void storePatchToken(const SPatchAllocateStatelessConstantMemorySurfaceWithInitialization *pStatelessConstantMemorySurfaceWithInitializationArg);
void storePatchToken(const SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization *pStatelessGlobalMemorySurfaceWithInitializationArg);
@ -216,18 +182,18 @@ struct KernelInfo {
std::string name;
std::string attributes;
HeapInfo heapInfo;
PatchInfo patchInfo;
HeapInfo heapInfo = {};
PatchInfo patchInfo = {};
std::vector<KernelArgInfo> kernelArgInfo;
std::vector<KernelArgInfo> kernelNonArgInfo;
WorkloadInfo workloadInfo;
WorkloadInfo workloadInfo = {};
std::vector<std::pair<uint32_t, uint32_t>> childrenKernelsIdOffset;
bool usesSsh = false;
bool requiresSshForBuffers = false;
bool isValid = false;
bool isVmeWorkload = false;
char *crossThreadData = nullptr;
size_t reqdWorkGroupSize[3];
size_t reqdWorkGroupSize[3] = {WorkloadInfo::undefinedOffset, WorkloadInfo::undefinedOffset, WorkloadInfo::undefinedOffset};
size_t requiredSubGroupSize = 0;
std::array<uint8_t, 3> workgroupWalkOrder = {{0, 1, 2}};
std::array<uint8_t, 3> workgroupDimensionsOrder = {{0, 1, 2}};

View File

@ -0,0 +1,185 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/program/kernel_info_from_patchtokens.h"
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/program/kernel_info.h"
namespace NEO {
using namespace iOpenCL;
template <typename T>
inline void storeTokenIfNotNull(KernelInfo &kernelInfo, T *token) {
if (token != nullptr) {
kernelInfo.storePatchToken(token);
}
}
template <typename T>
inline uint32_t getOffset(T *token) {
if (token != nullptr) {
return token->Offset;
}
return WorkloadInfo::undefinedOffset;
}
void populateKernelInfoArg(KernelInfo &dstKernelInfo, KernelArgInfo &dstKernelInfoArg, const PatchTokenBinary::KernelArgFromPatchtokens src) {
dstKernelInfoArg.needPatch = true;
dstKernelInfo.storeArgInfo(src.argInfo);
if (src.objectArg != nullptr) {
switch (src.objectArg->Token) {
default:
UNRECOVERABLE_IF(true);
case PATCH_TOKEN_IMAGE_MEMORY_OBJECT_KERNEL_ARGUMENT:
dstKernelInfo.storeKernelArgument(reinterpret_cast<const SPatchImageMemoryObjectKernelArgument *>(src.objectArg));
break;
case PATCH_TOKEN_SAMPLER_KERNEL_ARGUMENT:
dstKernelInfo.storeKernelArgument(reinterpret_cast<const SPatchSamplerKernelArgument *>(src.objectArg));
break;
case PATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
dstKernelInfo.storeKernelArgument(reinterpret_cast<const SPatchGlobalMemoryObjectKernelArgument *>(src.objectArg));
break;
case PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
dstKernelInfo.storeKernelArgument(reinterpret_cast<const SPatchStatelessGlobalMemoryObjectKernelArgument *>(src.objectArg));
break;
case PATCH_TOKEN_STATELESS_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT:
dstKernelInfo.storeKernelArgument(reinterpret_cast<const SPatchStatelessConstantMemoryObjectKernelArgument *>(src.objectArg));
break;
case PATCH_TOKEN_STATELESS_DEVICE_QUEUE_KERNEL_ARGUMENT:
dstKernelInfo.storeKernelArgument(reinterpret_cast<const SPatchStatelessDeviceQueueKernelArgument *>(src.objectArg));
break;
}
}
switch (src.objectType) {
default:
UNRECOVERABLE_IF(PatchTokenBinary::ArgObjectType::None != src.objectType);
break;
case PatchTokenBinary::ArgObjectType::Buffer:
dstKernelInfoArg.offsetBufferOffset = getOffset(src.metadata.buffer.bufferOffset);
dstKernelInfoArg.pureStatefulBufferAccess = (src.metadata.buffer.pureStateful != nullptr);
break;
case PatchTokenBinary::ArgObjectType::Image:
dstKernelInfoArg.offsetImgWidth = getOffset(src.metadata.image.width);
dstKernelInfoArg.offsetImgHeight = getOffset(src.metadata.image.height);
dstKernelInfoArg.offsetImgDepth = getOffset(src.metadata.image.depth);
dstKernelInfoArg.offsetChannelDataType = getOffset(src.metadata.image.channelDataType);
dstKernelInfoArg.offsetChannelOrder = getOffset(src.metadata.image.channelOrder);
dstKernelInfoArg.offsetArraySize = getOffset(src.metadata.image.arraySize);
dstKernelInfoArg.offsetNumSamples = getOffset(src.metadata.image.numSamples);
dstKernelInfoArg.offsetNumMipLevels = getOffset(src.metadata.image.numMipLevels);
break;
case PatchTokenBinary::ArgObjectType::Sampler:
dstKernelInfoArg.offsetSamplerSnapWa = getOffset(src.metadata.sampler.coordinateSnapWaRequired);
dstKernelInfoArg.offsetSamplerAddressingMode = getOffset(src.metadata.sampler.addressMode);
dstKernelInfoArg.offsetSamplerNormalizedCoords = getOffset(src.metadata.sampler.normalizedCoords);
break;
case PatchTokenBinary::ArgObjectType::Slm:
dstKernelInfoArg.slmAlignment = src.metadata.slm.token->SourceOffset;
break;
}
switch (src.objectTypeSpecialized) {
default:
UNRECOVERABLE_IF(PatchTokenBinary::ArgObjectTypeSpecialized::None != src.objectTypeSpecialized);
break;
case PatchTokenBinary::ArgObjectTypeSpecialized::Vme:
dstKernelInfoArg.offsetVmeMbBlockType = getOffset(src.metadataSpecialized.vme.mbBlockType);
dstKernelInfoArg.offsetVmeSubpixelMode = getOffset(src.metadataSpecialized.vme.subpixelMode);
dstKernelInfoArg.offsetVmeSadAdjustMode = getOffset(src.metadataSpecialized.vme.sadAdjustMode);
dstKernelInfoArg.offsetVmeSearchPathType = getOffset(src.metadataSpecialized.vme.searchPathType);
break;
}
for (auto &byValArg : src.byValMap) {
dstKernelInfo.storeKernelArgument(byValArg);
if (byValArg->Type == DATA_PARAMETER_KERNEL_ARGUMENT) {
dstKernelInfo.patchInfo.dataParameterBuffersKernelArgs.push_back(byValArg);
}
}
dstKernelInfoArg.offsetObjectId = getOffset(src.objectId);
}
void populateKernelInfo(KernelInfo &dst, const PatchTokenBinary::KernelFromPatchtokens &src) {
dst.heapInfo.pKernelHeader = src.header;
dst.name = std::string(src.name.begin(), src.name.end()).c_str();
dst.heapInfo.pKernelHeap = src.isa.begin();
dst.heapInfo.pGsh = src.heaps.generalState.begin();
dst.heapInfo.pDsh = src.heaps.dynamicState.begin();
dst.heapInfo.pSsh = src.heaps.surfaceState.begin();
storeTokenIfNotNull(dst, src.tokens.executionEnvironment);
dst.patchInfo.samplerStateArray = src.tokens.samplerStateArray;
dst.patchInfo.bindingTableState = src.tokens.bindingTableState;
dst.usesSsh = src.tokens.bindingTableState && (src.tokens.bindingTableState->Count > 0);
dst.patchInfo.localsurface = src.tokens.allocateLocalSurface;
dst.workloadInfo.slmStaticSize = src.tokens.allocateLocalSurface ? src.tokens.allocateLocalSurface->TotalInlineLocalMemorySize : 0U;
dst.patchInfo.mediavfestate = src.tokens.mediaVfeState[0];
dst.patchInfo.mediaVfeStateSlot1 = src.tokens.mediaVfeState[1];
dst.patchInfo.interfaceDescriptorDataLoad = src.tokens.mediaInterfaceDescriptorLoad;
dst.patchInfo.interfaceDescriptorData = src.tokens.interfaceDescriptorData;
dst.patchInfo.threadPayload = src.tokens.threadPayload;
dst.patchInfo.dataParameterStream = src.tokens.dataParameterStream;
dst.patchInfo.kernelArgumentInfo.reserve(src.tokens.kernelArgs.size());
dst.kernelArgInfo.resize(src.tokens.kernelArgs.size());
dst.argumentsToPatchNum = static_cast<uint32_t>(src.tokens.kernelArgs.size());
for (size_t i = 0U; i < src.tokens.kernelArgs.size(); ++i) {
auto &decodedKernelArg = src.tokens.kernelArgs[i];
auto &kernelInfoArg = dst.kernelArgInfo[i];
populateKernelInfoArg(dst, kernelInfoArg, decodedKernelArg);
}
storeTokenIfNotNull(dst, src.tokens.kernelAttributesInfo);
storeTokenIfNotNull(dst, src.tokens.allocateStatelessPrivateSurface);
storeTokenIfNotNull(dst, src.tokens.allocateStatelessConstantMemorySurfaceWithInitialization);
storeTokenIfNotNull(dst, src.tokens.allocateStatelessGlobalMemorySurfaceWithInitialization);
storeTokenIfNotNull(dst, src.tokens.allocateStatelessPrintfSurface);
storeTokenIfNotNull(dst, src.tokens.allocateStatelessEventPoolSurface);
storeTokenIfNotNull(dst, src.tokens.allocateStatelessDefaultDeviceQueueSurface);
for (auto &str : src.tokens.strings) {
dst.storePatchToken(str);
}
dst.isVmeWorkload = dst.isVmeWorkload || (src.tokens.inlineVmeSamplerInfo != nullptr);
dst.systemKernelOffset = src.tokens.stateSip ? src.tokens.stateSip->SystemKernelOffset : 0U;
storeTokenIfNotNull(dst, src.tokens.allocateSystemThreadSurface);
for (uint32_t i = 0; i < 3U; ++i) {
dst.workloadInfo.localWorkSizeOffsets[i] = getOffset(src.tokens.crossThreadPayloadArgs.localWorkSize[i]);
dst.workloadInfo.localWorkSizeOffsets2[i] = getOffset(src.tokens.crossThreadPayloadArgs.localWorkSize2[i]);
dst.workloadInfo.globalWorkOffsetOffsets[i] = getOffset(src.tokens.crossThreadPayloadArgs.globalWorkOffset[i]);
dst.workloadInfo.enqueuedLocalWorkSizeOffsets[i] = getOffset(src.tokens.crossThreadPayloadArgs.enqueuedLocalWorkSize[i]);
dst.workloadInfo.globalWorkSizeOffsets[i] = getOffset(src.tokens.crossThreadPayloadArgs.globalWorkSize[i]);
dst.workloadInfo.numWorkGroupsOffset[i] = getOffset(src.tokens.crossThreadPayloadArgs.numWorkGroups[i]);
}
dst.workloadInfo.maxWorkGroupSizeOffset = getOffset(src.tokens.crossThreadPayloadArgs.maxWorkGroupSize);
dst.workloadInfo.workDimOffset = getOffset(src.tokens.crossThreadPayloadArgs.workDimensions);
dst.workloadInfo.simdSizeOffset = getOffset(src.tokens.crossThreadPayloadArgs.simdSize);
dst.workloadInfo.parentEventOffset = getOffset(src.tokens.crossThreadPayloadArgs.parentEvent);
dst.workloadInfo.preferredWkgMultipleOffset = getOffset(src.tokens.crossThreadPayloadArgs.preferredWorkgroupMultiple);
dst.workloadInfo.privateMemoryStatelessSizeOffset = getOffset(src.tokens.crossThreadPayloadArgs.privateMemoryStatelessSize);
dst.workloadInfo.localMemoryStatelessWindowSizeOffset = getOffset(src.tokens.crossThreadPayloadArgs.localMemoryStatelessWindowSize);
dst.workloadInfo.localMemoryStatelessWindowStartAddressOffset = getOffset(src.tokens.crossThreadPayloadArgs.localMemoryStatelessWindowStartAddress);
for (auto &childSimdSize : src.tokens.crossThreadPayloadArgs.childBlockSimdSize) {
dst.childrenKernelsIdOffset.push_back({childSimdSize->ArgumentNumber, childSimdSize->Offset});
}
if (src.tokens.gtpinInfo) {
dst.igcInfoForGtpin = reinterpret_cast<const gtpin::igc_info_t *>(src.tokens.gtpinInfo + 1);
}
dst.isValid = (false == NEO::PatchTokenBinary::hasInvalidChecksum(src));
}
} // namespace NEO

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
namespace NEO {
struct KernelInfo;
namespace PatchTokenBinary {
struct KernelFromPatchtokens;
}
void populateKernelInfo(KernelInfo &dst, const PatchTokenBinary::KernelFromPatchtokens &src);
} // namespace NEO

View File

@ -7,6 +7,7 @@
#include "core/compiler_interface/compiler_interface.h"
#include "core/elf/writer.h"
#include "core/utilities/stackvec.h"
#include "runtime/compiler_interface/compiler_options.h"
#include "runtime/device/device.h"
#include "runtime/helpers/validators.h"

View File

@ -54,7 +54,7 @@ struct PatchInfo {
const SPatchInterfaceDescriptorData *interfaceDescriptorData = nullptr;
const SPatchSamplerStateArray *samplerStateArray = nullptr;
const SPatchBindingTableState *bindingTableState = nullptr;
::std::vector<const SPatchDataParameterBuffer *> dataParameterBuffers;
::std::vector<const SPatchDataParameterBuffer *> dataParameterBuffersKernelArgs;
::std::vector<const SPatchStatelessGlobalMemoryObjectKernelArgument *>
statelessGlobalMemObjKernelArgs;
::std::vector<const SPatchImageMemoryObjectKernelArgument *>
@ -74,9 +74,6 @@ struct PatchInfo {
const SPatchAllocateSystemThreadSurface *pAllocateSystemThreadSurface = nullptr;
::std::unordered_map<uint32_t, std::string> stringDataMap;
::std::vector<const SPatchKernelArgumentInfo *> kernelArgumentInfo;
PatchInfo() {
}
};
} // namespace NEO

View File

@ -9,6 +9,7 @@
#include "core/elf/reader.h"
#include "core/elf/writer.h"
#include "core/helpers/string.h"
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "program.h"
@ -61,12 +62,12 @@ cl_int Program::processElfBinary(
break;
case CLElfLib::E_SH_TYPE::SH_TYPE_OPENCL_DEV_BINARY:
if (sectionHeader.DataSize > 0 && validateGenBinaryHeader(reinterpret_cast<SProgramBinaryHeader *>(elfReader.getSectionData(sectionHeader.DataOffset)))) {
if (sectionHeader.DataSize > 0 && validateGenBinaryHeader(reinterpret_cast<iOpenCL::SProgramBinaryHeader *>(elfReader.getSectionData(sectionHeader.DataOffset)))) {
this->genBinary = makeCopy(elfReader.getSectionData(sectionHeader.DataOffset), static_cast<size_t>(sectionHeader.DataSize));
this->genBinarySize = static_cast<size_t>(sectionHeader.DataSize);
isCreatedFromBinary = true;
} else {
getProgramCompilerVersion(reinterpret_cast<SProgramBinaryHeader *>(elfReader.getSectionData(sectionHeader.DataOffset)), binaryVersion);
binaryVersion = reinterpret_cast<iOpenCL::SProgramBinaryHeader *>(elfReader.getSectionData(sectionHeader.DataOffset))->Version;
return CL_INVALID_BINARY;
}
break;

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,8 @@
#include "runtime/device/device.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/program/block_kernel_manager.h"
#include "runtime/program/kernel_info.h"
#include <sstream>
@ -53,8 +55,6 @@ Program::Program(ExecutionEnvironment &executionEnvironment, Context *context, b
constantSurface = nullptr;
globalSurface = nullptr;
globalVarTotalSize = 0;
programScopePatchListSize = 0;
programScopePatchList = nullptr;
programOptionVersion = 12u;
allowNonUniform = false;
char paramValue[32] = {};
@ -254,14 +254,6 @@ cl_int Program::updateSpecializationConstant(cl_uint specId, size_t specSize, co
return CL_INVALID_SPEC_ID;
}
void Program::getProgramCompilerVersion(
SProgramBinaryHeader *pSectionData,
uint32_t &binaryVersion) const {
if (pSectionData != nullptr) {
binaryVersion = pSectionData->Version;
}
}
bool Program::isValidLlvmBinary(
const void *pBinary,
size_t binarySize) {

View File

@ -8,29 +8,28 @@
#pragma once
#include "core/compiler_interface/compiler_interface.h"
#include "core/compiler_interface/linker.h"
#include "core/elf/reader.h"
#include "core/elf/writer.h"
#include "core/helpers/stdio.h"
#include "runtime/api/cl_types.h"
#include "runtime/helpers/base_object.h"
#include "runtime/helpers/string_helpers.h"
#include "runtime/program/block_kernel_manager.h"
#include "runtime/program/kernel_info.h"
#include "cif/builtins/memory/buffer/buffer.h"
#include "igfxfmid.h"
#include "patch_list.h"
#include <map>
#include <string>
#include <vector>
#define OCLRT_ALIGN(a, b) ((((a) % (b)) != 0) ? ((a) - ((a) % (b)) + (b)) : (a))
namespace NEO {
namespace PatchTokenBinary {
struct ProgramFromPatchtokens;
}
class BlockKernelManager;
class BuiltinDispatchInfoBuilder;
class Context;
class CompilerInterface;
class ExecutionEnvironment;
struct KernelInfo;
template <>
struct OpenCLObjectMapper<_cl_program> {
typedef class Program DerivedType;
@ -53,8 +52,6 @@ constexpr cl_int asClError(TranslationOutput::ErrorCode err) {
}
}
bool isSafeToSkipUnhandledToken(unsigned int token);
class Program : public BaseObject<_cl_program> {
public:
static const cl_ulong objectMagic = 0x5651C89100AAACFELL;
@ -122,8 +119,6 @@ class Program : public BaseObject<_cl_program> {
cl_int build(const cl_device_id device, const char *buildOptions, bool enableCaching,
std::unordered_map<std::string, BuiltinDispatchInfoBuilder *> &builtinsMap);
cl_int build(const char *pKernelData, size_t kernelDataSize);
MOCKABLE_VIRTUAL cl_int processGenBinary();
cl_int compile(cl_uint numDevices, const cl_device_id *deviceList, const char *buildOptions,
@ -191,10 +186,6 @@ class Program : public BaseObject<_cl_program> {
return isSpirV;
}
size_t getProgramScopePatchListSize() const {
return programScopePatchListSize;
}
GraphicsAllocation *getConstantSurface() const {
return constantSurface;
}
@ -255,32 +246,23 @@ class Program : public BaseObject<_cl_program> {
return this->linkerInput.get();
}
MOCKABLE_VIRTUAL bool isSafeToSkipUnhandledToken(unsigned int token) const;
protected:
Program(ExecutionEnvironment &executionEnvironment);
MOCKABLE_VIRTUAL bool isSafeToSkipUnhandledToken(unsigned int token) const;
MOCKABLE_VIRTUAL cl_int createProgramFromBinary(const void *pBinary, size_t binarySize);
bool optionsAreNew(const char *options) const;
cl_int processElfHeader(const CLElfLib::SElf64Header *pElfHeader,
cl_program_binary_type &binaryType, uint32_t &numSections);
void getProgramCompilerVersion(SProgramBinaryHeader *pSectionData, uint32_t &binaryVersion) const;
cl_int resolveProgramBinary();
MOCKABLE_VIRTUAL cl_int linkBinary();
cl_int parseProgramScopePatchList();
MOCKABLE_VIRTUAL cl_int isHandled(const PatchTokenBinary::ProgramFromPatchtokens &decodedProgram) const;
void processProgramScopeMetadata(const PatchTokenBinary::ProgramFromPatchtokens &decodedProgram);
void populateKernelInfo(const PatchTokenBinary::ProgramFromPatchtokens &decodedProgram, uint32_t kernelNum, cl_int &retVal);
MOCKABLE_VIRTUAL cl_int rebuildProgramFromIr();
cl_int parsePatchList(KernelInfo &pKernelInfo, uint32_t kernelNum);
size_t processKernel(const void *pKernelBlob, uint32_t kernelNum, cl_int &retVal);
bool validateGenBinaryDevice(GFXCORE_FAMILY device) const;
bool validateGenBinaryHeader(const iOpenCL::SProgramBinaryHeader *pGenBinaryHeader) const;
@ -321,10 +303,6 @@ class Program : public BaseObject<_cl_program> {
std::vector<KernelInfo *> kernelInfoArray;
std::vector<KernelInfo *> parentKernelInfoArray;
std::vector<KernelInfo *> subgroupKernelInfoArray;
BlockKernelManager *blockKernelManager;
const void *programScopePatchList;
size_t programScopePatchListSize;
GraphicsAllocation *constantSurface;
GraphicsAllocation *globalSurface;
@ -340,8 +318,6 @@ class Program : public BaseObject<_cl_program> {
std::string options;
std::string internalOptions;
static const std::vector<std::string> internalOptionsToExtract;
std::string hashFileName;
std::string hashFilePath;
uint32_t programOptionVersion;
bool allowNonUniform;
@ -356,6 +332,7 @@ class Program : public BaseObject<_cl_program> {
CIF::RAII::UPtr_t<CIF::Builtins::BufferSimple> specConstantsSizes;
CIF::RAII::UPtr_t<CIF::Builtins::BufferSimple> specConstantsValues;
BlockKernelManager *blockKernelManager;
ExecutionEnvironment &executionEnvironment;
Context *context;
Device *pDevice;
@ -363,6 +340,5 @@ class Program : public BaseObject<_cl_program> {
bool isBuiltIn;
bool kernelDebugEnabled = false;
friend class OfflineCompiler;
};
} // namespace NEO

View File

@ -9,6 +9,7 @@
#include "core/helpers/file_io.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/program/kernel_info.h"
#include "runtime/program/program.h"
#include "unit_tests/helpers/kernel_binary_helper.h"
#include "unit_tests/helpers/test_files.h"

View File

@ -7,6 +7,7 @@
#include "core/helpers/file_io.h"
#include "runtime/context/context.h"
#include "runtime/program/kernel_info.h"
#include "unit_tests/helpers/test_files.h"
#include "unit_tests/mocks/mock_program.h"

View File

@ -7,6 +7,10 @@
set(IGDRCL_SRCS_tests_compiler_interface
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/default_cl_cache_config_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_decoder_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_dumper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_validator_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_tests.h
)
get_property(NEO_CORE_COMPILER_INTERFACE_TESTS GLOBAL PROPERTY NEO_CORE_COMPILER_INTERFACE_TESTS)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,252 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "test.h"
#include <vector>
namespace PatchTokensTestData {
struct ValidEmptyProgram : NEO::PatchTokenBinary::ProgramFromPatchtokens {
ValidEmptyProgram() {
iOpenCL::SProgramBinaryHeader headerTok = {};
headerTok.Magic = iOpenCL::MAGIC_CL;
headerTok.Version = iOpenCL::CURRENT_ICBE_VERSION;
headerTok.Device = renderCoreFamily;
this->decodeStatus = NEO::PatchTokenBinary::DecoderError::Success;
storage.insert(storage.end(), reinterpret_cast<uint8_t *>(&headerTok), reinterpret_cast<uint8_t *>((&headerTok) + 1));
recalcTokPtr();
}
void recalcTokPtr() {
this->blobs.programInfo = storage;
this->headerMutable = reinterpret_cast<iOpenCL::SProgramBinaryHeader *>(storage.data());
this->header = this->headerMutable;
}
std::vector<uint8_t> storage;
iOpenCL::SProgramBinaryHeader *headerMutable = nullptr;
};
struct ValidProgramWithConstantSurface : ValidEmptyProgram {
ValidProgramWithConstantSurface() {
iOpenCL::SPatchAllocateConstantMemorySurfaceProgramBinaryInfo constSurfTok = {};
constSurfTok.Token = iOpenCL::PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
constSurfTok.Size = sizeof(constSurfTok);
constSurfTok.InlineDataSize = 128;
this->programScopeTokens.allocateConstantMemorySurface.push_back(nullptr);
storage.insert(storage.end(), reinterpret_cast<uint8_t *>(&constSurfTok), reinterpret_cast<uint8_t *>((&constSurfTok) + 1));
storage.resize(storage.size() + constSurfTok.InlineDataSize);
recalcTokPtr();
}
void recalcTokPtr() {
ValidEmptyProgram::recalcTokPtr();
this->constSurfMutable = reinterpret_cast<iOpenCL::SPatchAllocateConstantMemorySurfaceProgramBinaryInfo *>(storage.data() + sizeof(*this->headerMutable));
this->programScopeTokens.allocateConstantMemorySurface[0] = this->constSurfMutable;
this->blobs.patchList = ArrayRef<const uint8_t>(storage.data() + sizeof(*this->headerMutable), storage.size() - sizeof(*this->headerMutable));
this->headerMutable->PatchListSize = static_cast<uint32_t>(this->blobs.patchList.size());
}
iOpenCL::SPatchAllocateConstantMemorySurfaceProgramBinaryInfo *constSurfMutable = nullptr;
};
struct ValidProgramWithGlobalSurface : ValidEmptyProgram {
ValidProgramWithGlobalSurface() {
iOpenCL::SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo globalSurfTok = {};
globalSurfTok.Token = iOpenCL::PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
globalSurfTok.Size = sizeof(globalSurfTok);
globalSurfTok.InlineDataSize = 256;
this->programScopeTokens.allocateGlobalMemorySurface.push_back(nullptr);
storage.insert(storage.end(), reinterpret_cast<uint8_t *>(&globalSurfTok), reinterpret_cast<uint8_t *>((&globalSurfTok) + 1));
storage.resize(storage.size() + globalSurfTok.InlineDataSize);
recalcTokPtr();
}
void recalcTokPtr() {
ValidEmptyProgram::recalcTokPtr();
this->globalSurfMutable = reinterpret_cast<iOpenCL::SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo *>(storage.data() + sizeof(*this->headerMutable));
this->programScopeTokens.allocateGlobalMemorySurface[0] = this->globalSurfMutable;
this->blobs.patchList = ArrayRef<const uint8_t>(storage.data() + sizeof(*this->headerMutable), storage.size() - sizeof(*this->headerMutable));
this->headerMutable->PatchListSize = static_cast<uint32_t>(this->blobs.patchList.size());
}
iOpenCL::SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo *globalSurfMutable = nullptr;
};
struct ValidProgramWithConstantSurfaceAndPointer : ValidProgramWithConstantSurface {
ValidProgramWithConstantSurfaceAndPointer() {
iOpenCL::SPatchConstantPointerProgramBinaryInfo constantPointerTok = {};
constantPointerTok.Token = iOpenCL::PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO;
constantPointerTok.Size = sizeof(constantPointerTok);
constantPointerTok.ConstantBufferIndex = 0;
constantPointerTok.BufferIndex = 0;
constantPointerTok.BufferType = iOpenCL::PROGRAM_SCOPE_CONSTANT_BUFFER;
constantPointerTok.ConstantPointerOffset = 96;
this->programScopeTokens.constantPointer.push_back(nullptr);
storage.insert(storage.end(), reinterpret_cast<uint8_t *>(&constantPointerTok), reinterpret_cast<uint8_t *>((&constantPointerTok) + 1));
recalcTokPtr();
}
void recalcTokPtr() {
ValidProgramWithConstantSurface::recalcTokPtr();
this->constantPointerMutable = reinterpret_cast<iOpenCL::SPatchConstantPointerProgramBinaryInfo *>(storage.data() + sizeof(*this->headerMutable) + sizeof(*this->constSurfMutable) + this->constSurfMutable->InlineDataSize);
this->programScopeTokens.constantPointer[0] = this->constantPointerMutable;
}
iOpenCL::SPatchConstantPointerProgramBinaryInfo *constantPointerMutable = nullptr;
};
struct ValidProgramWithGlobalSurfaceAndPointer : ValidProgramWithGlobalSurface {
ValidProgramWithGlobalSurfaceAndPointer() {
iOpenCL::SPatchGlobalPointerProgramBinaryInfo globalPointerTok = {};
globalPointerTok.Token = iOpenCL::PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO;
globalPointerTok.Size = sizeof(globalPointerTok);
globalPointerTok.GlobalBufferIndex = 0;
globalPointerTok.BufferIndex = 0;
globalPointerTok.BufferType = iOpenCL::PROGRAM_SCOPE_GLOBAL_BUFFER;
globalPointerTok.GlobalPointerOffset = 48;
this->programScopeTokens.globalPointer.push_back(nullptr);
storage.insert(storage.end(), reinterpret_cast<uint8_t *>(&globalPointerTok), reinterpret_cast<uint8_t *>((&globalPointerTok) + 1));
recalcTokPtr();
}
void recalcTokPtr() {
ValidProgramWithGlobalSurface::recalcTokPtr();
this->globalPointerMutable = reinterpret_cast<iOpenCL::SPatchGlobalPointerProgramBinaryInfo *>(storage.data() + sizeof(*this->headerMutable) + sizeof(*this->globalSurfMutable) + this->globalSurfMutable->InlineDataSize);
this->programScopeTokens.globalPointer[0] = this->globalPointerMutable;
}
iOpenCL::SPatchGlobalPointerProgramBinaryInfo *globalPointerMutable = nullptr;
};
struct ValidEmptyKernel {
static NEO::PatchTokenBinary::KernelFromPatchtokens create(std::vector<uint8_t> &storage) {
NEO::PatchTokenBinary::KernelFromPatchtokens ret;
iOpenCL::SKernelBinaryHeaderCommon headerTokInl = {};
ret.decodeStatus = NEO::PatchTokenBinary::DecoderError::Success;
ret.name = "test_kernel";
headerTokInl.KernelNameSize = static_cast<uint32_t>(ret.name.size());
auto kernOffset = storage.size();
storage.reserve(storage.size() + 512);
storage.insert(storage.end(), reinterpret_cast<const uint8_t *>(&headerTokInl), reinterpret_cast<const uint8_t *>((&headerTokInl) + 1));
auto headerTok = reinterpret_cast<iOpenCL::SKernelBinaryHeaderCommon *>(&*(storage.begin() + kernOffset));
ret.NEO::PatchTokenBinary::KernelFromPatchtokens::header = headerTok;
storage.insert(storage.end(), reinterpret_cast<const uint8_t *>(ret.name.begin()), reinterpret_cast<const uint8_t *>(ret.name.end()));
ret.blobs.kernelInfo = ArrayRef<const uint8_t>(storage.data() + kernOffset, storage.data() + storage.size());
headerTok->CheckSum = NEO::PatchTokenBinary::calcKernelChecksum(ret.blobs.kernelInfo);
return ret;
}
};
struct ValidProgramWithKernel : ValidEmptyProgram {
ValidProgramWithKernel() {
this->headerMutable->NumberOfKernels = 1;
kernOffset = storage.size();
this->kernels.push_back(ValidEmptyKernel::create(storage));
this->kernels[0].decodeStatus = NEO::PatchTokenBinary::DecoderError::Success;
recalcTokPtr();
}
void recalcTokPtr() {
ValidEmptyProgram::recalcTokPtr();
this->kernels[0].blobs.kernelInfo = ArrayRef<const uint8_t>(storage.data() + kernOffset, storage.data() + storage.size());
kernelHeaderMutable = reinterpret_cast<iOpenCL::SKernelBinaryHeaderCommon *>(&*(storage.begin() + kernOffset));
this->kernels[0].header = kernelHeaderMutable;
kernelHeaderMutable->CheckSum = NEO::PatchTokenBinary::calcKernelChecksum(this->kernels[0].blobs.kernelInfo);
}
size_t kernOffset = 0U;
iOpenCL::SKernelBinaryHeaderCommon *kernelHeaderMutable = nullptr;
};
struct ValidProgramWithKernelUsingSlm : ValidProgramWithKernel {
ValidProgramWithKernelUsingSlm() {
patchlistOffset = storage.size();
iOpenCL::SPatchAllocateLocalSurface slmTok = {};
slmTok.Token = iOpenCL::PATCH_TOKEN_ALLOCATE_LOCAL_SURFACE;
slmTok.Size = sizeof(slmTok);
slmTok.TotalInlineLocalMemorySize = 16;
storage.insert(storage.end(), reinterpret_cast<const uint8_t *>(&slmTok), reinterpret_cast<const uint8_t *>((&slmTok) + 1));
recalcTokPtr();
}
void recalcTokPtr() {
ValidProgramWithKernel::recalcTokPtr();
this->kernels[0].blobs.patchList = ArrayRef<const uint8_t>(storage.data() + patchlistOffset, storage.data() + storage.size());
slmMutable = reinterpret_cast<iOpenCL::SPatchAllocateLocalSurface *>(storage.data() + patchlistOffset);
this->kernels[0].tokens.allocateLocalSurface = slmMutable;
this->kernelHeaderMutable->PatchListSize = static_cast<uint32_t>(this->kernels[0].blobs.patchList.size());
}
iOpenCL::SPatchAllocateLocalSurface *slmMutable = nullptr;
size_t patchlistOffset = 0U;
};
template <typename TokenT>
inline TokenT initToken(iOpenCL::PATCH_TOKEN tok) {
TokenT ret = {};
ret.Size = sizeof(TokenT);
ret.Token = tok;
return ret;
}
inline iOpenCL::SPatchDataParameterBuffer initDataParameterBufferToken(iOpenCL::DATA_PARAMETER_TOKEN type, uint32_t sourceIndex = 0, uint32_t argNum = 0) {
iOpenCL::SPatchDataParameterBuffer tok = {};
tok.Size = static_cast<uint32_t>(sizeof(iOpenCL::SPatchDataParameterBuffer));
tok.Token = iOpenCL::PATCH_TOKEN_DATA_PARAMETER_BUFFER;
tok.Type = type;
tok.SourceOffset = sourceIndex * sizeof(uint32_t);
tok.ArgumentNumber = argNum;
return tok;
}
inline uint32_t pushBackString(const std::string &str, std::vector<uint8_t> &storage) {
auto offset = storage.size();
storage.insert(storage.end(), reinterpret_cast<const uint8_t *>(str.c_str()), reinterpret_cast<const uint8_t *>(str.c_str()) + str.size());
return static_cast<uint32_t>(offset);
}
inline uint32_t pushBackStringToken(const std::string &str, uint32_t stringIndex, std::vector<uint8_t> &outStream) {
auto off = outStream.size();
outStream.reserve(outStream.size() + sizeof(iOpenCL::SPatchString) + str.length());
outStream.resize(outStream.size() + sizeof(iOpenCL::SPatchString));
iOpenCL::SPatchString *tok = reinterpret_cast<iOpenCL::SPatchString *>(outStream.data() + off);
*tok = initToken<iOpenCL::SPatchString>(iOpenCL::PATCH_TOKEN::PATCH_TOKEN_STRING);
tok->StringSize = static_cast<uint32_t>(str.length());
tok->Size += tok->StringSize;
tok->Index = stringIndex;
pushBackString(str, outStream);
return static_cast<uint32_t>(off);
};
inline uint32_t pushBackArgInfoToken(std::vector<uint8_t> &outStream,
uint32_t argNum = 0,
const std::string &addressQualifier = "__global", const std::string &accessQualifier = "read_write",
const std::string &argName = "custom_arg", const std::string &typeName = "int*;", std::string typeQualifier = "const") {
auto off = outStream.size();
iOpenCL::SPatchKernelArgumentInfo tok = {};
tok.Token = iOpenCL::PATCH_TOKEN_KERNEL_ARGUMENT_INFO;
tok.AddressQualifierSize = static_cast<uint32_t>(addressQualifier.size());
tok.AccessQualifierSize = static_cast<uint32_t>(accessQualifier.size());
tok.ArgumentNameSize = static_cast<uint32_t>(argName.size());
tok.TypeNameSize = static_cast<uint32_t>(typeName.size());
tok.TypeQualifierSize = static_cast<uint32_t>(typeQualifier.size());
tok.Size = sizeof(iOpenCL::SPatchKernelArgumentInfo) + tok.AddressQualifierSize + tok.AccessQualifierSize + tok.ArgumentNameSize + tok.TypeNameSize + tok.TypeQualifierSize;
outStream.insert(outStream.end(), reinterpret_cast<const uint8_t *>(&tok), reinterpret_cast<const uint8_t *>(&tok) + sizeof(tok));
pushBackString(addressQualifier, outStream);
pushBackString(accessQualifier, outStream);
pushBackString(argName, outStream);
pushBackString(typeName, outStream);
pushBackString(typeQualifier, outStream);
return static_cast<uint32_t>(off);
}
} // namespace PatchTokensTestData

View File

@ -0,0 +1,337 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/compiler_interface/patchtokens_validator.inl"
#include "test.h"
#include "patchtokens_tests.h"
struct UknownTokenValidator {
UknownTokenValidator(bool isSafeToSkip = true) : isSafeToSkip(isSafeToSkip) {
}
bool isSafeToSkipUnhandledToken(uint32_t token) const {
return isSafeToSkip;
}
bool isSafeToSkip = true;
};
TEST(PatchtokensValidator, GivenValidProgramThenValidationSucceeds) {
PatchTokensTestData::ValidEmptyProgram prog;
std::string error, warning;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_EQ(0U, error.size());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidOrUnknownStatusThenValidationFails) {
PatchTokensTestData::ValidEmptyProgram prog;
std::string error, warning;
prog.decodeStatus = NEO::PatchTokenBinary::DecoderError::Undefined;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("ProgramFromPatchtokens wasn't successfully decoded", error.c_str());
EXPECT_EQ(0U, warning.size());
error.clear();
warning.clear();
prog.decodeStatus = NEO::PatchTokenBinary::DecoderError::InvalidBinary;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("ProgramFromPatchtokens wasn't successfully decoded", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithASingleConstantSurfaceThenValidationSucceeds) {
PatchTokensTestData::ValidProgramWithConstantSurface prog;
std::string error, warning;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_EQ(0U, error.size());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithMultipleConstantSurfacesThenValidationFails) {
PatchTokensTestData::ValidProgramWithConstantSurface prog;
std::string error, warning;
iOpenCL::SPatchAllocateConstantMemorySurfaceProgramBinaryInfo constSurface2 = *prog.programScopeTokens.allocateConstantMemorySurface[0];
prog.programScopeTokens.allocateConstantMemorySurface.push_back(&constSurface2);
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled number of global constants surfaces > 1", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithASingleGlobalSurfaceThenValidationSucceeds) {
PatchTokensTestData::ValidProgramWithGlobalSurface prog;
std::string error, warning;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_EQ(0U, error.size());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithMultipleGlobalSurfacesThenValidationFails) {
PatchTokensTestData::ValidProgramWithGlobalSurface prog;
std::string error, warning;
iOpenCL::SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo globSurface2 = *prog.programScopeTokens.allocateGlobalMemorySurface[0];
prog.programScopeTokens.allocateGlobalMemorySurface.push_back(&globSurface2);
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled number of global variables surfaces > 1", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithValidConstantPointerThenValidationSucceeds) {
PatchTokensTestData::ValidProgramWithConstantSurfaceAndPointer prog;
std::string error, warning;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_EQ(0U, error.size());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidConstantPointerBufferIndexThenValidationFails) {
PatchTokensTestData::ValidProgramWithConstantSurfaceAndPointer prog;
std::string error, warning;
prog.constantPointerMutable->BufferIndex = 1;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchConstantPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidConstantPointerConstantBufferIndexThenValidationFails) {
PatchTokensTestData::ValidProgramWithConstantSurfaceAndPointer prog;
std::string error, warning;
prog.constantPointerMutable->ConstantBufferIndex = 1;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchConstantPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidConstantPointerBufferTypeThenValidationFails) {
PatchTokensTestData::ValidProgramWithConstantSurfaceAndPointer prog;
std::string error, warning;
prog.constantPointerMutable->BufferType = iOpenCL::PROGRAM_SCOPE_GLOBAL_BUFFER;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchConstantPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidConstantPointerOffsetThenValidationFails) {
PatchTokensTestData::ValidProgramWithConstantSurfaceAndPointer prog;
std::string error, warning;
prog.constantPointerMutable->ConstantPointerOffset = prog.constSurfMutable->InlineDataSize;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchConstantPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithoutConstantSurfaceButWithConstantPointerThenValidationFails) {
PatchTokensTestData::ValidProgramWithConstantSurfaceAndPointer prog;
std::string error, warning;
prog.programScopeTokens.allocateConstantMemorySurface.clear();
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchConstantPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithValidGlobalPointerThenValidationSucceeds) {
PatchTokensTestData::ValidProgramWithGlobalSurfaceAndPointer prog;
std::string error, warning;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_EQ(0U, error.size());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidGlobalPointerBufferIndexThenValidationFails) {
PatchTokensTestData::ValidProgramWithGlobalSurfaceAndPointer prog;
std::string error, warning;
prog.globalPointerMutable->BufferIndex = 1;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchGlobalPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidGlobalPointerGlobalBufferIndexThenValidationFails) {
PatchTokensTestData::ValidProgramWithGlobalSurfaceAndPointer prog;
std::string error, warning;
prog.globalPointerMutable->GlobalBufferIndex = 1;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchGlobalPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidGlobalPointerBufferTypeThenValidationFails) {
PatchTokensTestData::ValidProgramWithGlobalSurfaceAndPointer prog;
std::string error, warning;
prog.globalPointerMutable->BufferType = iOpenCL::PROGRAM_SCOPE_CONSTANT_BUFFER;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchGlobalPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithInvalidGlobalPointerOffsetThenValidationFails) {
PatchTokensTestData::ValidProgramWithGlobalSurfaceAndPointer prog;
std::string error, warning;
prog.globalPointerMutable->GlobalPointerOffset = prog.globalSurfMutable->InlineDataSize;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchGlobalPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithoutGlobalSurfaceButWithGlobalPointerThenValidationFails) {
PatchTokensTestData::ValidProgramWithGlobalSurfaceAndPointer prog;
std::string error, warning;
prog.programScopeTokens.allocateGlobalMemorySurface.clear();
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("Unhandled SPatchGlobalPointerProgramBinaryInfo", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithUnknownPatchTokenWhenUknownTokenCantBeSkippedThenValidationFails) {
PatchTokensTestData::ValidEmptyProgram prog;
std::string error, warning;
iOpenCL::SPatchItemHeader unknownToken = {};
unknownToken.Token = iOpenCL::NUM_PATCH_TOKENS + 1;
prog.unhandledTokens.push_back(&unknownToken);
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(false), error, warning));
auto expectedError = "Unhandled required program-scope Patch Token : " + std::to_string(unknownToken.Token);
EXPECT_STREQ(expectedError.c_str(), error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithUnknownPatchTokenWhenUknownTokenCanBeSkippedThenValidationSucceedsAndEmitsWarning) {
PatchTokensTestData::ValidEmptyProgram prog;
std::string error, warning;
iOpenCL::SPatchItemHeader unknownToken = {};
unknownToken.Token = iOpenCL::NUM_PATCH_TOKENS + 1;
prog.unhandledTokens.push_back(&unknownToken);
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(true), error, warning));
auto expectedWarning = "Unknown program-scope Patch Token : " + std::to_string(unknownToken.Token);
EXPECT_EQ(0U, error.size());
EXPECT_STREQ(expectedWarning.c_str(), warning.c_str());
}
TEST(PatchtokensValidator, GivenProgramWithUnsupportedPatchTokenVersionThenValidationFails) {
PatchTokensTestData::ValidEmptyProgram prog;
std::string error, warning;
prog.headerMutable->Version = std::numeric_limits<uint32_t>::max();
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(true), error, warning));
auto expectedError = "Unhandled Version of Patchtokens: expected: " + std::to_string(iOpenCL::CURRENT_ICBE_VERSION) + ", got: " + std::to_string(prog.header->Version);
EXPECT_STREQ(expectedError.c_str(), error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithUnsupportedPlatformThenValidationFails) {
PatchTokensTestData::ValidEmptyProgram prog;
std::string error, warning;
prog.headerMutable->Device = IGFX_MAX_CORE;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(true), error, warning));
auto expectedError = "Unsupported device binary, device GFXCORE_FAMILY : " + std::to_string(prog.header->Device);
EXPECT_STREQ(expectedError.c_str(), error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithKernelThenValidationSucceeds) {
PatchTokensTestData::ValidProgramWithKernel prog;
std::string error, warning;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_EQ(0U, error.size());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithKernelWhenKernelHasInvalidOrUnknownStatusThenValidationFails) {
PatchTokensTestData::ValidProgramWithKernel prog;
std::string error, warning;
prog.kernels[0].decodeStatus = NEO::PatchTokenBinary::DecoderError::Undefined;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("KernelFromPatchtokens wasn't successfully decoded", error.c_str());
EXPECT_EQ(0U, warning.size());
error.clear();
warning.clear();
prog.kernels[0].decodeStatus = NEO::PatchTokenBinary::DecoderError::InvalidBinary;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("KernelFromPatchtokens wasn't successfully decoded", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithKernelWhenKernelHasInvalidChecksumThenValidationFails) {
PatchTokensTestData::ValidProgramWithKernel prog;
std::string error, warning;
prog.kernelHeaderMutable->CheckSum += 1;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(), error, warning));
EXPECT_STREQ("KernelFromPatchtokens has invalid checksum", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithKernelUsingSlmThenValidationSucceeds) {
PatchTokensTestData::ValidProgramWithKernelUsingSlm prog;
std::string error, warning;
size_t slmSizeAvailable = 1 + prog.kernels[0].tokens.allocateLocalSurface->TotalInlineLocalMemorySize;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, slmSizeAvailable, UknownTokenValidator(), error, warning));
EXPECT_EQ(0U, error.size());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenProgramWithKernelUsingSlmWhenKernelRequiresTooMuchSlmThenValidationFails) {
PatchTokensTestData::ValidProgramWithKernelUsingSlm prog;
std::string error, warning;
size_t slmSizeAvailable = -1 + prog.kernels[0].tokens.allocateLocalSurface->TotalInlineLocalMemorySize;
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::NotEnoughSlm, NEO::PatchTokenBinary::validate(prog, slmSizeAvailable, UknownTokenValidator(), error, warning));
EXPECT_STREQ("KernelFromPatchtokens requires too much SLM", error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithKernelContainingUnknownPatchTokenWhenUknownTokenCantBeSkippedThenValidationFails) {
PatchTokensTestData::ValidProgramWithKernel prog;
std::string error, warning;
iOpenCL::SPatchItemHeader unknownToken = {};
unknownToken.Token = iOpenCL::NUM_PATCH_TOKENS + 1;
prog.kernels[0].unhandledTokens.push_back(&unknownToken);
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::InvalidBinary, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(false), error, warning));
auto expectedError = "Unhandled required kernel-scope Patch Token : " + std::to_string(unknownToken.Token);
EXPECT_STREQ(expectedError.c_str(), error.c_str());
EXPECT_EQ(0U, warning.size());
}
TEST(PatchtokensValidator, GivenValidProgramWithKernelContainingUnknownPatchTokenWhenUknownTokenCanBeSkippedThenValidationSucceedsAndEmitsWarning) {
PatchTokensTestData::ValidProgramWithKernel prog;
std::string error, warning;
iOpenCL::SPatchItemHeader unknownToken = {};
unknownToken.Token = iOpenCL::NUM_PATCH_TOKENS + 1;
prog.kernels[0].unhandledTokens.push_back(&unknownToken);
EXPECT_EQ(NEO::PatchTokenBinary::ValidatorError::Success, NEO::PatchTokenBinary::validate(prog, 0U, UknownTokenValidator(true), error, warning));
auto expectedWarning = "Unknown kernel-scope Patch Token : " + std::to_string(unknownToken.Token);
EXPECT_EQ(0U, error.size());
EXPECT_STREQ(expectedWarning.c_str(), warning.c_str());
}

View File

@ -796,7 +796,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, getProfilingEndCmdsSi
HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueHwTest, givenDeviceQueueWhenRunningOnCCsThenFfidSkipOffsetIsAddedToBlockKernelStartPointer) {
std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
std::unique_ptr<MockParentKernel> mockParentKernel(MockParentKernel::create(*pContext));
KernelInfo *blockInfo = const_cast<KernelInfo *>(mockParentKernel->mockProgram->getBlockKernelInfo(0));
KernelInfo *blockInfo = const_cast<KernelInfo *>(mockParentKernel->mockProgram->blockKernelManager->getBlockKernelInfo(0));
blockInfo->createKernelAllocation(device->getRootDeviceIndex(), device->getMemoryManager());
ASSERT_NE(nullptr, blockInfo->getGraphicsAllocation());
const_cast<SPatchThreadPayload *>(blockInfo->patchInfo.threadPayload)->OffsetToSkipSetFFIDGP = 0x1234;

View File

@ -310,12 +310,12 @@ HWCMDTEST_P(IGFX_GEN8_CORE, ParentKernelEnqueueTest, givenParentKernelWhenEnqueu
auto dstBindingTable = reinterpret_cast<BINDING_TABLE_STATE *>(dstBlockBti);
auto srcBlockBti = ptrOffset(pBlockInfo->heapInfo.pSsh, pBlockInfo->patchInfo.bindingTableState->Offset);
auto srcBindingTable = reinterpret_cast<BINDING_TABLE_STATE *>(srcBlockBti);
auto srcBindingTable = reinterpret_cast<const BINDING_TABLE_STATE *>(srcBlockBti);
for (uint32_t i = 0; i < blockKernel->getNumberOfBindingTableStates(); ++i) {
uint32_t dstSurfaceStatePointer = dstBindingTable[i].getSurfaceStatePointer();
uint32_t srcSurfaceStatePointer = srcBindingTable[i].getSurfaceStatePointer();
auto *dstSurfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(ssh->getCpuBase(), dstSurfaceStatePointer));
auto *srcSurfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(ptrOffset(pBlockInfo->heapInfo.pSsh, srcSurfaceStatePointer));
auto *srcSurfaceState = reinterpret_cast<const RENDER_SURFACE_STATE *>(ptrOffset(pBlockInfo->heapInfo.pSsh, srcSurfaceStatePointer));
EXPECT_EQ(0, memcmp(srcSurfaceState, dstSurfaceState, sizeof(RENDER_SURFACE_STATE)));
}

View File

@ -10,6 +10,7 @@
#include "core/helpers/aligned_memory.h"
#include "core/helpers/string.h"
#include "core/memory_manager/graphics_allocation.h"
#include "runtime/compiler_interface/patchtokens_decoder.h"
void KernelDataTest::buildAndDecode() {
cl_int error = CL_SUCCESS;
@ -78,16 +79,22 @@ void KernelDataTest::buildAndDecode() {
pCurPtr += sizeof(SPatchDataParameterStream);
// now build a program with this kernel data
error = program->build(pKernelData, kernelDataSize);
iOpenCL::SProgramBinaryHeader header = {};
NEO::PatchTokenBinary::ProgramFromPatchtokens programFromPatchtokens;
programFromPatchtokens.decodeStatus = PatchTokenBinary::DecoderError::Success;
programFromPatchtokens.header = &header;
programFromPatchtokens.kernels.resize(1);
auto &kernelFromPatchtokens = *programFromPatchtokens.kernels.rbegin();
auto kernelBlob = ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(pKernelData), kernelDataSize);
bool decodeSuccess = NEO::PatchTokenBinary::decodeKernelFromPatchtokensBlob(kernelBlob, kernelFromPatchtokens);
EXPECT_TRUE(decodeSuccess);
program->populateKernelInfo(programFromPatchtokens, 0, error);
EXPECT_EQ(CL_SUCCESS, error);
// extract the kernel info
pKernelInfo = program->Program::getKernelInfo(kernelName.c_str());
// validate kernel info
// vaidate entire set of data
EXPECT_EQ(0, memcmp(pKernelInfo->heapInfo.pBlob, pKernelData, kernelDataSize));
// validate header
EXPECT_EQ(0, memcmp(pKernelInfo->heapInfo.pKernelHeader, &kernelBinaryHeader, sizeof(SKernelBinaryHeaderCommon)));
@ -107,9 +114,6 @@ void KernelDataTest::buildAndDecode() {
if (pSsh != nullptr) {
EXPECT_EQ(0, memcmp(pKernelInfo->heapInfo.pSsh, pSsh, sshSize));
}
if (pPatchList != nullptr) {
EXPECT_EQ(0, memcmp(pKernelInfo->heapInfo.pPatchList, pPatchList, patchListSize));
}
if (kernelHeapSize) {
auto kernelAllocation = pKernelInfo->getGraphicsAllocation();
UNRECOVERABLE_IF(kernelAllocation == nullptr);

View File

@ -8,6 +8,7 @@
#include "core/helpers/basic_math.h"
#include "core/helpers/file_io.h"
#include "core/helpers/hash.h"
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/context/context.h"
#include "runtime/device/device.h"
#include "runtime/gtpin/gtpin_defs.h"
@ -2329,8 +2330,12 @@ TEST_F(ProgramTests, givenGenBinaryWithGtpinInfoWhenProcessGenBinaryCalledThenGt
pPatch->Token = iOpenCL::PATCH_TOKEN_GTPIN_INFO;
pPatch->Size = sizeof(iOpenCL::SPatchItemHeader);
binSize += sizeof(iOpenCL::SPatchItemHeader);
pBin += sizeof(iOpenCL::SPatchItemHeader);
pKHdr->CheckSum = PatchTokenBinary::calcKernelChecksum(ArrayRef<const uint8_t>(reinterpret_cast<uint8_t *>(pKHdr), reinterpret_cast<uint8_t *>(pBin)));
// Decode prepared program binary
pProgram->genBinary = makeCopy(&genBin[0], binSize);
pProgram->genBinarySize = binSize;
retVal = pProgram->processGenBinary();
auto kernelInfo = pProgram->getKernelInfo("TstCopy");
EXPECT_NE(kernelInfo->igcInfoForGtpin, nullptr);

View File

@ -336,7 +336,7 @@ TEST_P(KernelReflectionSurfaceTest, GivenKernelInfoWithBufferAndDataParameterBuf
dataParameterBuffer.SourceOffset = 0;
dataParameterBuffer.Type = iOpenCL::DATA_PARAMETER_KERNEL_ARGUMENT;
info.patchInfo.dataParameterBuffers.push_back(&dataParameterBuffer);
info.patchInfo.dataParameterBuffersKernelArgs.push_back(&dataParameterBuffer);
info.storeKernelArgument(&dataParameterBuffer);
std::vector<IGIL_KernelCurbeParams> curbeParams;
@ -669,7 +669,7 @@ TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithoutKern
EXPECT_TRUE(kernel.isParentKernel);
program.addBlockKernel(blockInfo);
program.blockKernelManager->addBlockKernelInfo(blockInfo);
kernel.createReflectionSurface();
auto reflectionSurface = kernel.getKernelReflectionSurface();
@ -734,7 +734,7 @@ TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithDeviceQ
EXPECT_TRUE(kernel.isParentKernel);
program.addBlockKernel(blockInfo);
program.blockKernelManager->addBlockKernelInfo(blockInfo);
kernel.createReflectionSurface();
auto reflectionSurface = kernel.getKernelReflectionSurface();
@ -1978,7 +1978,7 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithGlobalMemoryWh
parentKernel->patchBlocksCurbeWithConstantValues();
auto *blockInfo = parentKernel->mockProgram->getBlockKernelInfo(0);
auto *blockInfo = parentKernel->mockProgram->blockKernelManager->getBlockKernelInfo(0);
uint32_t blockPatchOffset = blockInfo->patchInfo.pAllocateStatelessGlobalMemorySurfaceWithInitialization->DataParamOffset;
@ -2012,7 +2012,7 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithGlobalMemoryAn
parentKernel->patchBlocksCurbeWithConstantValues();
auto *blockInfo = parentKernel->mockProgram->getBlockKernelInfo(0);
auto *blockInfo = parentKernel->mockProgram->blockKernelManager->getBlockKernelInfo(0);
uint32_t blockPatchOffset = blockInfo->patchInfo.pAllocateStatelessGlobalMemorySurfaceWithInitialization->DataParamOffset;
uint64_t *pCurbe = (uint64_t *)ptrOffset(reflectionSurface->getUnderlyingBuffer(), constBufferOffset + blockPatchOffset);
@ -2045,7 +2045,7 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithConstantMemory
parentKernel->patchBlocksCurbeWithConstantValues();
auto *blockInfo = parentKernel->mockProgram->getBlockKernelInfo(0);
auto *blockInfo = parentKernel->mockProgram->blockKernelManager->getBlockKernelInfo(0);
uint32_t blockPatchOffset = blockInfo->patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization->DataParamOffset;
@ -2088,7 +2088,7 @@ TEST_F(ReflectionSurfaceConstantValuesPatchingTest, GivenBlockWithConstantMemory
parentKernel->patchBlocksCurbeWithConstantValues();
auto *blockInfo = parentKernel->mockProgram->getBlockKernelInfo(0);
auto *blockInfo = parentKernel->mockProgram->blockKernelManager->getBlockKernelInfo(0);
uint32_t blockPatchOffset = blockInfo->patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization->DataParamOffset;

View File

@ -2459,7 +2459,7 @@ TEST_F(KernelCrossThreadTests, patchBlocksSimdSize) {
kernel->executionEnvironmentBlock.CompiledSIMD16 = 1;
kernel->executionEnvironmentBlock.CompiledSIMD32 = 0;
infoBlock->patchInfo.executionEnvironment = &kernel->executionEnvironmentBlock;
kernel->mockProgram->addBlockKernel(infoBlock);
kernel->mockProgram->blockKernelManager->addBlockKernelInfo(infoBlock);
// patch block's simd size
kernel->mockKernel->patchBlocksSimdSize();
@ -2469,7 +2469,7 @@ TEST_F(KernelCrossThreadTests, patchBlocksSimdSize) {
uint32_t *simdSize = reinterpret_cast<uint32_t *>(blockSimdSize);
// check of block's simd size has been patched correctly
EXPECT_EQ(kernel->mockProgram->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
EXPECT_EQ(kernel->mockProgram->blockKernelManager->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
delete kernel;
}

View File

@ -75,7 +75,7 @@ TEST(ParentKernelTest, patchBlocksSimdSize) {
void *blockSimdSize = ptrOffset(parentKernel->getCrossThreadData(), parentKernel->getKernelInfo().childrenKernelsIdOffset[0].second);
uint32_t *simdSize = reinterpret_cast<uint32_t *>(blockSimdSize);
EXPECT_EQ(program->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
EXPECT_EQ(program->blockKernelManager->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
}
TEST(ParentKernelTest, hasDeviceEnqueue) {
@ -104,7 +104,7 @@ TEST(ParentKernelTest, initializeOnParentKernelPatchesBlocksSimdSize) {
void *blockSimdSize = ptrOffset(parentKernel->getCrossThreadData(), parentKernel->getKernelInfo().childrenKernelsIdOffset[0].second);
uint32_t *simdSize = reinterpret_cast<uint32_t *>(blockSimdSize);
EXPECT_EQ(program->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
EXPECT_EQ(program->blockKernelManager->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
}
TEST(ParentKernelTest, initializeOnParentKernelAllocatesPrivateMemoryForBlocks) {
@ -194,7 +194,7 @@ TEST(ParentKernelTest, initializeOnParentKernelAllocatesPrivateMemoryForBlocks)
infoBlock->heapInfo.pDsh = (void *)new uint64_t[64];
infoBlock->crossThreadData = new char[crossThreadOffsetBlock];
program->addBlockKernel(infoBlock);
program->blockKernelManager->addBlockKernelInfo(infoBlock);
parentKernel->initialize();

View File

@ -11,6 +11,7 @@
#include "runtime/device/device.h"
#include "runtime/kernel/grf_config.h"
#include "runtime/kernel/kernel.h"
#include "runtime/program/block_kernel_manager.h"
#include "runtime/scheduler/scheduler_kernel.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_program.h"
@ -532,7 +533,7 @@ class MockParentKernel : public Kernel {
infoBlock->heapInfo.pDsh = (void *)new uint64_t[64];
infoBlock->crossThreadData = new char[crossThreadOffsetBlock > crossThreadSize ? crossThreadOffsetBlock : crossThreadSize];
mockProgram->addBlockKernel(infoBlock);
mockProgram->blockKernelManager->addBlockKernelInfo(infoBlock);
parent->mockProgram = mockProgram;
return parent;

View File

@ -11,6 +11,7 @@
#include "core/helpers/hash.h"
#include "runtime/context/context.h"
#include "runtime/program/create.inl"
#include "runtime/program/kernel_info.h"
#include "unit_tests/mocks/mock_compilers.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"

View File

@ -9,6 +9,7 @@
#include "core/helpers/hash.h"
#include "core/helpers/string.h"
#include "runtime/helpers/options.h"
#include "runtime/program/kernel_info.h"
#include "runtime/program/program.h"
#include "gmock/gmock.h"
@ -26,15 +27,17 @@ class MockProgram : public Program {
public:
using Program::createProgramFromBinary;
using Program::getKernelNamesString;
using Program::getProgramCompilerVersion;
using Program::isKernelDebugEnabled;
using Program::linkBinary;
using Program::populateKernelInfo;
using Program::prepareLinkerInputStorage;
using Program::rebuildProgramFromIr;
using Program::resolveProgramBinary;
using Program::separateBlockKernels;
using Program::updateNonUniformFlag;
using Program::areSpecializationConstantsInitialized;
using Program::blockKernelManager;
using Program::constantSurface;
using Program::context;
using Program::debugData;
@ -81,18 +84,6 @@ class MockProgram : public Program {
void setDevice(Device *device) {
this->pDevice = device;
};
const KernelInfo *getBlockKernelInfo(size_t ordinal) {
return blockKernelManager->getBlockKernelInfo(ordinal);
}
size_t getNumberOfBlocks() {
return blockKernelManager->getCount();
}
void addBlockKernel(KernelInfo *blockInfo) {
blockKernelManager->addBlockKernelInfo(blockInfo);
}
void separateBlockKernels() {
Program::separateBlockKernels();
}
std::vector<KernelInfo *> &getKernelInfoArray() {
return kernelInfoArray;
}
@ -138,7 +129,15 @@ class MockProgram : public Program {
extractInternalOptions(buildOptions);
}
cl_int isHandled(const PatchTokenBinary::ProgramFromPatchtokens &decodedProgram) const override {
if (skipValidationOfBinary) {
return CL_SUCCESS;
}
return Program::isHandled(decodedProgram);
}
bool contextSet = false;
bool skipValidationOfBinary = false;
};
class GlobalMockSipProgram : public Program {

View File

@ -11,6 +11,7 @@ set(IGDRCL_SRCS_tests_program
${CMAKE_CURRENT_SOURCE_DIR}/kernel_data.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_data_OCL2_0.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_info_from_patchtokens_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/printf_handler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/printf_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/process_debug_data_tests.cpp

View File

@ -5,6 +5,7 @@
*
*/
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/program/create.inl"
#include "runtime/program/program.h"
@ -89,7 +90,7 @@ inline std::vector<char> CreateBinary(bool addUnhandledProgramScopePatchToken, b
kernelName.push_back('\0');
}
iOpenCL::SKernelBinaryHeaderCommon kernBinHeader = {};
kernBinHeader.CheckSum = 0;
kernBinHeader.CheckSum = 0U;
kernBinHeader.ShaderHashCode = 0;
kernBinHeader.KernelNameSize = static_cast<uint32_t>(kernelName.size());
kernBinHeader.PatchListSize = 0;
@ -99,19 +100,21 @@ inline std::vector<char> CreateBinary(bool addUnhandledProgramScopePatchToken, b
kernBinHeader.SurfaceStateHeapSize = 0;
kernBinHeader.KernelUnpaddedSize = 0;
if (false == addUnhandledKernelScopePatchToken) {
PushBackToken(ret, kernBinHeader);
ret.insert(ret.end(), kernelName.begin(), kernelName.end());
} else {
kernBinHeader.PatchListSize = static_cast<uint32_t>(sizeof(iOpenCL::SPatchItemHeader));
PushBackToken(ret, kernBinHeader);
ret.insert(ret.end(), kernelName.begin(), kernelName.end());
auto headerOffset = ret.size();
PushBackToken(ret, kernBinHeader);
ret.insert(ret.end(), kernelName.begin(), kernelName.end());
uint32_t patchListSize = 0;
if (addUnhandledKernelScopePatchToken) {
iOpenCL::SPatchItemHeader unhandledToken = {};
unhandledToken.Size = static_cast<uint32_t>(sizeof(iOpenCL::SPatchItemHeader));
unhandledToken.Token = static_cast<uint32_t>(unhandledTokenId);
PushBackToken(ret, unhandledToken);
patchListSize = static_cast<uint32_t>(sizeof(iOpenCL::SPatchItemHeader));
}
iOpenCL::SKernelBinaryHeaderCommon *kernHeader = reinterpret_cast<iOpenCL::SKernelBinaryHeaderCommon *>(ret.data() + headerOffset);
kernHeader->PatchListSize = patchListSize;
auto kernelData = reinterpret_cast<const uint8_t *>(kernHeader);
kernHeader->CheckSum = NEO::PatchTokenBinary::calcKernelChecksum(ArrayRef<const uint8_t>(kernelData, reinterpret_cast<const uint8_t *>(&*ret.rbegin()) + 1));
}
return ret;
@ -156,6 +159,6 @@ TEST(EvaluateUnhandledToken, WhenDecodingKernelBinaryIfUnhandledTokenIsFoundAndI
TEST(EvaluateUnhandledToken, WhenDecodingKernelBinaryIfUnhandledTokenIsFoundAndIsUnsafeToSkipThenDecodingFails) {
int lastUnhandledTokenFound = -1;
auto retVal = GetDecodeErrorCode(CreateBinary(false, true, unhandledTokenId), false, -7, lastUnhandledTokenFound);
EXPECT_EQ(CL_INVALID_KERNEL, retVal);
EXPECT_EQ(CL_INVALID_BINARY, retVal);
EXPECT_EQ(unhandledTokenId, lastUnhandledTokenFound);
}

View File

@ -525,9 +525,9 @@ TEST_P(DataParameterTest, DataParameterTests) {
buildAndDecode();
if (pKernelInfo->patchInfo.dataParameterBuffers.size() > 0) {
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(GetParam(), pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
if (pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size() > 0) {
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs[0]->Token);
EXPECT_EQ_VAL(GetParam(), pKernelInfo->patchInfo.dataParameterBuffersKernelArgs[0]->Type);
if (pKernelInfo->kernelArgInfo.size() == dataParameterToken.ArgumentNumber + 1) {
if (GetParam() == DATA_PARAMETER_BUFFER_STATEFUL) {
EXPECT_TRUE(pKernelInfo->kernelArgInfo[dataParameterToken.ArgumentNumber].pureStatefulBufferAccess);
@ -553,7 +553,7 @@ TEST_F(KernelDataParameterTest, DataParameterTestsDataPatameterBufferOffset) {
dataParameterToken.DataSize = sizeof(uint32_t);
dataParameterToken.LocationIndex = 0x0;
dataParameterToken.LocationIndex2 = 0x0;
dataParameterToken.Offset = 0;
dataParameterToken.Offset = 128;
dataParameterToken.SourceOffset = 8;
pPatchList = &dataParameterToken;
@ -561,9 +561,9 @@ TEST_F(KernelDataParameterTest, DataParameterTestsDataPatameterBufferOffset) {
buildAndDecode();
ASSERT_EQ(1u, pKernelInfo->patchInfo.dataParameterBuffers.size());
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_BUFFER_OFFSET, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ_VAL(pKernelInfo->kernelArgInfo[1].offsetBufferOffset, dataParameterToken.Offset);
}
TEST_F(KernelDataParameterTest, givenDataParameterBufferStatefulWhenDecodingThenSetArgAsPureStateful) {
@ -578,10 +578,9 @@ TEST_F(KernelDataParameterTest, givenDataParameterBufferStatefulWhenDecodingThen
buildAndDecode();
ASSERT_EQ(1u, pKernelInfo->patchInfo.dataParameterBuffers.size());
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_BUFFER_STATEFUL, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_TRUE(pKernelInfo->kernelArgInfo[dataParameterToken.ArgumentNumber].pureStatefulBufferAccess);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_TRUE(pKernelInfo->kernelArgInfo[1].pureStatefulBufferAccess);
}
TEST_F(KernelDataParameterTest, givenUnknownDataParameterWhenDecodedThenParameterIsIgnored) {
@ -601,7 +600,7 @@ TEST_F(KernelDataParameterTest, givenUnknownDataParameterWhenDecodedThenParamete
buildAndDecode();
EXPECT_EQ_VAL(0u, pKernelInfo->patchInfo.dataParameterBuffers.size());
EXPECT_EQ_VAL(0u, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
}
TEST_F(KernelDataTest, DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES) {
@ -625,10 +624,10 @@ TEST_F(KernelDataTest, DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES)
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(alignment, pKernelInfo->kernelArgInfo[argumentNumber].slmAlignment);
ASSERT_EQ(1U, pKernelInfo->kernelArgInfo[argumentNumber].kernelArgPatchInfoVector.size());
EXPECT_EQ(offsetCrossThread, pKernelInfo->kernelArgInfo[argumentNumber].kernelArgPatchInfoVector[0].crossthreadOffset);
}
@ -653,9 +652,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_WIDTH) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_WIDTH, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetImgWidth, pKernelInfo->kernelArgInfo[argumentNumber].offsetImgWidth);
}
@ -680,8 +678,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_HEIGHT) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_HEIGHT, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetImgHeight, pKernelInfo->kernelArgInfo[argumentNumber].offsetImgHeight);
}
@ -707,8 +705,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_DEPTH) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_DEPTH, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetImgDepth, pKernelInfo->kernelArgInfo[argumentNumber].offsetImgDepth);
}
@ -734,8 +732,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_NUM_SAMPLES) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_NUM_SAMPLES, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetNumSamples, pKernelInfo->kernelArgInfo[argumentNumber].offsetNumSamples);
}
@ -761,8 +759,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_NUM_MIP_LEVELS) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_NUM_MIP_LEVELS, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetNumMipLevels, pKernelInfo->kernelArgInfo[argumentNumber].offsetNumMipLevels);
}
@ -788,8 +786,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_DATA_TYPE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_CHANNEL_DATA_TYPE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetChannelDataType, pKernelInfo->kernelArgInfo[argumentNumber].offsetChannelDataType);
}
@ -815,8 +813,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_CHANNEL_ORDER) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_CHANNEL_ORDER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetChannelOrder, pKernelInfo->kernelArgInfo[argumentNumber].offsetChannelOrder);
}
@ -842,8 +840,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_IMAGE_ARRAY_SIZE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_IMAGE_ARRAY_SIZE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetImageArraySize, pKernelInfo->kernelArgInfo[argumentNumber].offsetArraySize);
}
@ -869,8 +867,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_WORK_DIMENSIONS) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_WORK_DIMENSIONS, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetWorkDim, pKernelInfo->workloadInfo.workDimOffset);
}
@ -896,10 +894,9 @@ TEST_F(KernelDataTest, DATA_PARAMETER_SIMD_SIZE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_SIMD_SIZE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0u, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetSimdSize, pKernelInfo->workloadInfo.simdSizeOffset);
}
@ -924,8 +921,7 @@ TEST_F(KernelDataTest, DATA_PARAMETER_PRIVATE_MEMORY_STATELESS_SIZE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_PRIVATE_MEMORY_STATELESS_SIZE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0u, pKernelInfo->kernelArgInfo.size());
}
@ -950,8 +946,7 @@ TEST_F(KernelDataTest, DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_SIZE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_SIZE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0u, pKernelInfo->kernelArgInfo.size());
}
@ -976,8 +971,7 @@ TEST_F(KernelDataTest, DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRES
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0u, pKernelInfo->kernelArgInfo.size());
}
@ -1002,8 +996,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_NUM_WORK_GROUPS) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_NUM_WORK_GROUPS, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetNumWorkGroups[argumentNumber], pKernelInfo->workloadInfo.numWorkGroupsOffset[argumentNumber]);
}
@ -1029,8 +1023,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_MAX_WORKGROUP_SIZE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_MAX_WORKGROUP_SIZE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetMaxWorkGroupSize, pKernelInfo->workloadInfo.maxWorkGroupSizeOffset);
}
@ -1057,10 +1051,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_SAMPLER_ADDRESS_MODE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_SAMPLER_ADDRESS_MODE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
ASSERT_EQ(1u, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(1U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(dataOffset, pKernelInfo->kernelArgInfo[0].offsetSamplerAddressingMode);
}
@ -1087,10 +1079,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_SAMPLER_COORDINATE_SNAP_WA_REQUIRED) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_SAMPLER_COORDINATE_SNAP_WA_REQUIRED, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
ASSERT_EQ(2u, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(dataOffset, pKernelInfo->kernelArgInfo[1].offsetSamplerSnapWa);
}
@ -1117,10 +1107,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_SAMPLER_NORMALIZED_COORDS) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_SAMPLER_NORMALIZED_COORDS, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
ASSERT_EQ(2u, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(dataOffset, pKernelInfo->kernelArgInfo[1].offsetSamplerNormalizedCoords);
}
@ -1157,8 +1145,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_KERNEL_ARGUMENT) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_KERNEL_ARGUMENT, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_KERNEL_ARGUMENT, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs[0]->Type);
ASSERT_EQ(1u, pKernelInfo->kernelArgInfo.size());
ASSERT_EQ(2u, pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.size());
@ -1273,8 +1261,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_VME_MB_BLOCK_TYPE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_VME_MB_BLOCK_TYPE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetVmeMbBlockType, pKernelInfo->kernelArgInfo[argumentNumber].offsetVmeMbBlockType);
}
@ -1300,8 +1288,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_VME_SUBPIXEL_MODE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_VME_SUBPIXEL_MODE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetVmeSubpixelMode, pKernelInfo->kernelArgInfo[argumentNumber].offsetVmeSubpixelMode);
}
@ -1327,8 +1315,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_VME_SAD_ADJUST_MODE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_VME_SAD_ADJUST_MODE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetVmeSadAdjustMode, pKernelInfo->kernelArgInfo[argumentNumber].offsetVmeSadAdjustMode);
}
@ -1354,8 +1342,8 @@ TEST_F(KernelDataTest, DATA_PARAMETER_VME_SEARCH_PATH_TYPE) {
buildAndDecode();
EXPECT_EQ_CONST(PATCH_TOKEN_DATA_PARAMETER_BUFFER, pKernelInfo->patchInfo.dataParameterBuffers[0]->Token);
EXPECT_EQ_VAL(DATA_PARAMETER_VME_SEARCH_PATH_TYPE, pKernelInfo->patchInfo.dataParameterBuffers[0]->Type);
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
ASSERT_EQ(2U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ(offsetVmeSearchPathType, pKernelInfo->kernelArgInfo[argumentNumber].offsetVmeSearchPathType);
}
@ -1372,6 +1360,8 @@ TEST_F(KernelDataTest, PATCH_TOKEN_STATE_SIP) {
buildAndDecode();
EXPECT_EQ(0U, pKernelInfo->patchInfo.dataParameterBuffersKernelArgs.size());
EXPECT_EQ(0U, pKernelInfo->kernelArgInfo.size());
EXPECT_EQ_VAL(token.SystemKernelOffset, pKernelInfo->systemKernelOffset);
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/program/kernel_info.h"
#include "runtime/program/kernel_info_from_patchtokens.h"
#include "unit_tests/compiler_interface/patchtokens_tests.h"
TEST(GetInlineData, GivenValidEmptyKernelFromPatchtokensThenReturnEmptyKernelInfo) {
std::vector<uint8_t> storage;
auto src = PatchTokensTestData::ValidEmptyKernel::create(storage);
NEO::KernelInfo dst = {};
NEO::populateKernelInfo(dst, src);
NEO::KernelInfo expectedKernelInfo = {};
expectedKernelInfo.name = std::string(src.name.begin()).c_str();
expectedKernelInfo.heapInfo.pKernelHeader = src.header;
expectedKernelInfo.isValid = true;
EXPECT_STREQ(expectedKernelInfo.name.c_str(), dst.name.c_str());
EXPECT_EQ(expectedKernelInfo.heapInfo.pKernelHeader, dst.heapInfo.pKernelHeader);
EXPECT_EQ(expectedKernelInfo.isValid, dst.isValid);
}

View File

@ -5,6 +5,7 @@
*
*/
#include "core/elf/reader.h"
#include "core/helpers/file_io.h"
#include "core/helpers/string.h"
#include "runtime/device/device.h"

View File

@ -68,12 +68,12 @@ class ProgramDataTestBase : public testing::Test,
SPatchAllocateConstantMemorySurfaceProgramBinaryInfo allocateConstMemorySurface;
allocateConstMemorySurface.Token = PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
allocateConstMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo) + constSize);
allocateConstMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo));
allocateConstMemorySurface.ConstantBufferIndex = 0;
allocateConstMemorySurface.InlineDataSize = static_cast<uint32_t>(constSize);
pAllocateConstMemorySurface.reset(new cl_char[allocateConstMemorySurface.Size]);
pAllocateConstMemorySurface.reset(new cl_char[allocateConstMemorySurface.Size + constSize]);
memcpy_s(pAllocateConstMemorySurface.get(),
sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo),
@ -83,7 +83,7 @@ class ProgramDataTestBase : public testing::Test,
memcpy_s((cl_char *)pAllocateConstMemorySurface.get() + sizeof(allocateConstMemorySurface), constSize, constValue, constSize);
pProgramPatchList = (void *)pAllocateConstMemorySurface.get();
programPatchListSize = allocateConstMemorySurface.Size;
programPatchListSize = static_cast<uint32_t>(allocateConstMemorySurface.Size + constSize);
return constSize;
}
@ -94,12 +94,12 @@ class ProgramDataTestBase : public testing::Test,
SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface;
allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo) + globalSize);
allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo));
allocateGlobalMemorySurface.GlobalBufferIndex = 0;
allocateGlobalMemorySurface.InlineDataSize = static_cast<uint32_t>(globalSize);
pAllocateGlobalMemorySurface.reset(new cl_char[allocateGlobalMemorySurface.Size]);
pAllocateGlobalMemorySurface.reset(new cl_char[allocateGlobalMemorySurface.Size + globalSize]);
memcpy_s(pAllocateGlobalMemorySurface.get(),
sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo),
@ -109,7 +109,7 @@ class ProgramDataTestBase : public testing::Test,
memcpy_s((cl_char *)pAllocateGlobalMemorySurface.get() + sizeof(allocateGlobalMemorySurface), globalSize, globalValue, globalSize);
pProgramPatchList = pAllocateGlobalMemorySurface.get();
programPatchListSize = allocateGlobalMemorySurface.Size;
programPatchListSize = static_cast<uint32_t>(allocateGlobalMemorySurface.Size + globalSize);
return globalSize;
}
std::unique_ptr<cl_char[]> pAllocateConstMemorySurface;
@ -376,11 +376,11 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) {
// regular case - global surface exists
SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface;
allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo) + globalPointerSize);
allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo));
allocateGlobalMemorySurface.GlobalBufferIndex = 0;
allocateGlobalMemorySurface.InlineDataSize = static_cast<uint32_t>(globalPointerSize);
cl_char *pAllocateGlobalMemorySurface = new cl_char[allocateGlobalMemorySurface.Size];
cl_char *pAllocateGlobalMemorySurface = new cl_char[allocateGlobalMemorySurface.Size + globalPointerSize];
memcpy_s(pAllocateGlobalMemorySurface,
sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo),
@ -389,7 +389,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) {
memcpy_s((cl_char *)pAllocateGlobalMemorySurface + sizeof(allocateGlobalMemorySurface), globalPointerSize, &pGlobalPointerValue, globalPointerSize);
pProgramPatchList = pAllocateGlobalMemorySurface;
programPatchListSize = allocateGlobalMemorySurface.Size;
programPatchListSize = static_cast<uint32_t>(allocateGlobalMemorySurface.Size + globalPointerSize);
buildAndDecodeProgramPatchList();
EXPECT_NE(nullptr, pProgram->getGlobalSurface());
@ -418,7 +418,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) {
sizeof(SPatchGlobalPointerProgramBinaryInfo));
pProgramPatchList = (void *)pGlobalPointer;
programPatchListSize = globalPointer.Size;
this->allowDecodeFailure = true;
buildAndDecodeProgramPatchList();
EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize));
@ -441,7 +441,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) {
sizeof(SPatchGlobalPointerProgramBinaryInfo));
pProgramPatchList = (void *)pGlobalPointer;
programPatchListSize = globalPointer.Size;
this->allowDecodeFailure = true;
buildAndDecodeProgramPatchList();
EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize));
@ -472,6 +472,8 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) {
delete[] pGlobalPointer;
// regular case - global pointer to global surface - all parameters valid
this->pProgram->skipValidationOfBinary = true;
this->allowDecodeFailure = false;
globalPointer.Token = PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO;
globalPointer.Size = sizeof(SPatchGlobalPointerProgramBinaryInfo);
@ -506,12 +508,12 @@ TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHa
SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo allocateGlobalMemorySurface;
allocateGlobalMemorySurface.Token = PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo) + globalSize);
allocateGlobalMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo));
allocateGlobalMemorySurface.GlobalBufferIndex = 0;
allocateGlobalMemorySurface.InlineDataSize = static_cast<uint32_t>(globalSize);
cl_char *pAllocateGlobalMemorySurface = new cl_char[allocateGlobalMemorySurface.Size];
cl_char *pAllocateGlobalMemorySurface = new cl_char[allocateGlobalMemorySurface.Size + globalSize];
memcpy_s(pAllocateGlobalMemorySurface,
sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo),
@ -521,7 +523,7 @@ TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHa
memcpy_s((cl_char *)pAllocateGlobalMemorySurface + sizeof(allocateGlobalMemorySurface), globalSize, globalValue, globalSize);
pProgramPatchList = (void *)pAllocateGlobalMemorySurface;
programPatchListSize = allocateGlobalMemorySurface.Size;
programPatchListSize = static_cast<uint32_t>(allocateGlobalMemorySurface.Size + globalSize);
buildAndDecodeProgramPatchList();
@ -569,12 +571,12 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) {
SPatchAllocateConstantMemorySurfaceProgramBinaryInfo allocateConstMemorySurface;
allocateConstMemorySurface.Token = PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO;
// note : + sizeof(uint64_t) is to accomodate for constant buffer offset
allocateConstMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo) + constantDataLen + sizeof(uint64_t));
allocateConstMemorySurface.Size = static_cast<uint32_t>(sizeof(SPatchAllocateConstantMemorySurfaceProgramBinaryInfo));
allocateConstMemorySurface.ConstantBufferIndex = 0;
allocateConstMemorySurface.InlineDataSize = static_cast<uint32_t>(constantDataLen + sizeof(uint64_t));
auto pAllocateConstMemorySurface = std::unique_ptr<char>(new char[allocateConstMemorySurface.Size]);
auto pAllocateConstMemorySurface = std::unique_ptr<char>(new char[allocateConstMemorySurface.Size + allocateConstMemorySurface.InlineDataSize]);
// copy the token header
memcpy_s(pAllocateConstMemorySurface.get(),
@ -590,7 +592,7 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) {
*(uint64_t *)((char *)pAllocateConstMemorySurface.get() + sizeof(allocateConstMemorySurface) + constantBufferOffsetPatchOffset) = 0U;
pProgramPatchList = (void *)pAllocateConstMemorySurface.get();
programPatchListSize = allocateConstMemorySurface.Size;
programPatchListSize = allocateConstMemorySurface.Size + allocateConstMemorySurface.InlineDataSize;
buildAndDecodeProgramPatchList();
@ -630,6 +632,7 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) {
pProgramPatchList = (void *)pConstantPointer;
programPatchListSize = constantPointer.Size;
this->allowDecodeFailure = true;
buildAndDecodeProgramPatchList();
EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen));
// check that constant pointer offset was not patched
@ -704,7 +707,8 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) {
sizeof(SPatchConstantPointerProgramBinaryInfo));
pProgramPatchList = (void *)pConstantPointer;
programPatchListSize = constantPointer.Size;
this->pProgram->skipValidationOfBinary = true;
this->allowDecodeFailure = false;
buildAndDecodeProgramPatchList();
EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen));
@ -748,6 +752,7 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeConstantB
uint32_t sentinel = 0x17192329U;
constantSurfaceStorage[0] = 0U;
constantSurfaceStorage[1] = sentinel;
this->pProgram->skipValidationOfBinary = true;
buildAndDecodeProgramPatchList();
uint32_t expectedAddr = static_cast<uint32_t>(constantSurface.getGraphicsAllocation()->getGpuAddressToPatch());
EXPECT_EQ(expectedAddr, constantSurfaceStorage[0]);
@ -790,6 +795,7 @@ TEST_F(ProgramDataTest, GivenProgramWith32bitPointerOptWhenProgramScopeGlobalPoi
uint32_t sentinel = 0x17192329U;
globalSurfaceStorage[0] = 0U;
globalSurfaceStorage[1] = sentinel;
this->pProgram->skipValidationOfBinary = true;
buildAndDecodeProgramPatchList();
uint32_t expectedAddr = static_cast<uint32_t>(globalSurface.getGraphicsAllocation()->getGpuAddressToPatch());
EXPECT_EQ(expectedAddr, globalSurfaceStorage[0]);

View File

@ -18,6 +18,7 @@
#include "core/unit_tests/utilities/base_object_utils.h"
#include "runtime/command_stream/command_stream_receiver_hw.h"
#include "runtime/compiler_interface/compiler_options.h"
#include "runtime/compiler_interface/patchtokens_decoder.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/hardware_commands_helper.h"
#include "runtime/indirect_heap/indirect_heap.h"
@ -1564,7 +1565,6 @@ TEST_F(ProgramPatchTokenTests, DISABLED_ConstantMemorySurface) {
false);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(0u, pProgram->getProgramScopePatchListSize());
}
////////////////////////////////////////////////////////////////////////////////
@ -1882,12 +1882,6 @@ TEST_F(ProgramTests, givenStatelessToStatefullOptimizationOffWHenProgramIsCreate
EXPECT_THAT(pProgram->getInternalOptions(), Not(testing::HasSubstr(std::string("-cl-intel-has-buffer-offset-arg "))));
}
TEST_F(ProgramTests, ProgramCtorSetsProperProgramScopePatchListSize) {
MockProgram program(*pDevice->getExecutionEnvironment(), pContext, false);
EXPECT_EQ((size_t)0, program.getProgramScopePatchListSize());
}
TEST_F(ProgramTests, GivenContextWhenCreateProgramThenIncrementContextRefCount) {
auto initialApiRefCount = pContext->getReference();
auto initialInternalRefCount = pContext->getRefInternalCount();
@ -2062,7 +2056,7 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KE
pKHdr->CheckSum = 0;
pKHdr->ShaderHashCode = 0;
pKHdr->KernelNameSize = 8;
pKHdr->PatchListSize = 24;
pKHdr->PatchListSize = sizeof(iOpenCL::SPatchGlobalMemoryObjectKernelArgument);
pKHdr->KernelHeapSize = 0;
pKHdr->GeneralStateHeapSize = 0;
pKHdr->DynamicStateHeapSize = 0;
@ -2082,7 +2076,11 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KE
pPatch->Offset = 0x40;
pPatch->LocationIndex = iOpenCL::INVALID_INDEX;
pPatch->LocationIndex2 = iOpenCL::INVALID_INDEX;
binSize += sizeof(SPatchGlobalMemoryObjectKernelArgument);
binSize += pPatch->Size;
pBin += pPatch->Size;
ArrayRef<const uint8_t> kernelBlob(reinterpret_cast<uint8_t *>(pKHdr), reinterpret_cast<uint8_t *>(pBin));
pKHdr->CheckSum = PatchTokenBinary::calcKernelChecksum(kernelBlob);
// Decode prepared program binary
pProgram->genBinary = makeCopy(&genBin[0], binSize);
@ -2147,6 +2145,8 @@ TEST_F(ProgramTests, givenProgramFromGenBinaryWhenSLMSizeIsBiggerThenDeviceLimit
pPatch->TotalInlineLocalMemorySize = static_cast<uint32_t>(pDevice->getDeviceInfo().localMemSize * 2);
binSize += sizeof(SPatchAllocateLocalSurface);
pBin += sizeof(SPatchAllocateLocalSurface);
pKHdr->CheckSum = PatchTokenBinary::calcKernelChecksum(ArrayRef<const uint8_t>(reinterpret_cast<uint8_t *>(pKHdr), reinterpret_cast<uint8_t *>(pBin)));
// Decode prepared program binary
program->genBinary = makeCopy(&genBin[0], binSize);
@ -2186,11 +2186,12 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GTPIN_FREE_GRF_INFO) {
pBin += sizeof(SProgramBinaryHeader);
binSize += sizeof(SProgramBinaryHeader);
uint32_t patchTokenSize = sizeof(iOpenCL::SPatchGtpinFreeGRFInfo) + GRF_INFO_SIZE;
SKernelBinaryHeaderCommon *pKHdr = (SKernelBinaryHeaderCommon *)pBin;
pKHdr->CheckSum = 0;
pKHdr->ShaderHashCode = 0;
pKHdr->KernelNameSize = 8;
pKHdr->PatchListSize = 24;
pKHdr->PatchListSize = patchTokenSize;
pKHdr->KernelHeapSize = 0;
pKHdr->GeneralStateHeapSize = 0;
pKHdr->DynamicStateHeapSize = 0;
@ -2205,9 +2206,12 @@ TEST_F(ProgramTests, ProgramFromGenBinaryWithPATCH_TOKEN_GTPIN_FREE_GRF_INFO) {
SPatchGtpinFreeGRFInfo *pPatch = (SPatchGtpinFreeGRFInfo *)pBin;
pPatch->Token = iOpenCL::PATCH_TOKEN_GTPIN_FREE_GRF_INFO;
pPatch->Size = sizeof(iOpenCL::SPatchGtpinFreeGRFInfo) + GRF_INFO_SIZE;
pPatch->Size = patchTokenSize;
pPatch->BufferSize = GRF_INFO_SIZE;
binSize += pPatch->Size;
pBin += pPatch->Size;
pKHdr->CheckSum = PatchTokenBinary::calcKernelChecksum(ArrayRef<const uint8_t>(reinterpret_cast<uint8_t *>(pKHdr), reinterpret_cast<uint8_t *>(pBin)));
// Decode prepared program binary
pProgram->genBinary = makeCopy(&genBin[0], binSize);
@ -2423,32 +2427,6 @@ TEST_F(ProgramTests, RebuildBinaryWithProcessGenBinaryError) {
EXPECT_EQ(CL_INVALID_BINARY, retVal);
}
TEST_F(ProgramTests, GetProgramCompilerVersion) {
auto program = std::make_unique<MockProgram>(*pDevice->getExecutionEnvironment());
// Create example header of OpenCL Program Binary
cl_device_id deviceId = pContext->getDevice(0);
Device *pDevice = castToObject<Device>(deviceId);
struct SProgramBinaryHeader prgHdr;
prgHdr.Magic = iOpenCL::MAGIC_CL;
prgHdr.Version = 12;
prgHdr.Device = pDevice->getHardwareInfo().platform.eRenderCoreFamily;
prgHdr.GPUPointerSizeInBytes = 8;
prgHdr.NumberOfKernels = 1;
prgHdr.SteppingId = 0;
prgHdr.PatchListSize = 0;
// Check whether Program Binary version is returned correctly
uint32_t binaryVersion = 0;
program->getProgramCompilerVersion(&prgHdr, binaryVersion);
EXPECT_EQ(binaryVersion, 12u);
// Check whether Program Binary version is left intact
binaryVersion = 1;
program->getProgramCompilerVersion(nullptr, binaryVersion);
EXPECT_EQ(binaryVersion, 1u);
}
TEST_F(ProgramTests, GivenZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfacesCalledThenNoSurfaceIsCreated) {
MockProgram *program = new MockProgram(*pDevice->getExecutionEnvironment(), pContext, false);
@ -2465,7 +2443,7 @@ TEST_F(ProgramTests, GivenZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfaces
privateSurfaceBlock->PerThreadPrivateMemorySize = 0;
infoBlock->patchInfo.pAllocateStatelessPrivateSurface = privateSurfaceBlock;
program->addBlockKernel(infoBlock);
program->blockKernelManager->addBlockKernelInfo(infoBlock);
program->allocateBlockPrivateSurfaces(pDevice->getRootDeviceIndex());
@ -2491,7 +2469,7 @@ TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfa
privateSurfaceBlock->PerThreadPrivateMemorySize = 1000;
infoBlock->patchInfo.pAllocateStatelessPrivateSurface = privateSurfaceBlock;
program->addBlockKernel(infoBlock);
program->blockKernelManager->addBlockKernelInfo(infoBlock);
program->allocateBlockPrivateSurfaces(pDevice->getRootDeviceIndex());
@ -2517,7 +2495,7 @@ TEST_F(ProgramTests, GivenNonZeroPrivateSizeInBlockWhenAllocateBlockProvateSurfa
privateSurfaceBlock->PerThreadPrivateMemorySize = 1000;
infoBlock->patchInfo.pAllocateStatelessPrivateSurface = privateSurfaceBlock;
program->addBlockKernel(infoBlock);
program->blockKernelManager->addBlockKernelInfo(infoBlock);
program->allocateBlockPrivateSurfaces(pDevice->getRootDeviceIndex());
@ -2551,7 +2529,7 @@ TEST_F(ProgramTests, givenProgramWithBlockKernelsWhenfreeBlockResourcesisCalledT
privateSurfaceBlock->PerThreadPrivateMemorySize = 1000;
infoBlock->patchInfo.pAllocateStatelessPrivateSurface = privateSurfaceBlock;
program->addBlockKernel(infoBlock);
program->blockKernelManager->addBlockKernelInfo(infoBlock);
GraphicsAllocation *privateSurface = program->getDevice(0).getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
EXPECT_NE(nullptr, privateSurface);

View File

@ -7,6 +7,7 @@
#include "core/compiler_interface/compiler_interface.h"
#include "runtime/device/device.h"
#include "runtime/program/block_kernel_manager.h"
#include "unit_tests/fixtures/context_fixture.h"
#include "unit_tests/fixtures/platform_fixture.h"
#include "unit_tests/fixtures/program_fixture.h"
@ -67,16 +68,16 @@ TEST_F(ProgramWithBlockKernelsTest, GivenKernelWithBlockKernelsWhenProgramIsBuil
auto blockKernelInfo = mockProgram->Program::getKernelInfo("simple_block_kernel_dispatch_0");
EXPECT_EQ(nullptr, blockKernelInfo);
std::vector<const KernelInfo *> blockKernelInfos(mockProgram->getNumberOfBlocks());
std::vector<const KernelInfo *> blockKernelInfos(mockProgram->blockKernelManager->getCount());
for (size_t i = 0; i < mockProgram->getNumberOfBlocks(); i++) {
const KernelInfo *blockKernelInfo = mockProgram->getBlockKernelInfo(i);
for (size_t i = 0; i < mockProgram->blockKernelManager->getCount(); i++) {
const KernelInfo *blockKernelInfo = mockProgram->blockKernelManager->getBlockKernelInfo(i);
EXPECT_NE(nullptr, blockKernelInfo);
blockKernelInfos[i] = blockKernelInfo;
}
bool blockKernelFound = false;
for (size_t i = 0; i < mockProgram->getNumberOfBlocks(); i++) {
for (size_t i = 0; i < mockProgram->blockKernelManager->getCount(); i++) {
if (blockKernelInfos[i]->name.find("simple_block_kernel_dispatch") != std::string::npos) {
blockKernelFound = true;
break;