Refactor SIP acquiring

Acquire SIP by device, not by context

Change-Id: Iac850db1d65c52ebc8a331039046c0dd6acf1d4e
This commit is contained in:
Chodor, Jaroslaw
2018-01-08 03:25:27 +01:00
parent f6eb2617b9
commit 1fd771e5a5
6 changed files with 22 additions and 7 deletions

View File

@@ -111,7 +111,7 @@ SchedulerKernel &BuiltIns::getSchedulerKernel(Context &context) {
return *static_cast<SchedulerKernel *>(schedulerBuiltIn.pKernel);
}
SipKernel &BuiltIns::getSipKernel(SipKernelType type, Context &context) {
const SipKernel &BuiltIns::getSipKernel(SipKernelType type, const Device &device) {
uint32_t kernelId = static_cast<uint32_t>(type);
UNRECOVERABLE_IF(kernelId >= static_cast<uint32_t>(SipKernelType::COUNT));
auto &sipBuiltIn = this->sipKernels[kernelId];
@@ -123,11 +123,11 @@ SipKernel &BuiltIns::getSipKernel(SipKernelType type, Context &context) {
auto compilerInteface = CompilerInterface::getInstance();
UNRECOVERABLE_IF(compilerInteface == nullptr);
auto ret = compilerInteface->getSipKernelBinary(type, *context.getDevice(0), sipBinary);
auto ret = compilerInteface->getSipKernelBinary(type, device, sipBinary);
UNRECOVERABLE_IF(ret != CL_SUCCESS);
UNRECOVERABLE_IF(sipBinary.size() == 0);
auto program = Program::createFromGenBinary(&context,
auto program = Program::createFromGenBinary(nullptr,
sipBinary.data(),
sipBinary.size(),
true,

View File

@@ -197,7 +197,7 @@ class BuiltIns {
SchedulerKernel &getSchedulerKernel(Context &context);
SipKernel &getSipKernel(SipKernelType kernel, Context &context);
MOCKABLE_VIRTUAL const SipKernel &getSipKernel(SipKernelType type, const Device &device);
BuiltinsLib &getBuiltinsLib() {
DEBUG_BREAK_IF(!builtinsLib.get());
@@ -214,7 +214,7 @@ class BuiltIns {
protected:
BuiltIns();
~BuiltIns();
virtual ~BuiltIns();
// singleton
static BuiltIns *pInstance;

View File

@@ -49,10 +49,15 @@ class SipKernel {
const char *getBinary() const {
return binary.get();
}
size_t getBinarySize() const {
return binarySize;
}
SipKernelType getType() const {
return type;
}
protected:
SipKernelType type = SipKernelType::COUNT;
std::unique_ptr<char[]> binary = nullptr;

View File

@@ -92,7 +92,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
return gpuAddress + allocationOffset;
}
uint64_t getGpuAddressToPatch() {
uint64_t getGpuAddressToPatch() const {
DEBUG_BREAK_IF(gpuAddress < gpuBaseAddress);
return gpuAddress + allocationOffset - gpuBaseAddress;
}

View File

@@ -1486,7 +1486,7 @@ TEST_F(BuiltInTests, getSipKernelReturnsProgramCreatedOutOfIsaAcquiredFromCompil
errCode = p->processGenBinary();
ASSERT_EQ(CL_SUCCESS, errCode);
auto &sipKern = BuiltIns::getInstance().getSipKernel(SipKernelType::Csr, *pContext);
const SipKernel &sipKern = BuiltIns::getInstance().getSipKernel(SipKernelType::Csr, *pContext->getDevice(0));
const auto &sipKernelInfo = p->getKernelInfo(static_cast<size_t>(0));

View File

@@ -77,3 +77,13 @@ TEST(Sip, SipLlContainsMetadataRequiredByCompiler) {
EXPECT_NE(nullptr, strstr(src, "!opencl.compiler.options"));
EXPECT_NE(nullptr, strstr(src, "!opencl.kernels"));
}
TEST(Sip, getType) {
uint32_t binary = 0;
SipKernel csr{SipKernelType::Csr, &binary, sizeof(binary)};
EXPECT_EQ(SipKernelType::Csr, csr.getType());
SipKernel undefined{SipKernelType::COUNT, &binary, sizeof(binary)};
EXPECT_EQ(SipKernelType::COUNT, undefined.getType());
}