Changeset 116

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

Fix the io_fwrite_shared_async_ind, and io_fwrite_shared_async_comm bug.

The approach is to copy the correpsonding sync operations, and modify a little bit.

change the sync to async
use wait, then check.

Files:

Legend:

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

    r112 r116  
    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 
     
    1819main(int argc, char *argv[]){ 
    1920 
    20         int i, j; 
     21        int i,j; 
    2122        int nmemb = 60; 
    2223        int blocksize = BLOCKSIZE; 
    23        int memoff = 6; 
    24         upc_off_t fileoff = 19; 
    25        ssize_t bytes; 
    26        upc_off_t offset; 
     24        int memoff = 6; 
     25       upc_off_t fileoff = 19; 
     26        ssize_t bytes; 
     27        upc_off_t offset; 
    2728 
    2829#if BLOCKSIZE != 0 
     
    3031#endif 
    3132 
     33        if( MYTHREAD == 0) 
     34                for( i = 0; i< 180; i++ ) 
     35                        buffer[i] = i % 256; 
     36        upc_barrier; 
     37 
    3238        upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_COMMON_FP, 0, NULL); 
    33          
    34         if (fd == NULL) { 
     39        if (fd == NULL) { 
    3540#if BLOCKSIZE != 0 
    36                 if (MYTHREAD == 0) 
     41               if (MYTHREAD == 0) 
    3742                        upc_free(buffer); 
    3843#endif 
     
    4449        upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 
    4550         
    46         upc_all_fwrite_shared_async(fd, buffer+memoff, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     51        upc_all_fwrite_shared_async(fd, buffer + memoff, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    4752        bytes = upc_all_fwait_async(fd); 
    48          
     53 
    4954        if (bytes != nmemb * sizeof(TYPE)) 
    50                 GULA_FAIL("Short write is not expected, is disc full ?"); 
     55               GULA_FAIL("Short write is not expected, is disc full ?"); 
    5156 
    5257        offset = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
    5358        if (offset != (fileoff + nmemb) * sizeof(TYPE)) 
    54                 GULA_FAIL("Fail to setup the file pointer"); 
    55         upc_barrier; 
     59               GULA_FAIL("Fail to setup the file pointer"); 
     60       upc_barrier; 
    5661 
    57         /* Validation for data integrity */ 
    58         upc_all_fsync(fd); 
    59         upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 
    60         upc_all_fread_shared(fd, vfb, 0, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     62       /* Validation for data integrity */ 
     63       upc_all_fsync(fd); 
     64       upc_all_fseek(fd, fileoff * sizeof(TYPE), UPC_SEEK_SET); 
     65       upc_all_fread_shared(fd, vfb, 0, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    6166 
    62         for (i = 0; i < nmemb; i++) { 
    63                 if (vfb[i] != (memoff + i) % 0x80) 
    64                         GULA_FAIL("Data integrity is violated!"); 
    65         } 
    66  
    67         upc_barrier; 
    68  
     67        for (i = 0; i < nmemb; i++) { 
     68                if (vfb[i] != (memoff + i) % 0x80) 
     69                        GULA_FAIL("Data integrity is violated!"); 
     70        } 
     71         
     72        upc_barrier; 
    6973#if BLOCKSIZE != 0 
    7074        if (MYTHREAD == 0) 
     
    7579} 
    7680 
     81 
  • src/io_fwrite_shared_async_ind.upc

    r110 r116  
    1414#endif 
    1515 
     16 
    1617/* nmembs and offsets, this only works for up to 4 threads */ 
    1718static int nmembs [] = { 23, 5, 37, 6, 8, 12 }; 
     
    1920static TYPE vfb[180]; 
    2021 
    21 int 
     22int  
    2223main(int argc, char *argv[]){ 
    23  
    24         int i, j; 
    25         int nmemb = nmembs[MYTHREAD]; 
    26         upc_off_t offset = offsets[MYTHREAD]; 
    27         int blocksize = BLOCKSIZE; 
    28         size_t bytes; 
     24         
     25       int i, j; 
     26       int nmemb = nmembs[MYTHREAD]; 
     27       upc_off_t offset = offsets[MYTHREAD]; 
     28       int blocksize = BLOCKSIZE; 
     29        ssize_t bytes; 
    2930        upc_off_t vo; 
    30  
     31         
    3132#if BLOCKSIZE != 0 
    32         shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
     33       shared [BLOCKSIZE] TYPE *buffer = (shared[BLOCKSIZE] TYPE*) upc_all_alloc(180, blocksize*sizeof(TYPE)); 
    3334#endif 
    3435 
     
    3940 
    4041        upc_file_t* fd = upc_all_fopen("write_test.txt", UPC_RDWR | UPC_CREATE | UPC_TRUNC | UPC_INDIVIDUAL_FP, 0, NULL); 
    41         if (fd == NULL) { 
     42        if (fd == NULL) { 
    4243#if BLOCKSIZE != 0 
    4344                if (MYTHREAD == 0) 
    44                        upc_free(buffer); 
     45                upc_free(buffer); 
    4546#endif 
    4647                GULA_FAIL("failed to open the file using UPC_RDWR | UPC_INDIVIDUAL_FP"); 
    4748        } 
    48         upc_barrier; 
    4949 
    50         vo = upc_all_fseek(fd, offset, UPC_SEEK_SET); 
    51          
    52         upc_all_fwrite_shared_async(fd, buffer+offset, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
     50        upc_barrier; 
     51 
     52        vo = upc_all_fseek(fd, offset * sizeof(TYPE), UPC_SEEK_SET); 
     53        upc_all_fwrite_shared_async(fd, buffer + offset, blocksize, sizeof(TYPE), nmemb, UPC_IN_NOSYNC | UPC_OUT_NOSYNC); 
    5354        bytes = upc_all_fwait_async(fd); 
    5455 
    5556        if (bytes != nmemb * sizeof(TYPE)) 
    56                 GULA_FAIL("Short write is not expected, is disc full ?"); 
     57               GULA_FAIL("Short write is not expected, is disc full ?"); 
    5758 
    5859        vo = upc_all_fseek(fd, 0, UPC_SEEK_CUR); 
    5960        if (vo != (offset + nmemb) * sizeof(TYPE)) 
    60                 GULA_FAIL("Fail to setup the file pointer"); 
    61  
     61                GULA_FAIL("Fail to setup the file pointer"); 
    6262        upc_barrier; 
    6363 
    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; 
    74  
    75 #if BLOCKSIZE != 0         
    76         if (MYTHREAD == 0) 
     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; 
     74#if BLOCKSIZE != 0 
     75        if (MYTHREAD == 0) 
    7776                upc_free(buffer); 
    7877#endif 
     
    8079        return 0; 
    8180} 
     81 
     82