mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
test: correct setting out clEvent in mocked enqueue marker
move non-trivial definitions of MockCommandQueue methods to cpp file Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
b8faf7f092
commit
fefdcc5533
@@ -1395,6 +1395,7 @@ TEST(CommandQueue, givenEnqueuesForSharedObjectsWithImageWhenUsingSharingHandler
|
||||
MockContext context;
|
||||
MockCommandQueue cmdQ(&context, mockDevice.get(), 0, false);
|
||||
MockSharingHandler *mockSharingHandler = new MockSharingHandler;
|
||||
constexpr cl_command_type expectedCmd = CL_COMMAND_NDRANGE_KERNEL;
|
||||
|
||||
auto image = std::unique_ptr<Image>(ImageHelperUlt<Image2dDefaults>::create(&context));
|
||||
image->setSharingHandler(mockSharingHandler);
|
||||
@@ -1403,19 +1404,21 @@ TEST(CommandQueue, givenEnqueuesForSharedObjectsWithImageWhenUsingSharingHandler
|
||||
cl_uint numObjects = 1;
|
||||
cl_mem *memObjects = &memObject;
|
||||
|
||||
Event *eventAcquire = new Event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 1, 5);
|
||||
cl_event clEventAquire = eventAcquire;
|
||||
cl_int result = cmdQ.enqueueAcquireSharedObjects(numObjects, memObjects, 0, nullptr, &clEventAquire, 0);
|
||||
cl_event clEventAquire = nullptr;
|
||||
cl_int result = cmdQ.enqueueAcquireSharedObjects(numObjects, memObjects, 0, nullptr, &clEventAquire, expectedCmd);
|
||||
EXPECT_EQ(result, CL_SUCCESS);
|
||||
ASSERT_NE(clEventAquire, nullptr);
|
||||
eventAcquire->release();
|
||||
EXPECT_NE(clEventAquire, nullptr);
|
||||
cl_command_type actualCmd = castToObjectOrAbort<Event>(clEventAquire)->getCommandType();
|
||||
EXPECT_EQ(expectedCmd, actualCmd);
|
||||
clReleaseEvent(clEventAquire);
|
||||
|
||||
Event *eventRelease = new Event(&cmdQ, CL_COMMAND_NDRANGE_KERNEL, 1, 5);
|
||||
cl_event clEventRelease = eventRelease;
|
||||
result = cmdQ.enqueueReleaseSharedObjects(numObjects, memObjects, 0, nullptr, &clEventRelease, 0);
|
||||
cl_event clEventRelease = nullptr;
|
||||
result = cmdQ.enqueueReleaseSharedObjects(numObjects, memObjects, 0, nullptr, &clEventRelease, expectedCmd);
|
||||
EXPECT_EQ(result, CL_SUCCESS);
|
||||
ASSERT_NE(clEventRelease, nullptr);
|
||||
eventRelease->release();
|
||||
EXPECT_NE(clEventRelease, nullptr);
|
||||
actualCmd = castToObjectOrAbort<Event>(clEventRelease)->getCommandType();
|
||||
EXPECT_EQ(expectedCmd, actualCmd);
|
||||
clReleaseEvent(clEventRelease);
|
||||
}
|
||||
|
||||
TEST(CommandQueue, givenEnqueueAcquireSharedObjectsWhenIncorrectArgumentsThenReturnProperError) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2018-2024 Intel Corporation
|
||||
# Copyright (C) 2018-2025 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -13,6 +13,7 @@ set(IGDRCL_SRCS_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_cl_device.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_cl_device.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_cl_execution_environment.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_queue.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_command_queue.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_context.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_context.h
|
||||
|
||||
54
opencl/test/unit_test/mocks/mock_command_queue.cpp
Normal file
54
opencl/test/unit_test/mocks/mock_command_queue.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_command_queue.h"
|
||||
|
||||
#include "opencl/source/event/event.h"
|
||||
#include "opencl/source/event/event_builder.h"
|
||||
|
||||
namespace NEO {
|
||||
void MockCommandQueue::insertBcsEngine(aub_stream::EngineType bcsEngineType) {
|
||||
const auto index = NEO::EngineHelpers::getBcsIndex(bcsEngineType);
|
||||
const auto engine = &getDevice().getEngine(bcsEngineType, EngineUsage::regular);
|
||||
bcsEngines[index] = engine;
|
||||
bcsQueueEngineType = bcsEngineType;
|
||||
bcsInitialized = true;
|
||||
}
|
||||
|
||||
size_t MockCommandQueue::countBcsEngines() const {
|
||||
return std::count_if(bcsEngines.begin(), bcsEngines.end(), [](const EngineControl *engine) {
|
||||
return engine != nullptr && engine->getEngineUsage() == EngineUsage::regular;
|
||||
});
|
||||
}
|
||||
|
||||
MockCommandQueue::MockCommandQueue() : CommandQueue(nullptr, nullptr, 0, false) {}
|
||||
MockCommandQueue::MockCommandQueue(Context &context) : MockCommandQueue(&context, context.getDevice(0), nullptr, false) {}
|
||||
MockCommandQueue::MockCommandQueue(Context *context, ClDevice *device, const cl_queue_properties *props, bool internalUsage)
|
||||
: CommandQueue(context, device, props, internalUsage) {
|
||||
}
|
||||
|
||||
cl_int MockCommandQueue::enqueueMarkerWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) {
|
||||
if (event) {
|
||||
EventBuilder eventBuilder;
|
||||
eventBuilder.create<Event>(this, CL_COMMAND_MARKER, CompletionStamp::notReady, 0);
|
||||
auto eventObj = eventBuilder.getEvent();
|
||||
*event = eventObj;
|
||||
}
|
||||
enqueueMarkerWithWaitListCalled = true;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
bool MockCommandQueue::isCompleted(TaskCountType gpgpuTaskCount, const Range<CopyEngineState> &bcsStates) {
|
||||
isCompletedCalled++;
|
||||
|
||||
if (!device || !getGpgpuCommandStreamReceiver().getTagAddress()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return CommandQueue::isCompleted(gpgpuTaskCount, bcsStates);
|
||||
}
|
||||
} // namespace NEO
|
||||
@@ -7,14 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/command_stream/wait_status.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/test/common/libult/ult_command_stream_receiver.h"
|
||||
|
||||
#include "opencl/source/command_queue/command_queue_hw.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MockCommandQueue - Core implementation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -59,19 +55,9 @@ class MockCommandQueue : public CommandQueue {
|
||||
bcsQueueEngineType = std::nullopt;
|
||||
}
|
||||
|
||||
void insertBcsEngine(aub_stream::EngineType bcsEngineType) {
|
||||
const auto index = NEO::EngineHelpers::getBcsIndex(bcsEngineType);
|
||||
const auto engine = &getDevice().getEngine(bcsEngineType, EngineUsage::regular);
|
||||
bcsEngines[index] = engine;
|
||||
bcsQueueEngineType = bcsEngineType;
|
||||
bcsInitialized = true;
|
||||
}
|
||||
void insertBcsEngine(aub_stream::EngineType bcsEngineType);
|
||||
|
||||
size_t countBcsEngines() const {
|
||||
return std::count_if(bcsEngines.begin(), bcsEngines.end(), [](const EngineControl *engine) {
|
||||
return engine != nullptr && engine->getEngineUsage() == EngineUsage::regular;
|
||||
});
|
||||
}
|
||||
size_t countBcsEngines() const;
|
||||
|
||||
void setProfilingEnabled() {
|
||||
commandQueueProperties |= CL_QUEUE_PROFILING_ENABLE;
|
||||
@@ -79,18 +65,16 @@ class MockCommandQueue : public CommandQueue {
|
||||
void setOoqEnabled() {
|
||||
commandQueueProperties |= CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
|
||||
}
|
||||
MockCommandQueue() : CommandQueue(nullptr, nullptr, 0, false) {}
|
||||
MockCommandQueue(Context &context) : MockCommandQueue(&context, context.getDevice(0), nullptr, false) {}
|
||||
MockCommandQueue(Context *context, ClDevice *device, const cl_queue_properties *props, bool internalUsage)
|
||||
: CommandQueue(context, device, props, internalUsage) {
|
||||
}
|
||||
MockCommandQueue();
|
||||
MockCommandQueue(Context &context);
|
||||
MockCommandQueue(Context *context, ClDevice *device, const cl_queue_properties *props, bool internalUsage);
|
||||
|
||||
LinearStream &getCS(size_t minRequiredSize) override {
|
||||
requestedCmdStreamSize = minRequiredSize;
|
||||
return CommandQueue::getCS(minRequiredSize);
|
||||
}
|
||||
|
||||
void releaseIndirectHeap(IndirectHeap::Type heap) override {
|
||||
void releaseIndirectHeap(IndirectHeapType heap) override {
|
||||
releaseIndirectHeapCalled = true;
|
||||
CommandQueue::releaseIndirectHeap(heap);
|
||||
}
|
||||
@@ -171,10 +155,7 @@ class MockCommandQueue : public CommandQueue {
|
||||
cl_int enqueueSVMMemFill(void *svmPtr, const void *pattern, size_t patternSize, size_t size, cl_uint numEventsInWaitList,
|
||||
const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; }
|
||||
|
||||
cl_int enqueueMarkerWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override {
|
||||
enqueueMarkerWithWaitListCalled = true;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
cl_int enqueueMarkerWithWaitList(cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override;
|
||||
|
||||
cl_int enqueueMigrateMemObjects(cl_uint numMemObjects, const cl_mem *memObjects, cl_mem_migration_flags flags,
|
||||
cl_uint numEventsInWaitList, const cl_event *eventWaitList, cl_event *event) override { return CL_SUCCESS; }
|
||||
@@ -257,15 +238,7 @@ class MockCommandQueue : public CommandQueue {
|
||||
return false;
|
||||
};
|
||||
|
||||
bool isCompleted(TaskCountType gpgpuTaskCount, const Range<CopyEngineState> &bcsStates) override {
|
||||
isCompletedCalled++;
|
||||
|
||||
if (!device || !getGpgpuCommandStreamReceiver().getTagAddress()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return CommandQueue::isCompleted(gpgpuTaskCount, bcsStates);
|
||||
}
|
||||
bool isCompleted(TaskCountType gpgpuTaskCount, const Range<CopyEngineState> &bcsStates) override;
|
||||
|
||||
bool enqueueMarkerWithWaitListCalled = false;
|
||||
bool releaseIndirectHeapCalled = false;
|
||||
|
||||
Reference in New Issue
Block a user