2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2020-01-09 00:29:15 +08:00
|
|
|
* Copyright (C) 2017-2020 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 20:10:44 +08:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 20:10:44 +08:00
|
|
|
#include "shared/source/built_ins/sip.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/compiler_interface/compiler_interface.h"
|
|
|
|
#include "shared/source/helpers/basic_math.h"
|
|
|
|
#include "shared/source/helpers/debug_helpers.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-23 05:50:57 +08:00
|
|
|
#include "opencl/source/helpers/built_ins_helper.h"
|
|
|
|
#include "opencl/source/helpers/convert_color.h"
|
|
|
|
#include "opencl/source/helpers/dispatch_info_builder.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-12-01 23:13:21 +08:00
|
|
|
#include "compiler_options.h"
|
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <cstdint>
|
2017-12-21 07:45:38 +08:00
|
|
|
#include <sstream>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
BuiltIns::BuiltIns() {
|
|
|
|
builtinsLib.reset(new BuiltinsLib());
|
|
|
|
}
|
|
|
|
|
2020-02-19 23:32:00 +08:00
|
|
|
BuiltIns::~BuiltIns() = default;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-09 18:52:14 +08:00
|
|
|
const SipKernel &BuiltIns::getSipKernel(SipKernelType type, Device &device) {
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t kernelId = static_cast<uint32_t>(type);
|
|
|
|
UNRECOVERABLE_IF(kernelId >= static_cast<uint32_t>(SipKernelType::COUNT));
|
|
|
|
auto &sipBuiltIn = this->sipKernels[kernelId];
|
|
|
|
|
|
|
|
auto initializer = [&] {
|
2020-02-24 20:10:44 +08:00
|
|
|
int retVal = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
std::vector<char> sipBinary;
|
2018-08-01 15:06:46 +08:00
|
|
|
auto compilerInteface = device.getExecutionEnvironment()->getCompilerInterface();
|
2017-12-21 07:45:38 +08:00
|
|
|
UNRECOVERABLE_IF(compilerInteface == nullptr);
|
|
|
|
|
2019-08-29 21:10:51 +08:00
|
|
|
auto ret = compilerInteface->getSipKernelBinary(device, type, sipBinary);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-08-29 21:10:51 +08:00
|
|
|
UNRECOVERABLE_IF(ret != TranslationOutput::ErrorCode::Success);
|
2017-12-21 07:45:38 +08:00
|
|
|
UNRECOVERABLE_IF(sipBinary.size() == 0);
|
2018-08-14 16:56:42 +08:00
|
|
|
auto program = createProgramForSip(*device.getExecutionEnvironment(),
|
|
|
|
nullptr,
|
2018-05-14 17:25:18 +08:00
|
|
|
sipBinary,
|
|
|
|
sipBinary.size(),
|
2020-02-20 15:12:44 +08:00
|
|
|
&retVal,
|
|
|
|
&device);
|
2020-02-24 20:10:44 +08:00
|
|
|
DEBUG_BREAK_IF(retVal != 0);
|
2017-12-21 07:45:38 +08:00
|
|
|
UNRECOVERABLE_IF(program == nullptr);
|
|
|
|
|
2018-03-09 18:52:14 +08:00
|
|
|
program->setDevice(&device);
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
retVal = program->processGenBinary();
|
2020-02-24 20:10:44 +08:00
|
|
|
DEBUG_BREAK_IF(retVal != 0);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-06 22:29:06 +08:00
|
|
|
sipBuiltIn.first.reset(new SipKernel(type, program));
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
std::call_once(sipBuiltIn.second, initializer);
|
|
|
|
UNRECOVERABLE_IF(sipBuiltIn.first == nullptr);
|
|
|
|
return *sipBuiltIn.first;
|
|
|
|
}
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|