poor fp performance on alpha/linux/gcc

clarksimsgnu@my-deja.com clarksimsgnu@my-deja.com
Thu Sep 30 23:56:00 GMT 1999


In article < 37E3273E.60EA22C7@alumni.caltech.edu >,
  William Snyder <will@alumni.caltech.edu> wrote:
> Hi
>
> I am running Redhat 6.0 on both an alpha 21164A 533Mhz and a celeron
> 333Mhz. When I compile and run a simple floating point intensive
program
> under gcc I get about the same performance on these machines. The
alpha
> should be more than twice as fast. I am using the fast floating point
> library (libfm) for the alpha. My optimization is:
>

Have you profiled the program?
If you hand optimize the problematic loops with register variables, you
should get close to optimum performance. I have included an example of
a hand optimized template function for multiplying matrixes. Notice
that all intermost loops are executed using register variables.

template<class L, class R, class P, class S>
   void Matrix_Multiply(
      const L * lhs ,
      S         lnum,
      S         ldim,
      S         lfmt,
      const R * rhs ,
      S         rnum,
      S         rdim,
      S         rfmt,
      P *       prod,
      S         pnum,
      S         pdim,
      S         pfmt,
      int       skip_na)
   {
      S i, j;
      register const L * pl;
      register const R * pr, * prend;
      register P* pp;
      P pna;
      short all_na;

      if (skip_na)
      {
         pna = 0l;
         pna /= 0l;
      }


      if (ldim!=rnum || lnum!=pnum || rdim!=pdim) {
         error( "matrix's have mismatched dimensions in
Matrix_Multiply");
      }

      for (i=0;i<lnum;i++) {
         for (j=0;j<rdim;j++) {
            pp = prod + i + j*pfmt;
            pl = lhs  + i         ;
            pr = rhs  + j * rfmt  ;
            prend = pr + ldim;

            *pp = 0;

            if (skip_na)
            {
               all_na = 1;
               while (pr!=prend)
               {
                  if (!_is_nan( pl) && !_is_nan( pr))
                  {
                     *pp += *pl * *pr++;
                     all_na = 0;
                  }
                  else {
                     pr++;
                  }
                  pl  += lfmt;
               }
               if (all_na)
               {
                  *pp = pna;
               }
            }
            else
            {
               while (pr!=prend)
               {
                  *pp += *pl * *pr++;
                  pl  += lfmt;
               }
            }

            // prod[i+k*lnum] = 0;
            // for (j=0;j<ldim;j++) {
            //    prod[i+k*lnum] += lhs[i+j*lnum] * rhs[j+k*rnum];
            // }
         }
      }
   }




Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



More information about the Gcc-help mailing list