From 2393aceca6760d44b6dfd0f2c6c56fcea9b9a7b0 Mon Sep 17 00:00:00 2001 From: "Jobczyk, Lukasz" Date: Mon, 8 Apr 2019 13:08:08 +0200 Subject: [PATCH] Add dispatchable object to the clAddCommentINTEL Related-To: NEO-3082 Change-Id: Iae0117b32a81c97a37fb30e79bd4b9547c50c95c Signed-off-by: Jobczyk, Lukasz --- runtime/api/api.cpp | 22 +++++++----- runtime/api/api.h | 2 +- .../api/cl_add_comment_to_aub_tests.inl | 34 ++++++++++--------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 20aebdc2f3..3360a12801 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -4231,19 +4231,25 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueVerifyMemory(cl_command_queue commandQu return retVal; } -cl_int CL_API_CALL clAddCommentINTEL(const char *comment) { +cl_int CL_API_CALL clAddCommentINTEL(cl_platform_id platform, const char *comment) { cl_int retVal = CL_SUCCESS; API_ENTER(&retVal); + DBG_LOG_INPUTS("platform", platform, "comment", comment); - auto executionEnvironment = platform()->peekExecutionEnvironment(); - auto aubCenter = executionEnvironment->aubCenter.get(); + Platform *pPlatform = nullptr; + retVal = validateObjects(WithCastToInternal(platform, &pPlatform)); - if (!comment || (aubCenter && !aubCenter->getAubManager())) { - retVal = CL_INVALID_VALUE; - } + if (retVal == CL_SUCCESS) { + auto executionEnvironment = pPlatform->peekExecutionEnvironment(); + auto aubCenter = executionEnvironment->aubCenter.get(); - if (retVal == CL_SUCCESS && aubCenter) { - aubCenter->getAubManager()->addComment(comment); + if (!comment || (aubCenter && !aubCenter->getAubManager())) { + retVal = CL_INVALID_VALUE; + } + + if (retVal == CL_SUCCESS && aubCenter) { + aubCenter->getAubManager()->addComment(comment); + } } return retVal; } diff --git a/runtime/api/api.h b/runtime/api/api.h index 98c2903bb4..370d0b0212 100644 --- a/runtime/api/api.h +++ b/runtime/api/api.h @@ -848,7 +848,7 @@ cl_int CL_API_CALL clEnqueueVerifyMemory( size_t sizeOfComparison, cl_uint comparisonMode); -cl_int CL_API_CALL clAddCommentINTEL(const char *comment); +cl_int CL_API_CALL clAddCommentINTEL(cl_platform_id platform, const char *comment); // OpenCL 2.1 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 6352d3d9c2..cd8669e45c 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,7 @@ */ #include "runtime/execution_environment/execution_environment.h" +#include "runtime/platform/platform.h" #include "unit_tests/api/cl_api_tests.h" #include "unit_tests/mocks/mock_aub_center.h" #include "unit_tests/mocks/mock_aub_manager.h" @@ -14,27 +15,31 @@ using namespace NEO; namespace ULT { -TEST(clAddCommentToAubTest, givenProperCommentNullptrAubCenterWhenAddCommentToAubThenSuccessIsReturned) { - auto retVal = clAddCommentINTEL("comment"); +using clAddCommentToAubTest = api_tests; + +TEST(clAddCommentToAub, givenInvalidPlatformWhenAddCommentToAubThenErrorIsReturned) { + auto retVal = clAddCommentINTEL(nullptr, "comment"); + EXPECT_EQ(CL_INVALID_PLATFORM, retVal); +} + +TEST_F(clAddCommentToAubTest, givenProperCommentNullptrAubCenterWhenAddCommentToAubThenSuccessIsReturned) { + auto retVal = clAddCommentINTEL(pPlatform, "comment"); EXPECT_EQ(CL_SUCCESS, retVal); } -TEST(clAddCommentToAubTest, givenNullptrCommentWhenAddCommentToAubThenErrorIsReturned) { - auto retVal = clAddCommentINTEL(nullptr); +TEST_F(clAddCommentToAubTest, givenNullptrCommentWhenAddCommentToAubThenErrorIsReturned) { + auto retVal = clAddCommentINTEL(pPlatform, nullptr); EXPECT_EQ(CL_INVALID_VALUE, retVal); } -TEST(clAddCommentToAubTest, givenAubCenterAndProperCommentButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) { - auto executionEnvironment = platform()->peekExecutionEnvironment(); - executionEnvironment->aubCenter.reset(new MockAubCenter()); +TEST_F(clAddCommentToAubTest, givenAubCenterAndProperCommentButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) { + pPlatform->peekExecutionEnvironment()->aubCenter.reset(new MockAubCenter()); - auto retVal = clAddCommentINTEL("comment"); + auto retVal = clAddCommentINTEL(pPlatform, "comment"); EXPECT_EQ(CL_INVALID_VALUE, retVal); - - executionEnvironment->aubCenter.reset(nullptr); } -TEST(clAddCommentToAubTest, givenProperCommentAubCenterAndAubManagerWhenAddCommentToAubThenSuccessIsReturned) { +TEST_F(clAddCommentToAubTest, givenProperCommentAubCenterAndAubManagerWhenAddCommentToAubThenSuccessIsReturned) { struct AubManagerCommentMock : public MockAubManager { using MockAubManager::MockAubManager; void addComment(const char *message) override { @@ -46,15 +51,12 @@ TEST(clAddCommentToAubTest, givenProperCommentAubCenterAndAubManagerWhenAddComme auto mockAubCenter = new MockAubCenter(); auto mockAubManager = new AubManagerCommentMock; mockAubCenter->aubManager.reset(mockAubManager); - auto executionEnvironment = platform()->peekExecutionEnvironment(); - executionEnvironment->aubCenter.reset(mockAubCenter); + pPlatform->peekExecutionEnvironment()->aubCenter.reset(mockAubCenter); EXPECT_FALSE(mockAubManager->addCommentCalled); - auto retVal = clAddCommentINTEL("comment"); + auto retVal = clAddCommentINTEL(pPlatform, "comment"); EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_TRUE(mockAubManager->addCommentCalled); - - executionEnvironment->aubCenter.reset(nullptr); } } // namespace ULT