From e27c5a9475e2359de0227b7d10307788089c2e0b Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Mon, 9 Dec 2019 13:59:08 +0100 Subject: [PATCH] Change signature of clAddCommentINTEL function: pass device instead of platform Resolves: NEO-3939 Change-Id: I394ef7c2370771569a0ec50ac4644782ce8a384f Signed-off-by: Mateusz Jablonski --- runtime/api/api.cpp | 12 ++++++--- runtime/api/api.h | 2 +- runtime/device/device.h | 1 + .../api/cl_add_comment_to_aub_tests.inl | 27 +++++++++++++++---- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 4a9accb406..37bd1911e8 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -5071,13 +5071,17 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueVerifyMemoryINTEL(cl_command_queue comm return retVal; } -cl_int CL_API_CALL clAddCommentINTEL(cl_platform_id platform, const char *comment) { +cl_int CL_API_CALL clAddCommentINTEL(cl_device_id device, const char *comment) { cl_int retVal = CL_SUCCESS; API_ENTER(&retVal); - DBG_LOG_INPUTS("platform", platform, "comment", comment); + DBG_LOG_INPUTS("device", device, "comment", comment); - auto executionEnvironment = ::platform()->peekExecutionEnvironment(); - auto aubCenter = executionEnvironment->rootDeviceEnvironments[0]->aubCenter.get(); + Device *pDevice = nullptr; + retVal = validateObjects(WithCastToInternal(device, &pDevice)); + if (retVal != CL_SUCCESS) { + return retVal; + } + auto aubCenter = pDevice->getRootDeviceEnvironment().aubCenter.get(); if (!comment || (aubCenter && !aubCenter->getAubManager())) { retVal = CL_INVALID_VALUE; diff --git a/runtime/api/api.h b/runtime/api/api.h index f72a6daec5..46d7d28b07 100644 --- a/runtime/api/api.h +++ b/runtime/api/api.h @@ -861,7 +861,7 @@ cl_int CL_API_CALL clEnqueueVerifyMemoryINTEL( size_t sizeOfComparison, cl_uint comparisonMode); -cl_int CL_API_CALL clAddCommentINTEL(cl_platform_id platform, const char *comment); +cl_int CL_API_CALL clAddCommentINTEL(cl_device_id device, const char *comment); // OpenCL 2.1 diff --git a/runtime/device/device.h b/runtime/device/device.h index b5eb297dee..e42c6a32a2 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -79,6 +79,7 @@ class Device : public BaseObject<_cl_device_id> { MOCKABLE_VIRTUAL bool isSourceLevelDebuggerActive() const; SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); } ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; } + const RootDeviceEnvironment &getRootDeviceEnvironment() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; } const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; } bool isFullRangeSvm() const { return executionEnvironment->isFullRangeSvm(); diff --git a/unit_tests/api/cl_add_comment_to_aub_tests.inl b/unit_tests/api/cl_add_comment_to_aub_tests.inl index d5567464ec..4a2f27fc1d 100644 --- a/unit_tests/api/cl_add_comment_to_aub_tests.inl +++ b/unit_tests/api/cl_add_comment_to_aub_tests.inl @@ -6,6 +6,8 @@ */ #include "core/execution_environment/root_device_environment.h" +#include "runtime/context/context.h" +#include "runtime/device/device.h" #include "runtime/execution_environment/execution_environment.h" #include "runtime/platform/platform.h" #include "unit_tests/api/cl_api_tests.h" @@ -16,22 +18,37 @@ using namespace NEO; namespace ULT { -using clAddCommentToAubTest = api_tests; +struct clAddCommentToAubTest : api_tests { + void SetUp() override { + api_tests::SetUp(); + pDevice = pContext->getDevice(0); + } + void TearDown() override { + api_tests::TearDown(); + } + + Device *pDevice = nullptr; +}; TEST_F(clAddCommentToAubTest, givenProperCommentNullptrAubCenterWhenAddCommentToAubThenSuccessIsReturned) { - auto retVal = clAddCommentINTEL(pPlatform, "comment"); + auto retVal = clAddCommentINTEL(pDevice, "comment"); EXPECT_EQ(CL_SUCCESS, retVal); } +TEST_F(clAddCommentToAubTest, givenInvalidDeviceWhenAddCommentToAubThenErrorIsReturned) { + auto retVal = clAddCommentINTEL(nullptr, "comment"); + EXPECT_EQ(CL_INVALID_DEVICE, retVal); +} + TEST_F(clAddCommentToAubTest, givenNullptrCommentWhenAddCommentToAubThenErrorIsReturned) { - auto retVal = clAddCommentINTEL(pPlatform, nullptr); + auto retVal = clAddCommentINTEL(pDevice, nullptr); EXPECT_EQ(CL_INVALID_VALUE, retVal); } TEST_F(clAddCommentToAubTest, givenAubCenterAndProperCommentButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) { pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[testedRootDeviceIndex]->aubCenter.reset(new MockAubCenter()); - auto retVal = clAddCommentINTEL(pPlatform, "comment"); + auto retVal = clAddCommentINTEL(pDevice, "comment"); EXPECT_EQ(CL_INVALID_VALUE, retVal); } @@ -51,7 +68,7 @@ TEST_F(clAddCommentToAubTest, givenProperCommentAubCenterAndAubManagerWhenAddCom EXPECT_FALSE(mockAubManager->addCommentCalled); - auto retVal = clAddCommentINTEL(pPlatform, "comment"); + auto retVal = clAddCommentINTEL(pDevice, "comment"); EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_TRUE(mockAubManager->addCommentCalled); }