Changeset 118

Show
Ignore:
Timestamp:
03/21/07 21:52:03
Author:
kunxi
Message:

Fix fread_list_shared_async_comm, fread_list_shared_async_ind
Fix io_fwrite_list_shared_async_ind.upc

Make io_fwrite_list_shared_async_comm.upc to compile.
it still breaks.

Files:

Legend:

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

    r51 r118  
    11/* 
     2 * Copyright (C) 2006 Abdullah Kayi 
    23 * Copyright (C) 2006 Kun Xi 
    3  * Copyright (C) 2006 Abdullah Kayi 
    44 * Copyright (C) 2006 The George Washington University 
    55 * All rights reserved. 
     
    3232 
    3333#include <io.h> 
    34  
    3534#include <stdio.h> 
    3635 
     
    3938 
    4039static char fname[] = "read.test"; 
     40 
    4141static upc_file_t* fd = NULL; 
    42 static int flags[] ={  UPC_RDONLY | UPC_INDIVIDUAL_FP,  
    43                        UPC_RDONLY | UPC_COMMON_FP }; 
    44 static int flag; 
     42 
    4543static upc_flag_t sync_mode = NULL; 
     44static upc_flag_t sync = NULL; 
     45 
     46static int i, j, ret, flag; 
     47static int flags[] ={   UPC_RDONLY | UPC_INDIVIDUAL_FP,  
     48                        UPC_RDONLY | UPC_COMMON_FP }; 
     49 
     50static shared[] char **buffer; 
     51 
     52static size_t size, nmemb, blocksize; 
     53static upc_off_t  offset, ret_offset; 
    4654 
    4755static struct upc_shared_memvec memvec[]; 
    4856static struct upc_filevec filevec[]; 
    49  
    50 static upc_flag_t sync = 0; 
    51 static int i,j, ret; 
    52 static size_t size = 0; 
    53  
    54 static shared[] char **buffer; 
    55 static shared[] unsigned unsigned char *pd; 
    56 static shared[] unsigned unsigned char *base; 
    5757 
    5858static int  
     
    6868                        break; 
    6969        } 
    70  
    7170        shift = pfv[i].len - ( size - offset ); 
    7271        return ( x == (pfv[i].offset + shift)% 128 ); 
     
    7473         
    7574static int  
    76 verify(size_t me, struct upc_shared_memvec *pmv, size_t fe, struct upc_filevec *pfv) 
     75verify(size_t me, struct upc_shared_memvec* pmv, size_t fe, struct upc_filevec* pfv) 
    7776{ 
    7877        int i, j, k; 
    79         base = (shared[BLOCKSIZE] unsigned char*) upc_all_alloc(1, BLOCKSIZE); 
    80         base = NULL; 
    81  
     78        shared [BLOCKSIZE] unsigned char* base = NULL; 
    8279        int count = 0; 
    8380        for( i = 0; i < me; i++ ) { 
    84                 base = (shared[BLOCKSIZE] unsigned char*) pmv[i].baseaddr; 
     81                base = (shared [BLOCKSIZE] unsigned char*) pmv[i].baseaddr; 
    8582                for( j = 0; j < pmv[i].len; j++ ) { 
    8683                        /* Read the data */ 
     
    9693main() 
    9794{ 
    98 /* To check that each thread reads correct data according to the memvec and filevec from specified file  
    99  * to the shared buffer, regardless of whether the current file pointer type is individual or common  
    100  * Also make sure that this function call does not update the offset of the file pointer  
    101  */ 
    102         pd = (shared[BLOCKSIZE] char*) upc_all_alloc(1, BLOCKSIZE*sizeof(char)); 
    103  
    104         pd = NULL; 
     95/* To check that each thread reads correct data according to the memvec and filevec  
     96 * from specified file to the shared buffer, regardless of whether the current file  
     97 * pointer type is individual or common. And this function call does not update the  
     98 * offset of the file pointer  
     99 */      
    105100        buffer = upc_all_alloc(THREADS*NMEMB, BLOCKSIZE*sizeof(char *)); 
    106101 
     
    120115                size += memvec[i].len; 
    121116 
    122         for( i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) 
    123         { 
     117        for( i = 0; i < sizeof(flags)/sizeof(flags[0]); i++) { 
    124118                flag = flags[i]; 
    125  
    126119                fd = upc_all_fopen( fname, flag, 0, NULL); 
    127120                if( fd == NULL ) 
    128121                        GULA_FAIL("failed to open the file"); 
     122 
    129123                upc_barrier; 
    130124 
    131125                /* Now, we are going to launch upc_fread */ 
    132                 upc_all_fread_list_shared_async(fd, sizeof(memvec)/sizeof(memvec[0]), memvec, 
    133                         sizeof(filevec)/sizeof(filevec[0]), filevec, sync); 
    134                 upc_barrier; 
    135          
    136                 ret = upc_all_fwait_async(fd); 
    137                 if( ret == -1 ) { 
    138                         GULA_FAIL("failed on fwait_async"); 
    139                 } 
    140                 else { 
    141                         if( ret != size) { 
    142                                 GULA_FAIL("failed to read data equal to the amount requested"); 
    143                         } 
    144                 } 
    145                 upc_barrier; 
    146          
    147                 if( -1 == verify(sizeof(memvec)/sizeof(memvec[0]), memvec, sizeof(filevec)/sizeof(filevec[0]), filevec)) 
    148                         GULA_FAIL("failed to read correct data"); 
     126                ret = upc_all_fread_list_shared(fd, sizeof(memvec)/sizeof(memvec[0]), &memvec,sizeof(filevec)/sizeof(filevec[0]), &filevec, sync); 
    149127                 
    150128                upc_barrier; 
     129/*       
     130                if( ret != size ) 
     131                        GULA_FAIL("failed to return the requested bytes"); 
    151132 
    152                 if( upc_all_fclose(fd) != 0 ) 
    153                         GULA_FAIL("failed to close the file");  
    154          
     133                if( -1 == verify(sizeof(memvec)/sizeof(memvec[0]), memvec,sizeof(filevec)/sizeof(filevec[0]), filevec)) 
     134                        GULA_FAIL("failed to read correct data"); 
    155135                upc_barrier; 
     136 
     137                if( upc_all_fclose(fd) != 0 ) 
     138                        GULA_FAIL("failed to close the file"); 
     139          
     140                upc_barrier; 
     141*/ 
    156142        } 
    157  
    158143        return 0; 
    159144} 
  • src/io_fread_list_shared_async_comm.upc

    r113 r118  
    6363        upc_barrier; 
    6464         
    65         upc_all_fread_list_shared_async(fd, 2, memvec, 1, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     65        upc_all_fread_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    6666        bytes = upc_all_fwait_async(fd); 
    6767        upc_barrier; 
  • src/io_fread_list_shared_async_ind.upc

    r113 r118  
    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 
     
    1616static TYPE vbf[180]; 
    1717 
    18 /* nmembs and offsets, this only works for up to 6 threads */ 
     18 
     19/* nmembs and offsets, this only works for up to 3 threads */ 
     20/* Please consider the overlapping for list operation */ 
     21 
     22/* XXX: we need to test whether elemsize is enable for list operation ! */ 
     23 
    1924static int nmembs [] = { 23, 2, 37, 5, 41, 7}; 
    2025static int offsets [] = { 2, 130, 30, 140, 77, 150}; 
    2126 
    22 int 
     27 
     28 
     29int  
    2330main(int argc, char *argv[]){ 
    2431 
    2532        int i, j; 
    2633        int nmemb = nmembs[MYTHREAD]; 
    27         int offset = offsets[MYTHREAD]; 
    28         int blocksize = BLOCKSIZE;              
    29         TYPE *vbfp; 
    30          
     34        upc_off_t offset = offsets[MYTHREAD]; 
     35        int blocksize = BLOCKSIZE; 
     36        TYPE *vbfp;  
     37 
    3138#if BLOCKSIZE != 0 
    3239        shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
    3340#endif 
    34          
     41 
    3542        struct upc_shared_memvec  memvec[2]; 
    36         memvec[0].baseaddr = buffer + offsets[MYTHREAD * 2]; 
    37         memvec[0].blocksize = blocksize; 
    38         memvec[0].len = nmembs[MYTHREAD * 2]; 
    39         memvec[0].elemsize = sizeof(TYPE); 
     43       memvec[0].baseaddr = buffer + offsets[MYTHREAD * 2]; 
     44       memvec[0].blocksize = blocksize; 
     45       memvec[0].len = nmembs[MYTHREAD * 2]; 
     46       memvec[0].elemsize = sizeof(TYPE); 
    4047 
    41         memvec[1].baseaddr = buffer + offsets[MYTHREAD * 2 + 1]; 
    42         memvec[1].blocksize = blocksize; 
    43         memvec[1].len = nmembs[MYTHREAD * 2 + 1]; 
    44         memvec[1].elemsize = sizeof(TYPE); 
     48       memvec[1].baseaddr = buffer + offsets[MYTHREAD * 2 + 1]; 
     49       memvec[1].blocksize = blocksize; 
     50       memvec[1].len = nmembs[MYTHREAD * 2 + 1]; 
     51       memvec[1].elemsize = sizeof(TYPE); 
    4552 
    46         struct upc_filevec filevec[3]; 
    47         filevec[0].offset = offsets[MYTHREAD] * sizeof(TYPE); 
    48         filevec[0].len = 10 * sizeof(TYPE); 
    49         filevec[1].offset = offsets[MYTHREAD+1] * sizeof(TYPE); 
    50         filevec[1].len = 10 * sizeof(TYPE); 
    51         filevec[2].offset = offsets[MYTHREAD+2] * sizeof(TYPE); 
    52         filevec[2].len = (memvec[0].len + memvec[1].len - 20) * sizeof(TYPE); 
     53       struct upc_filevec filevec[3]; 
     54       filevec[0].offset = offsets[MYTHREAD] * sizeof(TYPE); 
     55       filevec[0].len = 10 * sizeof(TYPE); 
     56       filevec[1].offset = offsets[MYTHREAD+1] * sizeof(TYPE); 
     57       filevec[1].len = 10 * sizeof(TYPE); 
     58       filevec[2].offset = offsets[MYTHREAD+2] * sizeof(TYPE); 
     59       filevec[2].len = (memvec[0].len + memvec[1].len - 20) * sizeof(TYPE); 
    5360 
    5461        upc_file_t* fd = upc_all_fopen(argv[1], UPC_RDONLY | UPC_INDIVIDUAL_FP, 0, NULL); 
     
    5663#if BLOCKSIZE != 0 
    5764                if (MYTHREAD == 0) 
    58                        upc_free(buffer); 
     65                upc_free(buffer); 
    5966#endif 
    6067                GULA_FAIL("failed to open the file using UPC_RDONLY | UPC_INDIVIDUAL_FP"); 
    61         } 
     68        } 
     69 
    6270        upc_barrier; 
    6371         
    6472        upc_all_fread_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     73        upc_all_fwait_async(fd); 
    6574        upc_barrier; 
    6675 
    6776        /* Validation start */ 
    6877 
    69         /* copy the chunks to vbf */ 
    70         vbfp = vbf; 
    71         gupc_memget(vbfp, memvec[0].baseaddr, blocksize, sizeof(TYPE), memvec[0].len); 
    72         vbfp += memvec[0].len; 
    73         gupc_memget(vbfp, memvec[1].baseaddr, blocksize, sizeof(TYPE), memvec[1].len); 
     78        /* copy the chunks to vbf */ 
     79        vbfp = vbf; 
     80        gupc_memget(vbfp, memvec[0].baseaddr, blocksize, sizeof(TYPE), memvec[0].len); 
     81        vbfp += memvec[0].len;  
     82        gupc_memget(vbfp, memvec[1].baseaddr, blocksize, sizeof(TYPE), memvec[1].len); 
     83         
     84        /* verify the data using the filevec information */ 
     85        vbfp = vbf; 
     86        for (i = 0; i < 3; i++) { 
     87                for (j = 0; j < filevec[i].len/sizeof(TYPE); j++) { 
     88                        if (*vbfp != (filevec[i].offset / sizeof(TYPE) + j) % 0x80) 
     89                                GULA_FAIL("Data integrity is violated!"); 
     90                        vbfp ++; 
     91                } 
     92        } 
    7493 
    75         /* verify the data using the filevec information */ 
    76         vbfp = vbf; 
    77         for (i = 0; i < 3; i++) { 
    78                 for (j = 0; j < filevec[i].len/sizeof(TYPE); j++) { 
    79                         if (*vbfp != (filevec[i].offset / sizeof(TYPE) + j) % 0x80) 
    80                                 GULA_FAIL("Data integrity is violated!"); 
    81                         vbfp ++; 
    82                 } 
    83         } 
    84  
    85 #if BLOCKSIZE != 0         
    86          if (MYTHREAD == 0) 
    87                 upc_free(buffer); 
     94#if BLOCKSIZE != 0 
     95        if (MYTHREAD == 0) 
     96                upc_free(buffer); 
    8897#endif 
    89  
    9098        return 0; 
    9199} 
  • src/io_fwrite_list_shared_async_comm.upc

    r117 r118  
    6868         
    6969        upc_all_fwrite_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    70         ssize_t bytes = upc_all_fwait_async(fd); 
     70        bytes = upc_all_fwait_async(fd); 
    7171        upc_barrier; 
    7272         
  • src/io_fwrite_list_shared_async_ind.upc

    r113 r118  
    7070         
    7171        upc_all_fwrite_list_shared_async(fd, 2, memvec, 3, filevec, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     72        upc_all_fwait_async(fd); 
    7273        upc_barrier; 
    7374