Actual source code: PetscMemcmp.c

 2:  #include petsc.h

  6: int main(int argc,char **argv)
  7: {
  8:   PetscLogDouble x,y,z;
  9:   PetscScalar    A[10000],B[10000];
 10:   int            i,ierr;
 11:   PetscTruth     flg;

 13:   PetscInitialize(&argc,&argv,0,0);

 15:   for (i=0; i<10000; i++) {
 16:     A[i] = i%61897;
 17:     B[i] = i%61897;
 18:   }
 19:   /* To take care of paging effects */
 20:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 21:   PetscGetTime(&x);

 23:   PetscGetTime(&x);
 24:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 25:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 26:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 27:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 28:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 29:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 30:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 31:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 32:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 33:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
 34:   PetscGetTime(&y);
 35:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 36:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 37:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 38:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 39:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 40:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 41:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 42:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 43:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 44:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
 45:   PetscGetTime(&z);

 47:   fprintf(stdout,"%s : \n","PetscMemcmp");
 48:   fprintf(stdout,"    %-15s : %e sec\n","Latency",(z-y)/10.0);
 49:   fprintf(stdout,"    %-15s : %e sec\n","Per PetscScalar",(2*y-x-z)/100000);

 51:   PetscFinalize();
 52:   return(0);
 53: }