Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: George France <france@handhelds.org>
To: axp-list@redhat.com, chu@tes-mail.jpl.nasa.gov (Eugene Chu)
Subject: Re: Linux Super Page presentation in USA
Date: Wed, 18 Sep 2002 10:27:53 -0400	[thread overview]
Message-ID: <02091810275302.08176@shadowfax.middleearth> (raw)
In-Reply-To: <20020918065718.B9A046F61@tes-mail.jpl.nasa.gov>

[-- Attachment #1: Type: text/plain, Size: 720 bytes --]

On Wednesday 18 September 2002 02:57, Eugene Chu wrote:
>
> Are these any particular matrix transpose routines?  That was one of
> the holy grails in images processing:  an efficient corner-turn
> implementation.  The other was a fast random indexed addressing of
> arrays.  They were always very good at incurring TLB misses.
>

I have attached the two programs that I have been using for benchmarks.
They are both a 1000 x 1000 matrix transpose.  I have been seeing a minimum
of a 42%+ improvement in the execution of the C program and minimum 54%+
improvement on the Fortran version.  On some systems there has been reported
a 400%+ improvement on certain applications..

I hope this helps.

Best Regards,



--George

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mem2.c --]
[-- Type: text/x-c; name="mem2.c", Size: 3022 bytes --]

/*
 This program is for testing large stride data transfer

I put this program under the GPL.

Contact:Naohiko Shimizu, 
	School of Engineering, Tokai University.
	1117 Kitakaname, Kanagawa 259-12 Japan
	email:nshimizu@keyaki.cc.u-tokai.ac.jp
	TEL: +81-463-58-1211(ext.4084)
	FAX: +81-463-58-8320
	<URL:http://shimizu-lab.et.u-tokai.ac.jp/>
*/


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/resource.h>

#define DIMENSION 1025
#define MINORLOOP 1
#define ITR 20

struct rusage rusage;

double dtime()
{
 double q;

 getrusage(RUSAGE_SELF,&rusage);

 q = (double)(rusage.ru_utime.tv_sec);
 q = q + (double)(rusage.ru_utime.tv_usec) * 1.0e-06;
	
 return q;
}

int cmpdble(void *a, void *b) { 
 if(*(double *)a==*(double *)b) return 0;
 if(*(double *)a>*(double *)b) return 1;
 return -1; }

double bench1(double *a, double *b, int dim) {

 int i,j,kk,cnt;
 double	starttime, endtime,table[ITR];
 double time1,time2;

 for(i=0; i< dim*dim; i++) a[i] = b[i] = 0.0;
 for(kk=0; kk<ITR; kk++) {
 starttime = dtime();
	for(i=0; i<dim; i++) {
		for(j=0; j< dim*MINORLOOP; j++) {
			a[j*dim+i] = b[i*dim+j];
		  }
	 }
 endtime = dtime();
 table[kk] = endtime - starttime;
 }
 qsort((void *)table, ITR, sizeof(double), cmpdble);
 time1 = 0;
 cnt=0;
for(i=ITR*0.1; i<ITR*0.5; i++) {
 //   printf("%d %f\n", i, table[i]);
    time1 += table[i];
    cnt++;
 }
 return time1/(double)(cnt);
//return table[0];
}

double bench2(double *a, double *b, int dim) {

 int i,j,kk,cnt;
 double	starttime, endtime,table[ITR];
 double time1,time2;

 for(i=0; i< dim*dim; i++) a[i] = b[i] = 0.0;
 for(kk=0; kk<ITR; kk++) {
 starttime = dtime();
	for(j=0; j< dim; j++) {
		for(i=0; i<dim*MINORLOOP; i++) {
			a[j*dim+i] = b[i*dim+j];
		  }
	 }
 endtime = dtime();
 table[kk] = endtime - starttime;
 }
 qsort((void *)table, ITR, sizeof(double), cmpdble);
 time1 = 0;
 cnt=0;
 for(i=ITR*0.0; i<ITR*0.5; i++) {
 //   printf("%d %f\n", i, table[i]);
    time1 += table[i];
    cnt++;
 }
 return time1/(double)(cnt);
}

int main(int argc, char **argv)
{
 double	*a, *b;
 int    dim;
 double time1,time2;


 if(argc > 1) dim = atoi(argv[1]);
 else dim = DIMENSION;
 a = (double *)malloc(sizeof(double)*(dim*dim*2));
 b = a + dim*dim;
 if(a==NULL) {
   printf("not enough memory\n");
   exit(1);
 }
 time1=bench1(a,b,dim);
 printf("MMAP area(store stride): %5.2fMB/S\n", dim*dim*MINORLOOP*sizeof(double)*1e-6/time1);
 time2=bench2(a,b,dim);
 free(a);
 printf("MMAP area(store continuous): %5.2fMB/S\n", dim*dim*MINORLOOP*sizeof(double)*1e-6/time2);
 a = (double *)sbrk(sizeof(double)*(dim*dim*2));
 b = a + dim*dim;
 if(a==NULL) {
   printf("not enough memory\n");
   exit(1);
 }
 time1=bench1(a,b,dim);
 printf("BRK area(store stride): %5.2fMB/S\n", dim*dim*MINORLOOP*sizeof(double)*1e-6/time1);
 time2=bench2(a,b,dim);
 printf("BRK area(store continuous): %5.2fMB/S\n", dim*MINORLOOP*dim*sizeof(double)*1e-6/time2);
 munlockall();
 exit(0);
}



[-- Attachment #3: trans.f --]
[-- Type: text/plain, Size: 574 bytes --]

      DOUBLE PRECISION AA(1001,1001), BB(1001,1001)
      REAL*4 DUMMY(2)
C
      DO J = 1,1000
       DO I = 1,1000
         AA(I,J) = I
         BB(I,J) = J
       ENDDO
      ENDDO
      T1 = DTIME(DUMMY)
      DO k = 1,100
      DO J = 1,1000
       DO I = 1,1000
         AA(I,J) = BB(J,I)
       ENDDO
      ENDDO
      T0 = T0 + DTIME(DUMMY)
      ENDDO
      T0 = T0/100
      WRITE(6,*) (8*1000*1000)/T0/1E6, "MB/S"
      SUMA = 0.0
      DO I = 1,1000
      DO J = 1,1000
         SUMA = AA(I,J)
       ENDDO
      ENDDO
      WRITE(6,*) SUMA
      STOP
      END

  parent reply	other threads:[~2002-09-18 14:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-18  6:57 Linux Super Page presentation in USA Eugene Chu
2002-09-18  7:30 ` Naohiko Shimizu
2002-09-18 14:27 ` George France [this message]
2002-09-18 21:01   ` Uncle George
  -- strict thread matches above, loose matches on Subject: below --
2002-09-19  7:30 Eugene Chu
2002-09-19  9:20 ` Naohiko Shimizu
2002-09-19 14:19 ` George France
2002-09-19 14:36 ` George France
2002-09-19  1:35 Davies, Huw
2002-09-18 23:54 Robert M. Riches Jr.
2002-09-19  9:38 ` Uncle George
2002-09-18 21:26 Donsbach, Jeff
2002-09-18 21:39 ` Falk Hueffner
2002-09-18 23:37   ` Uncle George
2002-09-18 23:48     ` Falk Hueffner
2002-09-18  3:48 Naohiko Shimizu
2002-09-18  4:00 ` George France
2002-09-18  4:08   ` Ted Goodridge, Jr
2002-09-18  4:47     ` George France
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox