Changeset 108

Show
Ignore:
Timestamp:
03/19/07 01:18:56
Author:
apokayi
Message:

modify the unit for data integrity

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/io_fread_shared_async_comm.upc

    r103 r108  
    1616main(int argc, char *argv[]){ 
    1717 
    18         int i, j; 
    19         int nmemb = 60; 
    20         upc_off_t offset = 6; 
     18        int i; 
     19        int nmemb = 24; 
    2120        int blocksize = BLOCKSIZE; 
     21        int memoff = 6; 
     22        upc_off_t fileoff = 19; 
     23        ssize_t bytes; 
     24        upc_off_t offset; 
    2225 
    2326#if BLOCKSIZE != 0 
     
    3740        upc_barrier; 
    3841 
    39         upc_all_fseek(fd, 20, UPC_SEEK_SET); 
    40         upc_all_fread_shared_async(fd, buffer+offset, blocksize, sizeof(int), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    41         ssize_t bytes = upc_all_fwait_async(fd); 
    42         upc_off_t vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
    43         fprintf(stderr, "th%d: origin = 20 read %d bytes, offset = %d \n", MYTHREAD, bytes, vo); 
    44         upc_barrier; 
     42        upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 
     43        upc_all_fread_shared_async(fd, buffer+ memoff , blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     44        bytes = upc_all_fwait_async(fd); 
    4545 
    46         if( MYTHREAD == 0) { 
    47                 for(i = 0; i < nmemb; i++ ) 
    48                         fprintf( stderr, "%d ", buffer[i+offset] ); 
    49                 fprintf(stderr, "\n"); 
    50         } 
     46        /* Validation for data integrity */ 
     47        if( MYTHREAD == 0 ) { 
     48                for (i = 0; i < nmemb; i++) { 
     49                        if (buffer[memoff + i] != (fileoff + i) % 0x80) 
     50                                GULA_FAIL("Data integrity is violated!"); 
     51                } 
     52        } 
     53 
     54        offset = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
     55        if (offset != (fileoff + nmemb) * sizeof(TYPE)) 
     56                GULA_FAIL("Fail to setup the file pointer"); 
     57 
    5158        upc_barrier; 
    5259 
     
    5663#endif 
    5764 
    58  
    5965        return 0; 
    6066}