[Beignet] [PATCH 2/2] GBE: warning when the GEN binary version mismatch.

Yang, Rong R rong.r.yang at intel.com
Thu Jun 23 05:24:44 UTC 2016


Ok, I will push this patch first, and post a refine patch.

> -----Original Message-----
> From: Song, Ruiling
> Sent: Wednesday, June 22, 2016 10:31
> To: Yang, Rong R <rong.r.yang at intel.com>; beignet at lists.freedesktop.org
> Cc: Yang, Rong R <rong.r.yang at intel.com>
> Subject: RE: [Beignet] [PATCH 2/2] GBE: warning when the GEN binary
> version mismatch.
> 
> >    };
> > -
> > +#define GEN_BINARY_VERSION  1
> >    static const unsigned char
> > gen_binary_header[GBHI_MAX][GEN_BINARY_HEADER_LENGTH]= \
> > -                                             {{0, 'G','E', 'N', 'C', 'B', 'Y', 'T'},
> > -                                              {0, 'G','E', 'N', 'C', 'I', 'V', 'B'},
> > -                                              {0, 'G','E', 'N', 'C', 'H', 'S', 'W'},
> > -                                              {0, 'G','E', 'N', 'C', 'C', 'H', 'V'},
> > -                                              {0, 'G','E', 'N', 'C', 'B', 'D', 'W'},
> > -                                              {0, 'G','E', 'N', 'C', 'S', 'K', 'L'},
> > -                                              {0, 'G','E', 'N', 'C', 'B', 'X', 'T'}
> > +                                             {{GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'B', 'Y', 'T'},
> > +                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'I', 'V', 'B'},
> > +                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'H', 'S', 'W'},
> > +                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'C', 'H', 'V'},
> > +                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'B', 'D', 'W'},
> > +                                              {GEN_BINARY_VERSION, 'G','E', 'N', 'C', 'S', 'K', 'L'},
> > +                                              {GEN_BINARY_VERSION,
> > + 'G','E', 'N', 'C', 'B', 'X', 'T'}
> >                                                };
> >
> >  #define FILL_GEN_HEADER(binary, index)  do {int i = 0; do
> > {*(binary+i) = gen_binary_header[index][i]; i++; }while(i <
> > GEN_BINARY_HEADER_LENGTH);}while(0)
> > @@ -258,10 +258,16 @@ namespace gbe {
> >    static bool genHeaderCompare(const unsigned char *BufPtr,
> > GEN_BINARY_HEADER_INDEX index)
> >    {
> >      bool matched = true;
> > -    for (int i =0; i < GEN_BINARY_HEADER_LENGTH; ++i)
> > +    for (int i = 1; i < GEN_BINARY_HEADER_LENGTH; ++i)
> >      {
> >        matched = matched && (BufPtr[i] == gen_binary_header[index][i]);
> >      }
> > +    if(matched) {
> > +      if(BufPtr[0] != gen_binary_header[index][0]) {
> > +        std::cout << "Beignet binary format have been changed, please
> > + generate
> > binary again.\n";
> > +        matched = false;
> > +      }
> > +    }
> >      return matched;
> >    }
> >
> > diff --git a/backend/src/gbe_bin_generater.cpp
> > b/backend/src/gbe_bin_generater.cpp
> > index 7ed353a..8e42891 100644
> > --- a/backend/src/gbe_bin_generater.cpp
> > +++ b/backend/src/gbe_bin_generater.cpp
> > @@ -196,8 +196,8 @@ void
> > program_build_instance::serialize_program(void)
> > throw(int)
> >
> >        if(gen_pci_id){
> >          //add header to differeciate from llvm bitcode binary.
> > -        // (5 bytes: 1 byte for binary type, 4 byte for bc code, 'GENC' is for gen
> > binary.)
> > -        char gen_header[6] = "\0GENC";
> > +        // (5 bytes: 1 byte for binary version, 4 byte for bc code,
> > + 'GENC' is for gen
> > binary.)
> > +        char gen_header[6] = "\1GENC";
> 
> Can we move this gen_header definition to backend/src/backend/program.h?
> this file can be seen by both runtime and backend.
> So, all the references just use the magic string or number in program.h It
> would make binary_version easy to maintain.



More information about the Beignet mailing list