refactor: add param rootDeviceEnvironment to calculateNumThreadsPerThreadGroup

Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
Katarzyna Cencelewska
2024-03-21 18:54:41 +00:00
committed by Compute-Runtime-Automation
parent ec009cf9e3
commit dd1d52259e
30 changed files with 231 additions and 180 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Intel Corporation
* Copyright (C) 2022-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,7 @@
#include "shared/source/kernel/local_ids_cache.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/gfx_core_helper.h"
@@ -34,12 +35,13 @@ std::unique_lock<std::mutex> LocalIdsCache::lock() {
return std::unique_lock<std::mutex>(setLocalIdsMutex);
}
size_t LocalIdsCache::getLocalIdsSizeForGroup(const Vec3<uint16_t> &group, const GfxCoreHelper &gfxCoreHelper) const {
size_t LocalIdsCache::getLocalIdsSizeForGroup(const Vec3<uint16_t> &group, const RootDeviceEnvironment &rootDeviceEnvironment) const {
const auto numElementsInGroup = static_cast<uint32_t>(Math::computeTotalElementsCount({group[0], group[1], group[2]}));
if (isSimd1(simdSize)) {
return static_cast<size_t>(numElementsInGroup * localIdsSizePerThread);
}
const auto numberOfThreads = gfxCoreHelper.calculateNumThreadsPerThreadGroup(simdSize, numElementsInGroup, grfSize, false);
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<NEO::GfxCoreHelper>();
const auto numberOfThreads = gfxCoreHelper.calculateNumThreadsPerThreadGroup(simdSize, numElementsInGroup, grfSize, false, rootDeviceEnvironment);
return static_cast<size_t>(numberOfThreads * localIdsSizePerThread);
}
@@ -52,7 +54,7 @@ void LocalIdsCache::setLocalIdsForEntry(LocalIdsCacheEntry &entry, void *destina
std::memcpy(destination, entry.localIdsData, entry.localIdsSize);
}
void LocalIdsCache::setLocalIdsForGroup(const Vec3<uint16_t> &group, void *destination, const GfxCoreHelper &gfxCoreHelper) {
void LocalIdsCache::setLocalIdsForGroup(const Vec3<uint16_t> &group, void *destination, const RootDeviceEnvironment &rootDeviceEnvironment) {
auto setLocalIdsLock = lock();
LocalIdsCacheEntry *leastAccessedEntry = &cache[0];
for (auto &cacheEntry : cache) {
@@ -65,12 +67,12 @@ void LocalIdsCache::setLocalIdsForGroup(const Vec3<uint16_t> &group, void *desti
}
}
commitNewEntry(*leastAccessedEntry, group, gfxCoreHelper);
commitNewEntry(*leastAccessedEntry, group, rootDeviceEnvironment);
setLocalIdsForEntry(*leastAccessedEntry, destination);
}
void LocalIdsCache::commitNewEntry(LocalIdsCacheEntry &entry, const Vec3<uint16_t> &group, const GfxCoreHelper &gfxCoreHelper) {
entry.localIdsSize = getLocalIdsSizeForGroup(group, gfxCoreHelper);
void LocalIdsCache::commitNewEntry(LocalIdsCacheEntry &entry, const Vec3<uint16_t> &group, const RootDeviceEnvironment &rootDeviceEnvironment) {
entry.localIdsSize = getLocalIdsSizeForGroup(group, rootDeviceEnvironment);
entry.groupSize = group;
entry.accessCounter = 0U;
if (entry.localIdsSize > entry.localIdsSizeAllocated) {
@@ -79,7 +81,7 @@ void LocalIdsCache::commitNewEntry(LocalIdsCacheEntry &entry, const Vec3<uint16_
entry.localIdsSizeAllocated = entry.localIdsSize;
}
NEO::generateLocalIDs(entry.localIdsData, static_cast<uint16_t>(simdSize),
{group[0], group[1], group[2]}, wgDimOrder, usesOnlyImages, grfSize, gfxCoreHelper);
{group[0], group[1], group[2]}, wgDimOrder, usesOnlyImages, grfSize, rootDeviceEnvironment);
}
} // namespace NEO