2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2019-02-27 18:39:32 +08:00
|
|
|
* Copyright (C) 2017-2019 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2019-06-19 15:21:29 +08:00
|
|
|
#include "core/helpers/string.h"
|
2018-03-06 22:29:06 +08:00
|
|
|
#include "runtime/helpers/hash.h"
|
|
|
|
#include "runtime/helpers/options.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
#include "runtime/program/program.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-12-05 17:58:08 +08:00
|
|
|
#include "gmock/gmock.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-31 17:01:13 +08:00
|
|
|
#include <string>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
class GraphicsAllocation;
|
|
|
|
|
2018-05-28 22:16:06 +08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Program - Core implementation
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2017-12-21 07:45:38 +08:00
|
|
|
class MockProgram : public Program {
|
|
|
|
public:
|
2018-08-06 17:07:12 +08:00
|
|
|
using Program::createProgramFromBinary;
|
2019-07-04 23:14:51 +08:00
|
|
|
using Program::getKernelNamesString;
|
2018-08-06 17:07:12 +08:00
|
|
|
using Program::getProgramCompilerVersion;
|
2018-03-09 21:40:31 +08:00
|
|
|
using Program::isKernelDebugEnabled;
|
2019-07-04 23:14:51 +08:00
|
|
|
using Program::linkBinary;
|
|
|
|
using Program::prepareLinkerInputStorage;
|
2018-08-06 17:07:12 +08:00
|
|
|
using Program::rebuildProgramFromIr;
|
2018-08-07 00:12:20 +08:00
|
|
|
using Program::resolveProgramBinary;
|
2018-08-09 16:54:35 +08:00
|
|
|
using Program::updateNonUniformFlag;
|
2018-08-07 00:12:20 +08:00
|
|
|
|
2019-04-25 18:46:43 +08:00
|
|
|
using Program::areSpecializationConstantsInitialized;
|
2019-07-04 23:14:51 +08:00
|
|
|
using Program::constantSurface;
|
|
|
|
using Program::context;
|
2018-08-07 00:12:20 +08:00
|
|
|
using Program::elfBinary;
|
|
|
|
using Program::elfBinarySize;
|
2019-07-04 23:14:51 +08:00
|
|
|
using Program::exportedFunctionsSurface;
|
2018-08-07 00:12:20 +08:00
|
|
|
using Program::genBinary;
|
|
|
|
using Program::genBinarySize;
|
2019-07-04 23:14:51 +08:00
|
|
|
using Program::globalSurface;
|
2018-08-07 00:12:20 +08:00
|
|
|
using Program::irBinary;
|
|
|
|
using Program::irBinarySize;
|
|
|
|
using Program::isProgramBinaryResolved;
|
|
|
|
using Program::isSpirV;
|
2019-07-04 23:14:51 +08:00
|
|
|
using Program::linkerInput;
|
|
|
|
using Program::pDevice;
|
2018-08-07 00:12:20 +08:00
|
|
|
using Program::programBinaryType;
|
2019-04-25 18:46:43 +08:00
|
|
|
using Program::specConstantsIds;
|
|
|
|
using Program::specConstantsSizes;
|
|
|
|
using Program::specConstantsValues;
|
2019-07-04 23:14:51 +08:00
|
|
|
using Program::symbols;
|
2018-03-09 21:40:31 +08:00
|
|
|
|
2018-08-06 22:36:12 +08:00
|
|
|
using Program::sourceCode;
|
|
|
|
|
2018-08-06 15:46:57 +08:00
|
|
|
MockProgram(ExecutionEnvironment &executionEnvironment) : Program(executionEnvironment) {}
|
|
|
|
MockProgram(ExecutionEnvironment &executionEnvironment, Context *context, bool isBuiltinKernel) : Program(executionEnvironment, context, isBuiltinKernel) {}
|
2017-12-21 07:45:38 +08:00
|
|
|
~MockProgram() {
|
|
|
|
if (contextSet)
|
|
|
|
context = nullptr;
|
|
|
|
}
|
|
|
|
const KernelInfo *getKernelInfo() { return &mockKernelInfo; }
|
|
|
|
KernelInfo mockKernelInfo;
|
|
|
|
void setBuildOptions(const char *buildOptions) {
|
|
|
|
options = buildOptions != nullptr ? buildOptions : "";
|
|
|
|
}
|
|
|
|
std::string &getInternalOptions() { return internalOptions; };
|
|
|
|
void setConstantSurface(GraphicsAllocation *gfxAllocation) {
|
|
|
|
constantSurface = gfxAllocation;
|
|
|
|
}
|
|
|
|
void setGlobalSurface(GraphicsAllocation *gfxAllocation) {
|
|
|
|
globalSurface = gfxAllocation;
|
|
|
|
}
|
|
|
|
cl_int createProgramFromBinary(const void *pBinary, size_t binarySize) override {
|
|
|
|
return Program::createProgramFromBinary(pBinary, binarySize);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
void addKernelInfo(KernelInfo *inInfo) {
|
|
|
|
kernelInfoArray.push_back(inInfo);
|
|
|
|
}
|
|
|
|
std::vector<KernelInfo *> &getParentKernelInfoArray() {
|
|
|
|
return parentKernelInfoArray;
|
|
|
|
}
|
|
|
|
std::vector<KernelInfo *> &getSubgroupKernelInfoArray() {
|
|
|
|
return subgroupKernelInfoArray;
|
|
|
|
}
|
|
|
|
void setContext(Context *context) {
|
|
|
|
this->context = context;
|
|
|
|
contextSet = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBuildStatus(cl_build_status st) { buildStatus = st; }
|
|
|
|
void SetSourceCode(const char *ptr) { sourceCode = ptr; }
|
|
|
|
void ClearOptions() { options = ""; }
|
|
|
|
void SetCreatedFromBinary(bool createdFromBin) { isCreatedFromBinary = createdFromBin; }
|
|
|
|
void ClearLog() { buildLog.clear(); }
|
|
|
|
void SetGlobalVariableTotalSize(size_t globalVarSize) { globalVarTotalSize = globalVarSize; }
|
|
|
|
void SetDevice(Device *pDev) { pDevice = pDev; }
|
|
|
|
|
2018-06-18 20:36:23 +08:00
|
|
|
char *GetIrBinary() { return irBinary; }
|
|
|
|
size_t GetIrBinarySize() { return irBinarySize; }
|
|
|
|
void SetIrBinary(char *ptr, bool isSpirv) {
|
|
|
|
irBinary = ptr;
|
|
|
|
this->isSpirV = isSpirV;
|
|
|
|
}
|
|
|
|
void SetIrBinarySize(size_t bsz, bool isSpirv) {
|
|
|
|
irBinarySize = bsz;
|
|
|
|
this->isSpirV = isSpirV;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-31 17:01:13 +08:00
|
|
|
std::string getCachedFileName() const;
|
2018-02-16 16:15:36 +08:00
|
|
|
void setAllowNonUniform(bool allow) {
|
|
|
|
allowNonUniform = allow;
|
|
|
|
}
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-04-18 21:48:03 +08:00
|
|
|
char *getDebugDataBinary(size_t &debugDataBinarySize) const {
|
|
|
|
debugDataBinarySize = this->debugDataSize;
|
|
|
|
return this->debugData;
|
|
|
|
}
|
|
|
|
|
2018-03-09 18:52:14 +08:00
|
|
|
Device *getDevicePtr() { return this->pDevice; }
|
|
|
|
|
2018-10-02 21:08:23 +08:00
|
|
|
void extractInternalOptionsForward(std::string &buildOptions) {
|
|
|
|
extractInternalOptions(buildOptions);
|
|
|
|
}
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
bool contextSet = false;
|
|
|
|
};
|
2018-03-06 22:29:06 +08:00
|
|
|
|
2018-05-14 17:25:18 +08:00
|
|
|
class GlobalMockSipProgram : public Program {
|
|
|
|
public:
|
|
|
|
using Program::Program;
|
2018-08-06 15:46:57 +08:00
|
|
|
GlobalMockSipProgram(ExecutionEnvironment &executionEnvironment) : Program(executionEnvironment) {
|
2018-05-14 17:25:18 +08:00
|
|
|
}
|
|
|
|
cl_int processGenBinary() override;
|
|
|
|
cl_int processGenBinaryOnce();
|
|
|
|
void resetAllocationState();
|
|
|
|
void resetAllocation(GraphicsAllocation *allocation);
|
|
|
|
void deleteAllocation();
|
|
|
|
GraphicsAllocation *getAllocation();
|
|
|
|
static void initSipProgram();
|
|
|
|
static void shutDownSipProgram();
|
|
|
|
static GlobalMockSipProgram *sipProgram;
|
2018-08-08 19:05:16 +08:00
|
|
|
static Program *getSipProgramWithCustomBinary();
|
2018-05-14 17:25:18 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void *sipAllocationStorage;
|
2018-08-14 16:56:42 +08:00
|
|
|
static ExecutionEnvironment executionEnvironment;
|
2018-05-14 17:25:18 +08:00
|
|
|
};
|
|
|
|
|
2018-12-05 17:58:08 +08:00
|
|
|
class GMockProgram : public Program {
|
|
|
|
public:
|
|
|
|
using Program::Program;
|
|
|
|
MOCK_METHOD0(appendKernelDebugOptions, bool(void));
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|