Add clEnqueueVerifyMemory API
Change-Id: I15a514b14b9efdaeb182c7abd98b8e236932d50f Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
parent
cae49f35a9
commit
7e3884e22d
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -48,3 +48,7 @@ using cl_mem_flags_intel = cl_mem_flags;
|
|||
******************************/
|
||||
|
||||
#define CL_MEM_FLAGS_INTEL 0x10001
|
||||
|
||||
// Used with clEnqueueVerifyMemory
|
||||
#define CL_MEM_COMPARE_EQUAL 0u
|
||||
#define CL_MEM_COMPARE_NOT_EQUAL 1u
|
||||
|
|
|
@ -3325,8 +3325,8 @@ void *CL_API_CALL clGetExtensionFunctionAddress(const char *func_name) {
|
|||
RETURN_FUNC_PTR_IF_EXIST(clGetAcceleratorInfoINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clRetainAcceleratorINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clReleaseAcceleratorINTEL);
|
||||
|
||||
RETURN_FUNC_PTR_IF_EXIST(clCreateBufferWithPropertiesINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clEnqueueVerifyMemory);
|
||||
|
||||
void *ret = sharingFactory.getExtensionFunctionAddress(func_name);
|
||||
if (ret != nullptr)
|
||||
|
@ -4247,3 +4247,37 @@ cl_kernel CL_API_CALL clCloneKernel(cl_kernel sourceKernel,
|
|||
|
||||
return pClonedKernel;
|
||||
}
|
||||
|
||||
CL_API_ENTRY cl_int CL_API_CALL clEnqueueVerifyMemory(cl_command_queue commandQueue,
|
||||
const void *allocationPtr,
|
||||
const void *expectedData,
|
||||
size_t sizeOfComparison,
|
||||
cl_uint comparisonMode) {
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("commandQueue", commandQueue,
|
||||
"allocationPtr", allocationPtr,
|
||||
"expectedData", expectedData,
|
||||
"sizeOfComparison", sizeOfComparison,
|
||||
"comparisonMode", comparisonMode);
|
||||
|
||||
if (sizeOfComparison == 0 || expectedData == nullptr || allocationPtr == nullptr) {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
CommandQueue *pCommandQueue = nullptr;
|
||||
retVal = validateObjects(WithCastToInternal(commandQueue, &pCommandQueue));
|
||||
if (retVal != CL_SUCCESS) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
auto &csr = pCommandQueue->getCommandStreamReceiver();
|
||||
if (csr.expectMemory(allocationPtr, expectedData, sizeOfComparison, comparisonMode)) {
|
||||
retVal = CL_SUCCESS;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
retVal = CL_INVALID_VALUE;
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -840,6 +840,13 @@ cl_sampler CL_API_CALL clCreateSamplerWithProperties(
|
|||
const cl_sampler_properties *samplerProperties,
|
||||
cl_int *errcodeRet);
|
||||
|
||||
cl_int CL_API_CALL clEnqueueVerifyMemory(
|
||||
cl_command_queue commandQueue,
|
||||
const void *allocationPtr,
|
||||
const void *expectedData,
|
||||
size_t sizeOfComparison,
|
||||
cl_uint comparisonMode);
|
||||
|
||||
// OpenCL 2.1
|
||||
|
||||
cl_int CL_API_CALL clGetDeviceAndHostTimer(cl_device_id device,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -54,6 +54,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
|||
|
||||
void expectMemoryEqual(void *gfxAddress, const void *srcAddress, size_t length);
|
||||
void expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length);
|
||||
bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override;
|
||||
|
||||
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
|
||||
|
||||
|
@ -124,7 +125,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
|
|||
size_t getPreferredTagPoolSize() const override { return 1; }
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL void expectMemory(void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
|
||||
bool dumpAubNonWritable = false;
|
||||
ExternalAllocationsContainer externalAllocations;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -690,11 +690,11 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMemoryNotEqual(void *gfxAddres
|
|||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(void *gfxAddress, const void *srcAddress,
|
||||
bool AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(const void *gfxAddress, const void *srcAddress,
|
||||
size_t length, uint32_t compareOperation) {
|
||||
if (hardwareContext) {
|
||||
hardwareContext->expectMemory(reinterpret_cast<uint64_t>(gfxAddress), srcAddress, length, compareOperation);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset, uint64_t entryBits) {
|
||||
|
@ -708,6 +708,8 @@ void AUBCommandStreamReceiverHw<GfxFamily>::expectMemory(void *gfxAddress, const
|
|||
};
|
||||
|
||||
this->ppgtt->pageWalk(reinterpret_cast<uintptr_t>(gfxAddress), length, 0, PageTableEntry::nonValidBits, walker, MemoryBanks::BankNotSpecified);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -392,4 +392,9 @@ TagAllocator<TimestampPacket> *CommandStreamReceiver::getTimestampPacketAllocato
|
|||
return timestampPacketAllocator.get();
|
||||
}
|
||||
|
||||
bool CommandStreamReceiver::expectMemory(const void *gfxAddress, const void *srcAddress,
|
||||
size_t length, uint32_t compareOperation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -168,6 +168,8 @@ class CommandStreamReceiver {
|
|||
TagAllocator<HwPerfCounter> *getEventPerfCountAllocator();
|
||||
TagAllocator<TimestampPacket> *getTimestampPacketAllocator();
|
||||
|
||||
virtual bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation);
|
||||
|
||||
protected:
|
||||
void cleanupResources();
|
||||
void setDisableL3Cache(bool val) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2017-2018 Intel Corporation
|
||||
# Copyright (C) 2017-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
@ -59,6 +59,7 @@ set(IGDRCL_SRCS_tests_api
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/cl_enqueue_svm_unmap_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_enqueue_task_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_enqueue_unmap_mem_object_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_enqueue_verify_memory.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_enqueue_wait_for_events_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_enqueue_write_buffer_rect_tests.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cl_enqueue_write_buffer_tests.inl
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -18,6 +18,7 @@
|
|||
#include "unit_tests/api/cl_enqueue_svm_unmap_tests.inl"
|
||||
#include "unit_tests/api/cl_enqueue_task_tests.inl"
|
||||
#include "unit_tests/api/cl_enqueue_unmap_mem_object_tests.inl"
|
||||
#include "unit_tests/api/cl_enqueue_verify_memory.inl"
|
||||
#include "unit_tests/api/cl_enqueue_wait_for_events_tests.inl"
|
||||
#include "unit_tests/api/cl_enqueue_write_buffer_rect_tests.inl"
|
||||
#include "unit_tests/api/cl_enqueue_write_buffer_tests.inl"
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "public/cl_ext_private.h"
|
||||
#include "runtime/aub_mem_dump/aub_services.h"
|
||||
#include "unit_tests/api/cl_api_tests.h"
|
||||
#include "unit_tests/mocks/mock_csr.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
TEST(CheckVerifyMemoryRelatedApiConstants, givenVerifyMemoryRelatedApiConstantsWhenVerifyingTheirValueThenCorrectValuesAreReturned) {
|
||||
EXPECT_EQ(CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual, CL_MEM_COMPARE_EQUAL);
|
||||
EXPECT_EQ(CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual, CL_MEM_COMPARE_NOT_EQUAL);
|
||||
}
|
||||
|
||||
struct clEnqueueVerifyMemorySettings {
|
||||
const cl_uint comparisonMode = CL_MEM_COMPARE_EQUAL;
|
||||
const size_t bufferSize = 1;
|
||||
static constexpr size_t expectedSize = 1;
|
||||
int expected[expectedSize];
|
||||
// Use any valid pointer as gpu address because non aub tests will not actually validate the memory
|
||||
void *gpuAddress = expected;
|
||||
};
|
||||
|
||||
class clEnqueueVerifyMemoryTests : public api_tests,
|
||||
public clEnqueueVerifyMemorySettings {
|
||||
};
|
||||
|
||||
TEST_F(clEnqueueVerifyMemoryTests, givenSizeOfComparisonEqualZeroWhenCallingVerifyMemoryThenErrorIsReturned) {
|
||||
cl_int retval = clEnqueueVerifyMemory(nullptr, nullptr, nullptr, 0, comparisonMode);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retval);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueVerifyMemoryTests, givenNullExpectedDataWhenCallingVerifyMemoryThenErrorIsReturned) {
|
||||
cl_int retval = clEnqueueVerifyMemory(nullptr, nullptr, nullptr, expectedSize, comparisonMode);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retval);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueVerifyMemoryTests, givenInvalidAllocationPointerWhenCallingVerifyMemoryThenErrorIsReturned) {
|
||||
cl_int retval = clEnqueueVerifyMemory(nullptr, nullptr, expected, expectedSize, comparisonMode);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retval);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueVerifyMemoryTests, givenInvalidCommandQueueWhenCallingVerifyMemoryThenErrorIsReturned) {
|
||||
cl_int retval = clEnqueueVerifyMemory(nullptr, gpuAddress, expected, expectedSize, comparisonMode);
|
||||
EXPECT_EQ(CL_INVALID_COMMAND_QUEUE, retval);
|
||||
}
|
||||
|
||||
TEST_F(clEnqueueVerifyMemoryTests, givenCommandQueueWithoutAubCsrWhenCallingVerifyMemoryThenErrorIsReturned) {
|
||||
cl_int retval = clEnqueueVerifyMemory(pCommandQueue, gpuAddress, expected, expectedSize, comparisonMode);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retval);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct MockCsrWithExpectMemory : MockCsr<GfxFamily> {
|
||||
MockCsrWithExpectMemory() = delete;
|
||||
MockCsrWithExpectMemory(const HardwareInfo &hwInfoIn) = delete;
|
||||
MockCsrWithExpectMemory(int32_t &execStamp, ExecutionEnvironment &executionEnvironment)
|
||||
: MockCsr<GfxFamily>(execStamp, executionEnvironment) {
|
||||
}
|
||||
bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
HWTEST_F(clEnqueueVerifyMemoryTests, givenCommandQueueWithMockAubCsrWhenCallingVerifyMemoryThenSuccessIsReturned) {
|
||||
std::unique_ptr<MockDevice> mockDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
|
||||
int32_t executionStamp = 0;
|
||||
auto *mockCsr = new MockCsrWithExpectMemory<FamilyType>(executionStamp, *mockDevice.get()->executionEnvironment);
|
||||
mockDevice.get()->resetCommandStreamReceiver(mockCsr);
|
||||
CommandQueue cmdQ(nullptr, mockDevice.get(), 0);
|
||||
|
||||
cl_int retval = clEnqueueVerifyMemory(&cmdQ, gpuAddress, expected, expectedSize, comparisonMode);
|
||||
EXPECT_EQ(CL_SUCCESS, retval);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2017-2018 Intel Corporation
|
||||
# Copyright (C) 2017-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
@ -18,6 +18,8 @@ target_sources(igdrcl_aub_tests PRIVATE
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_read_buffer_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_read_buffer_rect_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_read_image_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_verify_memory_buffer_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_verify_memory_image_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_with_timestamp_packet_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_buffer_aub_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_buffer_rect_aub_tests.cpp
|
||||
|
@ -25,3 +27,5 @@ target_sources(igdrcl_aub_tests PRIVATE
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_copy_read_buffer_aub_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_write_image_aub_tests.cpp
|
||||
)
|
||||
|
||||
add_subdirectories()
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/api/api.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/mem_obj/buffer.h"
|
||||
#include "unit_tests/aub_tests/command_queue/command_enqueue_fixture.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "unit_tests/helpers/unit_test_helper.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
struct TestDataItem {
|
||||
uint8_t *item;
|
||||
uint8_t *itemWrongSmaller;
|
||||
uint8_t *itemWrongGreater;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct VerifyMemoryBufferHw
|
||||
: public CommandEnqueueAUBFixture,
|
||||
public ::testing::TestWithParam<std::tuple<TestDataItem, size_t, uint64_t>> {
|
||||
|
||||
void SetUp() override {
|
||||
CommandEnqueueAUBFixture::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
CommandEnqueueAUBFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
cl_int testClInt = 5;
|
||||
cl_int testClIntSmaller = 4;
|
||||
cl_int testClIntGreater = 6;
|
||||
cl_float testClFloat = 20.0;
|
||||
cl_float testClFloatSmaller = 19.5;
|
||||
cl_float testClFloatGreater = 20.5;
|
||||
|
||||
TestDataItem testDataItemTable[] = {
|
||||
{reinterpret_cast<uint8_t *>(&testClInt),
|
||||
reinterpret_cast<uint8_t *>(&testClIntSmaller),
|
||||
reinterpret_cast<uint8_t *>(&testClIntGreater),
|
||||
sizeof(testClInt)},
|
||||
{reinterpret_cast<uint8_t *>(&testClFloat),
|
||||
reinterpret_cast<uint8_t *>(&testClFloatSmaller),
|
||||
reinterpret_cast<uint8_t *>(&testClFloatGreater),
|
||||
sizeof(testClFloat)}};
|
||||
|
||||
size_t testDataSizeTable[] = {
|
||||
16,
|
||||
MemoryConstants::cacheLineSize};
|
||||
|
||||
cl_mem_flags testFlagsTable[] = {
|
||||
0,
|
||||
CL_MEM_COPY_HOST_PTR};
|
||||
|
||||
HWTEST_P(VerifyMemoryBufferHw, givenDifferentBuffersWhenValidatingMemoryThenSuccessIsReturned) {
|
||||
const auto &testDataItem = std::get<0>(GetParam());
|
||||
const auto &testDataSize = std::get<1>(GetParam());
|
||||
EXPECT_FALSE(testDataSize < testDataItem.size);
|
||||
const auto &flags = std::get<2>(GetParam());
|
||||
const auto usesHostPointer = ((flags & CL_MEM_USE_HOST_PTR) ||
|
||||
(flags & CL_MEM_COPY_HOST_PTR));
|
||||
|
||||
DebugManagerStateRestore restore;
|
||||
DebugManager.flags.DisableZeroCopyForBuffers.set(true);
|
||||
|
||||
// for each buffer size check also one object smaller and one object greater
|
||||
for (auto dataSize = testDataSize - testDataItem.size;
|
||||
dataSize <= testDataSize + testDataItem.size;
|
||||
dataSize += testDataItem.size) {
|
||||
|
||||
std::unique_ptr<uint8_t[]> bufferContent(new uint8_t[dataSize]);
|
||||
std::unique_ptr<uint8_t[]> validContent(new uint8_t[dataSize]);
|
||||
std::unique_ptr<uint8_t[]> invalidContent1(new uint8_t[dataSize]);
|
||||
std::unique_ptr<uint8_t[]> invalidContent2(new uint8_t[dataSize]);
|
||||
|
||||
for (size_t offset = 0; offset < dataSize; offset += testDataItem.size) {
|
||||
for (size_t itemOffset = 0; itemOffset < testDataItem.size; itemOffset++) {
|
||||
bufferContent.get()[offset + itemOffset] = testDataItem.item[itemOffset];
|
||||
validContent.get()[offset + itemOffset] = testDataItem.item[itemOffset];
|
||||
invalidContent1.get()[offset + itemOffset] = testDataItem.item[itemOffset];
|
||||
invalidContent2.get()[offset + itemOffset] = testDataItem.item[itemOffset];
|
||||
}
|
||||
}
|
||||
|
||||
// set last item for invalid contents
|
||||
size_t offset = dataSize - testDataItem.size;
|
||||
for (size_t itemOffset = 0; itemOffset < testDataItem.size; itemOffset++) {
|
||||
invalidContent1.get()[offset + itemOffset] = testDataItem.itemWrongSmaller[itemOffset];
|
||||
invalidContent2.get()[offset + itemOffset] = testDataItem.itemWrongGreater[itemOffset];
|
||||
}
|
||||
|
||||
MockContext context(&this->pCmdQ->getDevice());
|
||||
cl_int retVal = CL_INVALID_VALUE;
|
||||
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(
|
||||
&context,
|
||||
flags,
|
||||
dataSize,
|
||||
(usesHostPointer ? bufferContent.get() : nullptr),
|
||||
retVal));
|
||||
EXPECT_NE(nullptr, buffer);
|
||||
|
||||
if (!usesHostPointer) {
|
||||
retVal = pCmdQ->enqueueFillBuffer(
|
||||
buffer.get(),
|
||||
testDataItem.item,
|
||||
testDataItem.size,
|
||||
0,
|
||||
dataSize,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
auto mappedAddress = clEnqueueMapBuffer(pCmdQ, buffer.get(), CL_TRUE, CL_MAP_READ, 0, dataSize, 0, nullptr, nullptr, nullptr);
|
||||
|
||||
retVal = clEnqueueVerifyMemory(pCmdQ, mappedAddress, validContent.get(), dataSize, CL_MEM_COMPARE_EQUAL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
if (UnitTestHelper<FamilyType>::isExpectMemoryNotEqualSupported()) {
|
||||
retVal = clEnqueueVerifyMemory(pCmdQ, mappedAddress, invalidContent1.get(), dataSize, CL_MEM_COMPARE_NOT_EQUAL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
retVal = clEnqueueVerifyMemory(pCmdQ, mappedAddress, invalidContent2.get(), dataSize, CL_MEM_COMPARE_NOT_EQUAL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(VerifyMemoryBuffer,
|
||||
VerifyMemoryBufferHw,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(testDataItemTable),
|
||||
::testing::ValuesIn(testDataSizeTable),
|
||||
::testing::ValuesIn(testFlagsTable)));
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/api/api.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/ptr_math.h"
|
||||
#include "runtime/mem_obj/image.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "unit_tests/aub_tests/command_queue/command_enqueue_fixture.h"
|
||||
#include "unit_tests/helpers/unit_test_helper.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "test.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
struct TestOffset {
|
||||
size_t offset[3];
|
||||
};
|
||||
|
||||
struct VerifyMemoryImageHw
|
||||
: public CommandEnqueueAUBFixture,
|
||||
public ::testing::TestWithParam<TestOffset> {
|
||||
|
||||
void SetUp() override {
|
||||
CommandEnqueueAUBFixture::SetUp();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
CommandEnqueueAUBFixture::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
TestOffset testInput[] = {
|
||||
{{0, 0, 0}},
|
||||
{{1, 2, 3}},
|
||||
{{3, 2, 1}},
|
||||
{{5, 5, 5}}};
|
||||
|
||||
HWTEST_P(VerifyMemoryImageHw, givenDifferentImagesWhenValidatingMemoryThenSuccessIsReturned) {
|
||||
cl_image_format imageFormat;
|
||||
cl_image_desc imageDesc;
|
||||
|
||||
// clang-format off
|
||||
imageFormat.image_channel_data_type = CL_UNSIGNED_INT32;
|
||||
imageFormat.image_channel_order = CL_RGBA;
|
||||
|
||||
imageDesc.image_type = CL_MEM_OBJECT_IMAGE3D;
|
||||
imageDesc.image_width = 10;
|
||||
imageDesc.image_height = 19;
|
||||
imageDesc.image_depth = 7;
|
||||
imageDesc.image_array_size = 1;
|
||||
imageDesc.image_row_pitch = 0;
|
||||
imageDesc.image_slice_pitch = 0;
|
||||
imageDesc.num_mip_levels = 0;
|
||||
imageDesc.num_samples = 0;
|
||||
imageDesc.mem_object = NULL;
|
||||
// clang-format on
|
||||
|
||||
// data per channel multplied by number of channels
|
||||
size_t elementSize = 16;
|
||||
|
||||
cl_mem_flags flags = CL_MEM_READ_ONLY;
|
||||
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat);
|
||||
auto retVal = CL_INVALID_VALUE;
|
||||
std::unique_ptr<Image> image(Image::create(
|
||||
context,
|
||||
flags,
|
||||
surfaceFormat,
|
||||
&imageDesc,
|
||||
nullptr,
|
||||
retVal));
|
||||
EXPECT_NE(nullptr, image);
|
||||
|
||||
auto sizeMemory = image->getSize();
|
||||
EXPECT_GT(sizeMemory, 0u);
|
||||
|
||||
std::unique_ptr<uint8_t> srcMemory(new uint8_t[elementSize]);
|
||||
memset(srcMemory.get(), 0xAB, elementSize);
|
||||
memset(image->getCpuAddress(), 0xAB, sizeMemory);
|
||||
|
||||
const size_t *origin = GetParam().offset;
|
||||
|
||||
const size_t region[] = {
|
||||
imageDesc.image_width - origin[0],
|
||||
imageDesc.image_height - origin[1],
|
||||
imageDesc.image_depth - origin[2]};
|
||||
|
||||
uint32_t fillValues[] = {0x3f800000, 0x00000000, 0x3f555555, 0x3f2aaaaa};
|
||||
retVal = pCmdQ->enqueueFillImage(
|
||||
image.get(),
|
||||
fillValues,
|
||||
origin,
|
||||
region,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
size_t imgOrigin[] = {0, 0, 0};
|
||||
size_t imgRegion[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_depth};
|
||||
|
||||
size_t mappedRowPitch;
|
||||
size_t mappedSlicePitch;
|
||||
auto mappedAddress = clEnqueueMapImage(pCmdQ, image.get(), CL_TRUE, CL_MAP_READ, imgOrigin, imgRegion,
|
||||
&mappedRowPitch, &mappedSlicePitch, 0, nullptr, nullptr, &retVal);
|
||||
auto pImageData = reinterpret_cast<uint8_t *>(mappedAddress);
|
||||
for (size_t z = 0; z < imageDesc.image_depth; ++z) {
|
||||
for (size_t y = 0; y < imageDesc.image_height; ++y) {
|
||||
for (size_t x = 0; x < imageDesc.image_width; ++x) {
|
||||
void *validData = srcMemory.get();
|
||||
void *invalidData = fillValues;
|
||||
|
||||
if (z >= origin[2] && z < (origin[2] + region[2]) &&
|
||||
y >= origin[1] && y < (origin[1] + region[1]) &&
|
||||
x >= origin[0] && x < (origin[0] + region[0])) {
|
||||
std::swap(validData, invalidData);
|
||||
}
|
||||
|
||||
retVal = clEnqueueVerifyMemory(pCmdQ, &pImageData[x * elementSize], validData, elementSize, CL_MEM_COMPARE_EQUAL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
if (UnitTestHelper<FamilyType>::isExpectMemoryNotEqualSupported()) {
|
||||
retVal = clEnqueueVerifyMemory(pCmdQ, &pImageData[x * elementSize], invalidData, elementSize,
|
||||
CL_MEM_COMPARE_NOT_EQUAL);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
}
|
||||
pImageData = ptrOffset(pImageData, mappedRowPitch);
|
||||
}
|
||||
pImageData = ptrOffset(pImageData, mappedSlicePitch - (mappedRowPitch * imageDesc.image_height));
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(VerifyMemoryImage,
|
||||
VerifyMemoryImageHw,
|
||||
::testing::ValuesIn(testInput));
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -108,7 +108,8 @@ HWTEST_F(AubMemDumpTests, writeVerifyOneBytePPGTT) {
|
|||
OCLRT::AubHelperHw<FamilyType> aubHelperHw(false);
|
||||
AUB::reserveAddressPPGTT(aubFile, gAddress, sizeof(byte), physAddress, 7, aubHelperHw);
|
||||
AUB::addMemoryWrite(aubFile, physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal);
|
||||
aubFile.expectMemory(physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal, 0);
|
||||
aubFile.expectMemory(physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal,
|
||||
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual);
|
||||
|
||||
aubFile.fileHandle.close();
|
||||
}
|
||||
|
@ -130,7 +131,8 @@ HWTEST_F(AubMemDumpTests, writeVerifyOneByteGGTT) {
|
|||
AubGTTData data = {true, false};
|
||||
AUB::reserveAddressGGTT(aubFile, &byte, sizeof(byte), physAddress, data);
|
||||
AUB::addMemoryWrite(aubFile, physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal);
|
||||
aubFile.expectMemory(physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal, 0);
|
||||
aubFile.expectMemory(physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal,
|
||||
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual);
|
||||
|
||||
aubFile.fileHandle.close();
|
||||
}
|
||||
|
@ -154,7 +156,8 @@ HWTEST_F(AubMemDumpTests, writeVerifySevenBytesPPGTT) {
|
|||
OCLRT::AubHelperHw<FamilyType> aubHelperHw(false);
|
||||
AUB::reserveAddressPPGTT(aubFile, gAddress, sizeof(bytes), physAddress, 7, aubHelperHw);
|
||||
AUB::addMemoryWrite(aubFile, physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal);
|
||||
aubFile.expectMemory(physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal, 0);
|
||||
aubFile.expectMemory(physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal,
|
||||
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual);
|
||||
|
||||
aubFile.fileHandle.close();
|
||||
}
|
||||
|
@ -176,7 +179,8 @@ HWTEST_F(AubMemDumpTests, writeVerifySevenBytesGGTT) {
|
|||
AubGTTData data = {true, false};
|
||||
AUB::reserveAddressGGTT(aubFile, bytes, sizeof(bytes), physAddress, data);
|
||||
AUB::addMemoryWrite(aubFile, physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal);
|
||||
aubFile.expectMemory(physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal, 0);
|
||||
aubFile.expectMemory(physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal,
|
||||
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual);
|
||||
|
||||
aubFile.fileHandle.close();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -36,11 +36,10 @@ class AUBFixture : public CommandQueueHwFixture {
|
|||
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType).name;
|
||||
|
||||
executionEnvironment = new ExecutionEnvironment;
|
||||
|
||||
if (testMode == TestMode::AubTests) {
|
||||
this->csr = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment);
|
||||
} else if (testMode == TestMode::AubTestsWithTbx) {
|
||||
if (testMode == TestMode::AubTestsWithTbx) {
|
||||
this->csr = TbxCommandStreamReceiver::create(hwInfo, true, *executionEnvironment);
|
||||
} else {
|
||||
this->csr = AUBCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment);
|
||||
}
|
||||
|
||||
executionEnvironment->commandStreamReceivers.resize(deviceIndex + 1);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2017-2018 Intel Corporation
|
||||
# Copyright (C) 2017-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
@ -8,6 +8,7 @@ if(TESTS_GEN10)
|
|||
target_sources(igdrcl_aub_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_configuration_gen10.cpp
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/gen10/unit_test_helper_gen10.cpp
|
||||
)
|
||||
add_subdirectories()
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2018 Intel Corporation
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
@ -8,6 +8,7 @@ if(TESTS_GEN8)
|
|||
target_sources(igdrcl_aub_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_configuration_gen8.cpp
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/gen8/unit_test_helper_gen8.cpp
|
||||
)
|
||||
add_subdirectories()
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2018 Intel Corporation
|
||||
# Copyright (C) 2018-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
@ -7,6 +7,7 @@
|
|||
if(TESTS_GEN9)
|
||||
target_sources(igdrcl_aub_tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/aub_tests_configuration_gen9.cpp
|
||||
${IGDRCL_SOURCE_DIR}/unit_tests/gen9/unit_test_helper_gen9.cpp
|
||||
)
|
||||
add_subdirectories()
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -813,9 +813,10 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenAskedForMemoryExpectation
|
|||
public:
|
||||
using AUBCommandStreamReceiverHw<FamilyType>::AUBCommandStreamReceiverHw;
|
||||
|
||||
void expectMemory(void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override {
|
||||
bool expectMemory(const void *gfxAddress, const void *srcAddress, size_t length, uint32_t compareOperation) override {
|
||||
inputCompareOperation = compareOperation;
|
||||
AUBCommandStreamReceiverHw<FamilyType>::expectMemory(gfxAddress, srcAddress, length, compareOperation);
|
||||
return true;
|
||||
}
|
||||
uint32_t inputCompareOperation = 0;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -21,5 +21,7 @@ struct UnitTestHelper {
|
|||
static bool isPageTableManagerSupported(const HardwareInfo &hwInfo);
|
||||
|
||||
static bool isTimestampPacketWriteSupported();
|
||||
|
||||
static bool isExpectMemoryNotEqualSupported();
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
|
@ -29,4 +29,9 @@ template <typename GfxFamily>
|
|||
bool UnitTestHelper<GfxFamily>::isTimestampPacketWriteSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool UnitTestHelper<GfxFamily>::isExpectMemoryNotEqualSupported() {
|
||||
return false;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
|
Loading…
Reference in New Issue