Changeset 120

Show
Ignore:
Timestamp:
03/21/07 22:06:13
Author:
kunxi
Message:

Fix the io_fwrite_list_shared_async_comm,
just copy the sync test case, and modify with fwait.

Files:

Legend:

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

    r118 r120  
    44 
    55#include <stdio.h> 
     6#include <errno.h> 
    67 
    78/* For all BLOCKSIZE == 0, use the static memeory. 
    8 for all other cases, use the dynamic memory allocation 
    9 */ 
     9 * for all other cases, use the dynamic memory allocation 
     10 */ 
    1011 
    1112#if BLOCKSIZE == 0 
     
    1516shared [0] TYPE vbf[180]; 
    1617 
     18 
    1719/* nmembs and offsets, this only works for up to 8 threads */ 
    18 static int nmembs [] = { 23, 7, 15, 33}; 
    19 static int offsets [] = { 2, 35, 120, 50}; 
     20static int nmembs [] = {23, 37};  
     21static int offsets [] = {2, 35}; 
    2022 
    2123int 
     
    2426        int i, j; 
    2527        int blocksize = BLOCKSIZE; 
    26         ssize_t ret, bytes
    27         shared [0] TYPE *vbfp; 
     28        ssize_t ret
     29        shared [0] TYPE *vbfp;  
    2830 
    2931#if BLOCKSIZE != 0 
    30         shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
     32        shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize * sizeof(TYPE)); 
    3133#endif 
    3234 
    3335        struct upc_shared_memvec  memvec[2]; 
    34         memvec[0].baseaddr = buffer + offsets[0]; 
    35         memvec[0].blocksize = blocksize; 
    36         memvec[0].len = nmembs[0]; 
    37         memvec[0].elemsize = sizeof(TYPE); 
     36       memvec[0].baseaddr = buffer + offsets[0]; 
     37       memvec[0].blocksize = blocksize; 
     38       memvec[0].len = nmembs[0]; 
     39       memvec[0].elemsize = sizeof(TYPE); 
    3840 
    39         memvec[1].baseaddr = buffer + offsets[1]; 
    40         memvec[1].blocksize = blocksize; 
    41         memvec[1].len = nmembs[1]; 
    42         memvec[1].elemsize = sizeof(TYPE); 
     41       memvec[1].baseaddr = buffer + offsets[1]; 
     42       memvec[1].blocksize = blocksize; 
     43       memvec[1].len = nmembs[1]; 
     44       memvec[1].elemsize = sizeof(TYPE); 
    4345 
    44         struct upc_filevec filevec[3]; 
    45         filevec[0].offset = offsets[0] * sizeof(TYPE); 
    46         filevec[0].len = 30 * sizeof(TYPE); 
     46       struct upc_filevec filevec[3]; 
     47       filevec[0].offset = offsets[0] * sizeof(TYPE); 
     48       filevec[0].len = 30 * sizeof(TYPE); 
    4749 
    48         filevec[1].offset = offsets[1] * sizeof(TYPE); 
    49         filevec[1].len = 1 * sizeof(TYPE); 
     50       filevec[1].offset = offsets[1] * sizeof(TYPE); 
     51       filevec[1].len = 1 * sizeof(TYPE); 
    5052 
    51         filevec[2].offset = 40 * sizeof(TYPE); 
    52         filevec[2].len = 29 * sizeof(TYPE); 
     53       filevec[2].offset = 40 * sizeof(TYPE); 
     54       filevec[2].len = 29 * sizeof(TYPE); 
    5355 
    54         if( MYTHREAD == 0) 
    55                 for( i = 0; i< 180; i++ ) 
    56                         buffer[i] = i % 0x80; 
    57         upc_barrier; 
     56        if( MYTHREAD == 0)       
     57                for( i = 0; i< 180; i++ )        
     58                       buffer[i] = i % 0x80; 
     59       upc_barrier; 
    5860 
    5961        upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); 
     
    6163#if BLOCKSIZE != 0 
    6264                if (MYTHREAD == 0) 
    63                         upc_free(buffer); 
     65                upc_free(buffer); 
    6466#endif 
    6567                GULA_FAIL("failed to open the file using UPC_RDWR | UPC_COMMON_FP"); 
     
    6870         
    6971        upc_all_fwrite_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    70         bytes = upc_all_fwait_async(fd); 
     72        upc_all_fwait_async(fd); 
     73        upc_all_fsync(fd); 
    7174        upc_barrier; 
    72          
    73         /* Validation for data integirty */ 
    74         /* Read the data to vbf */ 
    75         vbfp = vbf;  
    76         for (i = 0; i < 3; i++) {  
    77                 upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET); 
    78                 ret = upc_all_fread_shared(fd, vbfp, 0, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    79                 vbfp += filevec[i].len / sizeof(TYPE); 
    80                 upc_barrier; 
    81         } 
    82          
    83         /* Check the data integrity based on the memvec */ 
    84         vbfp = vbf;  
    85         for (i = 0; i < 2; i++) { 
    86                 for (j = 0; j < memvec[i].len; j++) {  
    87                         if (*vbfp != (offsets[i] + j) % 0x80)    
    88                                 GULA_FAIL("Data integrity is violated!"); 
    89                         vbfp ++; 
    90                 } 
    91         } 
    92         upc_barrier; 
    9375 
    94 #if BLOCKSIZE != 0         
    95          if (MYTHREAD == 0) 
     76        /* Validation for data integirty */ 
     77        /* Read the data to vbf */ 
     78        vbfp = vbf; 
     79        for (i = 0; i < 3; i++) { 
     80                upc_all_fseek(fd, filevec[i].offset, UPC_SEEK_SET); 
     81                ret = upc_all_fread_shared(fd, vbfp, 0, sizeof(TYPE), filevec[i].len/sizeof(TYPE), UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     82                vbfp += filevec[i].len / sizeof(TYPE); 
     83                upc_barrier; 
     84        } 
     85 
     86        /* Check the data integrity based on the memvec */ 
     87        vbfp = vbf; 
     88        for (i = 0; i < 2; i++) { 
     89                for (j = 0; j < memvec[i].len; j++) { 
     90                        if (*vbfp != (offsets[i] + j) % 0x80)    
     91                                GULA_FAIL("Data integrity is violated!"); 
     92                        vbfp ++; 
     93                } 
     94        } 
     95        upc_barrier; 
     96 
     97#if BLOCKSIZE != 0 
     98        if (MYTHREAD == 0) 
    9699                upc_free(buffer); 
    97100#endif 
     
    99102        return 0; 
    100103} 
     104