2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2022-06-28 00:54:34 +00:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2022-06-29 19:17:47 +00:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-02-23 15:20:22 +01:00
|
|
|
#include "opencl/test/unit_test/command_queue/command_queue_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/command_stream/command_stream_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/fixtures/buffer_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/fixtures/hello_world_kernel_fixture.h"
|
|
|
|
#include "opencl/test/unit_test/indirect_heap/indirect_heap_fixture.h"
|
2020-02-22 22:50:57 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
// Factory used to pick various ingredients for use in aggregate tests
|
|
|
|
struct HelloWorldFixtureFactory {
|
2019-03-26 11:59:46 +01:00
|
|
|
typedef NEO::IndirectHeapFixture IndirectHeapFixture;
|
|
|
|
typedef NEO::CommandStreamFixture CommandStreamFixture;
|
|
|
|
typedef NEO::CommandQueueHwFixture CommandQueueFixture;
|
|
|
|
typedef NEO::HelloWorldKernelFixture KernelFixture;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Instantiates a fixture based on the supplied fixture factory.
|
|
|
|
// Used by most tests for integration testing with command queues.
|
|
|
|
template <typename FixtureFactory>
|
|
|
|
struct HelloWorldFixture : public FixtureFactory::IndirectHeapFixture,
|
|
|
|
public FixtureFactory::CommandStreamFixture,
|
|
|
|
public FixtureFactory::CommandQueueFixture,
|
|
|
|
public FixtureFactory::KernelFixture,
|
2020-05-28 14:05:12 +02:00
|
|
|
public ClDeviceFixture {
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
typedef typename FixtureFactory::IndirectHeapFixture IndirectHeapFixture;
|
|
|
|
typedef typename FixtureFactory::CommandStreamFixture CommandStreamFixture;
|
|
|
|
typedef typename FixtureFactory::CommandQueueFixture CommandQueueFixture;
|
|
|
|
typedef typename FixtureFactory::KernelFixture KernelFixture;
|
|
|
|
|
|
|
|
using CommandQueueFixture::pCmdQ;
|
2018-06-12 21:54:39 +02:00
|
|
|
using CommandQueueFixture::SetUp;
|
2017-12-21 00:45:38 +01:00
|
|
|
using CommandStreamFixture::pCS;
|
|
|
|
using CommandStreamFixture::SetUp;
|
2018-06-12 21:54:39 +02:00
|
|
|
using HelloWorldKernelFixture::SetUp;
|
|
|
|
using IndirectHeapFixture::SetUp;
|
|
|
|
using KernelFixture::pKernel;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
public:
|
2020-03-13 09:17:01 +01:00
|
|
|
void SetUp() override {
|
2020-05-28 14:05:12 +02:00
|
|
|
ClDeviceFixture::SetUp();
|
2020-01-14 14:32:11 +01:00
|
|
|
ASSERT_NE(nullptr, pClDevice);
|
|
|
|
CommandQueueFixture::SetUp(pClDevice, 0);
|
2017-12-21 00:45:38 +01:00
|
|
|
ASSERT_NE(nullptr, pCmdQ);
|
|
|
|
CommandStreamFixture::SetUp(pCmdQ);
|
|
|
|
ASSERT_NE(nullptr, pCS);
|
|
|
|
IndirectHeapFixture::SetUp(pCmdQ);
|
2020-01-14 14:32:11 +01:00
|
|
|
KernelFixture::SetUp(pClDevice, kernelFilename, kernelName);
|
2017-12-21 00:45:38 +01:00
|
|
|
ASSERT_NE(nullptr, pKernel);
|
|
|
|
|
2018-08-16 15:48:50 +02:00
|
|
|
auto retVal = CL_INVALID_VALUE;
|
2020-01-14 14:32:11 +01:00
|
|
|
BufferDefaults::context = new MockContext(pClDevice);
|
2018-08-16 15:48:50 +02:00
|
|
|
|
|
|
|
destBuffer = Buffer::create(
|
|
|
|
BufferDefaults::context,
|
|
|
|
CL_MEM_READ_WRITE,
|
|
|
|
sizeUserMemory,
|
|
|
|
nullptr,
|
|
|
|
retVal);
|
|
|
|
|
|
|
|
srcBuffer = Buffer::create(
|
|
|
|
BufferDefaults::context,
|
|
|
|
CL_MEM_READ_WRITE,
|
|
|
|
sizeUserMemory,
|
|
|
|
nullptr,
|
|
|
|
retVal);
|
|
|
|
|
|
|
|
pDestMemory = destBuffer->getCpuAddressForMapping();
|
|
|
|
pSrcMemory = srcBuffer->getCpuAddressForMapping();
|
|
|
|
|
2018-09-03 11:51:11 +02:00
|
|
|
memset(pDestMemory, destPattern, sizeUserMemory);
|
|
|
|
memset(pSrcMemory, srcPattern, sizeUserMemory);
|
|
|
|
|
2018-08-16 15:48:50 +02:00
|
|
|
pKernel->setArg(0, srcBuffer);
|
|
|
|
pKernel->setArg(1, destBuffer);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
2020-03-13 09:17:01 +01:00
|
|
|
void TearDown() override {
|
2018-03-13 10:44:35 +01:00
|
|
|
pCmdQ->flush();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-02-04 13:08:47 +01:00
|
|
|
srcBuffer->release();
|
|
|
|
destBuffer->release();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
KernelFixture::TearDown();
|
|
|
|
IndirectHeapFixture::TearDown();
|
|
|
|
CommandStreamFixture::TearDown();
|
|
|
|
CommandQueueFixture::TearDown();
|
2019-02-06 08:49:35 +01:00
|
|
|
BufferDefaults::context->release();
|
2020-05-28 14:05:12 +02:00
|
|
|
ClDeviceFixture::TearDown();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2020-03-13 14:59:00 +01:00
|
|
|
Buffer *srcBuffer = nullptr;
|
|
|
|
Buffer *destBuffer = nullptr;
|
|
|
|
void *pSrcMemory = nullptr;
|
|
|
|
void *pDestMemory = nullptr;
|
|
|
|
size_t sizeUserMemory = 128 * sizeof(float);
|
|
|
|
const char *kernelFilename = "CopyBuffer_simd";
|
|
|
|
const char *kernelName = "CopyBuffer";
|
2018-09-03 11:51:11 +02:00
|
|
|
const int srcPattern = 85;
|
|
|
|
const int destPattern = 170;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
cl_int callOneWorkItemNDRKernel(cl_event *eventWaitList = nullptr, cl_int waitListSize = 0, cl_event *returnEvent = nullptr) {
|
|
|
|
|
|
|
|
cl_uint workDim = 1;
|
|
|
|
size_t globalWorkOffset[3] = {0, 0, 0};
|
|
|
|
size_t globalWorkSize[3] = {1, 1, 1};
|
|
|
|
size_t localWorkSize[3] = {1, 1, 1};
|
|
|
|
|
|
|
|
return pCmdQ->enqueueKernel(
|
|
|
|
pKernel,
|
|
|
|
workDim,
|
|
|
|
globalWorkOffset,
|
|
|
|
globalWorkSize,
|
|
|
|
localWorkSize,
|
|
|
|
waitListSize,
|
|
|
|
eventWaitList,
|
|
|
|
returnEvent);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FixtureFactory>
|
2022-08-11 11:28:20 +00:00
|
|
|
struct HelloWorldTest : TestLegacy<HelloWorldFixture<FixtureFactory>> {
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FixtureFactory>
|
|
|
|
struct HelloWorldTestWithParam : HelloWorldFixture<FixtureFactory> {
|
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|