P4 to Git Change 1281189 by jatang@jatang-opencl-hsa-stg2 on 2016/06/17 15:16:29
SWDEV-1 - OCL PerfCounter on PAL.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbe/src/core/hw/gfxip/computeCmdBuffer.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbe/src/core/hw/gfxip/computeCmdBuffer.h#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbe/src/core/hw/gfxip/gfx6/gfx6ComputeCmdBuffer.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbe/src/core/hw/gfxip/gfx6/gfx6ComputeCmdBuffer.h#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbe/src/core/hw/gfxip/gfx6/gfx6PerfCounter.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbe/src/core/hw/gfxip/gfx6/gfx6PerfTrace.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcounters.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcounters.hpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#12 edit
[ROCm/clr commit: 6e099aabfb]
This commit is contained in:
@@ -33,7 +33,8 @@ PalCounterReference::Create(
|
||||
return memRef;
|
||||
}
|
||||
|
||||
PalCounterReference::~PalCounterReference() {
|
||||
PalCounterReference::~PalCounterReference()
|
||||
{
|
||||
// The counter object is always associated with a particular queue,
|
||||
// so we have to lock just this queue
|
||||
amd::ScopedLock lock(gpu_.execution());
|
||||
@@ -43,7 +44,8 @@ PalCounterReference::~PalCounterReference() {
|
||||
}
|
||||
|
||||
bool
|
||||
PalCounterReference::growResultArray(uint index) {
|
||||
PalCounterReference::growResultArray(uint index)
|
||||
{
|
||||
if (results_ != nullptr) {
|
||||
delete [] results_;
|
||||
}
|
||||
@@ -54,6 +56,68 @@ PalCounterReference::growResultArray(uint index) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PalCounterReference::finalize()
|
||||
{
|
||||
iPerf()->Finalize();
|
||||
|
||||
// Acquire GPU memory for the query from the pool and bind it.
|
||||
Pal::GpuMemoryRequirements gpuMemReqs = {};
|
||||
iPerf()->GetGpuMemoryRequirements(&gpuMemReqs);
|
||||
|
||||
Pal::GpuMemoryCreateInfo createInfo = {};
|
||||
createInfo.size = amd::alignUp(gpuMemReqs.size, gpuMemReqs.alignment);
|
||||
createInfo.alignment = gpuMemReqs.alignment;
|
||||
createInfo.vaRange = Pal::VaRange::Default;
|
||||
createInfo.heapCount = 1;
|
||||
//createInfo.heaps[0] = Pal::GpuHeapGartCacheable;
|
||||
createInfo.heaps[0] = gpuMemReqs.heaps[0];
|
||||
createInfo.priority = Pal::GpuMemPriority::Normal;
|
||||
|
||||
Pal::Result result;
|
||||
size_t gpuMemSize = gpu().dev().iDev()->GetGpuMemorySize(createInfo, &result);
|
||||
if (result != Pal::Result::Success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char* pMemory = new char[gpuMemSize];
|
||||
|
||||
if (pMemory != nullptr) {
|
||||
result = gpu().dev().iDev()->CreateGpuMemory(createInfo, pMemory, &pGpuMemory);
|
||||
|
||||
if (result == Pal::Result::Success) {
|
||||
// GPU profiler memory is perma-resident.
|
||||
result = gpu().dev().iDev()->AddGpuMemoryReferences(1, &pGpuMemory, nullptr, Pal::GpuMemoryRefCantTrim);
|
||||
|
||||
if (result == Pal::Result::Success) {
|
||||
// GPU profiler memory is perma-mapped.
|
||||
result = pGpuMemory->Map(&pCpuAddr);
|
||||
}
|
||||
}
|
||||
|
||||
if (result != Pal::Result::Success) {
|
||||
if (pGpuMemory != nullptr) {
|
||||
pGpuMemory->Destroy();
|
||||
pGpuMemory = nullptr;
|
||||
pCpuAddr = nullptr;
|
||||
}
|
||||
|
||||
delete pMemory;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
result = iPerf()->BindGpuMemory(pGpuMemory, 0);
|
||||
if (result == Pal::Result::Success) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PerfCounter::~PerfCounter()
|
||||
{
|
||||
if (calRef_ == nullptr) {
|
||||
@@ -106,8 +170,9 @@ PerfCounter::getInfo(uint64_t infoType) const
|
||||
return info()->eventIndex_;
|
||||
}
|
||||
case CL_PERFCOUNTER_DATA: {
|
||||
Unimplemented();
|
||||
//gslCounter()->GetResult(gpu().cs(), reinterpret_cast<uint64*>(calRef_->results()));
|
||||
Pal::GlobalCounterLayout layout = {};
|
||||
counter_->GetGlobalCounterLayout(&layout);
|
||||
|
||||
return calRef_->results()[index_];
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -38,11 +38,7 @@ public:
|
||||
uint maxIndex //!< the maximum HW counter index in the PAL counter
|
||||
);
|
||||
|
||||
void finalize() {
|
||||
iPerf()->Finalize();
|
||||
Pal::GlobalCounterLayout layout = {};
|
||||
layout.sampleCount = referenceCount() - 1;
|
||||
iPerf()->GetGlobalCounterLayout(&layout); }
|
||||
bool finalize();
|
||||
|
||||
//! Returns the PAL counter results
|
||||
uint64_t* results() const { return results_; }
|
||||
@@ -62,6 +58,8 @@ private:
|
||||
|
||||
VirtualGPU& gpu_; //!< The virtual GPU device object
|
||||
uint64_t* results_; //!< Counter results
|
||||
Pal::IGpuMemory* pGpuMemory;
|
||||
void* pCpuAddr;
|
||||
};
|
||||
|
||||
//! Performance counter implementation on GPU
|
||||
|
||||
@@ -2303,6 +2303,12 @@ VirtualGPU::submitPerfCounter(amd::PerfCounterCommand& vcmd)
|
||||
|
||||
// Create performance experiment
|
||||
Pal::PerfExperimentCreateInfo createInfo = {};
|
||||
|
||||
createInfo.optionFlags.sampleInternalOperations = 1;
|
||||
createInfo.optionFlags.cacheFlushOnCounterCollection = 1;
|
||||
createInfo.optionFlags.sqShaderMask = 1;
|
||||
createInfo.optionValues.sampleInternalOperations = true;
|
||||
createInfo.optionValues.cacheFlushOnCounterCollection = true;
|
||||
createInfo.optionValues.sqShaderMask = Pal::PerfShaderMaskCs;
|
||||
|
||||
PalCounterReference* palRef = PalCounterReference::Create(*this, createInfo);
|
||||
|
||||
Reference in New Issue
Block a user