Actual source code: PetscMemcpy.c

      2: #include <petscsys.h>
      3: #include <petsctime.h>

      5: int main(int argc,char **argv)
      6: {
      7:   PetscLogDouble x,y;
      9:   PetscScalar    *A,*B;

     11:   PetscInitialize(&argc,&argv,0,0);if (ierr) return ierr;
     12:   PetscCalloc1(8000000,&A);
     13:   PetscMalloc1(8000000,&B);

     15:   for (i=0; i<8000000; i++) {
     16:     A[i] = i%61897;
     17:     B[i] = i%61897;
     18:   }
     19:   /* To take care of paging effects */
     20:   PetscArraycpy(A,B,8000000);
     21:   PetscTime(&x);
     22:   PetscArraycpy(A,B,8000000);
     23:   PetscTime(&x);

     25:   fprintf(stdout,"%s : \n","PetscMemcpy");
     26:   fprintf(stdout,"    %-15s : %e MB/s\n","Bandwidth",10.0*8*8/(y-x));

     28:   PetscFree(A);
     29:   PetscFree(B);
     30:   PetscFinalize();
     31:   return ierr;
     32: }