Changeset 102

Show
Ignore:
Timestamp:
03/18/07 06:42:43
Author:
kunxi
Message:

Add validation for io_fwrite_shared_ind

Files:

Legend:

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

    r93 r102  
    1515 
    1616 
    17 /* nmembs and offsets, this only works for up to 8 threads */ 
    18 static int nmembs [] = { 23, 37, 12 , 20, 55, 3, 11, 40}; 
    19 static int offsets [] = { 2, 30, 81 , 33, 14, 17, 27, 43}; 
     17/* nmembs and offsets, this only works for up to 4 threads */ 
     18static int nmembs [] = { 23, 5, 37, 6, 8, 12 }; 
     19static int offsets [] = { 2, 120, 30, 102, 110, 81 }; 
     20static TYPE vfb[180]; 
    2021 
    2122int  
     
    2425        int i, j; 
    2526        int nmemb = nmembs[MYTHREAD]; 
    26         int offset = offsets[MYTHREAD]; 
     27        upc_off_t offset = offsets[MYTHREAD]; 
    2728        int blocksize = BLOCKSIZE; 
    2829        ssize_t bytes; 
     
    3536        if( MYTHREAD == 0)       
    3637                for( i = 0; i< 180; i++ )        
    37                         buffer[i] = i % 256; 
    38  
    39         fprintf(stderr, "start writing Th%d \n", MYTHREAD); 
     38                        buffer[i] = i % 0x80; 
    4039        upc_barrier; 
    4140 
    42         upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_WRONLY | UPC_INDIVIDUAL_FP, 0, NULL); 
     41        upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_INDIVIDUAL_FP, 0, NULL); 
    4342         if (fd == NULL) { 
    4443#if BLOCKSIZE != 0 
     
    4645                upc_free(buffer); 
    4746#endif 
    48                 GULA_FAIL("failed to open the file using UPC_WRONLY | UPC_INDIVIDUAL_FP"); 
     47                GULA_FAIL("failed to open the file using UPC_RDWR | UPC_INDIVIDUAL_FP"); 
    4948        } 
    5049 
    5150        upc_barrier; 
    5251 
    53         vo = upc_all_fseek(fd, offset, UPC_SEEK_SET); 
    54         fprintf(stderr, "Th%d: move to %d\n", MYTHREAD, vo); 
     52        vo = upc_all_fseek(fd, offset * sizeof(TYPE), UPC_SEEK_SET); 
     53        bytes = upc_all_fwrite_shared(fd, buffer+offset, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     54 
     55        if (bytes != nmemb * sizeof(TYPE)) 
     56                GULA_FAIL("Short write is not expected, is disc full ?"); 
     57 
     58        vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
     59        if (vo != (offset + nmemb) * sizeof(TYPE)) 
     60                GULA_FAIL("Fail to setup the file pointer"); 
    5561        upc_barrier; 
     62 
     63        /* Validation for data integrity */ 
     64        upc_all_fsync(fd); 
     65        vo = upc_all_fseek(fd, offset * sizeof(TYPE), UPC_SEEK_SET); 
     66        upc_all_fread_local(fd, vfb, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     67        for (i = 0; i < nmemb; i++) { 
     68                if (vfb[i] != (offset + i) % 0x80) 
     69                        GULA_FAIL("Data integrity is violated!"); 
     70        } 
    5671         
    57         bytes = upc_all_fwrite_shared(fd, buffer+offset, blocksize, sizeof(char), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    58         vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
    59         fprintf(stderr, "th%d: orign=%d, write %d bytes, offset = %d \n", MYTHREAD, offset, bytes, vo); 
    6072        upc_barrier; 
    6173#if BLOCKSIZE != 0