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
193 řádky
5.6 KiB
C++
193 řádky
5.6 KiB
C++
//
|
|
// Copyright (c) 2015 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
#ifndef PALPRINTFDBG_HPP_
|
|
#define PALPRINTFDBG_HPP_
|
|
|
|
#include "device/pal/palmemory.hpp"
|
|
|
|
/*! \addtogroup GPU GPU Device Implementation
|
|
* @{
|
|
*/
|
|
#ifndef isinf
|
|
#ifdef _MSC_VER
|
|
#define isinf(X) (!_finite(X) && !_isnan(X))
|
|
#endif //_MSC_VER
|
|
#endif //isinf
|
|
|
|
#ifndef isnan
|
|
#ifdef _MSC_VER
|
|
#define isnan(X) (_isnan(X))
|
|
#endif //_MSC_VER
|
|
#endif //isnan
|
|
|
|
#ifndef copysign
|
|
#ifdef _MSC_VER
|
|
#define copysign(X,Y) (_copysign(X,Y))
|
|
#endif //_MSC_VER
|
|
#endif //copysign
|
|
|
|
//! GPU Device Implementation
|
|
namespace pal {
|
|
|
|
//! Printf info structure
|
|
struct PrintfInfo
|
|
{
|
|
std::string fmtString_; //!< formated string for printf
|
|
std::vector<uint> arguments_; //!< passed arguments to the printf() call
|
|
};
|
|
|
|
class Kernel;
|
|
class VirtualGPU;
|
|
class Memory;
|
|
|
|
class PrintfDbg : public amd::HeapObject
|
|
{
|
|
public:
|
|
//! Debug buffer size per workitem
|
|
static const uint WorkitemDebugSize = 4096;
|
|
|
|
//! Default constructor
|
|
PrintfDbg(
|
|
Device& device,
|
|
FILE* file = NULL
|
|
);
|
|
|
|
//! Destructor
|
|
~PrintfDbg();
|
|
|
|
//! Creates the PrintfDbg object
|
|
bool create();
|
|
|
|
//! Initializes the debug buffer before kernel's execution
|
|
bool init(
|
|
VirtualGPU& gpu, //!< Virtual GPU object
|
|
bool printfEnabled, //!< checks for printf
|
|
const amd::NDRange& size //!< Kernel's workload
|
|
);
|
|
|
|
//! Prints the kernel's debug informaiton from the buffer
|
|
bool output(
|
|
VirtualGPU& gpu, //!< Virtual GPU object
|
|
bool printfEnabled, //!< checks for printf
|
|
const amd::NDRange& size, //!< Kernel's workload
|
|
const std::vector<PrintfInfo>& printfInfo //!< printf info
|
|
);
|
|
|
|
//! Debug buffer size per workitem
|
|
size_t wiDbgSize() const { return wiDbgSize_; }
|
|
|
|
//! Returns debug buffer object
|
|
Memory* dbgBuffer() const { return dbgBuffer_; }
|
|
|
|
protected:
|
|
Memory* dbgBuffer_; //!< Buffer to hold debug output
|
|
FILE* dbgFile_; //!< Debug file
|
|
Device& gpuDevice_; //!< GPU device object
|
|
Memory* xferBufRead_; //!< Transfer buffer for the dump read
|
|
|
|
//! Gets GPU device object
|
|
Device& dev() const { return gpuDevice_; }
|
|
|
|
//! Allocates the debug buffer
|
|
bool allocate(
|
|
bool realloc = false //!< If TRUE then reallocate the debug memory
|
|
);
|
|
|
|
//! Returns TRUE if a float value has to be printed
|
|
bool checkFloat(
|
|
const std::string& fmt //!< Format string
|
|
) const;
|
|
|
|
//! Returns TRUE if a string value has to be printed
|
|
bool checkString(
|
|
const std::string& fmt //!< Format string
|
|
) const;
|
|
|
|
//! Finds the specifier in the format string
|
|
int checkVectorSpecifier(
|
|
const std::string& fmt, //!< Format string
|
|
size_t startPos, //!< Start position for processing
|
|
size_t& curPos //!< End position for processing
|
|
) const;
|
|
|
|
//! Outputs an argument
|
|
size_t outputArgument(
|
|
const std::string& fmt, //!< Format strint
|
|
bool printFloat, //!< Argument is a float value
|
|
size_t size, //!< Argument's size
|
|
const uint32_t* argument //!< Argument's location
|
|
) const;
|
|
|
|
//! Displays the PrintfDbg
|
|
void outputDbgBuffer(
|
|
const PrintfInfo& info, //!< printf info
|
|
const uint32_t* workitemData, //!< The PrintfDbg dump buffer
|
|
size_t& i //!< index to the data in the buffer
|
|
) const;
|
|
|
|
private:
|
|
//! Disable copy constructor
|
|
PrintfDbg(const PrintfDbg&);
|
|
|
|
//! Disable assignment
|
|
PrintfDbg& operator=(const PrintfDbg&);
|
|
|
|
//! Returns the pointer to the workitem data block
|
|
bool clearWorkitems(
|
|
VirtualGPU& gpu, //!< Virtual GPU object
|
|
size_t idxStart, //!< Workitem global index start
|
|
size_t number //!< Number of workitems to clear
|
|
) const;
|
|
|
|
//! Returns the pointer to the workitem data block
|
|
uint32_t* mapWorkitem(
|
|
VirtualGPU& gpu, //!< Virtual GPU object
|
|
size_t idx, //!< Workitem global index
|
|
bool* realloc //!< Returns TRUE if workitem reached the buffer limit
|
|
);
|
|
|
|
//! Unamp the staged buffer
|
|
void unmapWorkitem(
|
|
VirtualGPU& gpu, //!< Virtual GPU object
|
|
const uint32_t* workitemData //!< The PrintfDbg dump buffer
|
|
) const;
|
|
|
|
size_t wiDbgSize_; //!< Workitem debug size
|
|
Memory initCntValue_; //!< Initialized count value
|
|
};
|
|
class PrintfDbgHSA : public PrintfDbg
|
|
{
|
|
public:
|
|
|
|
//! Default constructor
|
|
PrintfDbgHSA(
|
|
Device& device,
|
|
FILE* file = NULL
|
|
): PrintfDbg(device, file) { }
|
|
|
|
//! Initializes the debug buffer before kernel's execution
|
|
bool init(
|
|
VirtualGPU& gpu, //!< Virtual GPU object
|
|
bool printfEnabled //!< checks for printf
|
|
);
|
|
|
|
//! Prints the kernel's debug informaiton from the buffer
|
|
bool output(
|
|
VirtualGPU& gpu, //!< Virtual GPU object
|
|
bool printfEnabled, //!< checks for printf
|
|
const std::vector<PrintfInfo>& printfInfo //!< printf info
|
|
);
|
|
|
|
private:
|
|
//! Disable copy constructor
|
|
PrintfDbgHSA(const PrintfDbgHSA&);
|
|
|
|
//! Disable assignment
|
|
PrintfDbgHSA& operator=(const PrintfDbgHSA&);
|
|
};
|
|
|
|
/*@}*/} // namespace pal
|
|
|
|
#endif /*PALPRINTFDBG_HPP_*/
|