Adjust clGetKernelWorkGroupInfo api call

Signed-off-by: Sebastian Luzynski <sebastian.jozef.luzynski@intel.com>
This commit is contained in:
Sebastian Luzynski
2021-02-02 11:25:28 +00:00
committed by Compute-Runtime-Automation
parent d399613f25
commit 0871c1bb76
6 changed files with 96 additions and 79 deletions

View File

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

View File

@@ -17,4 +17,9 @@ inline cl_command_queue_capabilities_intel ClHwHelperHw<GfxFamily>::getAdditiona
return 0;
}
template <typename GfxFamily>
cl_ulong ClHwHelperHw<GfxFamily>::getKernelPrivateMemSize(const KernelInfo &kernelInfo) const {
return kernelInfo.patchInfo.pAllocateStatelessPrivateSurface ? kernelInfo.patchInfo.pAllocateStatelessPrivateSurface->PerThreadPrivateMemorySize : 0;
}
} // namespace NEO

View File

@@ -620,6 +620,7 @@ cl_int Kernel::getWorkGroupInfo(ClDevice &device, cl_kernel_work_group_info para
size_t maxWorkgroupSize;
const auto &hwInfo = device.getHardwareInfo();
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto &clHwHelper = ClHwHelper::get(hwInfo.platform.eRenderCoreFamily);
GetInfoHelper info(paramValue, paramValueSize, paramValueSizeRet);
switch (paramName) {
@@ -664,7 +665,7 @@ cl_int Kernel::getWorkGroupInfo(ClDevice &device, cl_kernel_work_group_info para
pSrc = &scratchSize;
break;
case CL_KERNEL_PRIVATE_MEM_SIZE:
privateMemSize = kernelInfo.patchInfo.pAllocateStatelessPrivateSurface ? kernelInfo.patchInfo.pAllocateStatelessPrivateSurface->PerThreadPrivateMemorySize : 0;
privateMemSize = clHwHelper.getKernelPrivateMemSize(kernelInfo);
srcSize = sizeof(privateMemSize);
pSrc = &privateMemSize;
break;

View File

@@ -1,89 +1,14 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/compiler_interface/compiler_interface.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/file_io.h"
#include "shared/test/unit_test/helpers/test_files.h"
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
#include "opencl/test/unit_test/mocks/mock_kernel.h"
#include "cl_api_tests.h"
#include "opencl/test/unit_test/fixtures/kernel_work_group_info_fixture.h"
using namespace NEO;
struct clGetKernelWorkGroupInfoTest : public ApiFixture<>,
public ::testing::Test {
typedef ApiFixture BaseClass;
void SetUp() override {
BaseClass::SetUp();
std::unique_ptr<char[]> pSource = nullptr;
size_t sourceSize = 0;
std::string testFile;
kbHelper = new KernelBinaryHelper("CopyBuffer_simd16", false);
testFile.append(clFiles);
testFile.append("CopyBuffer_simd16.cl");
ASSERT_EQ(true, fileExists(testFile));
pSource = loadDataFromFile(
testFile.c_str(),
sourceSize);
ASSERT_NE(0u, sourceSize);
ASSERT_NE(nullptr, pSource);
const char *sources[1] = {pSource.get()};
pProgram = clCreateProgramWithSource(
pContext,
1,
sources,
&sourceSize,
&retVal);
EXPECT_NE(nullptr, pProgram);
ASSERT_EQ(CL_SUCCESS, retVal);
pSource.reset();
retVal = clBuildProgram(
pProgram,
1,
&testedClDevice,
nullptr,
nullptr,
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
kernel = clCreateKernel(pProgram, "CopyBuffer", &retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
}
void TearDown() override {
retVal = clReleaseKernel(kernel);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
delete kbHelper;
BaseClass::TearDown();
}
cl_program pProgram = nullptr;
cl_kernel kernel = nullptr;
KernelBinaryHelper *kbHelper;
};
struct clGetKernelWorkGroupInfoTests : public clGetKernelWorkGroupInfoTest,
public ::testing::WithParamInterface<uint32_t /*cl_kernel_work_group_info*/> {
};
namespace ULT {
TEST_P(clGetKernelWorkGroupInfoTests, GivenValidParametersWhenGettingKernelWorkGroupInfoThenSuccessIsReturned) {
@@ -172,7 +97,8 @@ TEST_F(clGetKernelWorkGroupInfoTests, GivenKernelRequiringScratchSpaceWhenGettin
EXPECT_EQ(param_value, scratchSpaceSize);
}
TEST_F(clGetKernelWorkGroupInfoTests, givenKernelHavingPrivateMemoryAllocationWhenAskedForPrivateAllocationSizeThenProperSizeIsReturned) {
using matcher = IsWithinProducts<IGFX_SKYLAKE, IGFX_DG1>;
HWTEST2_F(clGetKernelWorkGroupInfoTests, givenKernelHavingPrivateMemoryAllocationWhenAskedForPrivateAllocationSizeThenProperSizeIsReturned, matcher) {
size_t paramValueSizeRet;
cl_ulong param_value;
auto pDevice = castToObject<ClDevice>(testedClDevice);

View File

@@ -30,6 +30,7 @@ set(IGDRCL_SRCS_tests_fixtures
${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_data_fixture.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_data_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_work_group_info_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/media_kernel_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_multi_device_fixture.h

View File

@@ -0,0 +1,82 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/file_io.h"
#include "shared/test/unit_test/helpers/test_files.h"
#include "opencl/test/unit_test/api/cl_api_tests.h"
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
#include "test.h"
using namespace NEO;
struct clGetKernelWorkGroupInfoTest : public ApiFixture<>,
public ::testing::Test {
typedef ApiFixture BaseClass;
void SetUp() override {
BaseClass::SetUp();
std::unique_ptr<char[]> pSource = nullptr;
size_t sourceSize = 0;
std::string testFile;
kbHelper = new KernelBinaryHelper("CopyBuffer_simd16", false);
testFile.append(clFiles);
testFile.append("CopyBuffer_simd16.cl");
ASSERT_EQ(true, fileExists(testFile));
pSource = loadDataFromFile(
testFile.c_str(),
sourceSize);
ASSERT_NE(0u, sourceSize);
ASSERT_NE(nullptr, pSource);
const char *sources[1] = {pSource.get()};
pProgram = clCreateProgramWithSource(
pContext,
1,
sources,
&sourceSize,
&retVal);
EXPECT_NE(nullptr, pProgram);
ASSERT_EQ(CL_SUCCESS, retVal);
pSource.reset();
retVal = clBuildProgram(
pProgram,
1,
&testedClDevice,
nullptr,
nullptr,
nullptr);
ASSERT_EQ(CL_SUCCESS, retVal);
kernel = clCreateKernel(pProgram, "CopyBuffer", &retVal);
ASSERT_EQ(CL_SUCCESS, retVal);
}
void TearDown() override {
retVal = clReleaseKernel(kernel);
EXPECT_EQ(CL_SUCCESS, retVal);
retVal = clReleaseProgram(pProgram);
EXPECT_EQ(CL_SUCCESS, retVal);
delete kbHelper;
BaseClass::TearDown();
}
cl_program pProgram = nullptr;
cl_kernel kernel = nullptr;
KernelBinaryHelper *kbHelper;
};
struct clGetKernelWorkGroupInfoTests : public clGetKernelWorkGroupInfoTest,
public ::testing::WithParamInterface<uint32_t> {
};