Add dispatchable object to the clAddCommentINTEL

Related-To: NEO-3082

Change-Id: Iae0117b32a81c97a37fb30e79bd4b9547c50c95c
Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
Jobczyk, Lukasz 2019-04-08 13:08:08 +02:00 committed by sys_ocldev
parent 40749080d3
commit 2393aceca6
3 changed files with 33 additions and 25 deletions

View File

@ -4231,11 +4231,16 @@ 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();
Platform *pPlatform = nullptr;
retVal = validateObjects(WithCastToInternal(platform, &pPlatform));
if (retVal == CL_SUCCESS) {
auto executionEnvironment = pPlatform->peekExecutionEnvironment();
auto aubCenter = executionEnvironment->aubCenter.get();
if (!comment || (aubCenter && !aubCenter->getAubManager())) {
@ -4245,5 +4250,6 @@ cl_int CL_API_CALL clAddCommentINTEL(const char *comment) {
if (retVal == CL_SUCCESS && aubCenter) {
aubCenter->getAubManager()->addComment(comment);
}
}
return retVal;
}

View File

@ -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

View File

@ -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