Add image view allocation
If deferred allocation is disabled, then make sure the image view is created without a delay. Also reset the allocation state, since create() method isn't called for a view creation. Change-Id: I7aa22a62bff18289ade83e56b5d3305ba68c715b
Este cometimento está contido em:
@@ -160,6 +160,15 @@ void Memory::initDeviceMemory() {
|
|||||||
memset(deviceMemories_, 0, NumDevicesWithP2P() * sizeof(DeviceMemory));
|
memset(deviceMemories_, 0, NumDevicesWithP2P() * sizeof(DeviceMemory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
|
void Memory::resetAllocationState() {
|
||||||
|
// Reset device memory allocation state
|
||||||
|
for (size_t i = 0; i < context_().devices().size(); i++) {
|
||||||
|
deviceAlloced_[context_().devices()[i]].store(AllocInit, std::memory_order_relaxed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
void* Memory::operator new(size_t size, const Context& context) {
|
void* Memory::operator new(size_t size, const Context& context) {
|
||||||
uint32_t devices = context.devices().size();
|
uint32_t devices = context.devices().size();
|
||||||
if (devices == 1) {
|
if (devices == 1) {
|
||||||
@@ -1150,9 +1159,10 @@ bool Image::Format::isSupported(const Context& context, cl_mem_object_type image
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
Image* Image::createView(const Context& context, const Format& format, device::VirtualDevice* vDev,
|
Image* Image::createView(const Context& context, const Format& format, device::VirtualDevice* vDev,
|
||||||
uint baseMipLevel, cl_mem_flags flags) {
|
uint baseMipLevel, cl_mem_flags flags) {
|
||||||
Image* view = NULL;
|
Image* view = nullptr;
|
||||||
|
|
||||||
// Find the image dimensions and create a corresponding object
|
// Find the image dimensions and create a corresponding object
|
||||||
view = new (context) Image(format, *this, baseMipLevel, flags);
|
view = new (context) Image(format, *this, baseMipLevel, flags);
|
||||||
@@ -1160,14 +1170,22 @@ Image* Image::createView(const Context& context, const Format& format, device::V
|
|||||||
// Set GPU virtual device for this view
|
// Set GPU virtual device for this view
|
||||||
view->setVirtualDevice(vDev);
|
view->setVirtualDevice(vDev);
|
||||||
|
|
||||||
if (view != NULL) {
|
if (view != nullptr) {
|
||||||
// Initialize view
|
view->resetAllocationState();
|
||||||
|
|
||||||
|
// Initialize array of the device memory pointers
|
||||||
view->initDeviceMemory();
|
view->initDeviceMemory();
|
||||||
|
|
||||||
|
// Check if runtime has to allocate memory
|
||||||
|
if ((context.devices().size() == 1) || DISABLE_DEFERRED_ALLOC) {
|
||||||
|
device::Memory* mem = view->getDeviceMemory(*context.devices()[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
bool Image::isEntirelyCovered(const Coord3D& origin, const Coord3D& region) const {
|
bool Image::isEntirelyCovered(const Coord3D& origin, const Coord3D& region) const {
|
||||||
return (origin[0] == 0 && origin[1] == 0 && origin[2] == 0 && region[0] == getWidth() &&
|
return (origin[0] == 0 && origin[1] == 0 && origin[2] == 0 && region[0] == getWidth() &&
|
||||||
region[1] == getHeight() && region[2] == getDepth())
|
region[1] == getHeight() && region[2] == getDepth())
|
||||||
|
|||||||
@@ -215,6 +215,8 @@ class Memory : public amd::RuntimeObject {
|
|||||||
void setSize(size_t size) { size_ = size; }
|
void setSize(size_t size) { size_ = size; }
|
||||||
void setInteropObj(InteropObject* obj) { interopObj_ = obj; }
|
void setInteropObj(InteropObject* obj) { interopObj_ = obj; }
|
||||||
|
|
||||||
|
void resetAllocationState();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Placement new operator.
|
//! Placement new operator.
|
||||||
void* operator new(size_t size, //!< Original allocation size
|
void* operator new(size_t size, //!< Original allocation size
|
||||||
|
|||||||
Criar uma nova questão referindo esta
Bloquear um utilizador