Some comments.

save the llvm bitcode to program->binary: insert a byte in front of the bitcode 
stands for binary type(1 means COMPILED_OBJECT, 2 means LIBRARY); load the 
binary to module by ParseIR.
>>>>>> you'd better add "0 means executable binary" like message to make it 
>>>>>> clear.

 namespace gbe {
 
@@ -188,7 +195,7 @@ namespace gbe {
   static gbe_program genProgramNewFromBinary(uint32_t deviceID, const char 
*binary, size_t size) {
     using namespace gbe;
     std::string binary_content;
-    binary_content.assign(binary, size);

>>>>> it is better you add one line comment here
+    binary_content.assign(binary+5, size-5);
     GenProgram *program = GBE_NEW(GenProgram, deviceID);
     std::istringstream ifs(binary_content, std::ostringstream::binary);
     // FIXME we need to check the whether the current device ID match the 
binary file's.
@@ -203,20 +210,64 @@ namespace gbe {
     return reinterpret_cast<gbe_program>(program);
   }
 
-  static size_t genProgramSerializeToBinary(gbe_program program, char 
**binary) {
+  static gbe_program genProgramNewFromLLVMBinary(uint32_t deviceID, 
+const char *binary, size_t size) { #ifdef GBE_COMPILER_AVAILABLE
+    using namespace gbe;
+    std::string binary_content;
+    //the first byte stands for binary_type.
+    binary_content.assign(binary+1, size-1);
+    llvm::StringRef llvm_bin_str(binary_content);
+    llvm::LLVMContext& c = llvm::getGlobalContext();
+    llvm::SMDiagnostic Err;
+    llvm::MemoryBuffer* memory_buffer = 
llvm::MemoryBuffer::getMemBuffer(llvm_bin_str, "llvm_bin_str");

>>>>> here parseIR would modify globalContext, I think you need to add the same 
>>>>> mutex as other places to protect globalcontext.
Other parts all looks good.

+    llvm::Module* module = llvm::ParseIR(memory_buffer, Err, c);
_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to