* Questions on performance methods
@ 1998-11-27 7:49 Martin Kahlert
1998-11-27 15:42 ` pshimizu
1998-11-28 12:53 ` Kazushige Goto
0 siblings, 2 replies; 16+ messages in thread
From: Martin Kahlert @ 1998-11-27 7:49 UTC (permalink / raw)
Hi,
i will own an alpha box in about 2 weaks or so and i want to do
heavy numerical calculation (analog circuit simulation) on it.
I would like to help improving the performance of Alpha software, too.
It seems to me, that Mr. Goto is T H E guru of alpha performance.
Hope he's listening.
Is there any introduction paper/www-site, where i can learn about
his methods? (e.g. cache optimization/scheduling...) perhaps with
some C-examples (or does this only make sense in assembler?)
How good is the scheduling of egcs these days on alpha?
Can I describe something like 'the alpha can do an floating point
add a fp mult and two int ops in one cycle, when they are in a block
starting on an x-Byte boundary' to the egcs-scheduler? Or is this even
implemented?
Any help would be great.
Thanks in advance,
Martin.
--
Your mouse has moved. Windows must be restarted for the change
to take effect. Reboot now?
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-11-27 7:49 Martin Kahlert
@ 1998-11-27 15:42 ` pshimizu
1998-11-28 12:53 ` Kazushige Goto
1 sibling, 0 replies; 16+ messages in thread
From: pshimizu @ 1998-11-27 15:42 UTC (permalink / raw)
Hi, Mr. Martin,
In article <199811270749.IAA14161@keksy.mchp.siemens.de>
martin.kahlert@mchp.siemens.de writes:
>> Hi,
>> i will own an alpha box in about 2 weaks or so and i want to do
>> heavy numerical calculation (analog circuit simulation) on it.
>>
It is more difficult for alpha to treat the problem like circuit
simulation, because it uses extensive sparce matrices and
alpha (21164A) has only 64 TLB entry and 5 MAF.
But it is very interesting problem to treat the sparce matrices and I
had a plan to make the task as my undergraduate student thesis.
Unfortunatly, there are few student in these years and I could not
do the plan yet.
>> I would like to help improving the performance of Alpha software, too.
>> It seems to me, that Mr. Goto is T H E guru of alpha performance.
>> Hope he's listening.
>> Is there any introduction paper/www-site, where i can learn about
>> his methods? (e.g. cache optimization/scheduling...) perhaps with
>> some C-examples (or does this only make sense in assembler?)
If you can read Japanese, I recommend you to read our mailing list
Linux-Alpha-JP. In the list, I and Mr. Goto and some other people
discussed about that theme for a long time.
The MAF and the TLB usage and load scheduling will be the key point
for the good performance (of cource, the blocking is basic). These
scheduling strongly depend on the high level structure of the program.
And you can control from FORTRAN or C.
The other minor scheduling will be covered with Out-Of-Order feature
of 21264.
Then there is a hope that we can use C or FORTRAN to retrieve full
performance from Alpha when released the 21264 for public(it means
low cost).
But I myself is not comfortable with 21264, because it does not
improve the peak floating point performance from 21164. The 21364
will use the same core with 21264 and then we cannot expect
outperformed performance with these chips.
I hope Samsung will enhance the 21164A with good price/performance.
Regards,
Naohiko Shimizu
School of Engr., Tokai University
http://shimizu-lab.et.u-tokai.ac.jp/indexe.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-11-27 7:49 Martin Kahlert
1998-11-27 15:42 ` pshimizu
@ 1998-11-28 12:53 ` Kazushige Goto
1998-11-28 19:28 ` Jonathan L Dubois
1 sibling, 1 reply; 16+ messages in thread
From: Kazushige Goto @ 1998-11-28 12:53 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2788 bytes --]
Hi,
# I'm pleased to organize ML of high performance computing.
From: Martin Kahlert <martin.kahlert@mchp.siemens.de>
Subject: Questions on performance methods
martin> I would like to help improving the performance of Alpha software, too.
martin> It seems to me, that Mr. Goto is T H E guru of alpha performance.
martin> Hope he's listening.
I can show/explain you how to optimize, but it's entirely dependent of
source code. Of course, there are some common "rules" to get faster
code, but it'll be slightly faster than before(or almost same).
# I'm not a guru, though :-)
For example,
From: Jonathan L Dubois <dubois@bec.physics.udel.edu>
Subject: request for perf improvement suggestions
void r12(double *rij,double *x1,double *x2){
int i;
double tmp1,tmp2;
tmp2 = 0;
for(i=0;i<3;i++){
tmp1 = x1[i]-x2[i];
tmp2 += tmp1*tmp1;
}
tmp2 = sqrt(tmp2);
*rij = tmp2;
}
First, you must check your routines(with profile(-pg option), you can
check No.1 and 2 easily).
1. find the bottle-necked subroutine.
2. check whether this(bottle-necked) routine is called a few times,
or many times.
If this routine is called many times, the overhead is important,
therefore using "inline function" or macro is good way to
improve.
3. check if this routine calls other subroutines.
Alpha has many registers, but we can not use enough registers
if subroutine calls other subroutines(egcs/gcc is not good at
optimizing such a case).
Obviosly, the subroutine "r12" is called many times and calles sqrt
routine and bottle neck is sqrt. Of course, you can modify as
Mr. Stefan Schroepfer said, but it'll be only slightly faster(5 to
10%).
Actually, sqrt routine is pretty "sparse" because of calculation
dependencies. If it's possible to store temporary array in the lump,
you may use my sqrtv(vectorlized sqrt) routine. This sqrtv routine is
5 times faster than normal sqrt routine. But you showed only kernel
routine, so I do not know whether it's possible to be faster or not.
In this case, it's important "how to call" r12 routine.
So, you should show the routines which call r12 routine.
martin> How good is the scheduling of egcs these days on alpha?
martin> Can I describe something like 'the alpha can do an floating point
martin> add a fp mult and two int ops in one cycle, when they are in a block
martin> starting on an x-Byte boundary' to the egcs-scheduler? Or is this even
martin> implemented?
Now, egcs has a good scheduler except for complex value, I think. We
need optimized pre-processor like KAP(SUIF is freely available, but
it's not good enough).
Thanks,
goto@statabo.rim.or.jp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-11-28 12:53 ` Kazushige Goto
@ 1998-11-28 19:28 ` Jonathan L Dubois
1998-11-29 3:40 ` Kazushige Goto
0 siblings, 1 reply; 16+ messages in thread
From: Jonathan L Dubois @ 1998-11-28 19:28 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1769 bytes --]
On Sat, 28 Nov 1998, Kazushige Goto wrote:
> Actually, sqrt routine is pretty "sparse" because of calculation
> dependencies. If it's possible to store temporary array in the lump,
> you may use my sqrtv(vectorlized sqrt) routine. This sqrtv routine is
> 5 times faster than normal sqrt routine. But you showed only kernel
> routine, so I do not know whether it's possible to be faster or not.
> In this case, it's important "how to call" r12 routine.
>
> So, you should show the routines which call r12 routine.
The loop which calls r12 is shown below.
N could be as large as 10000
int find_jastrow(double *result,int j,struct coord *q,double r[3],double b){
int i;
double rij;
double tmp;
tmp = 1.0;
if(b>0){
for(i=0;i < N;i++){
if(i!=j){
r12(&rij,q[i].x,r);
if(rij > b){
tmp *= (1.0 - b/rij);
}
else{
*result = 0;
return 0;
}
}
}
}
*result = tmp;
return 1;
}
void r12(double *rij,double *x1,double *x2){
int i;
double tmp1,tmp2;
tmp2 = 0;
for(i=0;i<3;i++){
tmp1 = x1[i]-x2[i];
tmp2 += tmp1*tmp1;
}
tmp2 = sqrt(tmp2);
*rij = tmp2;
}
The only problem I foresee with doing all the sqrts in r12 at once is that
I occasionally get some computational savings when (rij <= b) The
probability of this occurring is usually fairly low but it increases with
N and is not easily predicted ahead of time. It will also probably
require some restructuring since q[i] is an array of structures which
contain information other than the 3vectors of interest here.
Jonathan DuBois
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-11-28 19:28 ` Jonathan L Dubois
@ 1998-11-29 3:40 ` Kazushige Goto
1998-11-29 18:09 ` pshimizu
0 siblings, 1 reply; 16+ messages in thread
From: Kazushige Goto @ 1998-11-29 3:40 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4192 bytes --]
From: Jonathan L Dubois <dubois@bec.physics.udel.edu>
Date: Sat, 28 Nov 1998 14:28:39 -0500 (EST)
dubois> The only problem I foresee with doing all the sqrts in r12 at once is that
dubois> I occasionally get some computational savings when (rij <= b) The
dubois> probability of this occurring is usually fairly low but it increases with
dubois> N and is not easily predicted ahead of time. It will also probably
dubois> require some restructuring since q[i] is an array of structures which
dubois> contain information other than the 3vectors of interest here.
I modified your routine. One is slightly optimized, and another is
vectorlized sqrt version.
1. light optimize
The overhead of r12 is pretty heavy.
int find_jastrow(double *result,int j,struct coord *q,double r[3],double b){
int i;
double rij;
double tmp;
double tmp1, tmp2, tmp3;
double r1, r2, r3;
r1 = r[0];
r2 = r[1];
r3 = r[2];
tmp = 1.0;
if(b>0){
for(i=0;i < N;i++){
if(i!=j){
tmp1 = q[i].x[0]-r1;
tmp1 = tmp1*tmp1;
tmp2 = q[i].x[1]-r2;
tmp2 = tmp2*tmp2;
tmp3 = q[i].x[2]-r3;
tmp3 = tmp3*tmp3;
rij = sqrt(tmp1 + tmp2 + tmp3);
if(rij > b){
tmp *= (1.0 - b/rij);
}
else{
*result = 0;
return 0;
}
}
}
}
*result = tmp;
return 1;
}
2. using sqrti routine
tmp *= (1.0 - b/rij);
is pretty slow. You can use sqrti routine instead of sqrt.
This "sqrti" routine(calculates 1.0/sqrt() quickly) will be included
next libffm version.
double sqrti(double);
int find_jastrow(double *result,int j,struct coord *q,double r[3],double b){
int i;
double rij;
double tmp;
double tmp1, tmp2, tmp3;
double r1, r2, r3;
double bi = 1./b;
r1 = r[0];
r2 = r[1];
r3 = r[2];
tmp = 1.0;
if(b>0){
for(i=0;i < N;i++){
if(i!=j){
tmp1 = q[i].x[0]-r1;
tmp1 = tmp1*tmp1;
tmp2 = q[i].x[1]-r2;
tmp2 = tmp2*tmp2;
tmp3 = q[i].x[2]-r3;
tmp3 = tmp3*tmp3;
rij = sqrti(tmp1 + tmp2 + tmp3);
if(rij < bi){
tmp *= (1.0 - b * rij);
}
else{
*result = 0;
return 0;
}
}
}
}
*result = tmp;
return 1;
}
3. using vectorlized sqrtiv routine.
The sqrti routine is still bottle neck. We can modify to use
vectorlized sqrti routine. But it'll be slower if the probability of
"rij < bi" is low. If it's much improved(depend on your source
parameter), this routine can be faster still more.
I attached libffm.a, but it is a beta version.
void dsqrtiv(double *, double *, int);
int find_jastrow(double *result,int j,struct coord *q,double r[3],double b){
int i;
double tmp;
double tmp1, tmp2, tmp3;
double r1, r2, r3;
double bi;
double vtemp[N];
r1 = r[0];
r2 = r[1];
r3 = r[2];
tmp = 1.0;
if(b>0){
for(i=0;i < N;i++){
tmp1 = q[i].x[0]-r1;
tmp1 = tmp1*tmp1;
tmp2 = q[i].x[1]-r2;
tmp2 = tmp2*tmp2;
tmp3 = q[i].x[2]-r3;
tmp3 = tmp3*tmp3;
vtemp[i] = tmp1 + tmp2 + tmp3;
}
dsqrtiv(vtemp, vtemp, N);
bi = 1.0/b;
for(i=0;i < N;i++){
if(i!=j){
if(vtemp[i] < bi){
tmp *= (1.0 - b * vtemp[i]);
}
else{
*result = 0;
return 0;
}
}
}
}
*result = tmp;
return 1;
}
---
goto@statabo.rim.or.jp
Application/Octet-Stream attachment: ibffm.a.gz_
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-11-29 3:40 ` Kazushige Goto
@ 1998-11-29 18:09 ` pshimizu
1998-11-30 2:54 ` naohiko shimizu
0 siblings, 1 reply; 16+ messages in thread
From: pshimizu @ 1998-11-29 18:09 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4553 bytes --]
In article <19981129124047T.goto@statabo.rim.or.jp>
goto@statabo.rim.or.jp writes:
>>
>> 3. using vectorlized sqrtiv routine.
>>
>> The sqrti routine is still bottle neck. We can modify to use
>> vectorlized sqrti routine. But it'll be slower if the probability of
>> "rij < bi" is low. If it's much improved(depend on your source
>> parameter), this routine can be faster still more.
>>
In practice, the vectorlized sqrt/sqrti may need a (optional) mask
vector argument. In that case, we can set the mask for
((rijp2 > bp2) && (i != j)), where rijp2 is the 2nd power of rij and
bp2 is the 2nd power of b.
When I disscussed about vectorlised sqrt with Mr. Yamada in the Japanese
mailing list, the prototype routine was coded only to test the
effectiveness of the vectorlised routines. Both I and Mr.Yamada are
familliar with these conditional vectorlising and we intended not to
make the prototype as conditional routine for simplicity.
The masked vector routines will be useful when a vectorlizing
compiler is published to RISC communities.
But the limited memory band width may restrict the performance of the
code when the vector is too sparse. If one has time to tune, some compaction
of the vector with using the dense vector routine will be more effective.
I show the modified Goto's routine below (without debugging).
Naohiko Shimizu
http://shimizu-lab.et.u-tokai.ac.jp/
----------------------------------------------------------------------------
void dsqrtiv(double *, double *, int);
int find_jastrow(double *result,int j,struct coord *q,double r[3],double b){
int i,vcnt;
double tmp, tmp1, tmp2, tmp3;
double tmp4, tmp5, tmp6, tmp7;
double vtmp[8];
double r1, r2, r3;
double bi,bp2;
double vtemp[N+8];
r1 = r[0];
r2 = r[1];
r3 = r[2];
tmp = 1.0;
vcnt = 0;
bp2 = b*b;
if(b>0){
/*
To reduce inner loop conditional branch, I separate the loop.
This may not be required if the compiler is smart enough.
When b**2 < rij, we should return immediately, without calling sqrt.
Then I add one conditional branch *_*.
*/
for(i=0;i < j;i++){
tmp1 = q[i].x[0]-r1;
tmp1 = tmp1*tmp1;
tmp2 = q[i].x[1]-r2;
tmp2 = tmp2*tmp2;
tmp3 = q[i].x[2]-r3;
tmp3 = tmp3*tmp3;
if((vtemp[vcnt++] = tmp1 + tmp2 + tmp3) > bp2) {
*result = 0.0;
return 0;
}
}
for(i=j+1;i < N;i++){
tmp1 = q[i].x[0]-r1;
tmp1 = tmp1*tmp1;
tmp2 = q[i].x[1]-r2;
tmp2 = tmp2*tmp2;
tmp3 = q[i].x[2]-r3;
tmp3 = tmp3*tmp3;
if((vtemp[vcnt++] = tmp1 + tmp2 + tmp3) > bp2) {
*result = 0.0;
return 0;
}
}
dsqrtiv(vtemp, vtemp, vcnt);
bi = 1.0/b;
tmp = tmp1 = tmp2 = tmp3 = 1.0;
tmp4 = tmp5 = tmp6 = tmp7 = 1.0;
/*
Unrolling and software pipelining the loop.
*/
i = 0;
vtmp[0] = vtemp[i];
vtmp[1] = vtemp[i+1];
vtmp[2] = vtemp[i+2];
vtmp[3] = vtemp[i+3];
vtmp[4] = vtemp[i+4];
vtmp[5] = vtemp[i+5];
vtmp[6] = vtemp[i+6];
vtmp[7] = vtemp[i+7];
for(i=0;i < vcnt-8; i+=8){
tmp *= (1.0 - b * vtemp[0]);
tmp1 *= (1.0 - b * vtemp[1]);
tmp2 *= (1.0 - b * vtemp[2]);
tmp3 *= (1.0 - b * vtemp[3]);
tmp4 *= (1.0 - b * vtemp[4]);
tmp5 *= (1.0 - b * vtemp[5]);
tmp6 *= (1.0 - b * vtemp[6]);
tmp7 *= (1.0 - b * vtemp[7]);
vtmp[0] = vtemp[i+8];
vtmp[1] = vtemp[i+9];
vtmp[2] = vtemp[i+10];
vtmp[3] = vtemp[i+11];
vtmp[4] = vtemp[i+12];
vtmp[5] = vtemp[i+13];
vtmp[6] = vtemp[i+14];
vtmp[7] = vtemp[i+15];
}
/*
The rest of the loop will be here.
*/
for(i=0;i < vcnt - i;i++)
tmp *= (1.0 - b * vtmp[i]);
tmp = tmp*tmp1*tmp2*tmp3*tmp4*tmp5*tmp6*tmp7;
}
*result = tmp;
return 1;
}
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-11-29 18:09 ` pshimizu
@ 1998-11-30 2:54 ` naohiko shimizu
1998-12-01 6:24 ` naohiko shimizu
0 siblings, 1 reply; 16+ messages in thread
From: naohiko shimizu @ 1998-11-30 2:54 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4700 bytes --]
If the N is large (N > 10000), the code I and Goto wrote will use too much
memory traffic. Then we still have a chance to improve the
performance with blocking. Last night it was almost 3am in localtime
when I read the mail, and I had not enough time to code.
See the following, how to make the blocked code. (Still not debugged yet.)
(BTW, it is like a step by step tutorials for code tuning.)
In article <199811291821.DAA16533@mail.fa2.so-net.ne.jp>
pshimizu@fa2.so-net.ne.jp writes:
----------------------------------------------------------------------------
#define BLOCKINGSIZE 1000
void dsqrtiv(double *, double *, int);
double find_jastrow_sub(double *vtemp, double b, int count) {
int i;
double tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7;
double vtmp[8];
dsqrtiv(vtemp, vtemp, count);
/*
Unrolling and software pipelining the loop.
8 times unrolling is enough for the Scache pipeline.
*/
i = 0;
tmp0 = tmp1 = tmp2 = tmp3 =
tmp4 = tmp5 = tmp6 = tmp7 = 1.0;
vtmp[0] = vtemp[i];
vtmp[1] = vtemp[i+1];
vtmp[2] = vtemp[i+2];
vtmp[3] = vtemp[i+3];
vtmp[4] = vtemp[i+4];
vtmp[5] = vtemp[i+5];
vtmp[6] = vtemp[i+6];
vtmp[7] = vtemp[i+7];
for(i=0;i < count-8; i+=8){
tmp0 *= (1.0 - b * vtmp[0]);
tmp1 *= (1.0 - b * vtmp[1]);
tmp2 *= (1.0 - b * vtmp[2]);
tmp3 *= (1.0 - b * vtmp[3]);
tmp4 *= (1.0 - b * vtmp[4]);
tmp5 *= (1.0 - b * vtmp[5]);
tmp6 *= (1.0 - b * vtmp[6]);
tmp7 *= (1.0 - b * vtmp[7]);
vtmp[0] = vtemp[i+8];
vtmp[1] = vtemp[i+9];
vtmp[2] = vtemp[i+10];
vtmp[3] = vtemp[i+11];
vtmp[4] = vtemp[i+12];
vtmp[5] = vtemp[i+13];
vtmp[6] = vtemp[i+14];
vtmp[7] = vtemp[i+15];
}
/*
The rest of the loop will be here.
*/
for(i=0;i < count - i;i++)
tmp0 *= (1.0 - b * vtmp[i]);
return tmp0*tmp1*tmp2*tmp3*tmp4*tmp5*tmp6*tmp7;
}
int find_jastrow(double *result,int j,struct coord *q,double r[3],double b){
int i,vcnt;
double tmp, tmp1, tmp2, tmp3;
double r1, r2, r3;
double bp2;
double vtemp[BLOCKINGSIZE+16];
r1 = r[0];
r2 = r[1];
r3 = r[2];
tmp = 1.0;
vcnt = 0;
bp2 = b*b;
if(b>0){
/*
To reduce inner loop conditional branch, I separate the loop.
This may not be required if the compiler is smart enough.
When b**2 < rij, we should return immediately, without calling sqrt.
Then I add one conditional branch *_*.
*/
i = 0;
tmp1 = q[i].x[0]-r1;
tmp2 = q[i].x[1]-r2;
tmp3 = q[i].x[2]-r3;
for(i=0;i < j;i++){
tmp1 = tmp1*tmp1;
tmp2 = tmp2*tmp2;
tmp3 = tmp3*tmp3;
if((vtemp[vcnt++] = tmp1 + tmp2 + tmp3) > bp2) {
*result = 0.0;
return 0;
}
/*
You may want to prefetch the q[i+1].x here, to reduce the stall
*/
if(vcnt >= BLOCKINGSIZE) {
tmp *= find_jastrow_sub(vtemp, b, vcnt);
vcnt = 0;
}
tmp1 = q[i+1].x[0]-r1;
tmp2 = q[i+1].x[1]-r2;
tmp3 = q[i+1].x[2]-r3;
}
tmp1 = q[j+1].x[0]-r1;
tmp2 = q[j+1].x[1]-r2;
tmp3 = q[j+1].x[2]-r3;
for(i=j+1;i < N;i++){
tmp1 = tmp1*tmp1;
tmp2 = tmp2*tmp2;
tmp3 = tmp3*tmp3;
if((vtemp[vcnt++] = tmp1 + tmp2 + tmp3) > bp2) {
*result = 0.0;
return 0;
}
/*
You may want to prefetch the q[i+1].x here, to reduce the stall
*/
if(vcnt >= BLOCKINGSIZE) {
tmp *= find_jastrow_sub(vtemp, b, vcnt);
vcnt = 0;
}
tmp1 = q[i+1].x[0]-r1;
tmp2 = q[i+1].x[1]-r2;
tmp3 = q[i+1].x[2]-r3;
}
tmp *= find_jastrow_sub(vtemp, b, vcnt);
}
*result = tmp;
return 1;
}
Naohiko Shimizu
Dept. Communication Engr./Univ. TOKAI.
1117 Kitakaname Hiratsuka 259-12 Japan
TEL.+81-463-58-1211(ext. 4084) FAX.+81-463-58-8320
<URL http://shimizu-lab.et.u-tokai.ac.jp/>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
@ 1998-11-30 14:09 Richard Gorton
0 siblings, 0 replies; 16+ messages in thread
From: Richard Gorton @ 1998-11-30 14:09 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]
Naohiko Shimizu wrote:
>But I myself is not comfortable with 21264, because it does not
>improve the peak floating point performance from 21164. The 21364
>will use the same core with 21264 and then we cannot expect
>outperformed performance with these chips.
If by 'peak floating point performance' you mean "number of floating
point instructions issued/cycle" then this is a correct statement.
However, since it is an out-of-order machine, the actual elapsed time
to complete a job can be significantly less on a 21264 machine than on
a 21164 machine with the same clock rate.
Additionally, the number of cycles to execute some FP operations is
significantly better on the 21264 vs. the 21164 (i.e. divide)
The addition of instructions in the architecture to perform SQRT
(among other items) will result in additional performance gains.
Regards,
Rick
Richard Gorton http://www.digital.com/amt
Digital Equipment Corporation All standard disclaimers apply.
Reply-to: gorton@tallis.enet.dec.com
"A committee is a cul-de-sac down which ideas are lured and then quietly
strangled."
--Sir Barnett Cocks
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-11-30 2:54 ` naohiko shimizu
@ 1998-12-01 6:24 ` naohiko shimizu
1998-12-01 14:19 ` Joachim Wesner
1998-12-07 3:24 ` naohiko shimizu
0 siblings, 2 replies; 16+ messages in thread
From: naohiko shimizu @ 1998-12-01 6:24 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 9312 bytes --]
In article <9811301409.AA28540@liszt.amt.tay1.dec.com>
gorton@amt.tay1.dec.com writes:
>>
>> Naohiko Shimizu wrote:
>>
>> >But I myself is not comfortable with 21264, because it does not
>> >improve the peak floating point performance from 21164. The 21364
>> >will use the same core with 21264 and then we cannot expect
>> >outperformed performance with these chips.
>>
>> If by 'peak floating point performance' you mean "number of floating
>> point instructions issued/cycle" then this is a correct statement.
>>
>> However, since it is an out-of-order machine, the actual elapsed time
>> to complete a job can be significantly less on a 21264 machine than on
>> a 21164 machine with the same clock rate.
>>
Rick, if you feel that my post was miss leading for general users,
please excuse me. As I wrote, we can retrieve full power of
21264 with higher level languages and it will be very nice for general.
The chip is well designed, I think. But I wonder that if 21164A uses
same process rule, it will mark higher clock rating. And the easy
optimizable routine may have higher performance with (enhanced) 21164A.
>> Additionally, the number of cycles to execute some FP operations is
>> significantly better on the 21264 vs. the 21164 (i.e. divide)
>> The addition of instructions in the architecture to perform SQRT
>> (among other items) will result in additional performance gains.
I think multiply-accumulate type instruction is usefull for many
applicatoins, wouldn't you disscussed to include such instructions?
In article <19981130095516.B4303@keksy.mchp.siemens.de>
martin.kahlert@mchp.siemens.de writes:
>> Is it very stupid to ask what TLB and MAF means?
>> Sorry, to aks that silly questions.
TLB is reffered as DTB in the Digital documentations. It is a data
address translation buffer to support virtual addressing,
and no load can be issued behind DTB miss. Because, if DTB miss
occured the processor must check page table in the main memory to decide
whether an page fault interrupt may or may not be occured. The interrupt must
be precise and all instructions issued behind the load must be cancelled.
Then shortage of DTB cause performance degradation. I think 21164A could
have 1024 two way DTB with a few victim entries, instead of full associative
64 entries DTB.
The combination of Miss Address File(MAF) and pipelined Scache(L2 cache)
is the key point to get higher performance with 21164(A).
I will explain a little more:
21164(A) is not an out-of-order processor, but only the load instruction
can be treated as out-of-order with MAF.
There are 5 MAF in 21164(A), and each can hold a cache miss load address.
Then we can issue 5 independent address load which does not hit the cache
without stall. And four of them can have upto four miss load which share
the same cache line. So we can issue upto 21 miss load without stall.
Additionaly, Scache can handle L2->L1 cache block transfer as a pipeline.
The latency of Scache is 12 cycles, and if the loop is longer than 12,
the code will not stall for cache miss as far as Scache hit.
If Scache miss is occured, only two outstanding loads is allowed.
(21164PC can issue three outstanding loads, and 21264 will have eight.)
Then we need to control where the outstanding loads will be placed.
The basics are the same for 21264, and carefully designed program will
mark higher performance even for out-of-order processors.
BTW, when will the hardware refference manual for 21264 will be released?
Typical high performance programs for 21164(A) can be organized
as following.
21164(A) can issue two load per cycle, and this code is software pipelined.
foo:
load A[i+0] load A[i+1]
load A[i+2] load A[i+3]
load B[i+0] load B[i+1]
load B[i+2] load B[i+3]
load C[i+0] load C[i+1]
load C[i+2] load C[i+3]
load D[i+0] load D[i+1]
load D[i+2] load D[i+3]
loop:
execute something with A,B,C,D
load A[i+4] load A[i+5]
load A[i+6] load A[i+7]
load B[i+4] load B[i+5]
load B[i+6] load B[i+7]
load C[i+4] load C[i+5]
load C[i+6] load C[i+7]
load D[i+4] load D[i+5]
load D[i+6] load D[i+7]
update i by 4
goto loop
In article <199811300254.LAA26438@et.u-tokai.ac.jp>
nshimizu@et.u-tokai.ac.jp writes:
>> If the N is large (N > 10000), the code I and Goto wrote will use too much
>> memory traffic. Then we still have a chance to improve the
>> performance with blocking. Last night it was almost 3am in localtime
>> when I read the mail, and I had not enough time to code.
>>
I tune the code with prefetching and code optimization.
This may be my final for this problem.
The q[] should have at least additional 9 dummy entiries for prefetching.
Use gcc/egcs to compile the code.(still not debuged)
----------------------------------------------------------------------------
#define BLOCKINGSIZE 1000
#define prefetch(x) asm volatile ("ldt $f31,%0" :: "m"((x)))
void dsqrtiv(double *, double *, int);
double find_jastrow_sub(double *vtemp, double b, int count) {
int i;
double tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6,tmp7;
double vtmp[8];
dsqrtiv(vtemp, vtemp, count);
/*
Unrolling and software pipelining the loop.
8 times unrolling is enough for the Scache pipeline.
*/
i = 0;
tmp0 = tmp1 = tmp2 = tmp3 =
tmp4 = tmp5 = tmp6 = tmp7 = 1.0;
vtmp[0] = vtemp[i];
vtmp[1] = vtemp[i+1];
vtmp[2] = vtemp[i+2];
vtmp[3] = vtemp[i+3];
vtmp[4] = vtemp[i+4];
vtmp[5] = vtemp[i+5];
vtmp[6] = vtemp[i+6];
vtmp[7] = vtemp[i+7];
for(i=0;i < count-8; i+=8){
tmp0 *= (1.0 - b * vtmp[0]);
tmp1 *= (1.0 - b * vtmp[1]);
tmp2 *= (1.0 - b * vtmp[2]);
tmp3 *= (1.0 - b * vtmp[3]);
tmp4 *= (1.0 - b * vtmp[4]);
tmp5 *= (1.0 - b * vtmp[5]);
tmp6 *= (1.0 - b * vtmp[6]);
tmp7 *= (1.0 - b * vtmp[7]);
vtmp[0] = vtemp[i+8];
vtmp[1] = vtemp[i+9];
vtmp[2] = vtemp[i+10];
vtmp[3] = vtemp[i+11];
vtmp[4] = vtemp[i+12];
vtmp[5] = vtemp[i+13];
vtmp[6] = vtemp[i+14];
vtmp[7] = vtemp[i+15];
}
/*
The rest of the loop will be here.
*/
for(i=0;i < count - i;i++)
tmp0 *= (1.0 - b * vtmp[i]);
return tmp0*tmp1*tmp2*tmp3*tmp4*tmp5*tmp6*tmp7;
}
int find_jastrow(double *result,int j,struct coord *q,double r[3],double b){
int i,vcnt;
double tmp, tmp1, tmp2, tmp3;
double t1, t2, t3;
double r1, r2, r3;
double bp2;
double vtemp[BLOCKINGSIZE+16];
r1 = r[0];
r2 = r[1];
r3 = r[2];
tmp = 1.0;
vcnt = 0;
bp2 = b*b;
if(b>0){
/*
To reduce inner loop conditional branch, I separate the loop.
This may not be required if the compiler is smart enough.
When b**2 < rij, we should return immediately, without calling sqrt.
Then I add one conditional branch *_*.
*/
i = 0;
tmp1 = q[i].x[0]-r1;
tmp2 = q[i].x[1]-r2;
tmp3 = q[i].x[2]-r3;
for(i=0;i < j;i++){
t1 = tmp1*tmp1;
t2 = tmp2*tmp2;
t3 = tmp3*tmp3;
tmp1 = q[i+1].x[0]-r1;
tmp2 = q[i+1].x[1]-r2;
tmp3 = q[i+1].x[2]-r3;
prefetch(q[i+9].x[0]);
if((vtemp[vcnt++] = t1 + t2 + t3) > bp2) {
*result = 0.0;
return 0;
}
if(vcnt >= BLOCKINGSIZE) {
tmp *= find_jastrow_sub(vtemp, b, vcnt);
vcnt = 0;
}
}
tmp1 = q[j+1].x[0]-r1;
tmp2 = q[j+1].x[1]-r2;
tmp3 = q[j+1].x[2]-r3;
for(i=j+1;i < N;i++){
t1 = tmp1*tmp1;
t2 = tmp2*tmp2;
t3 = tmp3*tmp3;
tmp1 = q[i+1].x[0]-r1;
tmp2 = q[i+1].x[1]-r2;
tmp3 = q[i+1].x[2]-r3;
prefetch(q[i+9].x[0]);
if((vtemp[vcnt++] = t1 + t2 + t3) > bp2) {
*result = 0.0;
return 0;
}
if(vcnt >= BLOCKINGSIZE) {
tmp *= find_jastrow_sub(vtemp, b, vcnt);
vcnt = 0;
}
}
tmp *= find_jastrow_sub(vtemp, b, vcnt);
}
*result = tmp;
return 1;
}
Naohiko Shimizu
Dept. Communication Engr./Univ. TOKAI.
1117 Kitakaname Hiratsuka 259-12 Japan
TEL.+81-463-58-1211(ext. 4084) FAX.+81-463-58-8320
<URL http://shimizu-lab.et.u-tokai.ac.jp/>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-12-01 6:24 ` naohiko shimizu
@ 1998-12-01 14:19 ` Joachim Wesner
1998-12-02 3:35 ` naohiko shimizu
1998-12-07 3:24 ` naohiko shimizu
1 sibling, 1 reply; 16+ messages in thread
From: Joachim Wesner @ 1998-12-01 14:19 UTC (permalink / raw)
naohiko shimizu wrote:
> I think multiply-accumulate type instruction is usefull for many
> applicatoins, wouldn't you disscussed to include such instructions?
>
YEP, I too think this would help A LOT !!
> I will explain a little more:
>
> 21164(A) is not an out-of-order processor, but only the load instruction
> can be treated as out-of-order with MAF.
> There are 5 MAF in 21164(A), and each can hold a cache miss load address.
> Then we can issue 5 independent address load which does not hit the cache
> without stall. And four of them can have upto four miss load which share
> the same cache line. So we can issue upto 21 miss load without stall.
.........................
<much more detailed 21164 internal info >
Where did you get that "wisdom" from ?? Is it in the hardware ref.
manual (that is available in the web) ?? If yes, I must have missed it.
If not, where could we get it ??
Joachim
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-12-01 14:19 ` Joachim Wesner
@ 1998-12-02 3:35 ` naohiko shimizu
1998-12-02 9:21 ` Joachim Wesner
0 siblings, 1 reply; 16+ messages in thread
From: naohiko shimizu @ 1998-12-02 3:35 UTC (permalink / raw)
In article <3663FAF7.6DD32AB9@lmw.leica.com>
joachim.wesner@lmw.leica.com writes:
>>
>> <much more detailed 21164 internal info >
>>
>> Where did you get that "wisdom" from ?? Is it in the hardware ref.
>> manual (that is available in the web) ?? If yes, I must have missed it.
Yes, it is spreaded on that manual.
I myself does NOT have any EV5 based machine, then it completely depends
on the hardware ref. manual. (There are 6 MAF, my memory is so volatile!)
(I have three as200 4/100, a broken multia and a cablioret.)
It was almost a year ago (30 Oct 1997) when I introduced the strategy
to the Japanese mailing list. And I believe that my strategy is proved
with the gemm code.
(Before that I made the prototype patch for cos,sin,exp,pow,...,etc.,
and Mr. Goto coded them with the assembly language. It was useful
for Linux/Alpha community, wasn't it?)
Naohiko Shimizu
Dept. Communication Engr./Univ. TOKAI.
1117 Kitakaname Hiratsuka 259-12 Japan
TEL.+81-463-58-1211(ext. 4084) FAX.+81-463-58-8320
<URL http://shimizu-lab.et.u-tokai.ac.jp/>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-12-02 3:35 ` naohiko shimizu
@ 1998-12-02 9:21 ` Joachim Wesner
1998-12-02 15:42 ` pshimizu
0 siblings, 1 reply; 16+ messages in thread
From: Joachim Wesner @ 1998-12-02 9:21 UTC (permalink / raw)
naohiko shimizu wrote:
>
> In article <3663FAF7.6DD32AB9@lmw.leica.com>
> joachim.wesner@lmw.leica.com writes:
>
> >>
> >> <much more detailed 21164 internal info >
> >>
> >> Where did you get that "wisdom" from ?? Is it in the hardware ref.
> >> manual (that is available in the web) ?? If yes, I must have missed it.
>
> Yes, it is spreaded on that manual.
> I myself does NOT have any EV5 based machine, then it completely depends
> on the hardware ref. manual. (There are 6 MAF, my memory is so volatile!)
> It was almost a year ago (30 Oct 1997) when I introduced the strategy
> to the Japanese mailing list. And I believe that my strategy is proved
> with the gemm code.
Yep, thanx.
So this is about loads. I will try to find it in the manual, too. How
about stores ?? "Scheduling and issuing rules" in the 21164 manual only
gives some *static* rules here, for ex. that loads cannot be issued
together with stores or on certain cycles relative to other
instructions, however, the section on *dynamic* rules simply says:
"stores have no result", hence no latency. This clearly cannot be true
in real life. If the memory subsystem is busy, at some point the
execution must stop. Clearly, there will be some "write buffers" helping
here, but how many ??? Anybody knows that ?? And is there a fast bypass
if loads to the same datum follow shortly after the respective store ? I
aske because I think to have read about that in the Alpha-Linux FAQ
(about the different types of Alpha): As the Alphas < 21264 have no
direct fp to integer register move, all those move have to go through
memory (You will know that). However, the above FAQ has a note in it
that there is/mght be a special bypass to speed up such moves. Maybe it
simply the cache coming in here, so you must be able to read back the
stored value from write buffer or fast L1 cache, even if L2/L3 or DRAM
is still busy and unavailable.
> (Before that I made the prototype patch for cos,sin,exp,pow,...,etc.,
> and Mr. Goto coded them with the assembly language. It was useful
> for Linux/Alpha community, wasn't it?)
>
Thanx again
Joachim
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-12-02 9:21 ` Joachim Wesner
@ 1998-12-02 15:42 ` pshimizu
1998-12-02 16:48 ` Joachim Wesner
0 siblings, 1 reply; 16+ messages in thread
From: pshimizu @ 1998-12-02 15:42 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 687 bytes --]
In article <36650695.74EBCA5B@lmw.leica.com>
joachim.wesner@lmw.leica.com writes:
>>
>> So this is about loads. I will try to find it in the manual, too. How
>> about stores ??
>>
Of course, thier answer is in the manual.
In short, the load can hit on the six store buffer entries.
And if the store buffer is full replay traps will be occured.
See the sections:
2.1.4.3 Store Execution
2.3.4 Issue Rules
2.4 Replay Traps
2.7.1 The Write Buffer
2.7.4 Write-Buffer Entry Processing
I only have a copy of 21164 manual (not 21164A), then the section
number may be different.
Naohiko Shimizu,
School of Engr., Tokai Univ.
http://shimizu-lab.et.u-tokai.ac.jp
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-12-02 15:42 ` pshimizu
@ 1998-12-02 16:48 ` Joachim Wesner
0 siblings, 0 replies; 16+ messages in thread
From: Joachim Wesner @ 1998-12-02 16:48 UTC (permalink / raw)
pshimizu@fa2.so-net.ne.jp wrote:
>
> In article <36650695.74EBCA5B@lmw.leica.com>
> joachim.wesner@lmw.leica.com writes:
>
> >>
> >> So this is about loads. I will try to find it in the manual, too. How
> >> about stores ??
> >>
>
> Of course, thier answer is in the manual.
> In short, the load can hit on the six store buffer entries.
> And if the store buffer is full replay traps will be occured.
>
> See the sections:
> 2.1.4.3 Store Execution
> 2.3.4 Issue Rules
> 2.4 Replay Traps
> 2.7.1 The Write Buffer
> 2.7.4 Write-Buffer Entry Processing
>
> I only have a copy of 21164 manual (not 21164A), then the section
> number may be different.
Thanks much
Joachim Wesner
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
[not found] <Pine.LNX.3.96.981201174956.16291A-100000@bec.physics.udel.edu>
@ 1998-12-04 2:39 ` naohiko shimizu
0 siblings, 0 replies; 16+ messages in thread
From: naohiko shimizu @ 1998-12-04 2:39 UTC (permalink / raw)
Jonathan,
I posted that you may try the BLOCKINGSIZE from 16 to 1000, but
I checked the program again and now I think that the parameter
will hit the best performance with value 4 or 5.
(with that small value, the unrolling method of the subroutine
might be changed, but I will not mention for simplicity.)
The MAF has only 6 entries, and all the prefetch may use an entry,
then when it reaches to the 6th loop there may be some stall.
So, if you set the BLOCKINGSIZE to 5 the program will call the vectorlized
sqrti before the stall and the pending prefetch will be executed during
the calculation.
The last MAF entry can not merge same line load, then the parameter
of 4 may hit higher performance. Or if we can fully control load order
from high level language, we still can use 5 for best performance.
Naohiko Shimizu
Dept. Communication Engr./Univ. TOKAI.
1117 Kitakaname Hiratsuka 259-12 Japan
TEL.+81-463-58-1211(ext. 4084) FAX.+81-463-58-8320
<URL http://shimizu-lab.et.u-tokai.ac.jp/>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Questions on performance methods
1998-12-01 6:24 ` naohiko shimizu
1998-12-01 14:19 ` Joachim Wesner
@ 1998-12-07 3:24 ` naohiko shimizu
1 sibling, 0 replies; 16+ messages in thread
From: naohiko shimizu @ 1998-12-07 3:24 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1225 bytes --]
When I checked the generated code of the find_jastrow_sub,
I found the gcc generates unnecessary stores.
In this paticuler problem, we don't need to use software pipelining.
Because:
1. The vector will be divided into a block which will fit in Dcache.
2. The block size may be very small.
Then replace the subroutine with following code.
-------------------------------------------------------------
double find_jastrow_sub(double *vtemp, double b, int count) {
int i;
double tmp0,tmp1,tmp2,tmp3;
dsqrtiv(vtemp, vtemp, count);
tmp0 = tmp1 = tmp2 = tmp3 = 1.0;
for(i=0;i < count-4; i+=4){
tmp0 *= (1.0 - b * vtemp[i+0]);
tmp1 *= (1.0 - b * vtemp[i+1]);
tmp2 *= (1.0 - b * vtemp[i+2]);
tmp3 *= (1.0 - b * vtemp[i+3]);
}
/*
The rest of the loop will be here.
*/
for(i=i;i < count; i++)
tmp0 *= (1.0 - b * vtemp[i]);
return tmp0*tmp1*tmp2*tmp3;
}
Naohiko Shimizu
Dept. Communication Engr./Univ. TOKAI.
1117 Kitakaname Hiratsuka 259-12 Japan
TEL.+81-463-58-1211(ext. 4084) FAX.+81-463-58-8320
<URL http://shimizu-lab.et.u-tokai.ac.jp/>
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~1998-12-07 3:24 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-11-30 14:09 Questions on performance methods Richard Gorton
[not found] <Pine.LNX.3.96.981201174956.16291A-100000@bec.physics.udel.edu>
1998-12-04 2:39 ` naohiko shimizu
-- strict thread matches above, loose matches on Subject: below --
1998-11-27 7:49 Martin Kahlert
1998-11-27 15:42 ` pshimizu
1998-11-28 12:53 ` Kazushige Goto
1998-11-28 19:28 ` Jonathan L Dubois
1998-11-29 3:40 ` Kazushige Goto
1998-11-29 18:09 ` pshimizu
1998-11-30 2:54 ` naohiko shimizu
1998-12-01 6:24 ` naohiko shimizu
1998-12-01 14:19 ` Joachim Wesner
1998-12-02 3:35 ` naohiko shimizu
1998-12-02 9:21 ` Joachim Wesner
1998-12-02 15:42 ` pshimizu
1998-12-02 16:48 ` Joachim Wesner
1998-12-07 3:24 ` naohiko shimizu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox