diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp index 1d088139e2..7bd01093fc 100644 --- a/rocclr/runtime/device/gpu/gpudevice.cpp +++ b/rocclr/runtime/device/gpu/gpudevice.cpp @@ -2289,9 +2289,8 @@ Device::allocScratch(uint regNum, const VirtualGPU* vgpu) ScopedLockVgpus lock(*this); std::vector& mems = scratch_[s]->memObjs_; - // Calculate the size of the new buffer + - // (64 Ki) for alignment with generic address space - size_t size = calcScratchBufferSize(regNum) + 64 * Ki; + // Calculate the size of the new buffer + size_t size = calcScratchBufferSize(regNum); scratch_[s]->destroyMemory(); diff --git a/rocclr/runtime/device/gpu/gpuresource.cpp b/rocclr/runtime/device/gpu/gpuresource.cpp index 6de10e50d1..ad30cf6862 100644 --- a/rocclr/runtime/device/gpu/gpuresource.cpp +++ b/rocclr/runtime/device/gpu/gpuresource.cpp @@ -346,6 +346,7 @@ Resource::create(MemoryType memType, CreateParams* params, bool heap) bool useRowPitch = false; desc.vaBase = 0; + desc.minAlignment = 0; desc.section = GSL_SECTION_REGULAR; if (NULL != params && NULL != params->owner_) { //make sure params not NULL mcaddr svmPtr = reinterpret_cast(params->owner_->getSvmPtr()); @@ -453,7 +454,12 @@ Resource::create(MemoryType memType, CreateParams* params, bool heap) // Check resource cache first for an appropriate resource gslRef_ = dev().resourceCache().findCalResource(&cal_); if (memType == Scratch) { - desc.vaBase = static_cast(0x100000000ULL); + if ((dev().settings().hsail_) || (dev().settings().oclVersion_ >= OpenCL20)) { + desc.minAlignment = 64 * Ki; + } + else { + desc.vaBase = static_cast(0x100000000ULL); + } } else if ((gslRef_ != NULL) && (!dev().settings().use64BitPtr_)) { // Make sure runtime didn't pick a resource with > 4GB address diff --git a/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h b/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h index 07f0080383..59dd8e1b92 100644 --- a/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h +++ b/rocclr/runtime/device/gpu/gslbe/src/include/cal/calcl.h @@ -145,6 +145,7 @@ typedef struct CALresourceDescRec { CALuint64 busAddress[2]; mcaddr vaBase; gslMemObjectAttribSection section; + CALuint minAlignment; } CALresourceDesc; typedef enum CALresallocsliceviewflagsRec { diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp index e5ae58c975..5515dbe0ee 100644 --- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp +++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp @@ -741,6 +741,7 @@ CALGSLDevice::resAlloc(const CALresourceDesc* desc) const attribs.location = desc->type; attribs.vaBase = desc->vaBase; attribs.section = desc->section; + attribs.minAlignment = desc->minAlignment; //!@note GSL asserts with tiled 1D images of any type. if ((desc->dimension == GSL_MOA_BUFFER) ||