Changeset 114

Show
Ignore:
Timestamp:
03/20/07 20:20:42
Author:
kunxi
Message:

Add read_int.test in io_rw_compound.
Remove read_int.test from the depository.

Files:

Legend:

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

    r51 r114  
    3737 
    3838static char fname[] = "read.test"; 
     39static char fname_int[] = "read_int.test"; 
    3940static upc_file_t* fd = NULL; 
    4041struct upc_hint const hints = {"file_perm","rw-rw----"}; 
     
    4445static int ret; 
    4546static  char buffer[BUFSIZE]; 
     47static  int int_buffer[BUFSIZE]; 
    4648 
    4749/*To check that upc_all_fread_local and upc_all_fwrite_local work on individual file pointer*/ 
     
    5860        /* Initialize the data */ 
    5961        for( i = 0; i < BUFSIZE; i++ ) 
    60                 buffer[i] = i % 128; 
     62                buffer[i] = i;  
    6163 
    6264        upc_barrier; 
     
    9799         
    98100        upc_barrier; 
     101 
     102        /* Do the same operation for read_int.test */ 
     103        /* Create the target file */ 
     104        fd = upc_all_fopen( fname_int, 
     105                UPC_WRONLY | UPC_INDIVIDUAL_FP | UPC_CREATE | UPC_TRUNC, 1, &hints); 
     106         if( fd == NULL ) 
     107                GULA_FAIL("failed to create the file"); 
     108 
     109        /* Initialize the data */ 
     110        for( i = 0; i < BUFSIZE; i++ ) 
     111                int_buffer[i] = i;  
     112 
     113        upc_barrier; 
     114 
     115        /* The data is overwriten by THREADS times, so don't panic */ 
     116        for( i = 0; i< 1000; i++ ) { 
     117                ret = upc_all_fwrite_local(fd, int_buffer, sizeof(int), BUFSIZE, sync); 
     118                if (ret != BUFSIZE * sizeof(int)) 
     119                        GULA_FAIL("failed to write"); 
     120        } 
     121        if( upc_all_fclose(fd) != 0 ) 
     122                GULA_FAIL("failed to close the file"); 
     123 
     124        upc_barrier; 
     125 
     126        fd = upc_all_fopen( fname_int, 
     127                UPC_RDONLY | UPC_INDIVIDUAL_FP, 0, NULL); 
     128        if( fd == NULL ) 
     129                GULA_FAIL("failed to open the file"); 
     130 
     131        /* Initialize the data */ 
     132        for( i = 0; i < BUFSIZE; i++ ) 
     133                int_buffer[i] = 0; 
     134        upc_barrier; 
     135 
     136        count = 0; 
     137        for( i = 0; i < 1000; i++) { 
     138                ret = upc_all_fread_local(fd, int_buffer, sizeof(int), BUFSIZE, sync); 
     139                if( ret != BUFSIZE * sizeof(int)) 
     140                        GULA_FAIL("failed to upc_all_fread properly"); 
     141                /* Validation */ 
     142                for( j = 0; j < BUFSIZE; j++, count ++ ) 
     143                        if( int_buffer[j] !=  count % 128 ) 
     144                                GULA_FAIL("failed to read correct data using upc_all_fread_local"); 
     145        } 
     146        if( upc_all_fclose(fd) != 0 ) 
     147                GULA_FAIL("failed to close the file"); 
     148         
    99149        return 0; 
    100150}