Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: ici@qua.crl.melco.co.jp (Toshinao Ishii)
Subject: int v.s. long
Date: 1996/03/25	[thread overview]
Message-ID: <ICI.96Mar25173305@gigue.qua.crl.melco.co.jp> (raw)


Hi.

I've tried some simple benchmark about int and long on dUNIX 3.2C.
The source was just like what is attached in the last. It was just
a simple matrix multiplication of 'int' or 'long'. I want to know
whether calculation of 'long' is faster than that of 'int' on Alpha
which has 64bit architecture. (Of course, long is 8byte and  int is
4byte.)

According to my result on our Alpha Server 2100, calculation with
'int' was about 10% faster than the calculation with 'long'.

My question is how this result should be evaluated. Well, ideally,
it is very happy if the calculation with 'long' is faster than that
with 'int'. However, in the long calculation, about twice of data
have to come and go between memory and registers. My guess is that
if the machine as well as cpu is well designed, the data transfer
is parallelized so that the machine can handle 8byte data as fast
as or faster than 4byte data.

Since I am not a computer architect, I cannot well explain the
bechmark result. I want to hear comments of the experts.

Thanks you in advance.

-=-=-=-=-=-=-=-=-=-=-=-=
Toshinao Ishii

	Advanced Technology R&D Center
	Mitsubishi Electric Corporation
	email: ici@qua.crl.melco.co.jp (NeXTMAIL/MIME welcome)


#include <stdio.h>
#define TYPE long /* or int */
#define N    500

main(){
	int i,j,k;
	TYPE x;
	TYPE a[N][N], b[N][N],c[N][N];

	/* some initialization of a[][] and b[][] */
	...

	for(i=0; i<N; i++)
		for(j=0; j<N; j++){
			x = 0;
			for(k=0; k<N; k++) x += a[i][k] * b[k][j];
			c[i][j] = x;
		}

	printf("%d\n",c[N/2][N/2]);
}



             reply	other threads:[~1996-03-25  5:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-25  5:00 Toshinao Ishii [this message]
1996-03-25  5:00 ` int v.s. long Dirk Grunwald
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