mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
26 lines
725 B
Plaintext
26 lines
725 B
Plaintext
|
|
/*
|
||
|
|
* 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;
|
||
|
|
}
|