request for perf improvement suggestions


Jonathan L Dubois (dubois@bec.physics.udel.edu)
Wed, 25 Nov 1998 16:15:36 -0500 (EST)


Hello everyone,

I have some code I would like to optomize and I could use some suggestions
and pointers for where to get started.

The function which is called most often and the most likely candidate
for improvement (I think) calculates the distance between two vectors.
The source I am currently using is locate below:

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;
}

my guess is that this is a pretty classic problem and there are some nifty
tricks I could apply in assembly to make this quite fast. I'm fairly new
to this though (my only assembly experience was with the MC6800 several
years ago and I don't think I really understand all the issues involved
with optomization on a RISC chip) So my questions are, is this the best
form for the C code? Is there an existing assembly routine for finding
the distance between two vectors? If not, any suggestions for the
implementation of one?

Kind Regards,
Jonathan DuBois



This archive was generated by hypermail 2.0b3 on Wed Nov 25 1998 - 03:48:42 EST