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"
|
2020-10-13 17:41:48 +08:00
|
|
|
#include "shared/source/device_binary_format/device_binary_formats.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#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 = [&] {
|
|
|
|
std::vector<char> sipBinary;
|
2020-03-05 14:11:11 +08:00
|
|
|
auto compilerInteface = device.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);
|
|
|
|
|
2020-10-13 17:41:48 +08:00
|
|
|
ProgramInfo programInfo = createProgramInfoForSip(sipBinary, sipBinary.size(), device);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-10-13 17:41:48 +08:00
|
|
|
sipBuiltIn.first.reset(new SipKernel(type, std::move(programInfo)));
|
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
|