Skip to content

Commit 0871c1b

Browse files
Adjust clGetKernelWorkGroupInfo api call
Signed-off-by: Sebastian Luzynski <[email protected]>
1 parent d399613 commit 0871c1b

File tree

6 files changed

+96
-79
lines changed

6 files changed

+96
-79
lines changed

opencl/source/helpers/cl_hw_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class ClHwHelper {
2929
virtual bool allowRenderCompressionForContext(const HardwareInfo &hwInfo, const Context &context) const = 0;
3030
virtual cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const = 0;
3131
virtual bool getQueueFamilyName(std::string &name, EngineGroupType type) const = 0;
32+
virtual cl_ulong getKernelPrivateMemSize(const KernelInfo &kernelInfo) const = 0;
3233

3334
protected:
3435
virtual bool hasStatelessAccessToBuffer(const KernelInfo &kernelInfo) const = 0;
@@ -49,6 +50,7 @@ class ClHwHelperHw : public ClHwHelper {
4950
bool allowRenderCompressionForContext(const HardwareInfo &hwInfo, const Context &context) const override;
5051
cl_command_queue_capabilities_intel getAdditionalDisabledQueueFamilyCapabilities(EngineGroupType type) const override;
5152
bool getQueueFamilyName(std::string &name, EngineGroupType type) const override;
53+
cl_ulong getKernelPrivateMemSize(const KernelInfo &kernelInfo) const override;
5254

5355
protected:
5456
bool hasStatelessAccessToBuffer(const KernelInfo &kernelInfo) const override;

opencl/source/helpers/cl_hw_helper_bdw_plus.inl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ inline cl_command_queue_capabilities_intel ClHwHelperHw<GfxFamily>::getAdditiona
1717
return 0;
1818
}
1919

20+
template <typename GfxFamily>
21+
cl_ulong ClHwHelperHw<GfxFamily>::getKernelPrivateMemSize(const KernelInfo &kernelInfo) const {
22+
return kernelInfo.patchInfo.pAllocateStatelessPrivateSurface ? kernelInfo.patchInfo.pAllocateStatelessPrivateSurface->PerThreadPrivateMemorySize : 0;
23+
}
24+
2025
} // namespace NEO

