From c1683691c0fdc5a564e9e9272415c5f359fe88ee Mon Sep 17 00:00:00 2001 From: Artur Harasimiuk Date: Tue, 27 Feb 2018 10:33:10 +0100 Subject: [PATCH] enable perf counters for events added CL_PROFILING_COMMAND_PERFCOUNTERS_INTEL to cl_ext_private.h header to expose this query Change-Id: I8881456c54d391a66c2ce619a1a47ad1219c4376 --- public/cl_ext_private.h | 8 ++++- runtime/event/event.cpp | 33 +++++++++---------- .../api/cl_get_event_profiling_info_tests.cpp | 7 ++-- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/public/cl_ext_private.h b/public/cl_ext_private.h index 4f8c62705e..7a6d4ca4d7 100644 --- a/public/cl_ext_private.h +++ b/public/cl_ext_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -42,3 +42,9 @@ #define CL_KERNEL_BINARY_PROGRAM_INTEL 0x407D #define CL_KERNEL_BINARIES_INTEL 0x4102 #define CL_KERNEL_BINARY_SIZES_INTEL 0x4103 + +/*************************************** + * * event properties for performance counter * + * ****************************************/ +/* performance counter */ +#define CL_PROFILING_COMMAND_PERFCOUNTERS_INTEL 0x407F diff --git a/runtime/event/event.cpp b/runtime/event/event.cpp index 9c6b7e6655..5889129fa9 100644 --- a/runtime/event/event.cpp +++ b/runtime/event/event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,6 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "public/cl_ext_private.h" #include "runtime/command_queue/command_queue.h" #include "runtime/command_stream/command_stream_receiver.h" #include "runtime/memory_manager/memory_manager.h" @@ -195,23 +196,21 @@ cl_int Event::getEventProfilingInfo(cl_profiling_info paramName, srcSize = sizeof(cl_ulong); break; -#if defined(CL_PROFILING_COMMAND_PERFCOUNTERS_INTEL) - case CL_PROFILING_COMMAND_PERFCOUNTERS_INTEL: - if (!perfCountersEnabled) { - return CL_INVALID_VALUE; - } - if (!cmdQueue->getPerfCounters()->processEventReport(paramValueSize, - paramValue, - paramValueSizeRet, - getHwPerfCounter(), - perfConfigurationData, - updateStatusAndCheckCompletion())) { - return CL_PROFILING_INFO_NOT_AVAILABLE; - } - return CL_SUCCESS; -#endif - default: + case CL_PROFILING_COMMAND_PERFCOUNTERS_INTEL: + if (!perfCountersEnabled) { return CL_INVALID_VALUE; + } + if (!cmdQueue->getPerfCounters()->processEventReport(paramValueSize, + paramValue, + paramValueSizeRet, + getHwPerfCounter(), + perfConfigurationData, + updateStatusAndCheckCompletion())) { + return CL_PROFILING_INFO_NOT_AVAILABLE; + } + return CL_SUCCESS; + default: + return CL_INVALID_VALUE; } retVal = ::getInfo(paramValue, paramValueSize, src, srcSize); diff --git a/unit_tests/api/cl_get_event_profiling_info_tests.cpp b/unit_tests/api/cl_get_event_profiling_info_tests.cpp index 7707aa9af5..bcc8f827b2 100644 --- a/unit_tests/api/cl_get_event_profiling_info_tests.cpp +++ b/unit_tests/api/cl_get_event_profiling_info_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,10 +20,11 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#include "cl_api_tests.h" +#include "public/cl_ext_private.h" #include "runtime/command_queue/command_queue.h" #include "runtime/event/event.h" #include "runtime/event/user_event.h" +#include "unit_tests/api/cl_api_tests.h" #include "unit_tests/os_interface/mock_performance_counters.h" #include "test.h" @@ -288,7 +289,6 @@ TEST_F(clEventProfilingWithPerfCountersTests, clGetEventProfilingInfoGetPerfCoun bool Result = pEvent->isPerfCountersEnabled(); EXPECT_FALSE(Result); -#if defined(CL_PROFILING_COMMAND_PERFCOUNTERS_INTEL) cl_event event = (cl_event)pEvent; cl_ulong param_value = 0; size_t param_value_size_ret; @@ -315,7 +315,6 @@ TEST_F(clEventProfilingWithPerfCountersTests, clGetEventProfilingInfoGetPerfCoun ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_PROFILING_INFO_NOT_AVAILABLE, retVal); -#endif delete pEvent; delete pCommandQueue;