c99d679c9e
SWDEV-86035 - Add OCL backend for PAL - PAL backend build is disabled by default. "BUILD_PAL_DEVICE = yes" enables the build. You also have to update the client workspace with PAL mapping: //depot/stg/pal/... //<your_opencl_location>/runtime/device/pal/palbe/... Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#130 edit ... //depot/stg/opencl/drivers/opencl/compiler/sclibdefs.opencl#8 edit ... //depot/stg/opencl/drivers/opencl/opencldefs#166 edit ... //depot/stg/opencl/drivers/opencl/openclrules#91 edit ... //depot/stg/opencl/drivers/opencl/runtime/Makefile#21 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#192 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/build/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/build/Makefile.pal#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palappprofile.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palappprofile.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbinary.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbinary.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palblit.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palblit.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcompiler.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palconstbuf.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palconstbuf.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcounters.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcounters.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldebugger.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldebugmanager.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldebugmanager.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldefs.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldeviced3d10.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldeviced3d11.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldeviced3d9.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevicegl.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palkernel.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprintf.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsched.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palschedcl.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palthreadtrace.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palthreadtrace.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paltimestamp.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paltimestamp.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paltrap.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palwavelimiter.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palwavelimiter.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/runtimedefs#36 edit ... //depot/stg/opencl/drivers/opencl/runtime/top.hpp#23 edit
124 rader
3.3 KiB
C++
124 rader
3.3 KiB
C++
//
|
|
// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
#include "os/os.hpp"
|
|
#include "platform/perfctr.hpp"
|
|
#include "device/pal/paldefs.hpp"
|
|
#include "device/pal/paltimestamp.hpp"
|
|
#include "device/pal/palvirtual.hpp"
|
|
#include "device/pal/palcounters.hpp"
|
|
|
|
namespace pal {
|
|
|
|
TimeStamp::TimeStamp(
|
|
const VirtualGPU& gpu,
|
|
Pal::IGpuMemory* iMem,
|
|
uint memOffset,
|
|
address cpuAddr)
|
|
: gpu_(gpu)
|
|
, iMem_(iMem)
|
|
, memOffset_(memOffset)
|
|
{
|
|
values_ = reinterpret_cast<volatile uint64_t*>(cpuAddr + memOffset);
|
|
}
|
|
|
|
TimeStamp::~TimeStamp()
|
|
{
|
|
}
|
|
|
|
void
|
|
TimeStamp::begin(bool sdma)
|
|
{
|
|
if (!flags_.beginIssued_) {
|
|
gpu().iCmd()->CmdWriteTimestamp(Pal::HwPipePoint::HwPipeTop, *iMem_,
|
|
memOffset_ + CommandStartTime * sizeof(uint64_t));
|
|
flags_.beginIssued_ = true;
|
|
}
|
|
}
|
|
|
|
void
|
|
TimeStamp::end(bool sdma)
|
|
{
|
|
CondLog(!flags_.beginIssued_, "We didn't issue a begin operation!");
|
|
gpu().iCmd()->CmdWriteTimestamp(Pal::HwPipePoint::HwPipeBottom, *iMem_,
|
|
memOffset_ + CommandEndTime * sizeof(uint64_t));
|
|
flags_.endIssued_ = true;
|
|
flags_.sdma_ = sdma;
|
|
}
|
|
|
|
inline void
|
|
SetValue(uint64_t* time, uint64_t val, double nanos)
|
|
{
|
|
*time = static_cast<uint64_t>(static_cast<double>(val) * nanos);
|
|
}
|
|
|
|
void
|
|
TimeStamp::value(uint64_t* startTime, uint64_t* endTime)
|
|
{
|
|
CondLog(!flags_.endIssued_, "We didn't send the counter end operation!");
|
|
//! @todo optimize!
|
|
const double NanoSecondsPerTick = 1000000000.0 / (gpu_.dev().properties().timestampFrequency);
|
|
|
|
SetValue(startTime, values_[CommandStartTime], NanoSecondsPerTick);
|
|
SetValue(endTime, values_[CommandEndTime], NanoSecondsPerTick);
|
|
}
|
|
|
|
TimeStampCache::~TimeStampCache()
|
|
{
|
|
// Release all time stamp objects from the cache
|
|
for (uint i = 0; i < freedTS_.size(); ++i) {
|
|
delete freedTS_[i];
|
|
}
|
|
freedTS_.clear();
|
|
|
|
// Release all memory objects
|
|
for (uint i = 0; i < tsBuf_.size(); ++i) {
|
|
tsBuf_[i]->unmap(&gpu_);
|
|
gpu_.queue(MainEngine).removeMemRef(tsBuf_[i]->iMem());
|
|
gpu_.queue(SdmaEngine).removeMemRef(tsBuf_[i]->iMem());
|
|
delete tsBuf_[i];
|
|
}
|
|
tsBuf_.clear();
|
|
|
|
}
|
|
|
|
TimeStamp*
|
|
TimeStampCache::allocTimeStamp()
|
|
{
|
|
TimeStamp* ts = nullptr;
|
|
if (0 != freedTS_.size()) {
|
|
ts = freedTS_.back();
|
|
freedTS_.pop_back();
|
|
}
|
|
|
|
if (nullptr == ts) {
|
|
if ((tsBufCpu_ == nullptr) || ((tsOffset_ + TimerSlotSize) > TimerBufSize)) {
|
|
Memory* buf = new Memory(gpu_.dev(), TimerBufSize);
|
|
if (buf == nullptr || !buf->create(Resource::Remote)) {
|
|
return nullptr;
|
|
}
|
|
gpu_.queue(MainEngine).addMemRef(buf->iMem());
|
|
gpu_.queue(SdmaEngine).addMemRef(buf->iMem());
|
|
tsBufCpu_ = reinterpret_cast<address>(buf->map(&gpu_));
|
|
memset(tsBufCpu_, 0, TimerBufSize);
|
|
tsOffset_ = 0;
|
|
tsBuf_.push_back(buf);
|
|
}
|
|
// Allocate a TimeStamp object
|
|
ts = new TimeStamp(gpu_, tsBuf_[(tsBuf_.size() - 1)]->iMem(),
|
|
tsOffset_, tsBufCpu_);
|
|
// Create a timestamp
|
|
if (ts == nullptr) {
|
|
return nullptr;
|
|
}
|
|
tsOffset_ += TimerSlotSize;
|
|
}
|
|
|
|
// Set this timestamp into DRM profile mode if it was requested
|
|
ts->clearStates();
|
|
|
|
return ts;
|
|
}
|
|
|
|
} // namespace pal
|