Files
rocm-systems/rocclr/runtime/device/pal/paltimestamp.hpp
T
foreman c99d679c9e P4 to Git Change 1230521 by gandryey@gera-w8 on 2016/01/22 17:58:08
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
2016-01-22 18:18:55 -05:00

133 lines
3.7 KiB
C++

//
// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
//
#ifndef PALTIMESTAMP_HPP_
#define PALTIMESTAMP_HPP_
#include "device/pal/paldefs.hpp"
#include "device/pal/palresource.hpp"
/*! \addtogroup pal PAL Resource Implementation
* @{
*/
//! PAL Device Implementation
namespace pal {
class Device;
class VirtualGPU;
class Memory;
class TimeStamp : public amd::HeapObject
{
public:
//! Enums for the timestamp information
//! \note *4 is the limitaiton of SDMA HW
//! (address has to be aligned by 256 bit)
enum TimeStampValue {
CommandStartTime = 0,
CommandEndTime = 4,
CommandTotal = 8
};
//! The TimeStamp object flags
union Flags
{
struct
{
uint32_t beginIssued_ : 1;
uint32_t endIssued_ : 1;
uint32_t sdma_ : 1;
};
uint32_t value_;
Flags(): value_(0) {}
};
//! Default constructor
TimeStamp(
const VirtualGPU& gpu, //!< Virtual GPU
Pal::IGpuMemory* iMem, //!< Buffer with the timer values
uint memOffset, //!< Offset in the buffer for the current TS
address cpuAddr //!< CPU pointer for the values in memory
);
//! Default destructor
~TimeStamp();
//! Starts the timestamp
void begin(bool sdma = false);
//! Ends the timestamp
void end(bool sdma = false);
//! Returns the timestamp result in nano seconds
void value(uint64_t* startTime, uint64_t* endTime);
//! Clear all TimeStamp states
void clearStates()
{ flags_.value_ = 0;
values_[CommandStartTime] = 0;
values_[CommandEndTime] = 0;
}
//! Timer commands were submitted to HW
bool isValid() const { return (flags_.endIssued_) ? true : false; }
private:
//! Disable copy constructor
TimeStamp(const TimeStamp&);
//! Disable operator=
TimeStamp& operator=(const TimeStamp&);
//! Returns the GPU device object
const VirtualGPU& gpu() const { return gpu_; }
const VirtualGPU& gpu_; //!< Virtual GPU
Flags flags_; //!< The time stamp state
Pal::IGpuMemory* iMem_; //!< Buffer with the timer values
uint memOffset_; //!< Offset in the buffer for the current timer
volatile uint64_t* values_; //!< CPU pointer to the timer values
};
class TimeStampCache : public amd::HeapObject
{
public:
//! Default constructor
TimeStampCache(
VirtualGPU& gpu //!< Virtual GPU object
)
: gpu_(gpu)
, tsBufCpu_(NULL)
, tsOffset_(0) {}
//! Default destructor
~TimeStampCache();
//! Gets a time stamp object. It will find a freed object or allocate a new one
TimeStamp* allocTimeStamp();
//! Frees a time stamp object
void freeTimeStamp(TimeStamp* ts) { freedTS_.push_back(ts); }
private:
static const uint TimerSlotSize = TimeStamp::CommandTotal * sizeof(uint64_t);
static const uint TimerBufSize = TimerSlotSize * 4096;
//! Disable copy constructor
TimeStampCache(const TimeStampCache&);
//! Disable operator=
TimeStampCache& operator=(const TimeStampCache&);
std::vector<TimeStamp*> freedTS_; //!< Array of freed time stamp objects
VirtualGPU& gpu_; //!< Virtual GPU
std::vector<Memory*> tsBuf_; //!< Array of memory objects with the timer value
address tsBufCpu_; //!< CPU pointer for current TS memory
uint tsOffset_; //!< Active offset in the current mem object
};
/*@}*/} // namespace pal
#endif /*PALTIMESTAMP_HPP_*/