2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2020-01-14 14:32:11 +01:00
|
|
|
* Copyright (C) 2017-2020 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
|
2020-02-21 15:35:08 +01:00
|
|
|
#include "core/command_stream/command_stream_receiver.h"
|
2019-08-02 13:25:45 -07:00
|
|
|
#include "core/helpers/aligned_memory.h"
|
2020-02-07 17:00:20 +01:00
|
|
|
#include "core/memory_manager/memory_manager.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "test.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "unit_tests/command_queue/command_queue_fixture.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
#include "unit_tests/command_stream/command_stream_fixture.h"
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "unit_tests/fixtures/buffer_fixture.h"
|
2018-10-30 10:00:15 -07:00
|
|
|
#include "unit_tests/fixtures/hello_world_kernel_fixture.h"
|
|
|
|
#include "unit_tests/gen_common/gen_cmd_parse.h"
|
|
|
|
#include "unit_tests/indirect_heap/indirect_heap_fixture.h"
|
2017-12-21 00:45:38 +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,
|
2018-04-16 21:54:19 +02:00
|
|
|
public DeviceFixture {
|
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
|
|
|
|
|
|
|
HelloWorldFixture() : pSrcMemory(nullptr),
|
|
|
|
pDestMemory(nullptr),
|
|
|
|
sizeUserMemory(128 * sizeof(float)),
|
|
|
|
kernelFilename("CopyBuffer_simd"),
|
|
|
|
kernelName("CopyBuffer") {
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void SetUp() {
|
|
|
|
DeviceFixture::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
|
|
|
}
|
|
|
|
|
|
|
|
virtual void TearDown() {
|
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();
|
2017-12-21 00:45:38 +01:00
|
|
|
DeviceFixture::TearDown();
|
|
|
|
}
|
2018-08-16 15:48:50 +02:00
|
|
|
Buffer *srcBuffer;
|
|
|
|
Buffer *destBuffer;
|
2017-12-21 00:45:38 +01:00
|
|
|
void *pSrcMemory;
|
|
|
|
void *pDestMemory;
|
|
|
|
size_t sizeUserMemory;
|
|
|
|
const char *kernelFilename;
|
|
|
|
const char *kernelName;
|
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>
|
|
|
|
struct HelloWorldTest : Test<HelloWorldFixture<FixtureFactory>> {
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FixtureFactory>
|
|
|
|
struct HelloWorldTestWithParam : HelloWorldFixture<FixtureFactory> {
|
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|