[Beignet] [PATCH 1/6] Prepare the setCode and allcateKernel function for serialization
junyan.he at inbox.com
junyan.he at inbox.com
Thu Aug 22 01:18:30 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 | 4 ++++
backend/src/backend/gen_program.hpp | 6 ++++++
backend/src/backend/program.hpp | 2 ++
3 files changed, 12 insertions(+)
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp
index 3d7bedd..832b2c6 100644
--- a/backend/src/backend/gen_program.cpp
+++ b/backend/src/backend/gen_program.cpp
@@ -41,6 +41,10 @@ namespace gbe {
{}
GenKernel::~GenKernel(void) { GBE_SAFE_DELETE_ARRAY(insns); }
const char *GenKernel::getCode(void) const { return (const char*) insns; }
+ const void GenKernel::setCode(const char * ins, size_t size) {
+ insns = (GenInstruction *)ins;
+ insnNum = size / sizeof(GenInstruction);
+ }
size_t GenKernel::getCodeSize(void) const { return insnNum * sizeof(GenInstruction); }
GenProgram::GenProgram(void) {}
diff --git a/backend/src/backend/gen_program.hpp b/backend/src/backend/gen_program.hpp
index 68b0427..443d0c6 100644
--- a/backend/src/backend/gen_program.hpp
+++ b/backend/src/backend/gen_program.hpp
@@ -42,6 +42,8 @@ namespace gbe
virtual ~GenKernel(void);
/*! Implements base class */
virtual const char *getCode(void) const;
+ /*! Set the instruction stream (to be implemented) */
+ virtual const void setCode(const char *, size_t size);
/*! Implements base class */
virtual size_t getCodeSize(void) const;
GenInstruction *insns; //!< Instruction stream
@@ -59,6 +61,10 @@ namespace gbe
virtual ~GenProgram(void);
/*! Implements base class */
virtual Kernel *compileKernel(const ir::Unit &unit, const std::string &name);
+ /*! Allocate an empty kernel. */
+ virtual Kernel *allocateKernel(const std::string &name) {
+ return GBE_NEW(GenKernel, name);
+ }
/*! Use custom allocators */
GBE_CLASS(GenProgram);
};
diff --git a/backend/src/backend/program.hpp b/backend/src/backend/program.hpp
index 83aaab8..f1ab20e 100644
--- a/backend/src/backend/program.hpp
+++ b/backend/src/backend/program.hpp
@@ -189,6 +189,8 @@ namespace gbe {
protected:
/*! Compile a kernel */
virtual Kernel *compileKernel(const ir::Unit &unit, const std::string &name) = 0;
+ /*! Allocate an empty kernel. */
+ virtual Kernel *allocateKernel(const std::string &name) = 0;
/*! Kernels sorted by their name */
hash_map<std::string, Kernel*> kernels;
/*! Global (constants) outside any kernel */
--
1.7.9.5
More information about the Beignet
mailing list