Refactor calculating maxMemAllocSize

Signed-off-by: Szymon Morek <szymon.morek@intel.com>
This commit is contained in:
Szymon Morek
2021-08-10 18:52:02 +00:00
committed by Compute-Runtime-Automation
parent a4eb90a933
commit 217d067ad5
10 changed files with 35 additions and 42 deletions

View File

@@ -118,7 +118,6 @@ class Device : public ReferenceTrackedObject<Device> {
std::unique_ptr<SyncBufferHandler> syncBufferHandler;
GraphicsAllocation *getRTMemoryBackedBuffer() { return rtMemoryBackedBuffer; }
void initializeRayTracing();
void reduceMaxMemAllocSize();
virtual uint64_t getGlobalMemorySize(uint32_t deviceBitfield) const;

View File

@@ -7,6 +7,7 @@
#include "shared/source/debugger/debugger.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/memory_manager/memory_manager.h"
@@ -72,6 +73,7 @@ void Device::initializeCaps() {
deviceInfo.maxMemAllocSize = std::min(deviceInfo.globalMemSize, deviceInfo.maxMemAllocSize); // if globalMemSize was reduced for 32b
if (!deviceInfo.sharedSystemAllocationsSupport) {
deviceInfo.maxMemAllocSize = ApiSpecificConfig::getReducedMaxAllocSize(deviceInfo.maxMemAllocSize);
deviceInfo.maxMemAllocSize = std::min(deviceInfo.maxMemAllocSize, this->hardwareCapabilities.maxMemAllocSize);
}
@@ -168,16 +170,4 @@ void Device::initializeCaps() {
deviceInfo.name = deviceName.str();
}
void Device::reduceMaxMemAllocSize() {
deviceInfo.maxMemAllocSize = std::min(deviceInfo.globalMemSize, getGlobalMemorySize(1u));
if (!deviceInfo.sharedSystemAllocationsSupport) {
deviceInfo.maxMemAllocSize /= 2;
deviceInfo.maxMemAllocSize = std::min(deviceInfo.maxMemAllocSize, this->hardwareCapabilities.maxMemAllocSize);
}
// OpenCL 1.2 requires 128MB minimum
deviceInfo.maxMemAllocSize = std::max(deviceInfo.maxMemAllocSize, static_cast<uint64_t>(128llu * MB));
}
} // namespace NEO

View File

@@ -5,6 +5,8 @@
*
*/
#include <cstdint>
#pragma once
namespace NEO {
struct ApiSpecificConfig {
@@ -15,5 +17,6 @@ struct ApiSpecificConfig {
static bool getBindlessConfiguration();
static ApiType getApiType();
static const char *getAubPrefixForSpecificApi();
static uint64_t getReducedMaxAllocSize(uint64_t maxAllocSize);
};
} // namespace NEO
} // namespace NEO