[Beignet] [PATCH 3/6] Add one debug function to print the kernel status after deserialized
junyan.he at inbox.com
junyan.he at inbox.com
Thu Aug 22 01:18:43 PDT 2013
From: Junyan He <junyan.he at linux.intel.com>
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
backend/src/backend/gen_program.cpp | 8 ++++
backend/src/backend/gen_program.hpp | 2 +
backend/src/backend/program.cpp | 72 +++++++++++++++++++++++++++++++++++
backend/src/backend/program.hpp | 2 +
4 files changed, 84 insertions(+)
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
index 832b2c6..9429158 100644
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -27,12 +27,14 @@
#include "backend/gen_program.hpp"
#include "backend/gen_context.hpp"
#include "backend/gen_defs.hpp"
+#include "backend/gen/gen_mesa_disasm.h"
#include "backend/gen_reg_allocation.hpp"
#include "ir/unit.hpp"
#include "llvm/llvm_to_gen.hpp"
#include <cstring>
#include <memory>
+#include <iostream>
namespace gbe {
@@ -47,6 +49,12 @@ namespace gbe {
}
size_t GenKernel::getCodeSize(void) const { return insnNum * sizeof(GenInstruction); }
+ void GenKernel::dumpKernelStats(void) {
+ Kernel::dumpKernelStats();
+ for (uint32_t i = 0; i < insnNum; i++)
+ gen_disasm(stdout, insns+i);
+ }
+
GenProgram::GenProgram(void) {}
GenProgram::~GenProgram(void) {}
diff --git a/backend/src/backend/gen_program.hpp b/backend/src/backend/gen_program.hpp
index 443d0c6..1db472b 100644
--- a/backend/src/backend/gen_program.hpp
+++ b/backend/src/backend/gen_program.hpp
@@ -46,6 +46,8 @@ namespace gbe
virtual const void setCode(const char *, size_t size);
/*! Implements base class */
virtual size_t getCodeSize(void) const;
+ /*! Dump the kernel status. */
+ virtual void dumpKernelStats(void);
GenInstruction *insns; //!< Instruction stream
uint32_t insnNum; //!< Number of instructions
GBE_CLASS(GenKernel); //!< Use custom allocators
diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index dec5ae4..2485fdb 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -120,6 +120,7 @@ namespace gbe {
Kernel *kernel = this->compileKernel(unit, name);
kernel->setSamplerSet(pair.second->getSamplerSet());
kernel->setImageSet(pair.second->getImageSet());
+ //kernel->dumpKernelStats();
kernels.insert(std::make_pair(name, kernel));
}
return true;
@@ -519,6 +520,77 @@ namespace gbe {
#undef OUT_UPDATE_SZ
#undef IN_UPDATE_SZ
+ void Kernel::dumpKernelStats(void) {
+ int num;
+ using namespace std;
+ cout << "Kernel Name: " << name << "\n";
+ cout << " curbeSize: " << curbeSize << "\n";
+ cout << " simdWidth: " << simdWidth << "\n";
+ cout << " stackSize: " << stackSize << "\n";
+ cout << " useSLM: " << useSLM << "\n";
+
+ cout << " Argument Number is " << argNum << "\n";
+ for (uint32_t i = 0; i < argNum; i++) {
+ KernelArgument& arg = args[i];
+ cout << " Arg " << i << ":\n";
+ cout << " type value: "<< arg.type << "\n";
+ cout << " size: "<< arg.size << "\n";
+ cout << " bufSize: "<< arg.bufSize << "\n";
+ }
+
+ cout << " Patches Number is " << patches.size() << "\n";
+ num = 0;
+ for (auto patch : patches) {
+ num++;
+ cout << " patch " << num << ":\n";
+ cout << " type value: "<< patch.type << "\n";
+ cout << " subtype value: "<< patch.subType << "\n";
+ cout << " offset: "<< patch.offset << "\n";
+ }
+
+ cout << " SamplerSet Map: [index, sampler_reg, sampler_slot]\n";
+ cout << " samplerMap size: " << samplerSet->samplerMap.size() << "\n";
+ for (auto iter : samplerSet->samplerMap) {
+ cout << " [" << iter.first << ", "
+ << iter.second.reg << ", " << iter.second.slot << "]\n";
+ }
+ cout << " SamplerSet Map: [reg, sampler_reg, sampler_slot]\n";
+ cout << " regMap size: " << samplerSet->regMap.size() << "\n";
+ for (auto iter : samplerSet->regMap) {
+ cout << " [" << iter.first << ", "
+ << iter.second.reg << ", " << iter.second.slot << "]\n";
+ }
+
+ cout << " ImageSet Map: [reg, arg_idx, idx, wSlot, hSlot, depthSlot, "
+ "dataTypeSlot, channelOrderSlot, dimOrderSlot]\n";
+ cout << " regMap size: " << imageSet->regMap.size() << "\n";
+ for (auto iter : imageSet->regMap) {
+ cout << " [" << iter.first << ", "
+ << " [" << iter.second->arg_idx << ", "
+ << " [" << iter.second->idx << ", "
+ << " [" << iter.second->wSlot << ", "
+ << " [" << iter.second->hSlot << ", "
+ << " [" << iter.second->depthSlot << ", "
+ << " [" << iter.second->dataTypeSlot << ", "
+ << " [" << iter.second->channelOrderSlot << ", "
+ << " [" << iter.second->dimOrderSlot << ", " << "\n";
+ }
+ cout << " ImageSet Map: [index, arg_idx, idx, wSlot, hSlot, depthSlot, "
+ "dataTypeSlot, channelOrderSlot, dimOrderSlot]\n";
+ cout << " regMap size: " << imageSet->indexMap.size() << "\n";
+ for (auto iter : imageSet->indexMap) {
+ cout << " [" << iter.first << ", "
+ << " [" << iter.second->arg_idx << ", "
+ << " [" << iter.second->idx << ", "
+ << " [" << iter.second->wSlot << ", "
+ << " [" << iter.second->hSlot << ", "
+ << " [" << iter.second->depthSlot << ", "
+ << " [" << iter.second->dataTypeSlot << ", "
+ << " [" << iter.second->channelOrderSlot << ", "
+ << " [" << iter.second->dimOrderSlot << ", " << "\n";
+ }
+ }
+
/*********************** End of Program class member function *************************/
static void programDelete(gbe_program gbeProgram) {
diff --git a/backend/src/backend/program.hpp b/backend/src/backend/program.hpp
index 6d53253..e0eddf5 100644
--- a/backend/src/backend/program.hpp
+++ b/backend/src/backend/program.hpp
@@ -157,6 +157,8 @@ namespace gbe {
virtual size_t serializeToBin(std::ostream& outs);
virtual size_t deserializeFromBin(std::istream& ins);
+ /*! Dump the kernel status. */
+ virtual void dumpKernelStats(void);
protected:
friend class Context; //!< Owns the kernels
--
1.7.9.5
More information about the Beignet
mailing list