P4 to Git Change 1337009 by gandryey@gera-w8 on 2016/11/04 18:04:52
SWDEV-79445 - OCL generic changes and code clean-up - Use uint64_t for the scratch buffer size calculation Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#558 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#162 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#175 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.h#63 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#32 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#13 edit
Этот коммит содержится в:
@@ -2072,6 +2072,13 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu)
|
||||
// Serialize the scratch buffer allocation code
|
||||
amd::ScopedLock lk(*scratchAlloc_);
|
||||
uint sb = vgpu->hwRing();
|
||||
|
||||
static const uint WaveSizeLimit = ((1 << 21) - 256);
|
||||
const uint threadSizeLimit = WaveSizeLimit / getAttribs().wavefrontSize;
|
||||
if (regNum > threadSizeLimit) {
|
||||
LogError("Requested private memory is bigger than HW supports!");
|
||||
regNum = threadSizeLimit;
|
||||
}
|
||||
|
||||
// Check if the current buffer isn't big enough
|
||||
if (regNum > scratch_[sb]->regNum_) {
|
||||
@@ -2079,8 +2086,8 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu)
|
||||
ScopedLockVgpus lock(*this);
|
||||
|
||||
scratch_[sb]->regNum_ = regNum;
|
||||
size_t size = 0;
|
||||
uint offset = 0;
|
||||
uint64_t size = 0;
|
||||
uint64_t offset = 0;
|
||||
|
||||
// Destroy all views
|
||||
for (uint s = 0; s < scratch_.size(); ++s) {
|
||||
@@ -2089,6 +2096,9 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu)
|
||||
scratchBuf->destroyMemory();
|
||||
// Calculate the size of the scratch buffer for a queue
|
||||
scratchBuf->size_ = calcScratchBufferSize(scratchBuf->regNum_);
|
||||
scratchBuf->size_ = std::min(scratchBuf->size_, info().maxMemAllocSize_);
|
||||
scratchBuf->size_ = std::min(scratchBuf->size_, uint64_t(3 * Gi));
|
||||
scratchBuf->size_ = amd::alignUp(scratchBuf->size_, 0xFFFF);
|
||||
scratchBuf->offset_ = offset;
|
||||
size += scratchBuf->size_;
|
||||
offset += scratchBuf->size_;
|
||||
@@ -2098,7 +2108,7 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu)
|
||||
delete globalScratchBuf_;
|
||||
|
||||
// Allocate new buffer.
|
||||
globalScratchBuf_ = new gpu::Memory(*this, size);
|
||||
globalScratchBuf_ = new gpu::Memory(*this, static_cast<size_t>(size));
|
||||
if ((globalScratchBuf_ == NULL) ||
|
||||
!globalScratchBuf_->create(Resource::Scratch)) {
|
||||
LogError("Couldn't allocate scratch memory");
|
||||
|
||||
@@ -321,10 +321,10 @@ public:
|
||||
|
||||
struct ScratchBuffer : public amd::HeapObject
|
||||
{
|
||||
uint regNum_; //!< The number of used scratch registers
|
||||
Memory* memObj_; //!< Memory objects for scratch buffers
|
||||
uint offset_; //!< Offset from the global scratch store
|
||||
uint size_; //!< Scratch buffer size on this queue
|
||||
uint regNum_; //!< The number of used scratch registers
|
||||
Memory* memObj_; //!< Memory objects for scratch buffers
|
||||
uint64_t offset_; //!< Offset from the global scratch store
|
||||
uint64_t size_; //!< Scratch buffer size on this queue
|
||||
|
||||
//! Default constructor
|
||||
ScratchBuffer(): regNum_(0), memObj_(NULL), offset_(0) {}
|
||||
|
||||
@@ -1263,7 +1263,7 @@ CALGSLDevice::GetCopyType(
|
||||
return type;
|
||||
}
|
||||
|
||||
uint32
|
||||
uint64
|
||||
CALGSLDevice::calcScratchBufferSize(uint32 regNum) const
|
||||
{
|
||||
gslProgramTargetEnum target = GSL_COMPUTE_PROGRAM;
|
||||
@@ -1290,13 +1290,11 @@ CALGSLDevice::calcScratchBufferSize(uint32 regNum) const
|
||||
// be 64K alignment)
|
||||
if (scratchBufferSizes[target] > 0)
|
||||
{
|
||||
scratchBufferSizes[target] = (scratchBufferSizes[target] >> 2) & 0xFFFF0000;
|
||||
scratchBufferSizes[target] = (scratchBufferSizes[target] >> 2);
|
||||
|
||||
if (scratchBufferSizes[target] == 0) { // assign minimum scratch buffer size of 64K
|
||||
scratchBufferSizes[target] = 0x10000;
|
||||
}
|
||||
|
||||
assert(scratchBufferSizes[target] <= 0xFFFFFFFF); // scratch buffer size < 4GB
|
||||
}
|
||||
|
||||
return scratchBufferSizes[target];
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
CopyType GetCopyType(gslMemObject srcMem, gslMemObject destMem, size_t* srcOffset,
|
||||
size_t* destOffset, bool allowDMA, uint32 flags, size_t size, bool enableCopyRect) const;
|
||||
|
||||
uint32 calcScratchBufferSize(uint32 regNum) const;
|
||||
uint64 calcScratchBufferSize(uint32 regNum) const;
|
||||
|
||||
amd::Monitor& gslDeviceOps() const { return *gslDeviceOps_; }
|
||||
|
||||
|
||||
@@ -1804,15 +1804,21 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu)
|
||||
// Serialize the scratch buffer allocation code
|
||||
amd::ScopedLock lk(*scratchAlloc_);
|
||||
uint sb = vgpu->hwRing();
|
||||
|
||||
static const uint WaveSizeLimit = ((1 << 21) - 256);
|
||||
const uint threadSizeLimit = WaveSizeLimit /
|
||||
properties().gfxipProperties.shaderCore.wavefrontSize;
|
||||
if (regNum > threadSizeLimit) {
|
||||
LogError("Requested private memory is bigger than HW supports!");
|
||||
regNum = threadSizeLimit;
|
||||
}
|
||||
// Check if the current buffer isn't big enough
|
||||
if (regNum > scratch_[sb]->regNum_) {
|
||||
// Stall all command queues, since runtime will reallocate memory
|
||||
ScopedLockVgpus lock(*this);
|
||||
|
||||
scratch_[sb]->regNum_ = regNum;
|
||||
size_t size = 0;
|
||||
uint offset = 0;
|
||||
uint64_t size = 0;
|
||||
uint64_t offset = 0;
|
||||
|
||||
// Destroy all views
|
||||
for (uint s = 0; s < scratch_.size(); ++s) {
|
||||
@@ -1823,8 +1829,11 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu)
|
||||
uint32_t numTotalCUs = info().maxComputeUnits_;
|
||||
uint32_t numMaxWaves =
|
||||
properties().gfxipProperties.shaderCore.maxScratchWavesPerCu * numTotalCUs;
|
||||
scratchBuf->size_ = properties().gfxipProperties.shaderCore.wavefrontSize *
|
||||
scratchBuf->size_ = static_cast<uint64_t>(properties().
|
||||
gfxipProperties.shaderCore.wavefrontSize) *
|
||||
scratchBuf->regNum_ * numMaxWaves * sizeof(uint32_t);
|
||||
scratchBuf->size_ = std::min(scratchBuf->size_, info().maxMemAllocSize_);
|
||||
scratchBuf->size_ = std::min(scratchBuf->size_, uint64_t(3 * Gi));
|
||||
scratchBuf->size_ = amd::alignUp(scratchBuf->size_, 0xFFFF);
|
||||
scratchBuf->offset_ = offset;
|
||||
size += scratchBuf->size_;
|
||||
@@ -1835,7 +1844,7 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu)
|
||||
delete globalScratchBuf_;
|
||||
|
||||
// Allocate new buffer.
|
||||
globalScratchBuf_ = new pal::Memory(*this, size);
|
||||
globalScratchBuf_ = new pal::Memory(*this, static_cast<size_t>(size));
|
||||
if ((globalScratchBuf_ == nullptr) ||
|
||||
!globalScratchBuf_->create(Resource::Scratch)) {
|
||||
LogError("Couldn't allocate scratch memory");
|
||||
|
||||
@@ -246,10 +246,10 @@ public:
|
||||
|
||||
struct ScratchBuffer : public amd::HeapObject
|
||||
{
|
||||
uint regNum_; //!< The number of used scratch registers
|
||||
Memory* memObj_; //!< Memory objects for scratch buffers
|
||||
uint offset_; //!< Offset from the global scratch store
|
||||
uint size_; //!< Scratch buffer size on this queue
|
||||
uint regNum_; //!< The number of used scratch registers
|
||||
Memory* memObj_; //!< Memory objects for scratch buffers
|
||||
uint64_t offset_; //!< Offset from the global scratch store
|
||||
uint64_t size_; //!< Scratch buffer size on this queue
|
||||
|
||||
//! Default constructor
|
||||
ScratchBuffer(): regNum_(0), memObj_(NULL), offset_(0) {}
|
||||
|
||||
Ссылка в новой задаче
Block a user