Add device product table based on device_base file for ocloc use

Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
Kacper Nowak
2021-03-15 17:01:04 +01:00
committed by Compute-Runtime-Automation
parent 027a916107
commit 260f7e37cb
5 changed files with 52 additions and 5 deletions

View File

@@ -23,6 +23,8 @@ set(CLOC_LIB_SRCS_LIB
${NEO_SHARED_DIRECTORY}/device_binary_format/elf/elf_encoder.cpp
${NEO_SHARED_DIRECTORY}/device_binary_format/elf/elf_encoder.h
${NEO_SHARED_DIRECTORY}/device_binary_format/elf/ocl_elf.h
${NEO_SHARED_DIRECTORY}/dll/devices${BRANCH_DIR_SUFFIX}/devices.inl
${NEO_SHARED_DIRECTORY}/dll/devices/devices_base.inl
${NEO_SHARED_DIRECTORY}/helpers/abort.cpp
${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.cpp
${NEO_SHARED_DIRECTORY}/helpers/compiler_options_parser.h

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,8 +8,11 @@
#include "ocloc_arg_helper.h"
#include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string.h"
#include "hw_cmds.h"
#include <cstring>
#include <sstream>
@@ -44,7 +47,13 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo
uint32_t *numOutputs, uint8_t ***dataOutputs,
uint64_t **lenOutputs, char ***nameOutputs)
: numOutputs(numOutputs), nameOutputs(nameOutputs),
dataOutputs(dataOutputs), lenOutputs(lenOutputs), hasOutput(numOutputs != nullptr) {
dataOutputs(dataOutputs), lenOutputs(lenOutputs), hasOutput(numOutputs != nullptr), deviceProductTable({
#define NAMEDDEVICE(devId, product, ignored_gtType, ignored_devName) {devId, NEO::hardwarePrefix[NEO::product::hwInfo.platform.eProductFamily]},
#define DEVICE(devId, product, ignored_gtType) {devId, NEO::hardwarePrefix[NEO::product::hwInfo.platform.eProductFamily]},
#include "devices.inl"
#undef DEVICE
#undef NAMEDDEVICE
{0u, std::string("")}}) {
for (uint32_t i = 0; i < numSources; ++i) {
inputs.push_back(Source(dataSources[i], static_cast<size_t>(lenSources[i]), nameSources[i]));
}
@@ -150,3 +159,13 @@ void OclocArgHelper::saveOutput(const std::string &filename, const std::ostream
file << ss.str();
}
}
std::string OclocArgHelper::returnProductNameForDevice(unsigned short deviceId) {
std::string res = "";
for (int i = 0; deviceProductTable[i].deviceId != 0; i++) {
if (deviceProductTable[i].deviceId == deviceId) {
res = deviceProductTable[i].product;
}
}
return res;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,8 @@
#include "shared/offline_compiler/source/decoder/helper.h"
#include "hw_cmds.h"
#include <cctype>
#include <fstream>
#include <memory>
@@ -36,6 +38,11 @@ struct Output {
Output(const std::string &name, const void *data, const size_t &size);
};
struct DeviceProduct {
unsigned short deviceId;
std::string product;
};
class OclocArgHelper {
protected:
std::vector<Source> inputs, headers;
@@ -45,6 +52,7 @@ class OclocArgHelper {
uint8_t ***dataOutputs = nullptr;
uint64_t **lenOutputs = nullptr;
bool hasOutput = false;
const std::vector<DeviceProduct> deviceProductTable{{0u, std::string("")}};
void moveOutputs();
MessagePrinter messagePrinter;
Source *findSourceFile(const std::string &filename);
@@ -93,4 +101,5 @@ class OclocArgHelper {
void printf(const char *format, Args... args) {
messagePrinter.printf(format, std::forward<Args>(args)...);
}
std::string returnProductNameForDevice(unsigned short deviceId);
};