opencl/source/kernel/kernel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ cl_int Kernel::getWorkGroupInfo(ClDevice &device, cl_kernel_work_group_info para
620620
size_t maxWorkgroupSize;
621621
const auto &hwInfo = device.getHardwareInfo();
622622
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
623+
auto &clHwHelper = ClHwHelper::get(hwInfo.platform.eRenderCoreFamily);
623624
GetInfoHelper info(paramValue, paramValueSize, paramValueSizeRet);
624625

625626
switch (paramName) {
@@ -664,7 +665,7 @@ cl_int Kernel::getWorkGroupInfo(ClDevice &device, cl_kernel_work_group_info para
664665
pSrc = &scratchSize;
665666
break;
666667
case CL_KERNEL_PRIVATE_MEM_SIZE:
667-
privateMemSize = kernelInfo.patchInfo.pAllocateStatelessPrivateSurface ? kernelInfo.patchInfo.pAllocateStatelessPrivateSurface->PerThreadPrivateMemorySize : 0;
668+
privateMemSize = clHwHelper.getKernelPrivateMemSize(kernelInfo);
668669
srcSize = sizeof(privateMemSize);
669670
pSrc = &privateMemSize;
670671
break;

opencl/test/unit_test/api/cl_get_kernel_work_group_info_tests.inl

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,14 @@
11
/*
2-
* Copyright (C) 2017-2020 Intel Corporation
2+
* Copyright (C) 2017-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

8-
#include "shared/source/compiler_interface/compiler_interface.h"
9-
#include "shared/source/device/device.h"
10-
#include "shared/source/helpers/file_io.h"
11-
#include "shared/test/unit_test/helpers/test_files.h"
12-
13-
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
14-
#include "opencl/test/unit_test/mocks/mock_kernel.h"
15-
16-
#include "cl_api_tests.h"
8+
#include "opencl/test/unit_test/fixtures/kernel_work_group_info_fixture.h"
179

1810
using namespace NEO;
1911

20-
struct clGetKernelWorkGroupInfoTest : public ApiFixture<>,
21-
public ::testing::Test {
22-
typedef ApiFixture BaseClass;
23-
24-
void SetUp() override {
25-
BaseClass::SetUp();
26-
27-
std::unique_ptr<char[]> pSource = nullptr;
28-
size_t sourceSize = 0;
29-
std::string testFile;
30-
31-
kbHelper = new KernelBinaryHelper("CopyBuffer_simd16", false);
32-
testFile.append(clFiles);
33-
testFile.append("CopyBuffer_simd16.cl");
34-
ASSERT_EQ(true, fileExists(testFile));
35-
36-
pSource = loadDataFromFile(
37-
testFile.c_str(),
38-
sourceSize);
39-
ASSERT_NE(0u, sourceSize);
40-
ASSERT_NE(nullptr, pSource);
41-
42-
const char *sources[1] = {pSource.get()};
43-
pProgram = clCreateProgramWithSource(
44-
pContext,
45-
1,
46-
sources,
47-
&sourceSize,
48-
&retVal);
49-
EXPECT_NE(nullptr, pProgram);
50-
ASSERT_EQ(CL_SUCCESS, retVal);
51-
52-
pSource.reset();
53-
54-
retVal = clBuildProgram(
55-
pProgram,
56-
1,
57-
&testedClDevice,
58-
nullptr,
59-
nullptr,
60-
nullptr);
61-
ASSERT_EQ(CL_SUCCESS, retVal);
62-
63-
kernel = clCreateKernel(pProgram, "CopyBuffer", &retVal);
64-
ASSERT_EQ(CL_SUCCESS, retVal);
65-
}
66-
67-
void TearDown() override {
68-
retVal = clReleaseKernel(kernel);
69-
EXPECT_EQ(CL_SUCCESS, retVal);
70-
71-
retVal = clReleaseProgram(pProgram);
72-
EXPECT_EQ(CL_SUCCESS, retVal);
73-
74-
delete kbHelper;
75-
BaseClass::TearDown();
76-
}
77-
78-
cl_program pProgram = nullptr;
79-
cl_kernel kernel = nullptr;
80-
KernelBinaryHelper *kbHelper;
81-
};
82-
83-
struct clGetKernelWorkGroupInfoTests : public clGetKernelWorkGroupInfoTest,
84-
public ::testing::WithParamInterface<uint32_t /*cl_kernel_work_group_info*/> {
85-
};
86-
8712
namespace ULT {
8813

8914
TEST_P(clGetKernelWorkGroupInfoTests, GivenValidParametersWhenGettingKernelWorkGroupInfoThenSuccessIsReturned) {
@@ -172,7 +97,8 @@ TEST_F(clGetKernelWorkGroupInfoTests, GivenKernelRequiringScratchSpaceWhenGettin
17297
EXPECT_EQ(param_value, scratchSpaceSize);
17398
}
17499

175-
TEST_F(clGetKernelWorkGroupInfoTests, givenKernelHavingPrivateMemoryAllocationWhenAskedForPrivateAllocationSizeThenProperSizeIsReturned) {
100+
using matcher = IsWithinProducts<IGFX_SKYLAKE, IGFX_DG1>;
101+
HWTEST2_F(clGetKernelWorkGroupInfoTests, givenKernelHavingPrivateMemoryAllocationWhenAskedForPrivateAllocationSizeThenProperSizeIsReturned, matcher) {
176102
size_t paramValueSizeRet;
177103
cl_ulong param_value;
178104
auto pDevice = castToObject<ClDevice>(testedClDevice);

opencl/test/unit_test/fixtures/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(IGDRCL_SRCS_tests_fixtures
3030
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_fixture.h
3131
${CMAKE_CURRENT_SOURCE_DIR}/kernel_data_fixture.cpp
3232
${CMAKE_CURRENT_SOURCE_DIR}/kernel_data_fixture.h
33+
${CMAKE_CURRENT_SOURCE_DIR}/kernel_work_group_info_fixture.h
3334
${CMAKE_CURRENT_SOURCE_DIR}/media_kernel_fixture.h
3435
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_fixture.h
3536
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_multi_device_fixture.h
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "shared/source/helpers/file_io.h"
10+
#include "shared/test/unit_test/helpers/test_files.h"
11+
12+
#include "opencl/test/unit_test/api/cl_api_tests.h"
13+
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
14+
#include "test.h"
15+
16+
using namespace NEO;
17+
struct clGetKernelWorkGroupInfoTest : public ApiFixture<>,
18+
public ::testing::Test {
19+
typedef ApiFixture BaseClass;
20+
21+
void SetUp() override {
22+
BaseClass::SetUp();
23+
24+
std::unique_ptr<char[]> pSource = nullptr;
25+
size_t sourceSize = 0;
26+
std::string testFile;
27+
28+
kbHelper = new KernelBinaryHelper("CopyBuffer_simd16", false);
29+
testFile.append(clFiles);
30+
testFile.append("CopyBuffer_simd16.cl");
31+
ASSERT_EQ(true, fileExists(testFile));
32+
33+
pSource = loadDataFromFile(
34+
testFile.c_str(),
35+
sourceSize);
36+
ASSERT_NE(0u, sourceSize);
37+
ASSERT_NE(nullptr, pSource);
38+
39+
const char *sources[1] = {pSource.get()};
40+
pProgram = clCreateProgramWithSource(
41+
pContext,
42+
1,
43+
sources,
44+
&sourceSize,
45+
&retVal);
46+
EXPECT_NE(nullptr, pProgram);
47+
ASSERT_EQ(CL_SUCCESS, retVal);
48+
49+
pSource.reset();
50+
51+
retVal = clBuildProgram(
52+
pProgram,
53+
1,
54+
&testedClDevice,
55+
nullptr,
56+
nullptr,
57+
nullptr);
58+
ASSERT_EQ(CL_SUCCESS, retVal);
59+
60+
kernel = clCreateKernel(pProgram, "CopyBuffer", &retVal);
61+
ASSERT_EQ(CL_SUCCESS, retVal);
62+
}
63+
64+
void TearDown() override {
65+
retVal = clReleaseKernel(kernel);
66+
EXPECT_EQ(CL_SUCCESS, retVal);
67+
68+
retVal = clReleaseProgram(pProgram);
69+
EXPECT_EQ(CL_SUCCESS, retVal);
70+
71+
delete kbHelper;
72+
BaseClass::TearDown();
73+
}
74+
75+
cl_program pProgram = nullptr;
76+
cl_kernel kernel = nullptr;
77+
KernelBinaryHelper *kbHelper;
78+
};
79+
80+
struct clGetKernelWorkGroupInfoTests : public clGetKernelWorkGroupInfoTest,
81+
public ::testing::WithParamInterface<uint32_t> {
82+
};

0 commit comments

Comments
 (0)