Actual source code: PetscMemzero.c

petsc-3.4.5 2014-06-29
  2: #include <petscsys.h>
  3: #include <petsctime.h>

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

 13:   PetscInitialize(&argc,&argv,0,0);
 14:   /* To take care of paging effects */
 15:   PetscMemzero(A,sizeof(PetscScalar)*0);
 16:   PetscTime(&x);

 18:   PetscTime(&x);
 19:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 20:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 21:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 22:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 23:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 24:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 25:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 26:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 27:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 28:   PetscMemzero(A,sizeof(PetscScalar)*10000);
 29:   PetscTime(&y);
 30:   PetscMemzero(A,sizeof(PetscScalar)*0);
 31:   PetscMemzero(A,sizeof(PetscScalar)*0);
 32:   PetscMemzero(A,sizeof(PetscScalar)*0);
 33:   PetscMemzero(A,sizeof(PetscScalar)*0);
 34:   PetscMemzero(A,sizeof(PetscScalar)*0);
 35:   PetscMemzero(A,sizeof(PetscScalar)*0);
 36:   PetscMemzero(A,sizeof(PetscScalar)*0);
 37:   PetscMemzero(A,sizeof(PetscScalar)*0);
 38:   PetscMemzero(A,sizeof(PetscScalar)*0);
 39:   PetscMemzero(A,sizeof(PetscScalar)*0);
 40:   PetscTime(&z);

 42:   fprintf(stdout,"%s : \n","PetscMemzero");
 43:   fprintf(stdout,"    %-15s : %e sec\n","Latency",(z-y)/10.0);
 44:   fprintf(stdout,"    %-15s : %e sec\n","Per PetscScalar",(2*y-x-z)/100000.0);

 46:   PetscFinalize();
 47:   return(0);
 48: }