Changeset 112

Show
Ignore:
Timestamp:
03/20/07 17:32:46
Author:
apokayi
Message:

make the verification same as sync operation

Files:

Legend:

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

    r103 r112  
    1313#endif 
    1414 
     15shared [0] TYPE vfb[180]; 
     16 
    1517int 
    1618main(int argc, char *argv[]){ 
     
    1820        int i, j; 
    1921        int nmemb = 60; 
    20         upc_off_t offset = 6; 
    2122        int blocksize = BLOCKSIZE; 
     23        int memoff = 6; 
     24        upc_off_t fileoff = 19; 
    2225        ssize_t bytes; 
    23         upc_off_t vo
     26        upc_off_t offset
    2427 
    2528#if BLOCKSIZE != 0 
    26         shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(100, blocksize*sizeof(TYPE)); 
     29        shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
    2730#endif 
    2831 
    29         upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_WRONLY | UPC_COMMON_FP, 0, NULL); 
     32        upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); 
    3033         
    3134        if (fd == NULL) { 
    3235#if BLOCKSIZE != 0 
    3336                if (MYTHREAD == 0) 
    34                 upc_free(buffer); 
     37                       upc_free(buffer); 
    3538#endif 
    36                 GULA_FAIL("failed to open the file using UPC_WRONLY | UPC_COMMON_FP"); 
     39                GULA_FAIL("failed to open the file using UPC_RDWR | UPC_COMMON_FP"); 
    3740        } 
    3841 
    3942        upc_barrier; 
    4043 
    41         upc_all_fseek(fd, 16, UPC_SEEK_SET); 
     44        upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 
    4245         
    43         upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof(char), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    44         fprintf(stderr, "start writing Th%d \n", MYTHREAD); 
     46        upc_all_fwrite_shared_async(fd, buffer+memoff, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    4547        bytes = upc_all_fwait_async(fd); 
    46         vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
    47         fprintf(stderr, "Th%d: origin=%d, write %d bytes, cur=%d\n", MYTHREAD, 16, bytes, vo); 
     48         
     49        if (bytes != nmemb * sizeof(TYPE)) 
     50                GULA_FAIL("Short write is not expected, is disc full ?"); 
     51 
     52        offset = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
     53        if (offset != (fileoff + nmemb) * sizeof(TYPE)) 
     54                GULA_FAIL("Fail to setup the file pointer"); 
     55        upc_barrier; 
     56 
     57        /* Validation for data integrity */ 
     58        upc_all_fsync(fd); 
     59        upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 
     60        upc_all_fread_shared(fd, vfb, 0, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     61 
     62        for (i = 0; i < nmemb; i++) { 
     63                if (vfb[i] != (memoff + i) % 0x80) 
     64                        GULA_FAIL("Data integrity is violated!"); 
     65        } 
     66 
     67        upc_barrier; 
    4868 
    4969#if BLOCKSIZE != 0