mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Initial commit
Change-Id: I4bf1707bd3dfeadf2c17b0a7daff372b1925ebbd
This commit is contained in:
42
unit_tests/kernel/CMakeLists.txt
Normal file
42
unit_tests/kernel/CMakeLists.txt
Normal file
@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2017, Intel Corporation
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#We are setting all of the source / OpenCL / tests / kernel files here and
|
||||
#sending the variable up to the parent scope
|
||||
set(IGDRCL_SRCS_tests_kernel
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/clone_kernel_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_accelerator_arg_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_buffer_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_buffer_fixture.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_buffer_fixture.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_info_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_pipe_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_svm_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_image_arg_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_immediate_arg_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_is_patched_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_arg_dev_queue_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_reflection_surface_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_slm_arg_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_slm_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/kernel_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/parent_kernel_tests.cpp"
|
||||
PARENT_SCOPE)
|
547
unit_tests/kernel/clone_kernel_tests.cpp
Normal file
547
unit_tests/kernel/clone_kernel_tests.cpp
Normal file
@ -0,0 +1,547 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/mem_obj/pipe.h"
|
||||
#include "runtime/accelerators/intel_accelerator.h"
|
||||
#include "runtime/accelerators/intel_motion_estimation.h"
|
||||
#include "runtime/helpers/sampler_helpers.h"
|
||||
#include "runtime/memory_manager/svm_memory_manager.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_sampler.h"
|
||||
#include "unit_tests/mocks/mock_pipe.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_device_queue.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class CloneKernelFixture : public ContextFixture, public DeviceFixture, public MemoryManagementFixture {
|
||||
using ContextFixture::SetUp;
|
||||
|
||||
public:
|
||||
CloneKernelFixture() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
DeviceFixture::SetUp();
|
||||
cl_device_id device = pDevice;
|
||||
ContextFixture::SetUp(1, &device);
|
||||
|
||||
// define kernel info
|
||||
pKernelInfo = KernelInfo::create();
|
||||
|
||||
// setup kernel arg offsets
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
kernelHeader.SurfaceStateHeapSize = sizeof(surfaceStateHeap);
|
||||
pKernelInfo->heapInfo.pKernelHeader = &kernelHeader;
|
||||
pKernelInfo->heapInfo.pSsh = surfaceStateHeap;
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(1);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x20;
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].offsetHeap = 0x20;
|
||||
pKernelInfo->kernelArgInfo[0].offsetObjectId = 0x0;
|
||||
|
||||
// image
|
||||
pKernelInfo->kernelArgInfo[0].offsetImgWidth = 0x4;
|
||||
pKernelInfo->kernelArgInfo[0].offsetImgHeight = 0x8;
|
||||
pKernelInfo->kernelArgInfo[0].offsetImgDepth = 0xc;
|
||||
|
||||
// sampler
|
||||
pKernelInfo->kernelArgInfo[0].offsetSamplerSnapWa = 0x4;
|
||||
pKernelInfo->kernelArgInfo[0].offsetSamplerAddressingMode = 0x8;
|
||||
pKernelInfo->kernelArgInfo[0].offsetSamplerNormalizedCoords = 0x10;
|
||||
|
||||
// accelerator
|
||||
pKernelInfo->kernelArgInfo[0].samplerArgumentType = iOpenCL::SAMPLER_OBJECT_VME;
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeMbBlockType = 0x4;
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeSubpixelMode = 0xc;
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeSadAdjustMode = 0x14;
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeSearchPathType = 0x1c;
|
||||
|
||||
pProgram = new MockProgram(pContext);
|
||||
|
||||
pSourceKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pSourceKernel->initialize());
|
||||
char pSourceCrossThreadData[64] = {};
|
||||
pSourceKernel->setCrossThreadData(pSourceCrossThreadData, sizeof(pSourceCrossThreadData));
|
||||
|
||||
pClonedKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pClonedKernel->initialize());
|
||||
char pClonedCrossThreadData[64] = {};
|
||||
pClonedKernel->setCrossThreadData(pClonedCrossThreadData, sizeof(pClonedCrossThreadData));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pSourceKernel;
|
||||
delete pClonedKernel;
|
||||
delete pProgram;
|
||||
ContextFixture::TearDown();
|
||||
DeviceFixture::TearDown();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
MockProgram *pProgram = nullptr;
|
||||
MockKernel *pSourceKernel = nullptr;
|
||||
MockKernel *pClonedKernel = nullptr;
|
||||
KernelInfo *pKernelInfo = nullptr;
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
char surfaceStateHeap[128];
|
||||
};
|
||||
|
||||
typedef Test<CloneKernelFixture> CloneKernelTest;
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithUnsetArg) {
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::NONE_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(nullptr, pSourceKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(nullptr, pSourceKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(0u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_FALSE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgLocal) {
|
||||
const size_t slmSize = 0x800;
|
||||
|
||||
pSourceKernel->setKernelArgHandler(0, &Kernel::setArgLocal);
|
||||
pClonedKernel->setKernelArgHandler(0, &Kernel::setArgLocal);
|
||||
|
||||
retVal = pSourceKernel->setArg(0, slmSize, nullptr);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::SLM_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
EXPECT_EQ(alignUp(slmSize, 1024), pClonedKernel->slmTotalSize);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgBuffer) {
|
||||
MockBuffer buffer;
|
||||
cl_mem memObj = &buffer;
|
||||
|
||||
pSourceKernel->setKernelArgHandler(0, &Kernel::setArgBuffer);
|
||||
pClonedKernel->setKernelArgHandler(0, &Kernel::setArgBuffer);
|
||||
|
||||
retVal = pSourceKernel->setArg(0, sizeof(cl_mem), &memObj);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::BUFFER_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto pKernelArg = (cl_mem *)(pClonedKernel->getCrossThreadData() +
|
||||
pClonedKernel->getKernelInfo().kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(buffer.getCpuAddress(), *pKernelArg);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgPipe) {
|
||||
MockPipe pipe(pContext);
|
||||
cl_mem memObj = &pipe;
|
||||
|
||||
pSourceKernel->setKernelArgHandler(0, &Kernel::setArgPipe);
|
||||
pClonedKernel->setKernelArgHandler(0, &Kernel::setArgPipe);
|
||||
|
||||
retVal = pSourceKernel->setArg(0, sizeof(cl_mem), &memObj);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::PIPE_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto pKernelArg = (cl_mem *)(pClonedKernel->getCrossThreadData() +
|
||||
pClonedKernel->getKernelInfo().kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(pipe.getCpuAddress(), *pKernelArg);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgImage) {
|
||||
auto image = std::unique_ptr<Image>(Image2dHelper<>::create(pContext));
|
||||
ASSERT_NE(nullptr, image);
|
||||
|
||||
uint32_t objectId = pKernelInfo->kernelArgInfo[0].offsetHeap;
|
||||
size_t imageWidth = image->getImageDesc().image_width;
|
||||
size_t imageHeight = image->getImageDesc().image_height;
|
||||
size_t imageDepth = image->getImageDesc().image_depth;
|
||||
|
||||
cl_mem memObj = image.get();
|
||||
|
||||
pSourceKernel->setKernelArgHandler(0, &Kernel::setArgImage);
|
||||
pClonedKernel->setKernelArgHandler(0, &Kernel::setArgImage);
|
||||
|
||||
retVal = pSourceKernel->setArg(0, sizeof(cl_mem), &memObj);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::IMAGE_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint32_t *>(pClonedKernel->getCrossThreadData());
|
||||
EXPECT_EQ(objectId, *crossThreadData);
|
||||
|
||||
auto argInfo = pClonedKernel->getKernelInfo().kernelArgInfo[0];
|
||||
|
||||
auto pImgWidth = ptrOffset(crossThreadData, argInfo.offsetImgWidth);
|
||||
EXPECT_EQ(imageWidth, *pImgWidth);
|
||||
|
||||
auto pImgHeight = ptrOffset(crossThreadData, argInfo.offsetImgHeight);
|
||||
EXPECT_EQ(imageHeight, *pImgHeight);
|
||||
|
||||
auto pImgDepth = ptrOffset(crossThreadData, argInfo.offsetImgDepth);
|
||||
EXPECT_EQ(imageDepth, *pImgDepth);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgAccelerator) {
|
||||
cl_motion_estimation_desc_intel desc = {
|
||||
CL_ME_MB_TYPE_4x4_INTEL,
|
||||
CL_ME_SUBPIXEL_MODE_QPEL_INTEL,
|
||||
CL_ME_SAD_ADJUST_MODE_HAAR_INTEL,
|
||||
CL_ME_SEARCH_PATH_RADIUS_16_12_INTEL};
|
||||
|
||||
cl_accelerator_intel accelerator = VmeAccelerator::create(
|
||||
pContext,
|
||||
CL_ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL, sizeof(desc), &desc,
|
||||
retVal);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
ASSERT_NE(nullptr, accelerator);
|
||||
|
||||
pSourceKernel->setKernelArgHandler(0, &Kernel::setArgAccelerator);
|
||||
pClonedKernel->setKernelArgHandler(0, &Kernel::setArgAccelerator);
|
||||
|
||||
retVal = pSourceKernel->setArg(0, sizeof(cl_accelerator_intel), &accelerator);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::ACCELERATOR_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint32_t *>(pClonedKernel->getCrossThreadData());
|
||||
|
||||
auto argInfo = pClonedKernel->getKernelInfo().kernelArgInfo[0];
|
||||
|
||||
uint32_t *pMbBlockType = ptrOffset(crossThreadData, argInfo.offsetVmeMbBlockType);
|
||||
EXPECT_EQ(desc.mb_block_type, *pMbBlockType);
|
||||
|
||||
uint32_t *pSubpixelMode = ptrOffset(crossThreadData, argInfo.offsetVmeSubpixelMode);
|
||||
EXPECT_EQ(desc.subpixel_mode, *pSubpixelMode);
|
||||
|
||||
uint32_t *pSadAdjustMode = ptrOffset(crossThreadData, argInfo.offsetVmeSadAdjustMode);
|
||||
EXPECT_EQ(desc.sad_adjust_mode, *pSadAdjustMode);
|
||||
|
||||
uint32_t *pSearchPathType = ptrOffset(crossThreadData, argInfo.offsetVmeSearchPathType);
|
||||
EXPECT_EQ(desc.search_path_type, *pSearchPathType);
|
||||
|
||||
retVal = clReleaseAcceleratorINTEL(accelerator);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgSampler) {
|
||||
std::unique_ptr<Sampler> sampler(new MockSampler(pContext,
|
||||
true,
|
||||
(cl_addressing_mode)CL_ADDRESS_MIRRORED_REPEAT,
|
||||
(cl_filter_mode)CL_FILTER_NEAREST));
|
||||
|
||||
uint32_t objectId = SAMPLER_OBJECT_ID_SHIFT + pKernelInfo->kernelArgInfo[0].offsetHeap;
|
||||
|
||||
cl_sampler samplerObj = sampler.get();
|
||||
|
||||
pSourceKernel->setKernelArgHandler(0, &Kernel::setArgSampler);
|
||||
pClonedKernel->setKernelArgHandler(0, &Kernel::setArgSampler);
|
||||
|
||||
retVal = pSourceKernel->setArg(0, sizeof(cl_sampler), &samplerObj);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::SAMPLER_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint32_t *>(pClonedKernel->getCrossThreadData());
|
||||
EXPECT_EQ(objectId, *crossThreadData);
|
||||
|
||||
auto argInfo = pClonedKernel->getKernelInfo().kernelArgInfo[0];
|
||||
|
||||
auto pSnapWa = ptrOffset(crossThreadData, argInfo.offsetSamplerSnapWa);
|
||||
EXPECT_EQ(sampler->getSnapWaValue(), *pSnapWa);
|
||||
|
||||
auto pAddressingMode = ptrOffset(crossThreadData, argInfo.offsetSamplerAddressingMode);
|
||||
EXPECT_EQ(GetAddrModeEnum(sampler->addressingMode), *pAddressingMode);
|
||||
|
||||
auto pNormalizedCoords = ptrOffset(crossThreadData, argInfo.offsetSamplerNormalizedCoords);
|
||||
EXPECT_EQ(GetNormCoordsEnum(sampler->normalizedCoordinates), *pNormalizedCoords);
|
||||
}
|
||||
|
||||
HWTEST_F(CloneKernelTest, cloneKernelWithArgDeviceQueue) {
|
||||
cl_queue_properties queueProps[5] = {
|
||||
CL_QUEUE_PROPERTIES,
|
||||
CL_QUEUE_ON_DEVICE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,
|
||||
0, 0, 0};
|
||||
|
||||
MockDeviceQueueHw<FamilyType> mockDevQueue(pContext, pDevice, queueProps[0]);
|
||||
auto clDeviceQueue = static_cast<cl_command_queue>(&mockDevQueue);
|
||||
|
||||
pSourceKernel->setKernelArgHandler(0, &Kernel::setArgDevQueue);
|
||||
pClonedKernel->setKernelArgHandler(0, &Kernel::setArgDevQueue);
|
||||
|
||||
retVal = pSourceKernel->setArg(0, sizeof(cl_command_queue), &clDeviceQueue);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::DEVICE_QUEUE_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto pKernelArg = (uintptr_t *)(pClonedKernel->getCrossThreadData() +
|
||||
pClonedKernel->getKernelInfo().kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(static_cast<uintptr_t>(mockDevQueue.getQueueBuffer()->getGpuAddressToPatch()), *pKernelArg);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgSvm) {
|
||||
char *svmPtr = new char[256];
|
||||
|
||||
retVal = pSourceKernel->setArgSvm(0, 256, svmPtr);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::SVM_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto pKernelArg = (void **)(pClonedKernel->getCrossThreadData() +
|
||||
pClonedKernel->getKernelInfo().kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(svmPtr, *pKernelArg);
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgSvmAlloc) {
|
||||
char *svmPtr = new char[256];
|
||||
GraphicsAllocation svmAlloc(svmPtr, 256);
|
||||
|
||||
retVal = pSourceKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::SVM_ALLOC_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto pKernelArg = (void **)(pClonedKernel->getCrossThreadData() +
|
||||
pClonedKernel->getKernelInfo().kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(svmPtr, *pKernelArg);
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithArgImmediate) {
|
||||
using TypeParam = unsigned long;
|
||||
auto value = (TypeParam)0xAA55AA55UL;
|
||||
|
||||
retVal = pSourceKernel->setArg(0, sizeof(TypeParam), &value);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(Kernel::NONE_OBJ, pSourceKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_NE(0u, pSourceKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(1u, pSourceKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pSourceKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelArguments().size(), pClonedKernel->getKernelArguments().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).type, pClonedKernel->getKernelArgInfo(0).type);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).object, pClonedKernel->getKernelArgInfo(0).object);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).value, pClonedKernel->getKernelArgInfo(0).value);
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).size, pClonedKernel->getKernelArgInfo(0).size);
|
||||
EXPECT_EQ(pSourceKernel->getPatchedArgumentsNum(), pClonedKernel->getPatchedArgumentsNum());
|
||||
EXPECT_EQ(pSourceKernel->getKernelArgInfo(0).isPatched, pClonedKernel->getKernelArgInfo(0).isPatched);
|
||||
|
||||
auto pKernelArg = (TypeParam *)(pClonedKernel->getCrossThreadData() +
|
||||
pClonedKernel->getKernelInfo().kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(value, *pKernelArg);
|
||||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithExecInfo) {
|
||||
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256);
|
||||
ASSERT_NE(nullptr, ptrSVM);
|
||||
|
||||
GraphicsAllocation *pSvmAlloc = pContext->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
|
||||
ASSERT_NE(nullptr, pSvmAlloc);
|
||||
|
||||
pSourceKernel->setKernelExecInfo(pSvmAlloc);
|
||||
|
||||
EXPECT_EQ(1u, pSourceKernel->getKernelSvmGfxAllocations().size());
|
||||
|
||||
retVal = pClonedKernel->cloneKernel(pSourceKernel);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(pSourceKernel->getKernelSvmGfxAllocations().size(), pClonedKernel->getKernelSvmGfxAllocations().size());
|
||||
EXPECT_EQ(pSourceKernel->getKernelSvmGfxAllocations().at(0), pClonedKernel->getKernelSvmGfxAllocations().at(0));
|
||||
|
||||
pContext->getSVMAllocsManager()->freeSVMAlloc(ptrSVM);
|
||||
}
|
179
unit_tests/kernel/kernel_accelerator_arg_tests.cpp
Normal file
179
unit_tests/kernel/kernel_accelerator_arg_tests.cpp
Normal file
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
|
||||
#include "test.h"
|
||||
#include "runtime/accelerators/intel_accelerator.h"
|
||||
#include "runtime/accelerators/intel_motion_estimation.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class KernelArgAcceleratorFixture : public ContextFixture, public DeviceFixture, public MemoryManagementFixture {
|
||||
|
||||
using ContextFixture::SetUp;
|
||||
|
||||
public:
|
||||
KernelArgAcceleratorFixture() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
desc = {
|
||||
CL_ME_MB_TYPE_4x4_INTEL,
|
||||
CL_ME_SUBPIXEL_MODE_QPEL_INTEL,
|
||||
CL_ME_SAD_ADJUST_MODE_HAAR_INTEL,
|
||||
CL_ME_SEARCH_PATH_RADIUS_16_12_INTEL};
|
||||
|
||||
MemoryManagementFixture::SetUp();
|
||||
DeviceFixture::SetUp();
|
||||
cl_device_id device = pDevice;
|
||||
ContextFixture::SetUp(1, &device);
|
||||
|
||||
pKernelInfo = KernelInfo::create();
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(1);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].samplerArgumentType = iOpenCL::SAMPLER_OBJECT_VME;
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x20;
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(uint32_t);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = 1;
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeMbBlockType = 0x04;
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeSubpixelMode = 0x0c;
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeSadAdjustMode = 0x14;
|
||||
pKernelInfo->kernelArgInfo[0].offsetVmeSearchPathType = 0x1c;
|
||||
|
||||
pProgram = new MockProgram(pContext);
|
||||
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
|
||||
pKernel->setKernelArgHandler(0, &Kernel::setArgAccelerator);
|
||||
|
||||
pCrossThreadData[0x04] = desc.mb_block_type;
|
||||
pCrossThreadData[0x0c] = desc.subpixel_mode;
|
||||
pCrossThreadData[0x14] = desc.sad_adjust_mode;
|
||||
pCrossThreadData[0x1c] = desc.sad_adjust_mode;
|
||||
|
||||
pKernel->setCrossThreadData(&pCrossThreadData[0], sizeof(pCrossThreadData));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
delete pProgram;
|
||||
ContextFixture::TearDown();
|
||||
DeviceFixture::TearDown();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
cl_motion_estimation_desc_intel desc;
|
||||
MockProgram *pProgram = nullptr;
|
||||
MockKernel *pKernel = nullptr;
|
||||
KernelInfo *pKernelInfo = nullptr;
|
||||
char pCrossThreadData[64];
|
||||
};
|
||||
|
||||
typedef Test<KernelArgAcceleratorFixture> KernelArgAcceleratorTest;
|
||||
|
||||
TEST_F(KernelArgAcceleratorTest, SetKernelArgValidAccelerator) {
|
||||
cl_int status;
|
||||
cl_accelerator_intel accelerator = VmeAccelerator::create(
|
||||
pContext,
|
||||
CL_ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL, sizeof(desc), &desc,
|
||||
status);
|
||||
ASSERT_EQ(CL_SUCCESS, status);
|
||||
ASSERT_NE(nullptr, accelerator);
|
||||
|
||||
status = this->pKernel->setArg(0, sizeof(cl_accelerator_intel), &accelerator);
|
||||
ASSERT_EQ(CL_SUCCESS, status);
|
||||
|
||||
char *crossThreadData = pKernel->getCrossThreadData();
|
||||
|
||||
auto arginfo = pKernelInfo->kernelArgInfo[0];
|
||||
|
||||
uint32_t *pMbBlockType = ptrOffset(reinterpret_cast<uint32_t *>(crossThreadData),
|
||||
arginfo.offsetVmeMbBlockType);
|
||||
EXPECT_EQ(desc.mb_block_type, *pMbBlockType);
|
||||
|
||||
uint32_t *pSubpixelMode = ptrOffset(reinterpret_cast<uint32_t *>(crossThreadData),
|
||||
arginfo.offsetVmeSubpixelMode);
|
||||
EXPECT_EQ(desc.subpixel_mode, *pSubpixelMode);
|
||||
|
||||
uint32_t *pSadAdjustMode = ptrOffset(reinterpret_cast<uint32_t *>(crossThreadData),
|
||||
arginfo.offsetVmeSadAdjustMode);
|
||||
EXPECT_EQ(desc.sad_adjust_mode, *pSadAdjustMode);
|
||||
|
||||
uint32_t *pSearchPathType = ptrOffset(reinterpret_cast<uint32_t *>(crossThreadData),
|
||||
arginfo.offsetVmeSearchPathType);
|
||||
EXPECT_EQ(desc.search_path_type, *pSearchPathType);
|
||||
|
||||
status = clReleaseAcceleratorINTEL(accelerator);
|
||||
EXPECT_EQ(CL_SUCCESS, status);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgAcceleratorTest, SetKernelArgNullAccelerator) {
|
||||
cl_int status;
|
||||
|
||||
status = this->pKernel->setArg(0, sizeof(cl_accelerator_intel), nullptr);
|
||||
ASSERT_EQ(CL_INVALID_ARG_VALUE, status);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgAcceleratorTest, SetKernelArgInvalidSize) {
|
||||
cl_int status;
|
||||
cl_accelerator_intel accelerator = VmeAccelerator::create(
|
||||
pContext,
|
||||
CL_ACCELERATOR_TYPE_MOTION_ESTIMATION_INTEL, sizeof(desc), &desc,
|
||||
status);
|
||||
ASSERT_EQ(CL_SUCCESS, status);
|
||||
ASSERT_NE(nullptr, accelerator);
|
||||
|
||||
status = this->pKernel->setArg(0, sizeof(cl_accelerator_intel) - 1, accelerator);
|
||||
ASSERT_EQ(CL_INVALID_ARG_SIZE, status);
|
||||
|
||||
status = clReleaseAcceleratorINTEL(accelerator);
|
||||
EXPECT_EQ(CL_SUCCESS, status);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgAcceleratorTest, SetKernelArgInvalidAccelerator) {
|
||||
cl_int status;
|
||||
|
||||
const void *notAnAccelerator = static_cast<void *>(pKernel);
|
||||
|
||||
status = this->pKernel->setArg(0, sizeof(cl_accelerator_intel), notAnAccelerator);
|
||||
ASSERT_EQ(CL_INVALID_ARG_VALUE, status);
|
||||
}
|
82
unit_tests/kernel/kernel_arg_buffer_fixture.cpp
Normal file
82
unit_tests/kernel/kernel_arg_buffer_fixture.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "kernel_arg_buffer_fixture.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
void KernelArgBufferFixture::SetUp() {
|
||||
MemoryManagementFixture::SetUp();
|
||||
DeviceFixture::SetUp();
|
||||
cl_device_id device = pDevice;
|
||||
ContextFixture::SetUp(1, &device);
|
||||
|
||||
// define kernel info
|
||||
pKernelInfo = KernelInfo::create();
|
||||
|
||||
// setup kernel arg offsets
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
kernelHeader.SurfaceStateHeapSize = sizeof(pSshLocal);
|
||||
pKernelInfo->heapInfo.pSsh = pSshLocal;
|
||||
pKernelInfo->heapInfo.pKernelHeader = &kernelHeader;
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(1);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
|
||||
|
||||
pProgram = new MockProgram(pContext);
|
||||
|
||||
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
pKernel->setCrossThreadData(pCrossThreadData, sizeof(pCrossThreadData));
|
||||
|
||||
pKernel->setKernelArgHandler(0, &Kernel::setArgBuffer);
|
||||
}
|
||||
|
||||
void KernelArgBufferFixture::TearDown() {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
delete pProgram;
|
||||
ContextFixture::TearDown();
|
||||
DeviceFixture::TearDown();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
61
unit_tests/kernel/kernel_arg_buffer_fixture.h
Normal file
61
unit_tests/kernel/kernel_arg_buffer_fixture.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class KernelArgBufferFixture : public ContextFixture, public DeviceFixture, public MemoryManagementFixture {
|
||||
|
||||
using ContextFixture::SetUp;
|
||||
|
||||
public:
|
||||
KernelArgBufferFixture()
|
||||
: retVal(CL_SUCCESS), pProgram(nullptr), pKernel(nullptr), pKernelInfo(nullptr) {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
|
||||
cl_int retVal;
|
||||
MockProgram *pProgram;
|
||||
MockKernel *pKernel;
|
||||
KernelInfo *pKernelInfo;
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
char pSshLocal[64];
|
||||
char pCrossThreadData[64];
|
||||
};
|
186
unit_tests/kernel/kernel_arg_buffer_tests.cpp
Normal file
186
unit_tests/kernel/kernel_arg_buffer_tests.cpp
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "unit_tests/kernel/kernel_arg_buffer_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
typedef Test<KernelArgBufferFixture> KernelArgBufferTest;
|
||||
|
||||
TEST_F(KernelArgBufferTest, SetKernelArgValidBuffer) {
|
||||
Buffer *buffer = new MockBuffer();
|
||||
|
||||
auto val = (cl_mem)buffer;
|
||||
auto pVal = &val;
|
||||
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto pKernelArg = (cl_mem **)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(buffer->getCpuAddress(), *pKernelArg);
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgBufferTest, SetKernelArgValidSvmPtrStateless) {
|
||||
Buffer *buffer = new MockBuffer();
|
||||
|
||||
auto val = (cl_mem)buffer;
|
||||
auto pVal = &val;
|
||||
|
||||
pKernelInfo->usesSsh = false;
|
||||
pKernelInfo->requiresSshForBuffers = false;
|
||||
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_FALSE(pKernel->requiresCoherency());
|
||||
|
||||
EXPECT_EQ(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
HWTEST_F(KernelArgBufferTest, SetKernelArgValidSvmPtrStateful) {
|
||||
Buffer *buffer = new MockBuffer();
|
||||
|
||||
auto val = (cl_mem)buffer;
|
||||
auto pVal = &val;
|
||||
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_FALSE(pKernel->requiresCoherency());
|
||||
|
||||
EXPECT_NE(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
|
||||
auto surfaceState = reinterpret_cast<const RENDER_SURFACE_STATE *>(
|
||||
ptrOffset(pKernel->getSurfaceStateHeap(),
|
||||
pKernelInfo->kernelArgInfo[0].offsetHeap));
|
||||
|
||||
void *surfaceAddress = reinterpret_cast<void *>(surfaceState->getSurfaceBaseAddress());
|
||||
EXPECT_EQ(buffer->getCpuAddress(), surfaceAddress);
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
HWTEST_F(KernelArgBufferTest, SetKernelArgBufferFromSvmPtr) {
|
||||
|
||||
Buffer *buffer = new MockBuffer();
|
||||
buffer->getGraphicsAllocation()->setCoherent(true);
|
||||
|
||||
auto val = (cl_mem)buffer;
|
||||
auto pVal = &val;
|
||||
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_TRUE(pKernel->requiresCoherency());
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgBufferTest, SetKernelArgFakeBuffer) {
|
||||
char *ptr = new char[sizeof(Buffer)];
|
||||
|
||||
auto val = (cl_mem *)ptr;
|
||||
auto pVal = &val;
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||
|
||||
delete[] ptr;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgBufferTest, SetKernelArgPtrToNull) {
|
||||
auto val = (cl_mem *)nullptr;
|
||||
auto pVal = &val;
|
||||
this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
|
||||
auto pKernelArg = (cl_mem **)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(nullptr, *pKernelArg);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgBufferTest, given32BitDeviceWhenArgPtrPassedIsNullThenOnly4BytesAreBeingPatched) {
|
||||
auto val = (cl_mem *)nullptr;
|
||||
auto pVal = &val;
|
||||
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = 4;
|
||||
|
||||
auto pKernelArg64bit = (uint64_t *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
uint32_t *pKernelArg32bit = (uint32_t *)pKernelArg64bit;
|
||||
|
||||
*pKernelArg64bit = 0xffffffffffffffff;
|
||||
|
||||
this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
uint64_t expValue = 0u;
|
||||
|
||||
EXPECT_EQ(0u, *pKernelArg32bit);
|
||||
EXPECT_NE(expValue, *pKernelArg64bit);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgBufferTest, SetKernelArgNull) {
|
||||
auto pVal = nullptr;
|
||||
this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
|
||||
auto pKernelArg = (cl_mem **)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(nullptr, *pKernelArg);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgBufferTest, given32BitDeviceWhenArgPassedIsNullThenOnly4BytesAreBeingPatched) {
|
||||
auto pVal = nullptr;
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = 4;
|
||||
auto pKernelArg64bit = (uint64_t *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
*pKernelArg64bit = 0xffffffffffffffff;
|
||||
|
||||
uint32_t *pKernelArg32bit = (uint32_t *)pKernelArg64bit;
|
||||
|
||||
this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
uint64_t expValue = 0u;
|
||||
|
||||
EXPECT_EQ(0u, *pKernelArg32bit);
|
||||
EXPECT_NE(expValue, *pKernelArg64bit);
|
||||
}
|
147
unit_tests/kernel/kernel_arg_dev_queue_tests.cpp
Normal file
147
unit_tests/kernel/kernel_arg_dev_queue_tests.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/device_host_queue_fixture.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
using namespace DeviceHostQueue;
|
||||
|
||||
struct KernelArgDevQueueTest : public DeviceFixture,
|
||||
public DeviceHostQueueFixture<DeviceQueue> {
|
||||
KernelArgDevQueueTest() : program(), kernelArgPatchInfo() {}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
DeviceHostQueueFixture<DeviceQueue>::SetUp();
|
||||
|
||||
pDeviceQueue = createQueueObject();
|
||||
|
||||
pKernelInfo = KernelInfo::create();
|
||||
pKernelInfo->kernelArgInfo.resize(1);
|
||||
pKernelInfo->kernelArgInfo[0].isDeviceQueue = true;
|
||||
|
||||
kernelArgPatchInfo.crossthreadOffset = 0x4;
|
||||
kernelArgPatchInfo.size = 0x4;
|
||||
kernelArgPatchInfo.sourceOffset = 0;
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
|
||||
uint8_t pCrossThreadData[crossThreadDataSize];
|
||||
memset(pCrossThreadData, crossThreadDataInit, sizeof(pCrossThreadData));
|
||||
pKernel->setCrossThreadData(pCrossThreadData, sizeof(pCrossThreadData));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
delete pDeviceQueue;
|
||||
|
||||
DeviceHostQueueFixture<DeviceQueue>::TearDown();
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
bool crossThreadDataUnchanged() {
|
||||
for (uint32_t i = 0; i < crossThreadDataSize; i++) {
|
||||
if (pKernel->mockCrossThreadData[i] != crossThreadDataInit) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static const uint32_t crossThreadDataSize = 0x10;
|
||||
static const char crossThreadDataInit = 0x7e;
|
||||
|
||||
MockProgram program;
|
||||
DeviceQueue *pDeviceQueue = nullptr;
|
||||
MockKernel *pKernel = nullptr;
|
||||
KernelInfo *pKernelInfo = nullptr;
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
};
|
||||
|
||||
TEST_F(KernelArgDevQueueTest, GIVENkernelWithDevQueueArgWHENsetArgHandleTHENsetsProperHandle) {
|
||||
EXPECT_EQ(pKernel->kernelArgHandlers[0], &Kernel::setArgDevQueue);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgDevQueueTest, GIVENdevQueueArgHandlerWHENpassDevQueueTHENacceptObjAndPatch) {
|
||||
auto clDeviceQueue = static_cast<cl_command_queue>(pDeviceQueue);
|
||||
|
||||
auto ret = pKernel->setArgDevQueue(0, sizeof(cl_command_queue), &clDeviceQueue);
|
||||
EXPECT_EQ(ret, CL_SUCCESS);
|
||||
|
||||
auto gpuAddress = static_cast<uint32_t>(pDeviceQueue->getQueueBuffer()->getGpuAddressToPatch());
|
||||
auto patchLocation = ptrOffset(pKernel->mockCrossThreadData.data(), kernelArgPatchInfo.crossthreadOffset);
|
||||
EXPECT_EQ(*(reinterpret_cast<uint32_t *>(patchLocation)), gpuAddress);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgDevQueueTest, GIVENdevQueueArgHandlerWHENpassNormalQueueTHENrejectObjAndReturnError) {
|
||||
auto clCmdQueue = static_cast<cl_command_queue>(pCommandQueue);
|
||||
|
||||
auto ret = pKernel->setArgDevQueue(0, sizeof(cl_command_queue), &clCmdQueue);
|
||||
EXPECT_EQ(ret, CL_INVALID_DEVICE_QUEUE);
|
||||
EXPECT_EQ(crossThreadDataUnchanged(), true);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgDevQueueTest, GIVENdevQueueArgHandlerWHENpassNonQueueObjTHENrejectObjAndReturnError) {
|
||||
Buffer *buffer = new MockBuffer();
|
||||
auto clBuffer = static_cast<cl_mem>(buffer);
|
||||
|
||||
auto ret = pKernel->setArgDevQueue(0, sizeof(cl_command_queue), &clBuffer);
|
||||
EXPECT_EQ(ret, CL_INVALID_DEVICE_QUEUE);
|
||||
EXPECT_EQ(crossThreadDataUnchanged(), true);
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgDevQueueTest, GIVENdevQueueArgHandlerWHENpassFakeQueueTHENrejectObjAndReturnError) {
|
||||
char *pFakeDeviceQueue = new char[sizeof(DeviceQueue)];
|
||||
auto clFakeDeviceQueue = reinterpret_cast<cl_command_queue *>(pFakeDeviceQueue);
|
||||
|
||||
auto ret = pKernel->setArgDevQueue(0, sizeof(cl_command_queue), &clFakeDeviceQueue);
|
||||
EXPECT_EQ(ret, CL_INVALID_DEVICE_QUEUE);
|
||||
EXPECT_EQ(crossThreadDataUnchanged(), true);
|
||||
|
||||
delete[] pFakeDeviceQueue;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgDevQueueTest, GIVENdevQueueArgHandlerWHENpassNullptrTHENrejectObjAndReturnError) {
|
||||
auto ret = pKernel->setArgDevQueue(0, sizeof(cl_command_queue), nullptr);
|
||||
EXPECT_EQ(ret, CL_INVALID_ARG_VALUE);
|
||||
EXPECT_EQ(crossThreadDataUnchanged(), true);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgDevQueueTest, GIVENdevQueueArgHandlerWHENpassWrongSizeTHENrejectObjAndReturnError) {
|
||||
auto clDeviceQueue = static_cast<cl_command_queue>(pDeviceQueue);
|
||||
|
||||
auto ret = pKernel->setArgDevQueue(0, sizeof(cl_command_queue) - 1, &clDeviceQueue);
|
||||
EXPECT_EQ(ret, CL_INVALID_ARG_SIZE);
|
||||
EXPECT_EQ(crossThreadDataUnchanged(), true);
|
||||
}
|
203
unit_tests/kernel/kernel_arg_info_tests.cpp
Normal file
203
unit_tests/kernel/kernel_arg_info_tests.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "unit_tests/helpers/kernel_binary_helper.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "unit_tests/program/program_with_source.h"
|
||||
#include "unit_tests/program/program_tests.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class KernelArgInfoTest : public ProgramFromSourceTest {
|
||||
public:
|
||||
KernelArgInfoTest() {
|
||||
}
|
||||
|
||||
~KernelArgInfoTest() override = default;
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
kbHelper = new KernelBinaryHelper("copybuffer", true);
|
||||
ProgramFromSourceTest::SetUp();
|
||||
ASSERT_NE(nullptr, pProgram);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
cl_device_id device = pPlatform->getDevice(0);
|
||||
retVal = pProgram->build(
|
||||
1,
|
||||
&device,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
false);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
// create a kernel
|
||||
pKernel = Kernel::create(
|
||||
pProgram,
|
||||
*pProgram->getKernelInfo(KernelName),
|
||||
&retVal);
|
||||
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
ASSERT_NE(nullptr, pKernel);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernel;
|
||||
pKernel = nullptr;
|
||||
ProgramFromSourceTest::TearDown();
|
||||
delete kbHelper;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void queryArgInfo(cl_kernel_arg_info paramName, T ¶mValue) {
|
||||
size_t paramValueSize = 0;
|
||||
size_t param_value_size_ret = 0;
|
||||
|
||||
// get size
|
||||
retVal = pKernel->getArgInfo(
|
||||
0,
|
||||
paramName,
|
||||
paramValueSize,
|
||||
nullptr,
|
||||
¶m_value_size_ret);
|
||||
EXPECT_NE(0u, param_value_size_ret);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
// get the name
|
||||
paramValueSize = param_value_size_ret;
|
||||
|
||||
retVal = pKernel->getArgInfo(
|
||||
0,
|
||||
paramName,
|
||||
paramValueSize,
|
||||
¶mValue,
|
||||
nullptr);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
Kernel *pKernel = nullptr;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
KernelBinaryHelper *kbHelper = nullptr;
|
||||
};
|
||||
|
||||
TEST_P(KernelArgInfoTest, Create_Simple) {
|
||||
// included in the setup of fixture
|
||||
}
|
||||
|
||||
TEST_P(KernelArgInfoTest, getKernelArgAcessQualifier) {
|
||||
cl_kernel_arg_access_qualifier param_value = 0;
|
||||
queryArgInfo<cl_kernel_arg_access_qualifier>(CL_KERNEL_ARG_ACCESS_QUALIFIER, param_value);
|
||||
EXPECT_EQ(static_cast<cl_kernel_arg_access_qualifier>(CL_KERNEL_ARG_ACCESS_NONE), param_value);
|
||||
}
|
||||
|
||||
TEST_P(KernelArgInfoTest, getKernelAddressQulifier) {
|
||||
cl_kernel_arg_address_qualifier param_value = 0;
|
||||
queryArgInfo<cl_kernel_arg_address_qualifier>(CL_KERNEL_ARG_ADDRESS_QUALIFIER, param_value);
|
||||
EXPECT_EQ(static_cast<cl_kernel_arg_address_qualifier>(CL_KERNEL_ARG_ADDRESS_GLOBAL), param_value);
|
||||
}
|
||||
|
||||
TEST_P(KernelArgInfoTest, getKernelTypeQualifer) {
|
||||
cl_kernel_arg_type_qualifier param_value = 0;
|
||||
queryArgInfo<cl_kernel_arg_type_qualifier>(CL_KERNEL_ARG_TYPE_QUALIFIER, param_value);
|
||||
EXPECT_EQ(static_cast<cl_kernel_arg_type_qualifier>(CL_KERNEL_ARG_TYPE_NONE), param_value);
|
||||
}
|
||||
|
||||
TEST_P(KernelArgInfoTest, getKernelTypeName) {
|
||||
cl_kernel_arg_info param_name = CL_KERNEL_ARG_TYPE_NAME;
|
||||
char *param_value = nullptr;
|
||||
size_t paramValueSize = 0;
|
||||
size_t param_value_size_ret = 0;
|
||||
|
||||
// get size
|
||||
retVal = pKernel->getArgInfo(
|
||||
0,
|
||||
param_name,
|
||||
paramValueSize,
|
||||
nullptr,
|
||||
¶m_value_size_ret);
|
||||
EXPECT_NE(0u, param_value_size_ret);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
// allocate space for name
|
||||
param_value = new char[param_value_size_ret];
|
||||
|
||||
// get the name
|
||||
paramValueSize = param_value_size_ret;
|
||||
|
||||
retVal = pKernel->getArgInfo(
|
||||
0,
|
||||
param_name,
|
||||
paramValueSize,
|
||||
param_value,
|
||||
nullptr);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
const char expectedString[] = "uint*";
|
||||
auto result = strncmp(param_value, expectedString, sizeof(expectedString));
|
||||
EXPECT_EQ(0, result);
|
||||
delete[] param_value;
|
||||
}
|
||||
|
||||
TEST_P(KernelArgInfoTest, getKernelArgName) {
|
||||
cl_kernel_arg_info param_name = CL_KERNEL_ARG_NAME;
|
||||
char *param_value = nullptr;
|
||||
size_t paramValueSize = 0;
|
||||
size_t param_value_size_ret = 0;
|
||||
|
||||
// get size
|
||||
retVal = pKernel->getArgInfo(
|
||||
0,
|
||||
param_name,
|
||||
paramValueSize,
|
||||
nullptr,
|
||||
¶m_value_size_ret);
|
||||
EXPECT_NE(0u, param_value_size_ret);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
// allocate space for name
|
||||
param_value = new char[param_value_size_ret];
|
||||
|
||||
// get the name
|
||||
paramValueSize = param_value_size_ret;
|
||||
|
||||
retVal = pKernel->getArgInfo(
|
||||
0,
|
||||
param_name,
|
||||
paramValueSize,
|
||||
param_value,
|
||||
nullptr);
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_EQ(0, strcmp(param_value, "src"));
|
||||
delete[] param_value;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(KernelArgInfoTests,
|
||||
KernelArgInfoTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(SourceFileNames),
|
||||
::testing::ValuesIn(BinaryForSourceFileNames),
|
||||
::testing::ValuesIn(KernelNames)));
|
222
unit_tests/kernel/kernel_arg_pipe_tests.cpp
Normal file
222
unit_tests/kernel/kernel_arg_pipe_tests.cpp
Normal file
@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/mem_obj/pipe.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_pipe.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class KernelArgPipeFixture : public ContextFixture, public DeviceFixture, public MemoryManagementFixture {
|
||||
|
||||
using ContextFixture::SetUp;
|
||||
|
||||
public:
|
||||
KernelArgPipeFixture() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
DeviceFixture::SetUp();
|
||||
cl_device_id device = pDevice;
|
||||
ContextFixture::SetUp(1, &device);
|
||||
|
||||
// define kernel info
|
||||
pKernelInfo = KernelInfo::create();
|
||||
|
||||
// setup kernel arg offsets
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
kernelHeader.SurfaceStateHeapSize = sizeof(pSshLocal);
|
||||
pKernelInfo->heapInfo.pSsh = pSshLocal;
|
||||
pKernelInfo->heapInfo.pKernelHeader = &kernelHeader;
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(1);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
|
||||
|
||||
pProgram = new MockProgram(pContext);
|
||||
|
||||
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
pKernel->setCrossThreadData(pCrossThreadData, sizeof(pCrossThreadData));
|
||||
|
||||
pKernel->setKernelArgHandler(0, &Kernel::setArgPipe);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
delete pProgram;
|
||||
ContextFixture::TearDown();
|
||||
DeviceFixture::TearDown();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
MockProgram *pProgram = nullptr;
|
||||
MockKernel *pKernel = nullptr;
|
||||
KernelInfo *pKernelInfo = nullptr;
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
char pSshLocal[64];
|
||||
char pCrossThreadData[64];
|
||||
};
|
||||
|
||||
typedef Test<KernelArgPipeFixture> KernelArgPipeTest;
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgValidPipe) {
|
||||
Pipe *pipe = new MockPipe(pContext);
|
||||
|
||||
auto val = (cl_mem)pipe;
|
||||
auto pVal = &val;
|
||||
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto pKernelArg = (cl_mem **)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(pipe->getCpuAddress(), *pKernelArg);
|
||||
|
||||
delete pipe;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgValidSvmPtrStateless) {
|
||||
Pipe *pipe = new MockPipe(pContext);
|
||||
|
||||
auto val = (cl_mem)pipe;
|
||||
auto pVal = &val;
|
||||
|
||||
pKernelInfo->usesSsh = false;
|
||||
pKernelInfo->requiresSshForBuffers = false;
|
||||
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
delete pipe;
|
||||
}
|
||||
|
||||
HWTEST_F(KernelArgPipeTest, SetKernelArgValidSvmPtrStateful) {
|
||||
Pipe *pipe = new MockPipe(pContext);
|
||||
|
||||
auto val = (cl_mem)pipe;
|
||||
auto pVal = &val;
|
||||
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_NE(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
|
||||
auto surfaceState = reinterpret_cast<const RENDER_SURFACE_STATE *>(
|
||||
ptrOffset(pKernel->getSurfaceStateHeap(),
|
||||
pKernelInfo->kernelArgInfo[0].offsetHeap));
|
||||
|
||||
void *surfaceAddress = reinterpret_cast<void *>(surfaceState->getSurfaceBaseAddress());
|
||||
EXPECT_EQ(pipe->getCpuAddress(), surfaceAddress);
|
||||
|
||||
delete pipe;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgFakePipe) {
|
||||
char *ptr = new char[sizeof(Pipe)];
|
||||
|
||||
auto val = (cl_mem *)ptr;
|
||||
auto pVal = &val;
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||
|
||||
delete[] ptr;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgBufferAsPipe) {
|
||||
Buffer *buffer = new MockBuffer();
|
||||
|
||||
auto val = (cl_mem)buffer;
|
||||
auto pVal = &val;
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, retVal);
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgPipeFromDifferentContext) {
|
||||
Pipe *pipe = new MockPipe(pContext);
|
||||
Context *oldContext = &pKernel->getContext();
|
||||
MockContext newContext;
|
||||
this->pKernel->setContext(&newContext);
|
||||
|
||||
auto val = (cl_mem)pipe;
|
||||
auto pVal = &val;
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||
|
||||
pKernel->setContext(oldContext);
|
||||
|
||||
delete pipe;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgInvalidSize) {
|
||||
Pipe *pipe = new MockPipe(pContext);
|
||||
|
||||
auto val = (cl_mem *)pipe;
|
||||
auto pVal = &val;
|
||||
auto retVal = this->pKernel->setArg(0, 1, pVal);
|
||||
EXPECT_EQ(CL_INVALID_ARG_SIZE, retVal);
|
||||
|
||||
delete pipe;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgPtrToNull) {
|
||||
auto val = (cl_mem *)nullptr;
|
||||
auto pVal = &val;
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||
}
|
||||
|
||||
TEST_F(KernelArgPipeTest, SetKernelArgNull) {
|
||||
auto pVal = nullptr;
|
||||
auto retVal = this->pKernel->setArg(0, sizeof(cl_mem *), pVal);
|
||||
EXPECT_EQ(CL_INVALID_MEM_OBJECT, retVal);
|
||||
}
|
411
unit_tests/kernel/kernel_arg_svm_tests.cpp
Normal file
411
unit_tests/kernel/kernel_arg_svm_tests.cpp
Normal file
@ -0,0 +1,411 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
#include "unit_tests/mocks/mock_buffer.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "test.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class KernelArgSvmFixture_ : public ContextFixture, public DeviceFixture, public MemoryManagementFixture {
|
||||
|
||||
using ContextFixture::SetUp;
|
||||
|
||||
public:
|
||||
KernelArgSvmFixture_() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
MemoryManagementFixture::SetUp();
|
||||
DeviceFixture::SetUp();
|
||||
cl_device_id device = pDevice;
|
||||
ContextFixture::SetUp(1, &device);
|
||||
|
||||
// define kernel info
|
||||
pKernelInfo = KernelInfo::create();
|
||||
|
||||
// setup kernel arg offsets
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
kernelHeader.SurfaceStateHeapSize = sizeof(pSshLocal);
|
||||
pKernelInfo->heapInfo.pSsh = pSshLocal;
|
||||
pKernelInfo->heapInfo.pKernelHeader = &kernelHeader;
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(1);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = (uint32_t)sizeof(void *);
|
||||
|
||||
pProgram = new MockProgram(pContext);
|
||||
|
||||
pKernel = new MockKernel(pProgram, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
pKernel->setCrossThreadData(pCrossThreadData, sizeof(pCrossThreadData));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
delete pProgram;
|
||||
ContextFixture::TearDown();
|
||||
DeviceFixture::TearDown();
|
||||
MemoryManagementFixture::TearDown();
|
||||
}
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
MockProgram *pProgram = nullptr;
|
||||
MockKernel *pKernel = nullptr;
|
||||
KernelInfo *pKernelInfo = nullptr;
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
char pSshLocal[64];
|
||||
char pCrossThreadData[64];
|
||||
};
|
||||
|
||||
typedef Test<KernelArgSvmFixture_> KernelArgSvmTest;
|
||||
|
||||
TEST_F(KernelArgSvmTest, SetKernelArgValidSvmPtr) {
|
||||
char *svmPtr = new char[256];
|
||||
|
||||
auto retVal = pKernel->setArgSvm(0, 256, svmPtr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto pKernelArg = (void **)(pKernel->getCrossThreadData() +
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(svmPtr, *pKernelArg);
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgSvmTest, SetKernelArgValidSvmPtrStateless) {
|
||||
char *svmPtr = new char[256];
|
||||
|
||||
pKernelInfo->usesSsh = false;
|
||||
pKernelInfo->requiresSshForBuffers = false;
|
||||
|
||||
auto retVal = pKernel->setArgSvm(0, 256, svmPtr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
HWTEST_F(KernelArgSvmTest, SetKernelArgValidSvmPtrStateful) {
|
||||
char *svmPtr = new char[256];
|
||||
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
auto retVal = pKernel->setArgSvm(0, 256, svmPtr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_NE(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
|
||||
auto surfaceState = reinterpret_cast<const RENDER_SURFACE_STATE *>(
|
||||
ptrOffset(pKernel->getSurfaceStateHeap(),
|
||||
pKernelInfo->kernelArgInfo[0].offsetHeap));
|
||||
|
||||
void *surfaceAddress = reinterpret_cast<void *>(surfaceState->getSurfaceBaseAddress());
|
||||
EXPECT_EQ(svmPtr, surfaceAddress);
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgSvmTest, SetKernelArgValidSvmAlloc) {
|
||||
char *svmPtr = new char[256];
|
||||
|
||||
GraphicsAllocation svmAlloc(svmPtr, 256);
|
||||
|
||||
auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto pKernelArg = (void **)(pKernel->getCrossThreadData() +
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(svmPtr, *pKernelArg);
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgSvmTest, SetKernelArgValidSvmAllocStateless) {
|
||||
char *svmPtr = new char[256];
|
||||
|
||||
GraphicsAllocation svmAlloc(svmPtr, 256);
|
||||
|
||||
pKernelInfo->usesSsh = false;
|
||||
pKernelInfo->requiresSshForBuffers = false;
|
||||
|
||||
auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_EQ(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
HWTEST_F(KernelArgSvmTest, SetKernelArgValidSvmAllocStateful) {
|
||||
char *svmPtr = new char[256];
|
||||
|
||||
GraphicsAllocation svmAlloc(svmPtr, 256);
|
||||
|
||||
pKernelInfo->usesSsh = true;
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
|
||||
auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_NE(0u, pKernel->getSurfaceStateHeapSize());
|
||||
|
||||
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
|
||||
auto surfaceState = reinterpret_cast<const RENDER_SURFACE_STATE *>(
|
||||
ptrOffset(pKernel->getSurfaceStateHeap(),
|
||||
pKernelInfo->kernelArgInfo[0].offsetHeap));
|
||||
|
||||
void *surfaceAddress = reinterpret_cast<void *>(surfaceState->getSurfaceBaseAddress());
|
||||
EXPECT_EQ(svmPtr, surfaceAddress);
|
||||
|
||||
delete[] svmPtr;
|
||||
}
|
||||
|
||||
TEST_F(KernelArgSvmTest, SetKernelArgImmediateInvalidArgValue) {
|
||||
auto retVal = pKernel->setArgImmediate(0, 256, nullptr);
|
||||
EXPECT_EQ(CL_INVALID_ARG_VALUE, retVal);
|
||||
}
|
||||
|
||||
HWTEST_F(KernelArgSvmTest, PatchWithImplicitSurface) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
constexpr size_t rendSurfSize = sizeof(RENDER_SURFACE_STATE);
|
||||
|
||||
std::vector<char> svmPtr;
|
||||
svmPtr.resize(256);
|
||||
|
||||
pKernel->setCrossThreadData(nullptr, sizeof(void *));
|
||||
pKernel->setSshLocal(nullptr, rendSurfSize);
|
||||
pKernelInfo->requiresSshForBuffers = true;
|
||||
pKernelInfo->usesSsh = true;
|
||||
{
|
||||
GraphicsAllocation svmAlloc(svmPtr.data(), svmPtr.size());
|
||||
|
||||
SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization patch;
|
||||
memset(&patch, 0, sizeof(patch));
|
||||
patch.DataParamOffset = 0;
|
||||
patch.DataParamSize = sizeof(void *);
|
||||
patch.SurfaceStateHeapOffset = 0;
|
||||
|
||||
constexpr size_t patchOffset = 16;
|
||||
void *ptrToPatch = svmPtr.data() + patchOffset;
|
||||
ASSERT_GE(pKernel->getCrossThreadDataSize(), sizeof(void *));
|
||||
*reinterpret_cast<void **>(pKernel->getCrossThreadData()) = 0U;
|
||||
|
||||
ASSERT_GE(pKernel->getSurfaceStateHeapSize(), rendSurfSize);
|
||||
RENDER_SURFACE_STATE *surfState = reinterpret_cast<RENDER_SURFACE_STATE *>(pKernel->getSurfaceStateHeap());
|
||||
memset(surfState, 0, rendSurfSize);
|
||||
|
||||
pKernel->patchWithImplicitSurface(ptrToPatch, svmAlloc, patch);
|
||||
|
||||
// verify cross thread data was properly patched
|
||||
EXPECT_EQ(ptrToPatch, *reinterpret_cast<void **>(pKernel->getCrossThreadData()));
|
||||
|
||||
// create surface state for comparison
|
||||
RENDER_SURFACE_STATE expectedSurfaceState;
|
||||
memset(&expectedSurfaceState, 0, rendSurfSize);
|
||||
{
|
||||
void *addressToPatch = svmAlloc.getUnderlyingBuffer();
|
||||
size_t sizeToPatch = svmAlloc.getUnderlyingBufferSize();
|
||||
Buffer::setSurfaceState(pContext, &expectedSurfaceState, sizeToPatch, addressToPatch, &svmAlloc);
|
||||
}
|
||||
|
||||
// verify ssh was properly patched
|
||||
EXPECT_EQ(0, memcmp(&expectedSurfaceState, surfState, rendSurfSize));
|
||||
|
||||
// when cross thread and ssh data is not available then should not do anything
|
||||
pKernel->setCrossThreadData(nullptr, 0);
|
||||
pKernel->setSshLocal(nullptr, 0);
|
||||
pKernel->patchWithImplicitSurface(ptrToPatch, svmAlloc, patch);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(KernelArgSvmTest, patchBufferOffset) {
|
||||
std::vector<char> svmPtr;
|
||||
svmPtr.resize(256);
|
||||
|
||||
pKernel->setCrossThreadData(nullptr, sizeof(uint32_t));
|
||||
{
|
||||
constexpr uint32_t initVal = 7U;
|
||||
constexpr uint32_t svmOffset = 13U;
|
||||
|
||||
GraphicsAllocation svmAlloc(svmPtr.data(), 256);
|
||||
uint32_t *expectedPatchPtr = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData());
|
||||
|
||||
KernelArgInfo kai;
|
||||
void *returnedPtr = nullptr;
|
||||
|
||||
kai.offsetBufferOffset = static_cast<uint32_t>(-1);
|
||||
*expectedPatchPtr = initVal;
|
||||
returnedPtr = pKernel->patchBufferOffset(kai, svmPtr.data(), &svmAlloc);
|
||||
EXPECT_EQ(svmPtr.data(), returnedPtr);
|
||||
EXPECT_EQ(initVal, *expectedPatchPtr);
|
||||
|
||||
kai.offsetBufferOffset = static_cast<uint32_t>(-1);
|
||||
*expectedPatchPtr = initVal;
|
||||
returnedPtr = pKernel->patchBufferOffset(kai, svmPtr.data(), nullptr);
|
||||
EXPECT_EQ(svmPtr.data(), returnedPtr);
|
||||
EXPECT_EQ(initVal, *expectedPatchPtr);
|
||||
|
||||
kai.offsetBufferOffset = 0U;
|
||||
*expectedPatchPtr = initVal;
|
||||
returnedPtr = pKernel->patchBufferOffset(kai, svmPtr.data(), &svmAlloc);
|
||||
EXPECT_EQ(svmPtr.data(), returnedPtr);
|
||||
EXPECT_EQ(0U, *expectedPatchPtr);
|
||||
|
||||
kai.offsetBufferOffset = 0U;
|
||||
*expectedPatchPtr = initVal;
|
||||
returnedPtr = pKernel->patchBufferOffset(kai, svmPtr.data() + svmOffset, nullptr);
|
||||
void *expectedPtr = alignDown(svmPtr.data() + svmOffset, 4);
|
||||
// expecting to see DWORD alignment restriction in offset
|
||||
uint32_t expectedOffset = static_cast<uint32_t>(ptrDiff(svmPtr.data() + svmOffset, expectedPtr));
|
||||
EXPECT_EQ(expectedPtr, returnedPtr);
|
||||
EXPECT_EQ(expectedOffset, *expectedPatchPtr);
|
||||
|
||||
kai.offsetBufferOffset = 0U;
|
||||
*expectedPatchPtr = initVal;
|
||||
returnedPtr = pKernel->patchBufferOffset(kai, svmPtr.data() + svmOffset, &svmAlloc);
|
||||
EXPECT_EQ(svmPtr.data(), returnedPtr);
|
||||
EXPECT_EQ(svmOffset, *expectedPatchPtr);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SetArgHandlerT>
|
||||
class KernelArgSvmTestTyped : public KernelArgSvmTest {
|
||||
};
|
||||
|
||||
struct SetArgHandlerSetArgSvm {
|
||||
static void setArg(Kernel &kernel, uint32_t argNum, void *ptrToPatch, size_t allocSize, GraphicsAllocation &alloc) {
|
||||
kernel.setArgSvm(argNum, allocSize, ptrToPatch, &alloc);
|
||||
}
|
||||
|
||||
static constexpr bool supportsOffsets() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct SetArgHandlerSetArgSvmAlloc {
|
||||
static void setArg(Kernel &kernel, uint32_t argNum, void *ptrToPatch, size_t allocSize, GraphicsAllocation &alloc) {
|
||||
kernel.setArgSvmAlloc(argNum, ptrToPatch, &alloc);
|
||||
}
|
||||
|
||||
static constexpr bool supportsOffsets() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct SetArgHandlerSetArgBuffer {
|
||||
static void setArg(Kernel &kernel, uint32_t argNum, void *ptrToPatch, size_t allocSize, GraphicsAllocation &alloc) {
|
||||
MockBuffer mb{alloc};
|
||||
cl_mem memObj = &mb;
|
||||
kernel.setArgBuffer(argNum, sizeof(cl_mem), &memObj);
|
||||
}
|
||||
|
||||
static constexpr bool supportsOffsets() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
using SetArgHandlers = ::testing::Types<SetArgHandlerSetArgSvm, SetArgHandlerSetArgSvmAlloc, SetArgHandlerSetArgBuffer>;
|
||||
|
||||
TYPED_TEST_CASE(KernelArgSvmTestTyped, SetArgHandlers);
|
||||
HWTEST_TYPED_TEST(KernelArgSvmTestTyped, GivenBufferKernelArgWhenBufferOffsetIsNeededTheSetArgSetsIt) {
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
constexpr size_t rendSurfSize = sizeof(RENDER_SURFACE_STATE);
|
||||
|
||||
uint32_t svmSize = MemoryConstants::pageSize;
|
||||
char *svmPtr = reinterpret_cast<char *>(alignedMalloc(svmSize, MemoryConstants::pageSize));
|
||||
|
||||
KernelArgInfo &kai = this->pKernelInfo->kernelArgInfo[0];
|
||||
kai.offsetHeap = 0;
|
||||
kai.kernelArgPatchInfoVector[0].sourceOffset = 0;
|
||||
kai.kernelArgPatchInfoVector[0].crossthreadOffset = 0;
|
||||
kai.kernelArgPatchInfoVector[0].size = sizeof(void *);
|
||||
kai.offsetBufferOffset = kai.kernelArgPatchInfoVector[0].size;
|
||||
|
||||
this->pKernel->setCrossThreadData(nullptr, kai.offsetBufferOffset + sizeof(uint32_t));
|
||||
this->pKernel->setSshLocal(nullptr, rendSurfSize);
|
||||
this->pKernelInfo->requiresSshForBuffers = true;
|
||||
this->pKernelInfo->usesSsh = true;
|
||||
{
|
||||
GraphicsAllocation svmAlloc(svmPtr, svmSize);
|
||||
|
||||
constexpr size_t patchOffset = 16;
|
||||
void *ptrToPatch = svmPtr + patchOffset;
|
||||
size_t sizeToPatch = svmSize - patchOffset;
|
||||
ASSERT_GE(this->pKernel->getCrossThreadDataSize(), kai.offsetBufferOffset + sizeof(uint32_t));
|
||||
|
||||
void **expectedPointerPatchPtr = reinterpret_cast<void **>(this->pKernel->getCrossThreadData());
|
||||
uint32_t *expectedOffsetPatchPtr = reinterpret_cast<uint32_t *>(ptrOffset(this->pKernel->getCrossThreadData(), kai.offsetBufferOffset));
|
||||
*expectedPointerPatchPtr = reinterpret_cast<void *>(0U);
|
||||
*expectedOffsetPatchPtr = 0U;
|
||||
|
||||
ASSERT_GE(this->pKernel->getSurfaceStateHeapSize(), rendSurfSize);
|
||||
RENDER_SURFACE_STATE *surfState = reinterpret_cast<RENDER_SURFACE_STATE *>(this->pKernel->getSurfaceStateHeap());
|
||||
memset(surfState, 0, rendSurfSize);
|
||||
|
||||
TypeParam::setArg(*this->pKernel, 0U, ptrToPatch, sizeToPatch, svmAlloc);
|
||||
|
||||
// surface state for comparison
|
||||
RENDER_SURFACE_STATE expectedSurfaceState;
|
||||
memset(&expectedSurfaceState, 0, rendSurfSize);
|
||||
|
||||
if (TypeParam::supportsOffsets()) {
|
||||
// setArgSvm, setArgSvmAlloc
|
||||
EXPECT_EQ(ptrToPatch, *expectedPointerPatchPtr);
|
||||
EXPECT_EQ(patchOffset, *expectedOffsetPatchPtr);
|
||||
} else {
|
||||
// setArgBuffer
|
||||
EXPECT_EQ(svmAlloc.getUnderlyingBuffer(), *expectedPointerPatchPtr);
|
||||
EXPECT_EQ(0U, *expectedOffsetPatchPtr);
|
||||
}
|
||||
|
||||
Buffer::setSurfaceState(this->pContext, &expectedSurfaceState, svmAlloc.getUnderlyingBufferSize(), svmAlloc.getUnderlyingBuffer(), &svmAlloc);
|
||||
|
||||
// verify ssh was properly patched
|
||||
int32_t cmpResult = memcmp(&expectedSurfaceState, surfState, rendSurfSize);
|
||||
EXPECT_EQ(0, cmpResult);
|
||||
}
|
||||
|
||||
alignedFree(svmPtr);
|
||||
}
|
313
unit_tests/kernel/kernel_image_arg_tests.cpp
Normal file
313
unit_tests/kernel/kernel_image_arg_tests.cpp
Normal file
@ -0,0 +1,313 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/fixtures/image_fixture.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "unit_tests/mocks/mock_csr.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class KernelImageArgTest : public Test<DeviceFixture> {
|
||||
public:
|
||||
KernelImageArgTest() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
pKernelInfo = KernelInfo::create();
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
kernelHeader.SurfaceStateHeapSize = sizeof(surfaceStateHeap);
|
||||
pKernelInfo->heapInfo.pSsh = surfaceStateHeap;
|
||||
pKernelInfo->heapInfo.pKernelHeader = &kernelHeader;
|
||||
pKernelInfo->usesSsh = true;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(5);
|
||||
pKernelInfo->kernelArgInfo[4].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].offsetImgWidth = 0x4;
|
||||
pKernelInfo->kernelArgInfo[0].offsetNumSamples = 0x3c;
|
||||
pKernelInfo->kernelArgInfo[1].offsetImgHeight = 0xc;
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].crossthreadOffset = 0x20;
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].size = sizeof(void *);
|
||||
pKernelInfo->kernelArgInfo[3].offsetImgDepth = 0x30;
|
||||
pKernelInfo->kernelArgInfo[4].offsetHeap = 0x20;
|
||||
pKernelInfo->kernelArgInfo[4].offsetObjectId = 0x0;
|
||||
|
||||
pKernelInfo->kernelArgInfo[4].isImage = true;
|
||||
pKernelInfo->kernelArgInfo[3].isImage = true;
|
||||
pKernelInfo->kernelArgInfo[2].isImage = true;
|
||||
pKernelInfo->kernelArgInfo[1].isImage = true;
|
||||
pKernelInfo->kernelArgInfo[0].isImage = true;
|
||||
|
||||
DeviceFixture::SetUp();
|
||||
pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
|
||||
pKernel->setKernelArgHandler(0, &Kernel::setArgImage);
|
||||
pKernel->setKernelArgHandler(1, &Kernel::setArgImage);
|
||||
pKernel->setKernelArgHandler(2, &Kernel::setArgImmediate);
|
||||
pKernel->setKernelArgHandler(3, &Kernel::setArgImage);
|
||||
pKernel->setKernelArgHandler(4, &Kernel::setArgImage);
|
||||
|
||||
uint32_t crossThreadData[0x40] = {};
|
||||
crossThreadData[0x20 / sizeof(uint32_t)] = 0x12344321;
|
||||
pKernel->setCrossThreadData(crossThreadData, sizeof(crossThreadData));
|
||||
|
||||
context = new MockContext(pDevice);
|
||||
image = Image2dHelper<>::create(context);
|
||||
ASSERT_NE(nullptr, image);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
delete image;
|
||||
delete context;
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
MockProgram program;
|
||||
MockKernel *pKernel = nullptr;
|
||||
KernelInfo *pKernelInfo;
|
||||
|
||||
MockContext *context;
|
||||
Image *image;
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
char surfaceStateHeap[0x80];
|
||||
};
|
||||
|
||||
TEST_F(KernelImageArgTest, GIVENkernelWithImageArgsWHENcheckDifferentScenariosTHENproperBehaviour) {
|
||||
size_t imageWidth = image->getImageDesc().image_width;
|
||||
size_t imageHeight = image->getImageDesc().image_height;
|
||||
size_t imageDepth = image->getImageDesc().image_depth;
|
||||
uint32_t objectId = pKernelInfo->kernelArgInfo[4].offsetHeap;
|
||||
|
||||
cl_mem memObj = image;
|
||||
|
||||
pKernel->setArg(0, sizeof(memObj), &memObj);
|
||||
pKernel->setArg(1, sizeof(memObj), &memObj);
|
||||
pKernel->setArg(3, sizeof(memObj), &memObj);
|
||||
pKernel->setArg(4, sizeof(memObj), &memObj);
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData());
|
||||
auto imgWidthOffset = ptrOffset(crossThreadData, 0x4);
|
||||
EXPECT_EQ(imageWidth, *imgWidthOffset);
|
||||
|
||||
auto imgHeightOffset = ptrOffset(crossThreadData, 0xc);
|
||||
EXPECT_EQ(imageHeight, *imgHeightOffset);
|
||||
|
||||
auto dummyOffset = ptrOffset(crossThreadData, 0x20);
|
||||
EXPECT_EQ(0x12344321u, *dummyOffset);
|
||||
|
||||
auto imgDepthOffset = ptrOffset(crossThreadData, 0x30);
|
||||
EXPECT_EQ(imageDepth, *imgDepthOffset);
|
||||
|
||||
EXPECT_EQ(objectId, *crossThreadData);
|
||||
}
|
||||
|
||||
TEST_F(KernelImageArgTest, givenImageWithNumSamplesWhenSetArgIsCalledThenPatchNumSamplesInfo) {
|
||||
cl_image_format imgFormat = {CL_RGBA, CL_UNORM_INT8};
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.num_samples = 16;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imgDesc.image_width = 5;
|
||||
imgDesc.image_height = 5;
|
||||
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat);
|
||||
auto sampleImg = Image::create(context, 0, surfaceFormat, &imgDesc, nullptr, retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
cl_mem memObj = sampleImg;
|
||||
|
||||
pKernel->setArg(0, sizeof(memObj), &memObj);
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData());
|
||||
auto patchedNumSamples = ptrOffset(crossThreadData, 0x3c);
|
||||
EXPECT_EQ(16u, *patchedNumSamples);
|
||||
|
||||
sampleImg->release();
|
||||
}
|
||||
|
||||
TEST_F(KernelImageArgTest, givenImageWithWriteOnlyAccessAndReadOnlyArgWhenCheckCorrectImageAccessQualifierIsCalledThenRetValNotValid) {
|
||||
cl_image_format imgFormat = {CL_RGBA, CL_UNORM_INT8};
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
cl_mem_flags flags = CL_MEM_WRITE_ONLY;
|
||||
imgDesc.image_width = 5;
|
||||
imgDesc.image_height = 5;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat);
|
||||
std::unique_ptr<Image> img(Image::create(context, flags, surfaceFormat, &imgDesc, nullptr, retVal));
|
||||
pKernelInfo->kernelArgInfo[0].accessQualifier = CL_KERNEL_ARG_ACCESS_READ_ONLY;
|
||||
cl_mem memObj = img.get();
|
||||
retVal = pKernel->checkCorrectImageAccessQualifier(0, sizeof(memObj), &memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_KERNEL_ARGS);
|
||||
retVal = clSetKernelArg(
|
||||
pKernel,
|
||||
0,
|
||||
sizeof(memObj),
|
||||
&memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_KERNEL_ARGS);
|
||||
|
||||
retVal = clSetKernelArg(
|
||||
pKernel,
|
||||
0,
|
||||
sizeof(memObj),
|
||||
&memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_KERNEL_ARGS);
|
||||
|
||||
retVal = clSetKernelArg(
|
||||
pKernel,
|
||||
1000,
|
||||
sizeof(memObj),
|
||||
&memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_ARG_INDEX);
|
||||
}
|
||||
|
||||
TEST_F(KernelImageArgTest, givenImageWithReadOnlyAccessAndWriteOnlyArgWhenCheckCorrectImageAccessQualifierIsCalledThenRetValNotValid) {
|
||||
cl_image_format imgFormat = {CL_RGBA, CL_UNORM_INT8};
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
cl_mem_flags flags = CL_MEM_READ_ONLY;
|
||||
imgDesc.image_width = 5;
|
||||
imgDesc.image_height = 5;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat);
|
||||
std::unique_ptr<Image> img(Image::create(context, flags, surfaceFormat, &imgDesc, nullptr, retVal));
|
||||
pKernelInfo->kernelArgInfo[0].accessQualifier = CL_KERNEL_ARG_ACCESS_WRITE_ONLY;
|
||||
cl_mem memObj = img.get();
|
||||
retVal = pKernel->checkCorrectImageAccessQualifier(0, sizeof(memObj), &memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_KERNEL_ARGS);
|
||||
Image *image = NULL;
|
||||
memObj = image;
|
||||
retVal = pKernel->checkCorrectImageAccessQualifier(0, sizeof(memObj), &memObj);
|
||||
EXPECT_EQ(retVal, CL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
TEST_F(KernelImageArgTest, givenImageWithReadOnlyAccessAndReadOnlyArgWhenCheckCorrectImageAccessQualifierIsCalledThenRetValNotValid) {
|
||||
cl_image_format imgFormat = {CL_RGBA, CL_UNORM_INT8};
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
cl_mem_flags flags = CL_MEM_READ_ONLY;
|
||||
imgDesc.image_width = 5;
|
||||
imgDesc.image_height = 5;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat);
|
||||
std::unique_ptr<Image> img(Image::create(context, flags, surfaceFormat, &imgDesc, nullptr, retVal));
|
||||
pKernelInfo->kernelArgInfo[0].accessQualifier = CL_KERNEL_ARG_ACCESS_READ_ONLY;
|
||||
cl_mem memObj = img.get();
|
||||
retVal = pKernel->checkCorrectImageAccessQualifier(0, sizeof(memObj), &memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(KernelImageArgTest, givenImageWithWriteOnlyAccessAndWriteOnlyArgWhenCheckCorrectImageAccessQualifierIsCalledThenRetValNotValid) {
|
||||
cl_image_format imgFormat = {CL_RGBA, CL_UNORM_INT8};
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
cl_mem_flags flags = CL_MEM_WRITE_ONLY;
|
||||
imgDesc.image_width = 5;
|
||||
imgDesc.image_height = 5;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat);
|
||||
std::unique_ptr<Image> img(Image::create(context, flags, surfaceFormat, &imgDesc, nullptr, retVal));
|
||||
pKernelInfo->kernelArgInfo[0].accessQualifier = CL_KERNEL_ARG_ACCESS_WRITE_ONLY;
|
||||
cl_mem memObj = img.get();
|
||||
retVal = pKernel->checkCorrectImageAccessQualifier(0, sizeof(memObj), &memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(KernelImageArgTest, givenImgWithMcsAllocWhenMakeResidentThenMakeMcsAllocationResident) {
|
||||
int32_t execStamp = 0;
|
||||
cl_image_format imgFormat = {CL_RGBA, CL_UNORM_INT8};
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
imgDesc.image_width = 5;
|
||||
imgDesc.image_height = 5;
|
||||
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat);
|
||||
auto img = Image::create(context, 0, surfaceFormat, &imgDesc, nullptr, retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemory(4096);
|
||||
img->setMcsAllocation(mcsAlloc);
|
||||
cl_mem memObj = img;
|
||||
pKernel->setArg(0, sizeof(memObj), &memObj);
|
||||
|
||||
std::unique_ptr<OsAgnosticMemoryManager> memoryManager(new OsAgnosticMemoryManager());
|
||||
std::unique_ptr<MockCsr<FamilyType>> csr(new MockCsr<FamilyType>(execStamp));
|
||||
csr->setMemoryManager(memoryManager.get());
|
||||
|
||||
pKernel->makeResident(*csr.get());
|
||||
EXPECT_TRUE(csr->isMadeResident(mcsAlloc));
|
||||
|
||||
csr->makeSurfacePackNonResident();
|
||||
|
||||
EXPECT_TRUE(csr->isMadeNonResident(mcsAlloc));
|
||||
|
||||
delete img;
|
||||
}
|
||||
|
||||
TEST_F(KernelImageArgTest, givenKernelWithSettedArgWhenUnSetCalledThenArgIsUnsetAndArgCountIsDecreased) {
|
||||
cl_image_format imgFormat = {CL_RGBA, CL_UNORM_INT8};
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
cl_mem_flags flags = CL_MEM_WRITE_ONLY;
|
||||
imgDesc.image_width = 5;
|
||||
imgDesc.image_height = 5;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat);
|
||||
std::unique_ptr<Image> img(Image::create(context, flags, surfaceFormat, &imgDesc, nullptr, retVal));
|
||||
cl_mem memObj = img.get();
|
||||
|
||||
retVal = pKernel->setArg(0, sizeof(memObj), &memObj);
|
||||
EXPECT_EQ(1u, pKernel->getPatchedArgumentsNum());
|
||||
EXPECT_TRUE(pKernel->getKernelArguments()[0].isPatched);
|
||||
pKernel->unsetArg(0);
|
||||
EXPECT_EQ(0u, pKernel->getPatchedArgumentsNum());
|
||||
EXPECT_FALSE(pKernel->getKernelArguments()[0].isPatched);
|
||||
}
|
||||
|
||||
TEST_F(KernelImageArgTest, givenNullKernelWhenClSetKernelArgCalledThenInvalidKernelCodeReturned) {
|
||||
cl_mem memObj = NULL;
|
||||
retVal = clSetKernelArg(
|
||||
NULL,
|
||||
1000,
|
||||
sizeof(memObj),
|
||||
&memObj);
|
||||
|
||||
EXPECT_EQ(retVal, CL_INVALID_KERNEL);
|
||||
}
|
205
unit_tests/kernel/kernel_immediate_arg_tests.cpp
Normal file
205
unit_tests/kernel/kernel_immediate_arg_tests.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "CL/cl.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
template <typename T>
|
||||
class KernelArgImmediateTest : public Test<DeviceFixture> {
|
||||
public:
|
||||
KernelArgImmediateTest() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
memset(pCrossThreadData, 0xfe, sizeof(pCrossThreadData));
|
||||
|
||||
// define kernel info
|
||||
pKernelInfo = KernelInfo::create();
|
||||
|
||||
// setup kernel arg offsets
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(4);
|
||||
pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[1].crossthreadOffset = 0x28;
|
||||
pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[0].crossthreadOffset = 0x20;
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
|
||||
pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].crossthreadOffset = 0x40;
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x50;
|
||||
pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[1].size = sizeof(T);
|
||||
pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[0].size = sizeof(T);
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].size = sizeof(T);
|
||||
pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].size = sizeof(T);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].size = sizeof(T);
|
||||
|
||||
pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
pKernel->setCrossThreadData(pCrossThreadData, sizeof(pCrossThreadData));
|
||||
|
||||
pKernel->setKernelArgHandler(0, &Kernel::setArgImmediate);
|
||||
pKernel->setKernelArgHandler(1, &Kernel::setArgImmediate);
|
||||
pKernel->setKernelArgHandler(2, &Kernel::setArgImmediate);
|
||||
pKernel->setKernelArgHandler(3, &Kernel::setArgImmediate);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
MockProgram program;
|
||||
MockKernel *pKernel = nullptr;
|
||||
KernelInfo *pKernelInfo;
|
||||
char pCrossThreadData[0x60];
|
||||
};
|
||||
|
||||
typedef ::testing::Types<
|
||||
char,
|
||||
float,
|
||||
int,
|
||||
short,
|
||||
long,
|
||||
unsigned char,
|
||||
unsigned int,
|
||||
unsigned short,
|
||||
unsigned long>
|
||||
KernelArgImmediateTypes;
|
||||
|
||||
TYPED_TEST_CASE(KernelArgImmediateTest, KernelArgImmediateTypes);
|
||||
|
||||
TYPED_TEST(KernelArgImmediateTest, SetKernelArg) {
|
||||
auto val = (TypeParam)0xaaaaaaaaULL;
|
||||
auto pVal = &val;
|
||||
this->pKernel->setArg(0, sizeof(TypeParam), pVal);
|
||||
|
||||
auto pKernelArg = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(val, *pKernelArg);
|
||||
}
|
||||
|
||||
TYPED_TEST(KernelArgImmediateTest, SetKernelArgWithInvalidIndex) {
|
||||
auto val = (TypeParam)0U;
|
||||
auto pVal = &val;
|
||||
auto ret = this->pKernel->setArg((uint32_t)-1, sizeof(TypeParam), pVal);
|
||||
|
||||
EXPECT_EQ(ret, CL_INVALID_ARG_INDEX);
|
||||
}
|
||||
|
||||
TYPED_TEST(KernelArgImmediateTest, setKernelArgMultipleArguments) {
|
||||
auto val = (TypeParam)0xaaaaaaaaULL;
|
||||
auto pVal = &val;
|
||||
this->pKernel->setArg(0, sizeof(TypeParam), pVal);
|
||||
|
||||
auto pKernelArg = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(val, *pKernelArg);
|
||||
|
||||
val = (TypeParam)0xbbbbbbbbULL;
|
||||
this->pKernel->setArg(1, sizeof(TypeParam), &val);
|
||||
|
||||
pKernelArg = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(val, *pKernelArg);
|
||||
|
||||
val = (TypeParam)0xccccccccULL;
|
||||
this->pKernel->setArg(2, sizeof(TypeParam), &val);
|
||||
|
||||
pKernelArg = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(val, *pKernelArg);
|
||||
}
|
||||
|
||||
TYPED_TEST(KernelArgImmediateTest, setKernelArgOverwritesCrossThreadData) {
|
||||
TypeParam val = (TypeParam)0xaaaaaaaaULL;
|
||||
TypeParam *pVal = &val;
|
||||
this->pKernel->setArg(0, sizeof(TypeParam), pVal);
|
||||
|
||||
TypeParam *pKernelArg = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(val, *pKernelArg);
|
||||
|
||||
val = (TypeParam)0xbbbbbbbbULL;
|
||||
this->pKernel->setArg(1, sizeof(TypeParam), &val);
|
||||
|
||||
pKernelArg = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(val, *pKernelArg);
|
||||
|
||||
val = (TypeParam)0xccccccccULL;
|
||||
this->pKernel->setArg(0, sizeof(TypeParam), &val);
|
||||
|
||||
pKernelArg = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
|
||||
EXPECT_EQ(val, *pKernelArg);
|
||||
}
|
||||
|
||||
TYPED_TEST(KernelArgImmediateTest, setSingleKernelArgMultipleStructElements) {
|
||||
struct ImmediateStruct {
|
||||
TypeParam a;
|
||||
unsigned char unused[3]; // want to force a gap, ideally unpadded
|
||||
TypeParam b;
|
||||
} immediateStruct;
|
||||
|
||||
immediateStruct.a = (TypeParam)0xaaaaaaaaULL;
|
||||
immediateStruct.b = (TypeParam)0xbbbbbbbbULL;
|
||||
immediateStruct.unused[0] = 0xfe;
|
||||
immediateStruct.unused[1] = 0xfe;
|
||||
immediateStruct.unused[2] = 0xfe;
|
||||
|
||||
this->pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[0].sourceOffset = offsetof(struct ImmediateStruct, a);
|
||||
this->pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[1].sourceOffset = offsetof(struct ImmediateStruct, b);
|
||||
|
||||
this->pKernel->setArg(3, sizeof(immediateStruct), &immediateStruct);
|
||||
|
||||
auto pCrossthreadA = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[0].crossthreadOffset);
|
||||
EXPECT_EQ(immediateStruct.a, *pCrossthreadA);
|
||||
|
||||
auto pCrossthreadB = (TypeParam *)(this->pKernel->getCrossThreadData() +
|
||||
this->pKernelInfo->kernelArgInfo[3].kernelArgPatchInfoVector[1].crossthreadOffset);
|
||||
EXPECT_EQ(immediateStruct.b, *pCrossthreadB);
|
||||
}
|
114
unit_tests/kernel/kernel_is_patched_tests.cpp
Normal file
114
unit_tests/kernel/kernel_is_patched_tests.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class PatchedKernelTest : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
device.reset(MockDevice::create<MockDevice>(nullptr));
|
||||
program.reset(Program::create("FillBufferBytes", &context, *device.get(), true, &retVal));
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
cl_device_id clDevice = device.get();
|
||||
program->build(1, &clDevice, nullptr, nullptr, nullptr, false);
|
||||
kernel.reset(Kernel::create(program.get(), *program->getKernelInfo("FillBufferBytes"), &retVal));
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
MockContext context;
|
||||
std::unique_ptr<MockDevice> device;
|
||||
std::unique_ptr<Program> program;
|
||||
std::unique_ptr<Kernel> kernel;
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
};
|
||||
|
||||
TEST_F(PatchedKernelTest, givenKernelWithoutPatchedArgsWhenIsPatchedIsCalledThenReturnsFalse) {
|
||||
EXPECT_FALSE(kernel->isPatched());
|
||||
}
|
||||
|
||||
TEST_F(PatchedKernelTest, givenKernelWithAllArgsSetWithBufferWhenIsPatchedIsCalledThenReturnsTrue) {
|
||||
auto buffer = clCreateBuffer(&context, CL_MEM_READ_ONLY, sizeof(int), nullptr, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
auto argsNum = kernel->getKernelArgsNumber();
|
||||
for (uint32_t i = 0; i < argsNum; i++) {
|
||||
kernel->setArg(i, buffer);
|
||||
}
|
||||
EXPECT_TRUE(kernel->isPatched());
|
||||
clReleaseMemObject(buffer);
|
||||
}
|
||||
|
||||
TEST_F(PatchedKernelTest, givenKernelWithoutAllArgsSetWhenIsPatchedIsCalledThenReturnsFalse) {
|
||||
auto buffer = clCreateBuffer(&context, CL_MEM_READ_ONLY, sizeof(int), nullptr, &retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
auto argsNum = kernel->getKernelArgsNumber();
|
||||
for (uint32_t i = 0; i < argsNum; i++) {
|
||||
kernel->setArg(0, buffer);
|
||||
}
|
||||
EXPECT_FALSE(kernel->isPatched());
|
||||
clReleaseMemObject(buffer);
|
||||
}
|
||||
|
||||
TEST_F(PatchedKernelTest, givenKernelWithAllArgsSetWithSvmAllocWhenIsPatchedIsCalledThenReturnsTrue) {
|
||||
auto argsNum = kernel->getKernelArgsNumber();
|
||||
for (uint32_t i = 0; i < argsNum; i++) {
|
||||
kernel->setArgSvmAlloc(0, nullptr, nullptr);
|
||||
}
|
||||
EXPECT_FALSE(kernel->isPatched());
|
||||
for (uint32_t i = 0; i < argsNum; i++) {
|
||||
kernel->setArgSvmAlloc(i, nullptr, nullptr);
|
||||
}
|
||||
EXPECT_TRUE(kernel->isPatched());
|
||||
}
|
||||
|
||||
TEST_F(PatchedKernelTest, givenKernelWithAllArgsSetWithSvmWhenIsPatchedIsCalledThenReturnsTrue) {
|
||||
uint32_t size = sizeof(int);
|
||||
auto argsNum = kernel->getKernelArgsNumber();
|
||||
for (uint32_t i = 0; i < argsNum; i++) {
|
||||
kernel->setArgSvm(0, size, nullptr, nullptr);
|
||||
}
|
||||
EXPECT_FALSE(kernel->isPatched());
|
||||
for (uint32_t i = 0; i < argsNum; i++) {
|
||||
kernel->setArgSvm(i, size, nullptr, nullptr);
|
||||
}
|
||||
EXPECT_TRUE(kernel->isPatched());
|
||||
}
|
||||
|
||||
TEST_F(PatchedKernelTest, givenKernelWithOneArgumentToPatchWhichIsNonzeroIndexedWhenThatArgumentIsSetThenKernelIsPatched) {
|
||||
uint32_t size = sizeof(int);
|
||||
MockKernelWithInternals mockKernel(*device.get(), &context);
|
||||
EXPECT_EQ(0u, mockKernel.kernelInfo.argumentsToPatchNum);
|
||||
mockKernel.kernelInfo.storeKernelArgPatchInfo(1, 0, 0, 0, 0);
|
||||
EXPECT_EQ(1u, mockKernel.kernelInfo.argumentsToPatchNum);
|
||||
mockKernel.kernelInfo.storeKernelArgPatchInfo(1, 0, 0, 0, 0);
|
||||
EXPECT_EQ(1u, mockKernel.kernelInfo.argumentsToPatchNum);
|
||||
kernel.reset(mockKernel.mockKernel);
|
||||
kernel->initialize();
|
||||
EXPECT_FALSE(kernel->Kernel::isPatched());
|
||||
kernel->setArgSvm(1, size, nullptr, nullptr);
|
||||
EXPECT_TRUE(kernel->Kernel::isPatched());
|
||||
kernel.release();
|
||||
}
|
2143
unit_tests/kernel/kernel_reflection_surface_tests.cpp
Normal file
2143
unit_tests/kernel/kernel_reflection_surface_tests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
119
unit_tests/kernel/kernel_slm_arg_tests.cpp
Normal file
119
unit_tests/kernel/kernel_slm_arg_tests.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "runtime/helpers/basic_math.h"
|
||||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class KernelSlmArgTest : public Test<DeviceFixture> {
|
||||
public:
|
||||
KernelSlmArgTest() {
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
pKernelInfo = KernelInfo::create();
|
||||
KernelArgPatchInfo kernelArgPatchInfo;
|
||||
|
||||
pKernelInfo->kernelArgInfo.resize(3);
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector.push_back(kernelArgPatchInfo);
|
||||
|
||||
pKernelInfo->kernelArgInfo[0].kernelArgPatchInfoVector[0].crossthreadOffset = 0x10;
|
||||
pKernelInfo->kernelArgInfo[0].slmAlignment = 0x1;
|
||||
pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].crossthreadOffset = 0x20;
|
||||
pKernelInfo->kernelArgInfo[1].kernelArgPatchInfoVector[0].size = sizeof(void *);
|
||||
pKernelInfo->kernelArgInfo[2].kernelArgPatchInfoVector[0].crossthreadOffset = 0x30;
|
||||
pKernelInfo->kernelArgInfo[2].slmAlignment = 0x400;
|
||||
pKernelInfo->workloadInfo.slmStaticSize = 3 * KB;
|
||||
|
||||
pKernel = new MockKernel(&program, *pKernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, pKernel->initialize());
|
||||
|
||||
pKernel->setKernelArgHandler(0, &Kernel::setArgLocal);
|
||||
pKernel->setKernelArgHandler(1, &Kernel::setArgImmediate);
|
||||
pKernel->setKernelArgHandler(2, &Kernel::setArgLocal);
|
||||
|
||||
uint32_t crossThreadData[0x40] = {};
|
||||
crossThreadData[0x20 / sizeof(uint32_t)] = 0x12344321;
|
||||
pKernel->setCrossThreadData(crossThreadData, sizeof(crossThreadData));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete pKernelInfo;
|
||||
delete pKernel;
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
MockProgram program;
|
||||
MockKernel *pKernel = nullptr;
|
||||
KernelInfo *pKernelInfo;
|
||||
|
||||
static const size_t slmSize0 = 0x200;
|
||||
static const size_t slmSize2 = 0x30;
|
||||
};
|
||||
|
||||
TEST_F(KernelSlmArgTest, settingSizeUpdatesAlignmentOfHigherSlmArgs) {
|
||||
pKernel->setArg(0, slmSize0, nullptr);
|
||||
pKernel->setArg(2, slmSize2, nullptr);
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData());
|
||||
auto slmOffset = ptrOffset(crossThreadData, 0x10);
|
||||
EXPECT_EQ(0u, *slmOffset);
|
||||
|
||||
slmOffset = ptrOffset(crossThreadData, 0x20);
|
||||
EXPECT_EQ(0x12344321u, *slmOffset);
|
||||
|
||||
slmOffset = ptrOffset(crossThreadData, 0x30);
|
||||
EXPECT_EQ(0x400u, *slmOffset);
|
||||
|
||||
EXPECT_EQ(5 * KB, pKernel->slmTotalSize);
|
||||
}
|
||||
|
||||
TEST_F(KernelSlmArgTest, settingSizeUpdatesAlignmentOfHigherSlmArgsReverseOrder) {
|
||||
pKernel->setArg(2, slmSize2, nullptr);
|
||||
pKernel->setArg(0, slmSize0, nullptr);
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint32_t *>(pKernel->getCrossThreadData());
|
||||
auto slmOffset = ptrOffset(crossThreadData, 0x10);
|
||||
EXPECT_EQ(0u, *slmOffset);
|
||||
|
||||
slmOffset = ptrOffset(crossThreadData, 0x20);
|
||||
EXPECT_EQ(0x12344321u, *slmOffset);
|
||||
|
||||
slmOffset = ptrOffset(crossThreadData, 0x30);
|
||||
EXPECT_EQ(0x400u, *slmOffset);
|
||||
|
||||
EXPECT_EQ(5 * KB, pKernel->slmTotalSize);
|
||||
}
|
160
unit_tests/kernel/kernel_slm_tests.cpp
Normal file
160
unit_tests/kernel/kernel_slm_tests.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "hw_cmds.h"
|
||||
#include "runtime/helpers/kernel_commands.h"
|
||||
#include "runtime/command_queue/command_queue_hw.h"
|
||||
#include "test.h"
|
||||
#include "runtime/kernel/kernel.h"
|
||||
#include "runtime/program/kernel_info.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
struct KernelSLMAndBarrierTest : public DeviceFixture,
|
||||
public ::testing::TestWithParam<uint32_t> {
|
||||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
|
||||
memset(&kernelHeader, 0, sizeof(kernelHeader));
|
||||
kernelHeader.KernelHeapSize = sizeof(kernelIsa);
|
||||
|
||||
memset(&dataParameterStream, 0, sizeof(dataParameterStream));
|
||||
dataParameterStream.DataParameterStreamSize = sizeof(crossThreadData);
|
||||
|
||||
executionEnvironment = {};
|
||||
memset(&executionEnvironment, 0, sizeof(executionEnvironment));
|
||||
executionEnvironment.CompiledSIMD32 = 1;
|
||||
executionEnvironment.LargestCompiledSIMDSize = 32;
|
||||
|
||||
memset(&threadPayload, 0, sizeof(threadPayload));
|
||||
threadPayload.LocalIDXPresent = 1;
|
||||
threadPayload.LocalIDYPresent = 1;
|
||||
threadPayload.LocalIDZPresent = 1;
|
||||
|
||||
kernelInfo.heapInfo.pKernelHeap = kernelIsa;
|
||||
kernelInfo.heapInfo.pKernelHeader = &kernelHeader;
|
||||
kernelInfo.patchInfo.dataParameterStream = &dataParameterStream;
|
||||
kernelInfo.patchInfo.executionEnvironment = &executionEnvironment;
|
||||
kernelInfo.patchInfo.threadPayload = &threadPayload;
|
||||
}
|
||||
void TearDown() override {
|
||||
DeviceFixture::TearDown();
|
||||
}
|
||||
|
||||
uint32_t simd;
|
||||
uint32_t numChannels;
|
||||
|
||||
MockProgram program;
|
||||
|
||||
SKernelBinaryHeaderCommon kernelHeader;
|
||||
SPatchDataParameterStream dataParameterStream;
|
||||
SPatchExecutionEnvironment executionEnvironment;
|
||||
SPatchThreadPayload threadPayload;
|
||||
KernelInfo kernelInfo;
|
||||
|
||||
uint32_t kernelIsa[32];
|
||||
uint32_t crossThreadData[32];
|
||||
uint32_t perThreadData[8];
|
||||
};
|
||||
|
||||
static uint32_t slmSizeInKb[] = {1, 4, 8, 16, 32, 64};
|
||||
|
||||
HWTEST_P(KernelSLMAndBarrierTest, test_SLMProgramming) {
|
||||
ASSERT_NE(nullptr, pDevice);
|
||||
CommandQueueHw<FamilyType> cmdQ(nullptr, pDevice, 0);
|
||||
typedef typename FamilyType::INTERFACE_DESCRIPTOR_DATA INTERFACE_DESCRIPTOR_DATA;
|
||||
|
||||
// define kernel info
|
||||
executionEnvironment.HasBarriers = 1;
|
||||
kernelInfo.workloadInfo.slmStaticSize = GetParam() * KB;
|
||||
|
||||
MockKernel kernel(&program, kernelInfo, *pDevice);
|
||||
ASSERT_EQ(CL_SUCCESS, kernel.initialize());
|
||||
|
||||
// After creating Mock Kernel now create Indirect Heap
|
||||
auto &indirectHeap = cmdQ.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 8192);
|
||||
|
||||
uint64_t interfaceDescriptorOffset = indirectHeap.getUsed();
|
||||
|
||||
size_t offsetInterfaceDescriptorData = KernelCommandsHelper<FamilyType>::sendInterfaceDescriptorData(
|
||||
indirectHeap,
|
||||
interfaceDescriptorOffset,
|
||||
0,
|
||||
sizeof(crossThreadData),
|
||||
sizeof(perThreadData),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
kernelInfo.workloadInfo.slmStaticSize,
|
||||
!!executionEnvironment.HasBarriers); // Barriers Enabled
|
||||
|
||||
// add the heap base + offset
|
||||
uint32_t *pIdData = (uint32_t *)indirectHeap.getBase() + offsetInterfaceDescriptorData;
|
||||
|
||||
INTERFACE_DESCRIPTOR_DATA *pSrcIDData = (INTERFACE_DESCRIPTOR_DATA *)pIdData;
|
||||
|
||||
uint32_t ExpectedSLMSize = 0;
|
||||
|
||||
if (::renderCoreFamily == IGFX_GEN8_CORE) {
|
||||
if (kernelInfo.workloadInfo.slmStaticSize <= (4 * 1024)) {
|
||||
ExpectedSLMSize = 1;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (8 * 1024)) {
|
||||
ExpectedSLMSize = 2;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (16 * 1024)) {
|
||||
ExpectedSLMSize = 4;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (32 * 1024)) {
|
||||
ExpectedSLMSize = 8;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (64 * 1024)) {
|
||||
ExpectedSLMSize = 16;
|
||||
}
|
||||
} else {
|
||||
if (kernelInfo.workloadInfo.slmStaticSize <= (1 * 1024)) // its a power of "2" +1 for example 1 is 2^0 ( 0+1); 2 is 2^1 is (1+1) etc.
|
||||
{
|
||||
ExpectedSLMSize = 1;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (2 * 1024)) {
|
||||
ExpectedSLMSize = 2;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (4 * 1024)) {
|
||||
ExpectedSLMSize = 3;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (8 * 1024)) {
|
||||
ExpectedSLMSize = 4;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (16 * 1024)) {
|
||||
ExpectedSLMSize = 5;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (32 * 1024)) {
|
||||
ExpectedSLMSize = 6;
|
||||
} else if (kernelInfo.workloadInfo.slmStaticSize <= (64 * 1024)) {
|
||||
ExpectedSLMSize = 7;
|
||||
}
|
||||
}
|
||||
ASSERT_GT(ExpectedSLMSize, 0u);
|
||||
EXPECT_EQ(ExpectedSLMSize, pSrcIDData->getSharedLocalMemorySize());
|
||||
EXPECT_EQ(!!executionEnvironment.HasBarriers, pSrcIDData->getBarrierEnable());
|
||||
EXPECT_EQ(INTERFACE_DESCRIPTOR_DATA::DENORM_MODE_SETBYKERNEL, pSrcIDData->getDenormMode());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
SlmSizes,
|
||||
KernelSLMAndBarrierTest,
|
||||
testing::ValuesIn(slmSizeInKb));
|
2036
unit_tests/kernel/kernel_tests.cpp
Normal file
2036
unit_tests/kernel/kernel_tests.cpp
Normal file
File diff suppressed because it is too large
Load Diff
237
unit_tests/kernel/parent_kernel_tests.cpp
Normal file
237
unit_tests/kernel/parent_kernel_tests.cpp
Normal file
@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "unit_tests/fixtures/execution_model_kernel_fixture.h"
|
||||
#include "unit_tests/mocks/mock_device.h"
|
||||
#include "unit_tests/mocks/mock_kernel.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
#include "test.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
typedef ExecutionModelKernelFixture ParentKernelFromBinaryTest;
|
||||
|
||||
class MockKernelWithArgumentAccess : public Kernel {
|
||||
public:
|
||||
std::vector<SimpleKernelArgInfo> &getKernelArguments() {
|
||||
return kernelArguments;
|
||||
}
|
||||
|
||||
class ObjectCountsPublic : public Kernel::ObjectCounts {
|
||||
};
|
||||
|
||||
MockKernelWithArgumentAccess(Program *programArg, const KernelInfo &kernelInfoArg, const Device &deviceArg) : Kernel(programArg, kernelInfoArg, deviceArg) {
|
||||
}
|
||||
|
||||
void getParentObjectCountsPublic(MockKernelWithArgumentAccess::ObjectCountsPublic &objectCount) {
|
||||
getParentObjectCounts(objectCount);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(ParentKernelTest, GetObjectCounts) {
|
||||
KernelInfo info;
|
||||
MockDevice *device = new MockDevice(*platformDevices[0]);
|
||||
MockProgram program;
|
||||
|
||||
SPatchExecutionEnvironment environment;
|
||||
environment.HasDeviceEnqueue = 1;
|
||||
|
||||
info.patchInfo.executionEnvironment = &environment;
|
||||
|
||||
MockKernelWithArgumentAccess kernel(&program, info, *device);
|
||||
|
||||
std::vector<Kernel::SimpleKernelArgInfo> &args = kernel.getKernelArguments();
|
||||
|
||||
Kernel::SimpleKernelArgInfo argInfo;
|
||||
argInfo.type = Kernel::kernelArgType::SAMPLER_OBJ;
|
||||
args.push_back(argInfo);
|
||||
argInfo.type = Kernel::kernelArgType::IMAGE_OBJ;
|
||||
args.push_back(argInfo);
|
||||
|
||||
MockKernelWithArgumentAccess::ObjectCountsPublic objectCounts;
|
||||
|
||||
kernel.getParentObjectCountsPublic(objectCounts);
|
||||
|
||||
EXPECT_EQ(1u, objectCounts.imageCount);
|
||||
EXPECT_EQ(1u, objectCounts.samplerCount);
|
||||
|
||||
delete device;
|
||||
}
|
||||
|
||||
TEST(ParentKernelTest, patchBlocksSimdSize) {
|
||||
MockDevice *device = new MockDevice(*platformDevices[0]);
|
||||
MockParentKernel *parentKernel = MockParentKernel::create(*device, true);
|
||||
MockProgram *program = (MockProgram *)parentKernel->mockProgram;
|
||||
|
||||
parentKernel->patchBlocksSimdSize();
|
||||
|
||||
void *blockSimdSize = ptrOffset(parentKernel->getCrossThreadData(), parentKernel->getKernelInfo().childrenKernelsIdOffset[0].second);
|
||||
uint32_t *simdSize = reinterpret_cast<uint32_t *>(blockSimdSize);
|
||||
|
||||
EXPECT_EQ(program->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
|
||||
delete parentKernel;
|
||||
delete device;
|
||||
}
|
||||
|
||||
TEST(ParentKernelTest, hasDeviceEnqueue) {
|
||||
MockDevice device(*platformDevices[0]);
|
||||
std::unique_ptr<MockParentKernel> parentKernel(MockParentKernel::create(device));
|
||||
|
||||
EXPECT_TRUE(parentKernel->getKernelInfo().hasDeviceEnqueue());
|
||||
}
|
||||
|
||||
TEST(ParentKernelTest, doesnthaveDeviceEnqueue) {
|
||||
MockDevice device(*platformDevices[0]);
|
||||
MockKernelWithInternals kernel(device);
|
||||
|
||||
EXPECT_FALSE(kernel.kernelInfo.hasDeviceEnqueue());
|
||||
}
|
||||
|
||||
TEST(ParentKernelTest, initializeOnParentKernelPatchesBlocksSimdSize) {
|
||||
MockDevice *device = new MockDevice(*platformDevices[0]);
|
||||
MockParentKernel *parentKernel = MockParentKernel::create(*device, true);
|
||||
MockProgram *program = (MockProgram *)parentKernel->mockProgram;
|
||||
|
||||
parentKernel->initialize();
|
||||
|
||||
void *blockSimdSize = ptrOffset(parentKernel->getCrossThreadData(), parentKernel->getKernelInfo().childrenKernelsIdOffset[0].second);
|
||||
uint32_t *simdSize = reinterpret_cast<uint32_t *>(blockSimdSize);
|
||||
|
||||
EXPECT_EQ(program->getBlockKernelInfo(0)->getMaxSimdSize(), *simdSize);
|
||||
delete parentKernel;
|
||||
delete device;
|
||||
}
|
||||
|
||||
TEST(ParentKernelTest, initializeOnParentKernelAllocatesPrivateMemoryForBlocks) {
|
||||
MockDevice *device = new MockDevice(*platformDevices[0]);
|
||||
MockParentKernel *parentKernel = MockParentKernel::create(*device, true);
|
||||
MockProgram *program = (MockProgram *)parentKernel->mockProgram;
|
||||
|
||||
uint32_t crossThreadOffsetBlock = 0;
|
||||
|
||||
KernelInfo *infoBlock = new KernelInfo();
|
||||
SPatchAllocateStatelessDefaultDeviceQueueSurface *allocateDeviceQueueBlock = new SPatchAllocateStatelessDefaultDeviceQueueSurface;
|
||||
allocateDeviceQueueBlock->DataParamOffset = crossThreadOffsetBlock;
|
||||
allocateDeviceQueueBlock->DataParamSize = 8;
|
||||
allocateDeviceQueueBlock->SurfaceStateHeapOffset = 0;
|
||||
allocateDeviceQueueBlock->Size = 8;
|
||||
infoBlock->patchInfo.pAllocateStatelessDefaultDeviceQueueSurface = allocateDeviceQueueBlock;
|
||||
|
||||
crossThreadOffsetBlock += 8;
|
||||
|
||||
SPatchAllocateStatelessEventPoolSurface *eventPoolBlock = new SPatchAllocateStatelessEventPoolSurface;
|
||||
eventPoolBlock->DataParamOffset = crossThreadOffsetBlock;
|
||||
eventPoolBlock->DataParamSize = 8;
|
||||
eventPoolBlock->EventPoolSurfaceIndex = 0;
|
||||
eventPoolBlock->Size = 8;
|
||||
infoBlock->patchInfo.pAllocateStatelessEventPoolSurface = eventPoolBlock;
|
||||
|
||||
crossThreadOffsetBlock += 8;
|
||||
|
||||
SPatchAllocateStatelessPrivateSurface *privateSurfaceBlock = new SPatchAllocateStatelessPrivateSurface;
|
||||
privateSurfaceBlock->DataParamOffset = crossThreadOffsetBlock;
|
||||
privateSurfaceBlock->DataParamSize = 8;
|
||||
privateSurfaceBlock->Size = 8;
|
||||
privateSurfaceBlock->SurfaceStateHeapOffset = 0;
|
||||
privateSurfaceBlock->Token = 0;
|
||||
privateSurfaceBlock->PerThreadPrivateMemorySize = 1000;
|
||||
infoBlock->patchInfo.pAllocateStatelessPrivateSurface = privateSurfaceBlock;
|
||||
|
||||
crossThreadOffsetBlock += 8;
|
||||
|
||||
SKernelBinaryHeaderCommon *headerBlock = new SKernelBinaryHeaderCommon;
|
||||
headerBlock->DynamicStateHeapSize = 0;
|
||||
headerBlock->GeneralStateHeapSize = 0;
|
||||
headerBlock->KernelHeapSize = 0;
|
||||
headerBlock->KernelNameSize = 0;
|
||||
headerBlock->PatchListSize = 0;
|
||||
headerBlock->SurfaceStateHeapSize = 0;
|
||||
infoBlock->heapInfo.pKernelHeader = headerBlock;
|
||||
|
||||
SPatchThreadPayload *threadPayloadBlock = new SPatchThreadPayload;
|
||||
threadPayloadBlock->LocalIDXPresent = 0;
|
||||
threadPayloadBlock->LocalIDYPresent = 0;
|
||||
threadPayloadBlock->LocalIDZPresent = 0;
|
||||
threadPayloadBlock->HeaderPresent = 0;
|
||||
threadPayloadBlock->Size = 128;
|
||||
|
||||
infoBlock->patchInfo.threadPayload = threadPayloadBlock;
|
||||
|
||||
SPatchExecutionEnvironment *executionEnvironmentBlock = new SPatchExecutionEnvironment;
|
||||
executionEnvironmentBlock->HasDeviceEnqueue = 1;
|
||||
infoBlock->patchInfo.executionEnvironment = executionEnvironmentBlock;
|
||||
|
||||
SPatchDataParameterStream *streamBlock = new SPatchDataParameterStream;
|
||||
streamBlock->DataParameterStreamSize = 0;
|
||||
streamBlock->Size = 0;
|
||||
infoBlock->patchInfo.dataParameterStream = streamBlock;
|
||||
|
||||
SPatchBindingTableState *bindingTable = new SPatchBindingTableState;
|
||||
bindingTable->Count = 0;
|
||||
bindingTable->Offset = 0;
|
||||
bindingTable->Size = 0;
|
||||
bindingTable->SurfaceStateOffset = 0;
|
||||
infoBlock->patchInfo.bindingTableState = bindingTable;
|
||||
|
||||
SPatchInterfaceDescriptorData *idData = new SPatchInterfaceDescriptorData;
|
||||
idData->BindingTableOffset = 0;
|
||||
idData->KernelOffset = 0;
|
||||
idData->Offset = 0;
|
||||
idData->SamplerStateOffset = 0;
|
||||
idData->Size = 0;
|
||||
infoBlock->patchInfo.interfaceDescriptorData = idData;
|
||||
|
||||
infoBlock->patchInfo.pAllocateStatelessGlobalMemorySurfaceWithInitialization = nullptr;
|
||||
infoBlock->patchInfo.pAllocateStatelessConstantMemorySurfaceWithInitialization = nullptr;
|
||||
|
||||
infoBlock->heapInfo.pDsh = (void *)new uint64_t[64];
|
||||
infoBlock->crossThreadData = new char[crossThreadOffsetBlock];
|
||||
|
||||
program->addBlockKernel(infoBlock);
|
||||
|
||||
parentKernel->initialize();
|
||||
|
||||
EXPECT_NE(nullptr, program->getBlockKernelManager()->getPrivateSurface(program->getBlockKernelManager()->getCount() - 1));
|
||||
|
||||
delete privateSurfaceBlock;
|
||||
delete parentKernel;
|
||||
delete device;
|
||||
}
|
||||
|
||||
TEST_P(ParentKernelFromBinaryTest, getInstructionHeapSizeForExecutionModelReturnsNonZeroForParentKernel) {
|
||||
if (std::string(pPlatform->getDevice(0)->getDeviceInfo().clVersion).find("OpenCL 2.") != std::string::npos) {
|
||||
EXPECT_TRUE(pKernel->isParentKernel);
|
||||
|
||||
EXPECT_LT(0u, pKernel->getInstructionHeapSizeForExecutionModel());
|
||||
}
|
||||
}
|
||||
|
||||
static const char *binaryFile = "simple_block_kernel";
|
||||
static const char *KernelNames[] = {"simple_block_kernel"};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(ParentKernelFromBinaryTest,
|
||||
ParentKernelFromBinaryTest,
|
||||
::testing::Combine(
|
||||
::testing::Values(binaryFile),
|
||||
::testing::ValuesIn(KernelNames)));
|
Reference in New Issue
Block a user