mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Move metrics library to shared
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9d49c56b75
commit
b14da0aeb2
@@ -26,6 +26,7 @@ set(NEO_CORE_OS_INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_bdw_and_later.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/metrics_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_environment.h
|
||||
|
||||
@@ -58,6 +58,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_linux.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_metrics_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_socket.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_linux.h
|
||||
|
||||
51
shared/source/os_interface/linux/os_metrics_library.cpp
Normal file
51
shared/source/os_interface/linux/os_metrics_library.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/utilities/metrics_library.h"
|
||||
|
||||
namespace NEO {
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::oaConfigurationActivate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationActivate(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
ConfigurationActivateData_1_0 data = {};
|
||||
data.Type = GpuConfigurationActivationType::Tbs;
|
||||
|
||||
return api->functions.ConfigurationActivate(
|
||||
handle,
|
||||
&data) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::oaConfigurationDeactivate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationDeactivate(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
return api->functions.ConfigurationDeactivate(
|
||||
handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::userConfigurationCreate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::userConfigurationCreate(
|
||||
const ContextHandle_1_0 &context,
|
||||
ConfigurationHandle_1_0 &handle) {
|
||||
// Not supported on Linux.
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::userConfigurationDelete
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::userConfigurationDelete(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
// Not supported on Linux.
|
||||
return true;
|
||||
}
|
||||
} // namespace NEO
|
||||
203
shared/source/os_interface/metrics_library.cpp
Normal file
203
shared/source/os_interface/metrics_library.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/utilities/metrics_library.h"
|
||||
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/os_interface/os_inc_base.h"
|
||||
|
||||
namespace NEO {
|
||||
///////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::MetricsLibrary
|
||||
///////////////////////////////////////////////////////
|
||||
MetricsLibrary::MetricsLibrary() {
|
||||
api = std::make_unique<MetricsLibraryInterface>();
|
||||
osLibrary.reset(OsLibrary::load(Os::metricsLibraryDllName));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::open
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::open() {
|
||||
|
||||
UNRECOVERABLE_IF(osLibrary.get() == nullptr);
|
||||
|
||||
if (osLibrary->isLoaded()) {
|
||||
api->contextCreate = reinterpret_cast<ContextCreateFunction_1_0>(osLibrary->getProcAddress(METRICS_LIBRARY_CONTEXT_CREATE_1_0));
|
||||
api->contextDelete = reinterpret_cast<ContextDeleteFunction_1_0>(osLibrary->getProcAddress(METRICS_LIBRARY_CONTEXT_DELETE_1_0));
|
||||
} else {
|
||||
api->contextCreate = nullptr;
|
||||
api->contextDelete = nullptr;
|
||||
}
|
||||
|
||||
if (!api->contextCreate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!api->contextDelete) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::createContext
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::contextCreate(
|
||||
const ClientType_1_0 &clientType,
|
||||
ClientOptionsSubDeviceData_1_0 &subDevice,
|
||||
ClientOptionsSubDeviceIndexData_1_0 &subDeviceIndex,
|
||||
ClientOptionsSubDeviceCountData_1_0 &subDeviceCount,
|
||||
ClientData_1_0 &clientData,
|
||||
ContextCreateData_1_0 &createData,
|
||||
ContextHandle_1_0 &handle) {
|
||||
|
||||
MetricsLibraryApi::ClientOptionsData_1_0 clientOptions[4] = {};
|
||||
clientOptions[0].Type = MetricsLibraryApi::ClientOptionsType::Compute;
|
||||
clientOptions[0].Compute.Asynchronous = true;
|
||||
clientOptions[1].Type = MetricsLibraryApi::ClientOptionsType::SubDevice;
|
||||
clientOptions[1].SubDevice = subDevice;
|
||||
clientOptions[2].Type = MetricsLibraryApi::ClientOptionsType::SubDeviceIndex;
|
||||
clientOptions[2].SubDeviceIndex = subDeviceIndex;
|
||||
clientOptions[3].Type = MetricsLibraryApi::ClientOptionsType::SubDeviceCount;
|
||||
clientOptions[3].SubDeviceCount = subDeviceCount;
|
||||
clientData.ClientOptionsCount = 4;
|
||||
clientData.ClientOptions = clientOptions;
|
||||
|
||||
createData.Api = &api->functions;
|
||||
createData.ClientCallbacks = &api->callbacks;
|
||||
createData.ClientData = &clientData;
|
||||
|
||||
return api->contextCreate(
|
||||
clientType,
|
||||
&createData,
|
||||
&handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::contextDelete
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::contextDelete(
|
||||
const ContextHandle_1_0 &handle) {
|
||||
return api->contextDelete(handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::hwCountersCreate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::hwCountersCreate(
|
||||
const ContextHandle_1_0 &context,
|
||||
const uint32_t slots,
|
||||
const ConfigurationHandle_1_0 user,
|
||||
QueryHandle_1_0 &query) {
|
||||
QueryCreateData_1_0 data = {};
|
||||
data.HandleContext = context;
|
||||
data.Type = ObjectType::QueryHwCounters;
|
||||
data.Slots = slots;
|
||||
|
||||
return api->functions.QueryCreate(
|
||||
&data,
|
||||
&query) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::hwCountersDelete
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::hwCountersDelete(
|
||||
const QueryHandle_1_0 &query) {
|
||||
return api->functions.QueryDelete(query) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::hwCountersGetReport
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::hwCountersGetReport(
|
||||
const QueryHandle_1_0 &handle,
|
||||
const uint32_t slot,
|
||||
const uint32_t slotsCount,
|
||||
const uint32_t dataSize,
|
||||
void *data) {
|
||||
GetReportData_1_0 report = {};
|
||||
report.Type = ObjectType::QueryHwCounters;
|
||||
report.Query.Handle = handle;
|
||||
report.Query.Slot = slot;
|
||||
report.Query.SlotsCount = slotsCount;
|
||||
report.Query.Data = data;
|
||||
report.Query.DataSize = dataSize;
|
||||
|
||||
return api->functions.GetData(&report) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::hwCountersGetApiReportSize
|
||||
//////////////////////////////////////////////////////
|
||||
uint32_t MetricsLibrary::hwCountersGetApiReportSize() {
|
||||
ValueType type = ValueType::Uint32;
|
||||
TypedValue_1_0 value = {};
|
||||
|
||||
return api->functions.GetParameter(ParameterType::QueryHwCountersReportApiSize, &type, &value) == StatusCode::Success
|
||||
? value.ValueUInt32
|
||||
: 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::hwCountersGetGpuReportSize
|
||||
//////////////////////////////////////////////////////
|
||||
uint32_t MetricsLibrary::hwCountersGetGpuReportSize() {
|
||||
ValueType type = ValueType::Uint32;
|
||||
TypedValue_1_0 value = {};
|
||||
|
||||
return api->functions.GetParameter(ParameterType::QueryHwCountersReportGpuSize, &type, &value) == StatusCode::Success
|
||||
? value.ValueUInt32
|
||||
: 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::commandBufferGet
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::commandBufferGet(
|
||||
CommandBufferData_1_0 &data) {
|
||||
return api->functions.CommandBufferGet(
|
||||
&data) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::commandBufferGetSize
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::commandBufferGetSize(
|
||||
const CommandBufferData_1_0 &commandBufferData,
|
||||
CommandBufferSize_1_0 &commandBufferSize) {
|
||||
return api->functions.CommandBufferGetSize(
|
||||
&commandBufferData,
|
||||
&commandBufferSize) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::oaConfigurationCreate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationCreate(
|
||||
const ContextHandle_1_0 &context,
|
||||
ConfigurationHandle_1_0 &handle) {
|
||||
ConfigurationCreateData_1_0 data = {};
|
||||
data.HandleContext = context;
|
||||
data.Type = ObjectType::ConfigurationHwCountersOa;
|
||||
|
||||
return api->functions.ConfigurationCreate(
|
||||
&data,
|
||||
&handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// MetricsLibrary::oaConfigurationDelete
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationDelete(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
|
||||
return api->functions.ConfigurationDelete(handle) == StatusCode::Success;
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -25,6 +25,7 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_library_win.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_metrics_library.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_socket.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.h
|
||||
|
||||
55
shared/source/os_interface/windows/os_metrics_library.cpp
Normal file
55
shared/source/os_interface/windows/os_metrics_library.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/utilities/metrics_library.h"
|
||||
|
||||
namespace NEO {
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::oaConfigurationActivate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationActivate(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
ConfigurationActivateData_1_0 data = {};
|
||||
data.Type = GpuConfigurationActivationType::EscapeCode;
|
||||
|
||||
return api->functions.ConfigurationActivate(
|
||||
handle,
|
||||
&data) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::oaConfigurationDeactivate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::oaConfigurationDeactivate(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
return api->functions.ConfigurationDeactivate(
|
||||
handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::userConfigurationCreate
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::userConfigurationCreate(
|
||||
const ContextHandle_1_0 &context,
|
||||
ConfigurationHandle_1_0 &handle) {
|
||||
ConfigurationCreateData_1_0 data = {};
|
||||
data.HandleContext = context;
|
||||
data.Type = ObjectType::ConfigurationHwCountersUser;
|
||||
|
||||
return api->functions.ConfigurationCreate(
|
||||
&data,
|
||||
&handle) == StatusCode::Success;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// FUNCTION: MetricsLibrary::userConfigurationDelete
|
||||
//////////////////////////////////////////////////////
|
||||
bool MetricsLibrary::userConfigurationDelete(
|
||||
const ConfigurationHandle_1_0 &handle) {
|
||||
return api->functions.ConfigurationDelete(handle) == StatusCode::Success;
|
||||
}
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user