build: add ocloc CURRENT and FORMER definitions
Related-To: NEO-6683 Signed-off-by: Artur Harasimiuk <artur.harasimiuk@intel.com>
This commit is contained in:
parent
e085205850
commit
5bb1bc0396
|
@ -508,11 +508,12 @@ endif()
|
|||
if(NOT DEFINED NEO_CURRENT_PLATFORMS_SUPPORT)
|
||||
set(NEO_CURRENT_PLATFORMS_SUPPORT TRUE)
|
||||
endif()
|
||||
set(NEO__LEGACY_NAME_SUFFIX "_legacy1")
|
||||
if(NEO_LEGACY_PLATFORMS_SUPPORT AND NOT NEO_CURRENT_PLATFORMS_SUPPORT)
|
||||
if(NOT DEFINED NEO_OCLOC_VERSION_MODE)
|
||||
set(NEO_OCLOC_VERSION_MODE "0")
|
||||
endif()
|
||||
set(NEO__SO_NAME_SUFFIX "_legacy1")
|
||||
set(NEO__SO_NAME_SUFFIX ${NEO__LEGACY_NAME_SUFFIX})
|
||||
endif()
|
||||
if(NOT DEFINED NEO_OCLOC_VERSION_MODE)
|
||||
set(NEO_OCLOC_VERSION_MODE "1")
|
||||
|
|
|
@ -456,12 +456,20 @@ if(WIN32)
|
|||
elseif(UNIX)
|
||||
if(NOT NEO_CURRENT_PLATFORMS_SUPPORT)
|
||||
set(LIBOCLOC_OUTPUT_NAME_SUFFIX ${NEO__SO_NAME_SUFFIX})
|
||||
elseif(NEO_CURRENT_PLATFORMS_SUPPORT AND NOT NEO_LEGACY_PLATFORMS_SUPPORT)
|
||||
set(NEO_OCLOC_FORMER_LIB_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${OCLOC_NAME}${NEO__LEGACY_NAME_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
endif()
|
||||
|
||||
set(OCLOC_OUTPUT_NAME_SUFFIX "-${NEO_OCL_VERSION_MAJOR}.${NEO_OCL_VERSION_MINOR}.${NEO_OCLOC_VERSION_MODE}")
|
||||
endif()
|
||||
set_target_properties(${OCLOC_NAME} PROPERTIES OUTPUT_NAME ${OCLOC_NAME}${OCLOC_OUTPUT_NAME_SUFFIX})
|
||||
set_target_properties(${OCLOC_NAME}_lib PROPERTIES OUTPUT_NAME ${OCLOC_NAME}${LIBOCLOC_OUTPUT_NAME_SUFFIX})
|
||||
|
||||
set(NEO_OCLOC_CURRENT_LIB_NAME $<TARGET_FILE_NAME:${OCLOC_NAME}_lib>)
|
||||
|
||||
message(STATUS "ocloc_lib current name: ${NEO_OCLOC_CURRENT_LIB_NAME}")
|
||||
message(STATUS "ocloc_lib former name: ${NEO_OCLOC_FORMER_LIB_NAME}")
|
||||
|
||||
add_definitions(-DNEO_OCLOC_CURRENT_LIB_NAME="${NEO_OCLOC_CURRENT_LIB_NAME}")
|
||||
add_definitions(-DNEO_OCLOC_FORMER_LIB_NAME="${NEO_OCLOC_FORMER_LIB_NAME}")
|
||||
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ocloc_wrapper.h"
|
||||
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
typedef int (*pOclocInvoke)(
|
||||
unsigned int numArgs, const char *argv[],
|
||||
const uint32_t numSources, const uint8_t **dataSources, const uint64_t *lenSources, const char **nameSources,
|
||||
const uint32_t numInputHeaders, const uint8_t **dataInputHeaders, const uint64_t *lenInputHeaders, const char **nameInputHeaders,
|
||||
uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs);
|
||||
|
||||
typedef int (*pOclocFreeOutput)(
|
||||
uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs);
|
||||
|
||||
struct OclocLibrary {
|
||||
pOclocInvoke invoke = nullptr;
|
||||
pOclocFreeOutput freeOutput = nullptr;
|
||||
|
||||
std::unique_ptr<NEO::OsLibrary> library;
|
||||
bool isLoaded() {
|
||||
return library != nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
OclocWrapper::OclocWrapper() : pImpl(std::make_unique<Impl>()){};
|
||||
OclocWrapper::~OclocWrapper() = default;
|
||||
|
||||
struct OclocWrapper::Impl {
|
||||
OclocLibrary oclocLib;
|
||||
|
||||
void loadOcloc() {
|
||||
OclocLibrary ocloc;
|
||||
std::string oclocLibName = OCLOC_LIB_NAME;
|
||||
ocloc.library.reset(NEO::OsLibrary::load(oclocLibName));
|
||||
if (nullptr == (ocloc.invoke = reinterpret_cast<pOclocInvoke>(ocloc.library->getProcAddress("oclocInvoke")))) {
|
||||
std::cout << "Error! Couldn't find OclocInvoke function.\n";
|
||||
return;
|
||||
}
|
||||
if (nullptr == (ocloc.freeOutput = reinterpret_cast<pOclocFreeOutput>(ocloc.library->getProcAddress("oclocFreeOutput")))) {
|
||||
std::cout << "Error! Couldn't find OclocFreeOutput function.\n";
|
||||
return;
|
||||
}
|
||||
this->oclocLib = std::move(ocloc);
|
||||
}
|
||||
};
|
||||
|
||||
int OclocWrapper::invokeOcloc(unsigned int numArgs, const char *argv[]) {
|
||||
return invokeOcloc(numArgs, argv, 0, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr,
|
||||
nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
int OclocWrapper::invokeOcloc(unsigned int numArgs, const char *argv[],
|
||||
const uint32_t numSources, const uint8_t **dataSources, const uint64_t *lenSources, const char **nameSources,
|
||||
const uint32_t numInputHeaders, const uint8_t **dataInputHeaders, const uint64_t *lenInputHeaders, const char **nameInputHeaders,
|
||||
uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs) {
|
||||
if (false == tryLoadOcloc()) {
|
||||
std::cout << "Error! Ocloc Library couldn't be loaded.\n";
|
||||
return -1;
|
||||
}
|
||||
return pImpl->oclocLib.invoke(numArgs, argv,
|
||||
numSources, dataSources, lenSources, nameSources,
|
||||
numInputHeaders, dataInputHeaders, lenInputHeaders, nameInputHeaders,
|
||||
numOutputs, dataOutputs, lenOutputs, nameOutputs);
|
||||
}
|
||||
|
||||
int OclocWrapper::freeOutput(uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs) {
|
||||
if (false == tryLoadOcloc()) {
|
||||
std::cout << "Error! Ocloc Library couldn't be loaded.\n";
|
||||
return -1;
|
||||
}
|
||||
return pImpl->oclocLib.freeOutput(numOutputs, dataOutputs, lenOutputs, nameOutputs);
|
||||
}
|
||||
|
||||
bool OclocWrapper::tryLoadOcloc() {
|
||||
if (false == pImpl->oclocLib.isLoaded()) {
|
||||
pImpl->loadOcloc();
|
||||
}
|
||||
return pImpl->oclocLib.isLoaded();
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cctype>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
struct OclocWrapper {
|
||||
public:
|
||||
OclocWrapper();
|
||||
~OclocWrapper();
|
||||
|
||||
OclocWrapper(OclocWrapper &) = delete;
|
||||
OclocWrapper(const OclocWrapper &&) = delete;
|
||||
OclocWrapper &operator=(const OclocWrapper &) = delete;
|
||||
OclocWrapper &operator=(OclocWrapper &&) = delete;
|
||||
|
||||
int invokeOcloc(unsigned int numArgs, const char *argv[]);
|
||||
int invokeOcloc(unsigned int numArgs, const char *argv[],
|
||||
const uint32_t numSources, const uint8_t **dataSources, const uint64_t *lenSources, const char **nameSources,
|
||||
const uint32_t numInputHeaders, const uint8_t **dataInputHeaders, const uint64_t *lenInputHeaders, const char **nameInputHeaders,
|
||||
uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs);
|
||||
int freeOutput(uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs);
|
||||
|
||||
protected:
|
||||
bool tryLoadOcloc();
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> pImpl;
|
||||
};
|
Loading…
Reference in New Issue