P4 to Git Change 1254144 by gandryey@gera-rcf-lnx on 2016/04/04 11:14:17

SWDEV-79445 - OCL generic changes and code clean-up
	- Move prepinned logic to the abstraciton layer

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#193 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#270 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#543 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#158 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#398 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.cpp#61 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.hpp#29 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsavirtual.cpp#62 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#3 edit


[ROCm/clr commit: 8756fa14cb]
This commit is contained in:
foreman
2016-04-04 11:25:36 -04:00
parent 841cb089da
commit 5b5b3b8cdc
8 changed files with 109 additions and 222 deletions
@@ -559,8 +559,6 @@ Device::Device()
, mapCacheOps_(nullptr)
, xferRead_(nullptr)
, xferWrite_(nullptr)
, vaCacheAccess_(nullptr)
, vaCacheList_(nullptr)
, mapCache_(nullptr)
, resourceCache_(nullptr)
, numComputeEngines_(0)
@@ -578,9 +576,6 @@ Device::~Device()
delete hwDebugMgr_;
hwDebugMgr_ = nullptr;
CondLog(vaCacheList_ == nullptr ||
(vaCacheList_->size() != 0), "Application didn't unmap all host memory!");
delete srdManager_;
for (uint s = 0; s < scratch_.size(); ++s) {
@@ -618,8 +613,6 @@ Device::~Device()
delete vgpusAccess_;
delete scratchAlloc_;
delete mapCacheOps_;
delete vaCacheAccess_;
delete vaCacheList_;
if (context_ != nullptr) {
context_->release();
@@ -633,6 +626,10 @@ extern const char* SchedulerSourceCode;
bool
Device::create(Pal::IDevice* device)
{
if (!amd::Device::create()) {
return false;
}
appProfile_.init();
device_ = device;
Pal::Result result;
@@ -721,15 +718,6 @@ Device::create(Pal::IDevice* device)
return false;
}
vaCacheAccess_ = new amd::Monitor("VA Cache Ops Lock", true);
if (nullptr == vaCacheAccess_) {
return false;
}
vaCacheList_ = new std::list<VACacheEntry*>();
if (nullptr == vaCacheList_) {
return false;
}
mapCache_ = new std::vector<amd::Memory*>();
if (mapCache_ == nullptr) {
return false;
@@ -1630,68 +1618,6 @@ Device::globalFreeMemory(size_t* freeMemory) const
return true;
}
void
Device::addVACache(Memory* memory) const
{
// Make sure system memory has direct access
if (memory->isHostMemDirectAccess()) {
// VA cache access must be serialised
amd::ScopedLock lk(*vaCacheAccess_);
void* start = memory->owner()->getHostMem();
void* end = reinterpret_cast<address>(start) + memory->owner()->getSize();
size_t offset;
Memory* doubleMap = findMemoryFromVA(start, &offset);
if (doubleMap == nullptr) {
// Allocate a new entry
VACacheEntry* entry = new VACacheEntry(start, end, memory);
if (entry != nullptr) {
vaCacheList_->push_back(entry);
}
}
else {
LogError("Unexpected double map() call from the app!");
}
}
}
void
Device::removeVACache(const Memory* memory) const
{
// Make sure system memory has direct access
if (memory->isHostMemDirectAccess() && memory->owner()) {
// VA cache access must be serialised
amd::ScopedLock lk(*vaCacheAccess_);
void* start = memory->owner()->getHostMem();
void* end = reinterpret_cast<address>(start) + memory->owner()->getSize();
// Find VA cache entry for the specified memory
for (const auto& entry : *vaCacheList_) {
if (entry->startAddress_ == start) {
CondLog((entry->endAddress_ != end), "Incorrect VA range");
delete entry;
vaCacheList_->remove(entry);
break;
}
}
}
}
Memory*
Device::findMemoryFromVA(const void* ptr, size_t* offset) const
{
// VA cache access must be serialised
amd::ScopedLock lk(*vaCacheAccess_);
for (const auto& entry : *vaCacheList_) {
if ((entry->startAddress_ <= ptr) && (entry->endAddress_ > ptr)) {
*offset = static_cast<size_t>(reinterpret_cast<const char*>(ptr) -
reinterpret_cast<char*>(entry->startAddress_));
return entry->memory_;
}
}
return nullptr;
}
amd::Memory*
Device::findMapTarget(size_t size) const
{