Changeset 110

Show
Ignore:
Timestamp:
03/19/07 01:38:27
Author:
apokayi
Message:

added data integrity verification
TO CHECK: integer test cases are failing for multiple threads

Files:

Legend:

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

    r103 r110  
    1414#endif 
    1515 
    16  
    17 /* nmembs and offsets, this only works for up to 8 threads */ 
    18 static int nmembs [] = { 23, 37, 12 , 44, 14, 31, 4, 55}; 
    19 static int offsets [] = { 2, 30, 81 , 25, 77, 121, 139, 47}
     16/* nmembs and offsets, this only works for up to 4 threads */ 
     17static int nmembs [] = { 23, 5, 37, 6, 8, 12 }; 
     18static int offsets [] = { 2, 120, 30, 102, 110, 81 }; 
     19static TYPE vfb[180]
    2020 
    2121int 
     
    3030 
    3131#if BLOCKSIZE != 0 
    32         shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(100, blocksize*sizeof(TYPE)); 
     32        shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
    3333#endif 
     34 
    3435        if( MYTHREAD == 0)       
    3536                for( i = 0; i< 180; i++ )        
    36                         buffer[i] = i % 256; 
    37  
    38         fprintf(stderr, "start writing Th%d \n", MYTHREAD); 
     37                        buffer[i] = i % 0x80; 
    3938        upc_barrier; 
    4039 
    41         upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_WRONLY | UPC_INDIVIDUAL_FP, 0, NULL); 
     40        upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_INDIVIDUAL_FP, 0, NULL); 
    4241        if (fd == NULL) { 
    4342#if BLOCKSIZE != 0 
     
    4544                        upc_free(buffer); 
    4645#endif 
    47                 GULA_FAIL("failed to open the file using UPC_WRONLY | UPC_INDIVIDUAL_FP"); 
     46                GULA_FAIL("failed to open the file using UPC_RDWR | UPC_INDIVIDUAL_FP"); 
    4847        } 
    4948        upc_barrier; 
     
    5150        vo = upc_all_fseek(fd, offset, UPC_SEEK_SET); 
    5251         
    53         upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof(char), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     52        upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    5453        bytes = upc_all_fwait_async(fd); 
     54 
     55        if (bytes != nmemb * sizeof(TYPE)) 
     56                GULA_FAIL("Short write is not expected, is disc full ?"); 
     57 
    5558        vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
    56         fprintf(stderr, "Th%d: origin=%d, write %d bytes, cur=%d\n", MYTHREAD, offsets[MYTHREAD], bytes, vo); 
     59        if (vo != (offset + nmemb) * sizeof(TYPE)) 
     60                GULA_FAIL("Fail to setup the file pointer"); 
     61 
    5762        upc_barrier; 
     63 
     64        /* Validation for data integrity */ 
     65        upc_all_fsync(fd); 
     66        vo = upc_all_fseek(fd, offset * sizeof(TYPE), UPC_SEEK_SET); 
     67        upc_all_fread_local(fd, vfb, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     68        for (i = 0; i < nmemb; i++) { 
     69                if (vfb[i] != (offset + i) % 0x80) 
     70                        GULA_FAIL("Data integrity is violated!"); 
     71        } 
     72 
     73        upc_barrier; 
    5874 
    5975#if BLOCKSIZE != 0