Changeset 111

Show
Ignore:
Timestamp:
03/19/07 19:06:05
Author:
kunxi
Message:

Add validation for io_fwrite_list_shared_comm

Files:

Legend:

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

    r109 r111  
    77 
    88/* For all BLOCKSIZE == 0, use the static memeory. 
    9 for all other cases, use the dynamic memory allocation 
    10 */ 
     9 *for all other cases, use the dynamic memory allocation 
     10 */ 
    1111 
    1212#if BLOCKSIZE == 0 
     
    3131 
    3232#if BLOCKSIZE != 0 
    33         shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(100, blocksize*sizeof(TYPE)); 
     33        shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
    3434#endif 
    3535 
  • src/io_fwrite_list_shared_comm.upc

    r103 r111  
    77 
    88/* For all BLOCKSIZE == 0, use the static memeory. 
    9 for all other cases, use the dynamic memory allocation 
    10 */ 
     9 * for all other cases, use the dynamic memory allocation 
     10 */ 
    1111 
    1212#if BLOCKSIZE == 0 
     
    1414#endif 
    1515 
     16shared [0] TYPE vbf[180]; 
     17 
    1618 
    1719/* 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}; 
     20static int nmembs [] = {23, 37};  
     21static int offsets [] = {2, 35}; 
    2022 
    2123int 
     
    2325 
    2426        int i, j; 
    25         int nmemb = nmembs[MYTHREAD]; 
    26         upc_off_t offset = offsets[MYTHREAD]; 
    2727        int blocksize = BLOCKSIZE; 
    28         ssize_t bytes
    29         upc_off_t vo; 
     28        ssize_t ret
     29        shared [0] TYPE *vbfp;  
    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 
    3434 
     
    3737        memvec[0].blocksize = blocksize; 
    3838        memvec[0].len = nmembs[0]; 
    39         memvec[0].elemsize = 1
     39        memvec[0].elemsize = sizeof(TYPE)
    4040 
    4141        memvec[1].baseaddr = buffer + offsets[1]; 
    4242        memvec[1].blocksize = blocksize; 
    4343        memvec[1].len = nmembs[1]; 
    44         memvec[1].elemsize = 1
     44        memvec[1].elemsize = sizeof(TYPE)
    4545 
    4646        struct upc_filevec filevec[3]; 
    47         filevec[0].offset = offsets[0]
    48         filevec[0].len = 30
     47        filevec[0].offset = offsets[0] * sizeof(TYPE)
     48        filevec[0].len = 30 * sizeof(TYPE)
    4949 
    50         filevec[1].offset = offsets[1]
    51         filevec[1].len = 1
     50        filevec[1].offset = offsets[1] * sizeof(TYPE)
     51        filevec[1].len = 1 * sizeof(TYPE)
    5252 
    53         filevec[2].offset = 40
    54         filevec[2].len = 29
     53        filevec[2].offset = 40 * sizeof(TYPE)
     54        filevec[2].len = 29 * sizeof(TYPE)
    5555 
     56        if( MYTHREAD == 0)       
     57                for( i = 0; i< 180; i++ )        
     58                        buffer[i] = i % 0x80; 
     59        upc_barrier; 
    5660 
    57         for( j = 0; j< THREADS; j++ ) { 
    58                 if( MYTHREAD == j) { 
    59                         fprintf(stderr, "TH%d : ", j); 
    60                         for(i = 0; i < 2; i++ ) 
    61                                 fprintf( stderr, "memvec: len = %d, fv: offset = %d\n", memvec[i].len, filevec[i].offset ); 
    62                         fprintf(stderr, "\n"); 
    63                 } 
    64                 sleep(3); 
    65                 upc_barrier; 
    66         } 
    67  
    68         upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_WRONLY | UPC_COMMON_FP, 0, NULL); 
     61        upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); 
    6962        if (fd == NULL) { 
    7063#if BLOCKSIZE != 0 
     
    7265                upc_free(buffer); 
    7366#endif 
    74                 GULA_FAIL("failed to open the file using UPC_WRONLY | UPC_COMMON_FP"); 
     67                GULA_FAIL("failed to open the file using UPC_RDWR | UPC_COMMON_FP"); 
    7568        } 
    7669        upc_barrier; 
    7770         
    78         bytes = upc_all_fwrite_list_shared(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    79         vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
    80         fprintf(stderr, "Th%d: origin=%d, write %d bytes, cur=%d\n", MYTHREAD, 0, bytes, vo); 
     71        upc_all_fwrite_list_shared(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     72        upc_all_fsync(fd); 
     73        upc_barrier; 
     74 
     75        /* Validation for data integirty */ 
     76        /* Read the data to vbf */ 
     77        vbfp = vbf; 
     78        for (i = 0; i < 3; i++) { 
     79                upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET); 
     80                ret = upc_all_fread_shared(fd, vbfp, 0, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     81                vbfp += filevec[i].len / sizeof(TYPE); 
     82                upc_barrier; 
     83        } 
     84 
     85        /* Check the data integrity based on the memvec */ 
     86        vbfp = vbf; 
     87        for (i = 0; i < 2; i++) { 
     88                for (j = 0; j < memvec[i].len; j++) { 
     89                        if (*vbfp != (offsets[i] + j) % 0x80)    
     90                                GULA_FAIL("Data integrity is violated!"); 
     91                        vbfp ++; 
     92                } 
     93        } 
    8194        upc_barrier; 
    8295 
  • src/io_fwrite_list_shared_ind.upc

    r106 r111  
    3434 
    3535#if BLOCKSIZE != 0 
    36         shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
     36        shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize * sizeof(TYPE)); 
    3737#endif 
    3838 
     
    8383                upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET); 
    8484                upc_all_fread_local(fd, vbfp, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    85                 vbfp += filevec[i].len/sizeof(TYPE); 
     85                vbfp += filevec[i].len / sizeof(TYPE); 
    8686        } 
    8787 
  • src/units_shared

    r109 r111  
    55io_fread_list_shared_ind 
    66io_fread_list_shared_comm 
     7io_fwrite_list_shared_ind 
     8io_fwrite_list_shared_comm