mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-13 18:23:03 +08:00
Introducing AubFixture with minimum required initialization
- fixture is creating AUBCsr or TBXWithAubCsr only and sets executionEnvironment used by Device - this sequence ensures correct initialization without redundant objects creation - adding new AUB test: AubWriteCopyReadBufferTest Change-Id: I678410585c91c008fc53a44b13e885e970fd315b
This commit is contained in:
committed by
sys_ocldev
parent
9f4f152e3a
commit
dfd4e767e0
@@ -20,5 +20,7 @@ target_sources(igdrcl_aub_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_read_image_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_buffer_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_buffer_rect_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_copy_read_buffer_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_copy_read_buffer_aub_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_image_aub_tests.cpp
|
||||
)
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "unit_tests/aub_tests/command_queue/enqueue_write_copy_read_buffer_aub_tests.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
template <typename FamilyType>
|
||||
void AubWriteCopyReadBuffer::runTest() {
|
||||
auto aubCsr = AUBFixture::getAubCsr<FamilyType>();
|
||||
|
||||
char srcMemoryInitial[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
char dstMemoryInitial[] = {11, 12, 13, 14, 15, 16, 17, 18};
|
||||
|
||||
char srcMemoryToWrite[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
char dstMemoryToWrite[] = {11, 12, 13, 14, 15, 16, 17, 18};
|
||||
|
||||
const size_t bufferSize = sizeof(srcMemoryInitial);
|
||||
|
||||
static_assert(bufferSize == sizeof(dstMemoryInitial), "");
|
||||
static_assert(bufferSize == sizeof(srcMemoryToWrite), "");
|
||||
static_assert(bufferSize == sizeof(dstMemoryToWrite), "");
|
||||
|
||||
auto retVal = CL_INVALID_VALUE;
|
||||
auto srcBuffer = std::unique_ptr<Buffer>(Buffer::create(
|
||||
context,
|
||||
CL_MEM_COPY_HOST_PTR,
|
||||
bufferSize,
|
||||
srcMemoryInitial,
|
||||
retVal));
|
||||
ASSERT_NE(nullptr, srcBuffer);
|
||||
|
||||
auto dstBuffer = std::unique_ptr<Buffer>(Buffer::create(
|
||||
context,
|
||||
CL_MEM_COPY_HOST_PTR,
|
||||
bufferSize,
|
||||
dstMemoryInitial,
|
||||
retVal));
|
||||
ASSERT_NE(nullptr, dstBuffer);
|
||||
|
||||
aubCsr->writeMemory(*srcBuffer->getGraphicsAllocation());
|
||||
aubCsr->writeMemory(*dstBuffer->getGraphicsAllocation());
|
||||
|
||||
getAubCsr<FamilyType>()->expectMemory(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryInitial, bufferSize);
|
||||
getAubCsr<FamilyType>()->expectMemory(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryInitial, bufferSize);
|
||||
|
||||
cl_uint numEventsInWaitList = 0;
|
||||
cl_event *eventWaitList = nullptr;
|
||||
cl_event *event = nullptr;
|
||||
|
||||
retVal = pCmdQ->enqueueWriteBuffer(
|
||||
srcBuffer.get(),
|
||||
true,
|
||||
0,
|
||||
bufferSize,
|
||||
srcMemoryToWrite,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
retVal = pCmdQ->enqueueWriteBuffer(
|
||||
dstBuffer.get(),
|
||||
true,
|
||||
0,
|
||||
bufferSize,
|
||||
dstMemoryToWrite,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
getAubCsr<FamilyType>()->expectMemory(AUBFixture::getGpuPointer(srcBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize);
|
||||
getAubCsr<FamilyType>()->expectMemory(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), dstMemoryToWrite, bufferSize);
|
||||
|
||||
retVal = pCmdQ->enqueueCopyBuffer(
|
||||
srcBuffer.get(),
|
||||
dstBuffer.get(),
|
||||
0,
|
||||
0,
|
||||
bufferSize,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
pCmdQ->flush();
|
||||
|
||||
// Destination buffer should have src buffer content
|
||||
getAubCsr<FamilyType>()->expectMemory(AUBFixture::getGpuPointer(dstBuffer->getGraphicsAllocation()), srcMemoryToWrite, bufferSize);
|
||||
|
||||
char hostPtrMemory[] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
ASSERT_EQ(bufferSize, sizeof(hostPtrMemory));
|
||||
|
||||
retVal = pCmdQ->enqueueReadBuffer(
|
||||
dstBuffer.get(),
|
||||
false,
|
||||
0,
|
||||
bufferSize,
|
||||
hostPtrMemory,
|
||||
numEventsInWaitList,
|
||||
eventWaitList,
|
||||
event);
|
||||
|
||||
pCmdQ->flush();
|
||||
|
||||
GraphicsAllocation *allocation = csr->getMemoryManager()->graphicsAllocations.peekHead();
|
||||
while (allocation && allocation->getUnderlyingBuffer() != hostPtrMemory) {
|
||||
allocation = allocation->next;
|
||||
}
|
||||
|
||||
getAubCsr<FamilyType>()->expectMemory(AUBFixture::getGpuPointer(allocation), srcMemoryToWrite, bufferSize);
|
||||
}
|
||||
|
||||
HWTEST_F(AubWriteCopyReadBuffer, givenTwoBuffersFilledWithPatternWhenSourceIsCopiedToDestinationThenDestinationDataValidates) {
|
||||
runTest<FamilyType>();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
|
||||
#include "unit_tests/aub_tests/fixtures/aub_fixture.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
struct AubWriteCopyReadBuffer : public AUBFixture,
|
||||
public ::testing::Test {
|
||||
|
||||
void SetUp() override {
|
||||
AUBFixture::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
AUBFixture::TearDown();
|
||||
}
|
||||
|
||||
template <typename FamilyType>
|
||||
void runTest();
|
||||
};
|
||||
Reference in New Issue
Block a user