AnsweredAssumed Answered

Software pipelining

Question asked by Sisik2205 on Jan 31, 2013
Latest reply on Feb 1, 2013 by MikeP

Hello AD Society!

 

I have a question about software pipelining. It may be simple but browsing the internet I've found various examples and one of them was implemented in C. Can software pipelining be implemented in C in Visual DSP++? Because I've the following program:

 

#include <stdlib.h>

#include <stdio.h>

 

#define rozmiar 10

 

int dm wektora[rozmiar];

int pm wektorb[rozmiar];

 

int start_odliczania(void);

int koniec_odliczania(int);

volatile int time_temp, ilosc_cykli;

 

void main(void)

{

   int i;     

   for (i = 0; i < rozmiar; i++)

   {

      wektora[i] = i;

      wektorb[i] = i+1;

   }

   int sum=0;

   time_temp = start_odliczania();

   for (i = 0; i < rozmiar; i++)

   {

            sum+=wektora[i]*wektorb[i];

   }

   ilosc_cykli = koniec_odliczania(time_temp);

   printf("suma %d .",sum);

   printf("Program bez pipeliningu zostal wykonany w %d cyklach.\n",ilosc_cykli);

   int ai,bi,p;

   sum=0;

   time_temp = start_odliczania();

   ai=wektora[0]; bi=wektorb[0];

   p=ai*bi; ai=wektora[1]; bi=wektorb[1];

   for(i=2;i<rozmiar;i++)

   {

                       sum+=p;

                       p=ai*bi;

                       ai=wektora[i];bi=wektorb[i];

   }

   sum+=p; p=ai*bi;

   sum+=p;

   ilosc_cykli = koniec_odliczania(time_temp);

   printf("suma %d .",sum);

   printf("Program z pipeliningiem zostal wykonany w %d cyklach.\n",ilosc_cykli);

   exit(0);

}

 

There are two for loops that are meant to do the same [It's in polish but I think that it's easy to understand by operands]. The 2nd loop is implemented with pipelining. Or at least it's meant to be but the cycle count says that the first loop is done faster. Thanks for any help!

Another question would be, what other code optimization can be implemented on C, beside SIMD and software pipelining (if it can be implemented on C)?

 

Regards,

Bartek

Outcomes