#include <stdio.h>
#include <errno.h>
#include <nx.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>


#define FILNM "/pfs/pfay/tmp/tmp####"
#define FILNM "/pfs_grande/multi/tmp_1/pfay/tmpa/tmp####"
#define MAX_WRITES 10
#define BUF_SIZE (2*1024*1024)
char buf[BUF_SIZE];

int main(int argc, char **argv)
{
     void *dum, *dum1;
     int status,i,fd,j;
     double x,y,bytes;
     int max_writes=MAX_WRITES;

     if(mynode()==0){
        printf("run on %d nodes with req_size= %d\n",
         numnodes(),sizeof(buf));
     }


  for(j=0; j<=1; j++)
  {
     fd = open(FILNM,O_WRONLY|O_CREAT,0777);
     if(fd == -1)
     {fprintf(stderr,"cant open file\n"); exit(1);}
     gsync();
     bytes = 0;
     x = dclock();
     for(i=0; i< max_writes; i++)
     {
        if(j==0) 
        { write(fd,buf,sizeof(buf)); }
        else
        { cwrite(fd,buf,sizeof(buf));}
        bytes += sizeof(buf);
     }
     gsync();
     y = dclock() -x;
     x = numnodes()*bytes/(1024.0*1024.0);
     close(fd);
     if(mynode()==0)
     { printf("%swrite() runs at %f MB/s\n",(j==1?"c":""),x/y); }

     fd = open(FILNM,O_RDONLY);
     if(fd == -1)
     {fprintf(stderr,"cant open file\n"); perror(""); exit(1);}
     gsync();
     bytes = 0;
     x = dclock();
     for(i=0; i< max_writes; i++)
     {
        if(j==0)
        { read(fd,buf,sizeof(buf));}
        else
        { cread(fd,buf,sizeof(buf));}
        bytes += sizeof(buf);
     }
     y = dclock() -x;
     x = numnodes()*bytes/(1024.0*1024.0);
     close(fd);
     if(mynode()==0)
     { printf("%sread() runs at %f MB/s\n",(j==1?"c":""),x/y); }
  }
}



Acknowledgement and Disclaimer