mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
Support for enabling perf counters with clCreateCommandQueueWithProperties
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
073e15d75e
commit
0fd8b850a6
@@ -257,3 +257,12 @@ typedef struct _cl_device_pci_bus_info_khr {
|
||||
|
||||
// New query for clGetDeviceInfo:
|
||||
#define CL_MEM_COMPRESSED_INTEL 0x417D
|
||||
|
||||
/* cl_queue_properties */
|
||||
#define CL_QUEUE_MDAPI_PROPERTIES_INTEL 0x425E
|
||||
#define CL_QUEUE_MDAPI_CONFIGURATION_INTEL 0x425F
|
||||
|
||||
typedef cl_bitfield cl_command_queue_mdapi_properties_intel;
|
||||
|
||||
/* cl_command_queue_mdapi_properties_intel - bitfield */
|
||||
#define CL_QUEUE_MDAPI_ENABLE_INTEL (1 << 0)
|
||||
|
||||
@@ -5199,13 +5199,18 @@ cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties(cl_context conte
|
||||
auto propertiesAddress = properties;
|
||||
|
||||
while (tokenValue != 0) {
|
||||
if (tokenValue != CL_QUEUE_PROPERTIES &&
|
||||
tokenValue != CL_QUEUE_SIZE &&
|
||||
tokenValue != CL_QUEUE_PRIORITY_KHR &&
|
||||
tokenValue != CL_QUEUE_THROTTLE_KHR &&
|
||||
tokenValue != CL_QUEUE_SLICE_COUNT_INTEL &&
|
||||
tokenValue != CL_QUEUE_FAMILY_INTEL &&
|
||||
tokenValue != CL_QUEUE_INDEX_INTEL) {
|
||||
switch (tokenValue) {
|
||||
case CL_QUEUE_PROPERTIES:
|
||||
case CL_QUEUE_SIZE:
|
||||
case CL_QUEUE_PRIORITY_KHR:
|
||||
case CL_QUEUE_THROTTLE_KHR:
|
||||
case CL_QUEUE_SLICE_COUNT_INTEL:
|
||||
case CL_QUEUE_FAMILY_INTEL:
|
||||
case CL_QUEUE_INDEX_INTEL:
|
||||
case CL_QUEUE_MDAPI_PROPERTIES_INTEL:
|
||||
case CL_QUEUE_MDAPI_CONFIGURATION_INTEL:
|
||||
break;
|
||||
default:
|
||||
err.set(CL_INVALID_VALUE);
|
||||
TRACING_EXIT(clCreateCommandQueueWithProperties, &commandQueue);
|
||||
return commandQueue;
|
||||
@@ -5281,12 +5286,37 @@ cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties(cl_context conte
|
||||
TRACING_EXIT(clCreateCommandQueueWithProperties, &commandQueue);
|
||||
return commandQueue;
|
||||
}
|
||||
|
||||
bool mdapiPropertySet = false;
|
||||
bool mdapiConfigurationSet = false;
|
||||
cl_command_queue_mdapi_properties_intel mdapiProperties = getCmdQueueProperties<cl_command_queue_mdapi_properties_intel>(properties, CL_QUEUE_MDAPI_PROPERTIES_INTEL, &mdapiPropertySet);
|
||||
cl_uint mdapiConfiguration = getCmdQueueProperties<cl_uint>(properties, CL_QUEUE_MDAPI_CONFIGURATION_INTEL, &mdapiConfigurationSet);
|
||||
|
||||
if (mdapiConfigurationSet && mdapiConfiguration != 0) {
|
||||
err.set(CL_INVALID_OPERATION);
|
||||
TRACING_EXIT(clCreateCommandQueueWithProperties, &commandQueue);
|
||||
return commandQueue;
|
||||
}
|
||||
|
||||
commandQueue = CommandQueue::create(
|
||||
pContext,
|
||||
pDevice,
|
||||
properties,
|
||||
false,
|
||||
retVal);
|
||||
|
||||
if (mdapiPropertySet && (mdapiProperties & CL_QUEUE_MDAPI_ENABLE_INTEL)) {
|
||||
auto commandQueueObj = castToObjectOrAbort<CommandQueue>(commandQueue);
|
||||
|
||||
if (!commandQueueObj->setPerfCountersEnabled()) {
|
||||
clReleaseCommandQueue(commandQueue);
|
||||
TRACING_EXIT(clCreateCommandQueueWithProperties, &commandQueue);
|
||||
|
||||
err.set(CL_OUT_OF_RESOURCES);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (pContext->isProvidingPerformanceHints()) {
|
||||
pContext->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_NEUTRAL_INTEL, DRIVER_CALLS_INTERNAL_CL_FLUSH);
|
||||
if (castToObjectOrAbort<CommandQueue>(commandQueue)->isProfilingEnabled()) {
|
||||
@@ -5297,8 +5327,9 @@ cl_command_queue CL_API_CALL clCreateCommandQueueWithProperties(cl_context conte
|
||||
}
|
||||
}
|
||||
|
||||
if (!commandQueue)
|
||||
if (!commandQueue) {
|
||||
retVal = CL_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
DBG_LOG_INPUTS("commandQueue", commandQueue, "properties", static_cast<int>(getCmdQueueProperties<cl_command_queue_properties>(properties)));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -179,4 +179,57 @@ TEST_F(clCreatePerfCountersCommandQueueINTELTests, givenInvalidMetricsLibraryWhe
|
||||
EXPECT_EQ(CL_OUT_OF_RESOURCES, retVal);
|
||||
}
|
||||
|
||||
struct clCreateCommandQueueWithPropertiesMdapiTests : public clCreatePerfCountersCommandQueueINTELTests {
|
||||
cl_queue_properties queueProperties[7] = {CL_QUEUE_PROPERTIES, CL_QUEUE_PROFILING_ENABLE,
|
||||
CL_QUEUE_MDAPI_PROPERTIES_INTEL, CL_QUEUE_MDAPI_ENABLE_INTEL,
|
||||
CL_QUEUE_MDAPI_CONFIGURATION_INTEL, 0,
|
||||
0};
|
||||
};
|
||||
|
||||
TEST_F(clCreateCommandQueueWithPropertiesMdapiTests, givenCorrectParamsWhenCreatingQueueWithPropertiesThenEnablePerfCounters) {
|
||||
auto cmdQ = clCreateCommandQueueWithProperties(context.get(), deviceId, queueProperties, &retVal);
|
||||
|
||||
ASSERT_NE(nullptr, cmdQ);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto commandQueueObject = castToObject<CommandQueue>(cmdQ);
|
||||
EXPECT_TRUE(commandQueueObject->isPerfCountersEnabled());
|
||||
|
||||
clReleaseCommandQueue(cmdQ);
|
||||
}
|
||||
|
||||
TEST_F(clCreateCommandQueueWithPropertiesMdapiTests, givenParamsWithDisabledPerfCounterWhenCreatingQueueWithPropertiesThenCreateRegularQueue) {
|
||||
queueProperties[3] = 0;
|
||||
auto cmdQ = clCreateCommandQueueWithProperties(context.get(), deviceId, queueProperties, &retVal);
|
||||
|
||||
ASSERT_NE(nullptr, cmdQ);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto commandQueueObject = castToObject<CommandQueue>(cmdQ);
|
||||
EXPECT_FALSE(commandQueueObject->isPerfCountersEnabled());
|
||||
|
||||
clReleaseCommandQueue(cmdQ);
|
||||
}
|
||||
|
||||
TEST_F(clCreateCommandQueueWithPropertiesMdapiTests, givenIncorrectConfigurationWhenCreatingQueueWithPropertiesThenFail) {
|
||||
queueProperties[5] = 1;
|
||||
|
||||
auto cmdQ = clCreateCommandQueueWithProperties(context.get(), deviceId, queueProperties, &retVal);
|
||||
|
||||
EXPECT_EQ(nullptr, cmdQ);
|
||||
EXPECT_NE(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clCreateCommandQueueWithPropertiesMdapiTests, givenInvalidMdapiOpenWhenCreatingQueueWithPropertiesThenFail) {
|
||||
auto performanceCounters = device->getPerformanceCounters();
|
||||
|
||||
auto metricsLibary = static_cast<MockMetricsLibrary *>(performanceCounters->getMetricsLibraryInterface());
|
||||
metricsLibary->validOpen = false;
|
||||
|
||||
auto cmdQ = clCreateCommandQueueWithProperties(context.get(), deviceId, queueProperties, &retVal);
|
||||
|
||||
EXPECT_EQ(nullptr, cmdQ);
|
||||
EXPECT_NE(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
||||
Reference in New Issue
Block a user