Application Acceleration With FPGAs
Programmable Acceleration Cards (PACs), DCP, DLA, Software Stack, and Reference Designs
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Double buffering

ADua0
Beginner
606 Views

I am trying to implement double buffering for my code, but somehow it leads to data dependency which I am not able to resolve.

 

Here is piece of my code:

 

float __attribute__((register)) sum[12];

float __attribute__((register)) sum1[2][48];

float __attribute__((register)) sum2[12];

float __attribute__((register)) sum3[2][48];

 

float __attribute__((register)) sum5[12];

float __attribute__((register)) sum6[2][48];

float __attribute__((register)) sum7[12];

float __attribute__((register)) sum8[2][48];

 

 

 

 

 

int iter = input_height * window * window;

int index =0;

sum_struct sum4;

sum_struct sum9, sum10, sum11, sum12, sum21, sum22, sum23,sum24;

int flag=0;

int inputWidth1 = inputWidth-2; 

 

while (index != iter)

{

 index++;

for(int r =0 ; r<3*kernel_width; r++)

{

 

for(int y=0;y<2; y++)

{

 #pragma unroll

for(int j=0;j<6;j++)

 {

   sum[j] = sum[j+6];

   sum2[j] = sum2[j+6];

 

    

    

 

  }

  sum9 = read_channel_intel(c8); 

  sum10 = read_channel_intel(c9);

  

   

  sum[11] = sum9[5];   

  sum[10] = sum9[4];

  sum[9] = sum9[3];   

  sum[8] = sum9[2];

  sum[7] = sum9[1];   

  sum[6] = sum9[0];

 

  sum2[11] = sum10[5];   

  sum2[10] = sum10[4];

  sum2[9] = sum10[3];   

  sum2[8] = sum10[2];

  sum2[7] = sum10[1];   

  sum2[6] = sum10[0];

   

 // flag= read_channel_intel(c16);

 }  

 

#pragma unroll

for(int i=0;i<12;i++)

{

sum1[index & 0x01][47-i] +=sum[11-i];

sum3[index & 0x01][47-i] +=sum2[11-i]; 

  }  

 

       int e5=0;

       int e10 =0;

 

       for(int y=0;y<pool_width2;y++)

       {  

 

        if( y<6)

       {

        e5 = e1 + (y) * inputWidth1;

        sum4.dat[0]= sum1[index & 0x01][ (y)* pool_width+0];

        sum4.dat[1] = sum1[index & 0x01][ (y)* pool_width+1];                

        sum4.dat[2] = sum1[index & 0x01][ (y)* pool_width+2];

        sum4.dat[3] = sum1[index & 0x01][ (y)* pool_width+3];                

        sum4.dat[4] = sum1[index & 0x01][ (y)* pool_width+4];

        sum4.dat[5] = sum1[index & 0x01][ (y)* pool_width+5];   

        }             

       else   

        { 

        e5 = e2+ (y-6) * inputWidth1;

        

          

        sum4.dat[0] = sum3[index & 0x01][ (y-6)* pool_width+0];

        sum4.dat[1] = sum3[index & 0x01][ (y-6)* pool_width+1];                

        sum4.dat[2] = sum3[index & 0x01][ (y-6)* pool_width+2];

        sum4.dat[3] = sum3[index & 0x01][ (y-6)* pool_width+3];                

        sum4.dat[4] = sum3[index & 0x01][ (y-6)* pool_width+4];

        sum4.dat[5] = sum3[index & 0x01][ (y-6)* pool_width+5];               

       }

        

 

Any suggestions on how to effectively implement double buffering will be really helpful

0 Kudos
2 Replies
Fawaz_J_Intel
Employee
177 Views
Hello, I will go through your code and let you know the feedback Thanks
ADua0
Beginner
177 Views
Reply