mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
Add multithread test for blit enqueue
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a79b5184e2
commit
a00ad8cb2b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "opencl/test/unit_test/fixtures/image_fixture.h"
|
||||
#include "opencl/test/unit_test/mocks/mock_buffer.h"
|
||||
|
||||
#include <future>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
typedef HelloWorldTest<HelloWorldFixtureFactory> IOQTaskTestsMt;
|
||||
@@ -224,3 +226,56 @@ TEST_F(IOQTaskTestsMt, GivenMultipleThreadsWhenMappingImageThenEventsAreComplete
|
||||
retVal = clReleaseEvent(outputEvent);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(IOQTaskTestsMt, givenBlitterWhenCopyUsingMultipleThreadsThenSuccessReturned) {
|
||||
auto hwInfo = *defaultHwInfo;
|
||||
hwInfo.capabilityTable.blitterOperationsSupported = true;
|
||||
REQUIRE_FULL_BLITTER_OR_SKIP(&hwInfo);
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.EnableBlitterForEnqueueOperations.set(1);
|
||||
DebugManager.flags.DoCpuCopyOnReadBuffer.set(0);
|
||||
|
||||
constexpr uint32_t numThreads = 32;
|
||||
std::atomic_uint32_t barrier = numThreads;
|
||||
std::array<std::future<void>, numThreads> threads;
|
||||
|
||||
auto device = MockClDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo, rootDeviceIndex);
|
||||
MockClDevice clDevice(device);
|
||||
auto cmdQ = createCommandQueue(&clDevice);
|
||||
EXPECT_EQ(cmdQ->taskCount, 0u);
|
||||
EXPECT_EQ(cmdQ->getGpgpuCommandStreamReceiver().peekTaskCount(), 0u);
|
||||
EXPECT_EQ(cmdQ->peekBcsTaskCount(aub_stream::EngineType::ENGINE_BCS), 0u);
|
||||
auto buffer = std::unique_ptr<Buffer>(BufferHelper<>::create());
|
||||
|
||||
for (auto &thread : threads) {
|
||||
thread = std::async(std::launch::async, [&]() {
|
||||
auto alignedReadPtr = alignedMalloc(BufferDefaults::sizeInBytes, MemoryConstants::cacheLineSize);
|
||||
barrier.fetch_sub(1u);
|
||||
while (barrier.load() != 0u) {
|
||||
std::this_thread::yield();
|
||||
}
|
||||
auto retVal = EnqueueReadBufferHelper<>::enqueueReadBuffer(cmdQ,
|
||||
buffer.get(),
|
||||
CL_TRUE,
|
||||
0,
|
||||
BufferDefaults::sizeInBytes,
|
||||
alignedReadPtr,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
alignedFree(alignedReadPtr);
|
||||
});
|
||||
}
|
||||
for (auto &thread : threads) {
|
||||
thread.get();
|
||||
}
|
||||
|
||||
EXPECT_EQ(cmdQ->taskCount, 0u);
|
||||
EXPECT_EQ(cmdQ->getGpgpuCommandStreamReceiver().peekTaskCount(), 0u);
|
||||
EXPECT_EQ(cmdQ->peekBcsTaskCount(aub_stream::EngineType::ENGINE_BCS), numThreads);
|
||||
|
||||
clReleaseCommandQueue(cmdQ);
|
||||
}
|
||||
Reference in New Issue
Block a user