Files
compute-runtime/shared/source/program/sync_buffer_handler.inl
Filip Hazubski 8d55bfe21d Implement zeCommandListAppendLaunchCooperativeKernel
Resolves: NEO-4725


Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
2021-03-22 19:26:41 +01:00

26 lines
725 B
C++

/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/memory_manager/memory_manager.h"
template <typename KernelT>
void NEO::SyncBufferHandler::prepareForEnqueue(size_t workGroupsCount, KernelT &kernel) {
auto requiredSize = workGroupsCount;
std::lock_guard<std::mutex> guard(this->mutex);
bool isCurrentBufferFull = (usedBufferSize + requiredSize > bufferSize);
if (isCurrentBufferFull) {
memoryManager.checkGpuUsageAndDestroyGraphicsAllocations(graphicsAllocation);
allocateNewBuffer();
usedBufferSize = 0;
}
kernel.patchSyncBuffer(device, graphicsAllocation, usedBufferSize);
usedBufferSize += requiredSize;
}