Skip to content

Commit e27c5a9

Browse files
Change signature of clAddCommentINTEL function: pass device instead of platform
Resolves: NEO-3939 Change-Id: I394ef7c2370771569a0ec50ac4644782ce8a384f Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
1 parent 16c6d7e commit e27c5a9

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

runtime/api/api.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,13 +5071,17 @@ CL_API_ENTRY cl_int CL_API_CALL clEnqueueVerifyMemoryINTEL(cl_command_queue comm
50715071
return retVal;
50725072
}
50735073

5074-
cl_int CL_API_CALL clAddCommentINTEL(cl_platform_id platform, const char *comment) {
5074+
cl_int CL_API_CALL clAddCommentINTEL(cl_device_id device, const char *comment) {
50755075
cl_int retVal = CL_SUCCESS;
50765076
API_ENTER(&retVal);
5077-
DBG_LOG_INPUTS("platform", platform, "comment", comment);
5077+
DBG_LOG_INPUTS("device", device, "comment", comment);
50785078

5079-
auto executionEnvironment = ::platform()->peekExecutionEnvironment();
5080-
auto aubCenter = executionEnvironment->rootDeviceEnvironments[0]->aubCenter.get();
5079+
Device *pDevice = nullptr;
5080+
retVal = validateObjects(WithCastToInternal(device, &pDevice));
5081+
if (retVal != CL_SUCCESS) {
5082+
return retVal;
5083+
}
5084+
auto aubCenter = pDevice->getRootDeviceEnvironment().aubCenter.get();
50815085

50825086
if (!comment || (aubCenter && !aubCenter->getAubManager())) {
50835087
retVal = CL_INVALID_VALUE;

runtime/api/api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ cl_int CL_API_CALL clEnqueueVerifyMemoryINTEL(
861861
size_t sizeOfComparison,
862862
cl_uint comparisonMode);
863863

864-
cl_int CL_API_CALL clAddCommentINTEL(cl_platform_id platform, const char *comment);
864+
cl_int CL_API_CALL clAddCommentINTEL(cl_device_id device, const char *comment);
865865

866866
// OpenCL 2.1
867867

runtime/device/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class Device : public BaseObject<_cl_device_id> {
7979
MOCKABLE_VIRTUAL bool isSourceLevelDebuggerActive() const;
8080
SourceLevelDebugger *getSourceLevelDebugger() { return executionEnvironment->sourceLevelDebugger.get(); }
8181
ExecutionEnvironment *getExecutionEnvironment() const { return executionEnvironment; }
82+
const RootDeviceEnvironment &getRootDeviceEnvironment() const { return *executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]; }
8283
const HardwareCapabilities &getHardwareCapabilities() const { return hardwareCapabilities; }
8384
bool isFullRangeSvm() const {
8485
return executionEnvironment->isFullRangeSvm();

unit_tests/api/cl_add_comment_to_aub_tests.inl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77

88
#include "core/execution_environment/root_device_environment.h"
9+
#include "runtime/context/context.h"
10+
#include "runtime/device/device.h"
911
#include "runtime/execution_environment/execution_environment.h"
1012
#include "runtime/platform/platform.h"
1113
#include "unit_tests/api/cl_api_tests.h"
@@ -16,22 +18,37 @@ using namespace NEO;
1618

1719
namespace ULT {
1820

19-
using clAddCommentToAubTest = api_tests;
21+
struct clAddCommentToAubTest : api_tests {
22+
void SetUp() override {
23+
api_tests::SetUp();
24+
pDevice = pContext->getDevice(0);
25+
}
26+
void TearDown() override {
27+
api_tests::TearDown();
28+
}
29+
30+
Device *pDevice = nullptr;
31+
};
2032

2133
TEST_F(clAddCommentToAubTest, givenProperCommentNullptrAubCenterWhenAddCommentToAubThenSuccessIsReturned) {
22-
auto retVal = clAddCommentINTEL(pPlatform, "comment");
34+
auto retVal = clAddCommentINTEL(pDevice, "comment");
2335
EXPECT_EQ(CL_SUCCESS, retVal);
2436
}
2537

38+
TEST_F(clAddCommentToAubTest, givenInvalidDeviceWhenAddCommentToAubThenErrorIsReturned) {
39+
auto retVal = clAddCommentINTEL(nullptr, "comment");
40+
EXPECT_EQ(CL_INVALID_DEVICE, retVal);
41+
}
42+
2643
TEST_F(clAddCommentToAubTest, givenNullptrCommentWhenAddCommentToAubThenErrorIsReturned) {
27-
auto retVal = clAddCommentINTEL(pPlatform, nullptr);
44+
auto retVal = clAddCommentINTEL(pDevice, nullptr);
2845
EXPECT_EQ(CL_INVALID_VALUE, retVal);
2946
}
3047

3148
TEST_F(clAddCommentToAubTest, givenAubCenterAndProperCommentButNullptrAubManagerWhenAddCommentToAubThenErrorIsReturned) {
3249
pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[testedRootDeviceIndex]->aubCenter.reset(new MockAubCenter());
3350

34-
auto retVal = clAddCommentINTEL(pPlatform, "comment");
51+
auto retVal = clAddCommentINTEL(pDevice, "comment");
3552
EXPECT_EQ(CL_INVALID_VALUE, retVal);
3653
}
3754

@@ -51,7 +68,7 @@ TEST_F(clAddCommentToAubTest, givenProperCommentAubCenterAndAubManagerWhenAddCom
5168

5269
EXPECT_FALSE(mockAubManager->addCommentCalled);
5370

54-
auto retVal = clAddCommentINTEL(pPlatform, "comment");
71+
auto retVal = clAddCommentINTEL(pDevice, "comment");
5572
EXPECT_EQ(CL_SUCCESS, retVal);
5673
EXPECT_TRUE(mockAubManager->addCommentCalled);
5774
}

0 commit comments

Comments
 (0)