Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory copy performance on G5



Yes, I understand that memcpy/memmove/BlockMove are optitimized that is why I got better performance than with STREAM benchmark.

What I want to understand is if half of the ideal bandwidth is the best of what I can get. Why is this happening from hardware point of view or I did sth. wrong? It would be great if someone could point to me some links explaining how the optimized bcopy() works since I am writing similar things instead of calling it. Or maybe there is some other maillist suitable to my questions?

My small test program:

mysecond.c

#include <sys/time.h>
/* int gettimeofday(struct timeval *tp, struct timezone *tzp); */

#ifdef UNDERSCORE
double mysecond_()
#else
double mysecond()
#endif
{
/* struct timeval { long        tv_sec;
            long        tv_usec;        };

struct timezone { int   tz_minuteswest;
             int        tz_dsttime;      };     */

        struct timeval tp;
        struct timezone tzp;
        int i;

        i = gettimeofday(&tp,&tzp);
        return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 );
}


copy-memmove.c

#include <stdio.h>
#include <string.h>

#define CLOCKRATE 2.0e9
#define N 1024*1024*64
#define NTIMES 10

extern double mysecond();

double a[N], b[N];

int main () {

  unsigned long t0,t1;
  double t;

  int k;

  for (k=0; k<NTIMES; k++) {

  t = mysecond();
  memcpy(a,b,N*sizeof(double));
  t = mysecond() - t;

  printf(" cycles/element = %lf, bandwidth = %lf\n",t*CLOCKRATE/(N*1.0), N*2.0*sizeof(double)/t);
  }

}


The test is repeated 10 times to ingore VM paging overhead.

Thanks a lot!

Best,
QD

On 11/8/05, Chris Cox <email@hidden> wrote:
STREAM is not optimized for a G5, and won't get anywhere near the
peak bandwidth.

The fastest memory copy is just BlockMove or the libc copy of memcpy.

Chris






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden

References: 
 >Memory copy performance on G5 (From: Qingda Lu <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.