[MPICH] slow IOR when using fileview

Wei-keng Liao wkliao at ece.northwestern.edu
Wed Jul 11 00:48:35 CDT 2007


I just found that the fix I provided earlier is still not correct.
I am checking the function ADIOI_GEN_WriteStrided() in file ad_write_str.c.

The codes between lines 222 and 241 look odd to me. My testing sometimes
generates strange values of
   st_index == flat_file->count-1 && flat_file->indices[st_index] == 0
Although this case will be handled correctly later, it is more readable
if st_index points to the beginning of next filetype, i.e.
st_index == 0 and n_filetypes is one larger in numerical value.

In fact, the while loop can be avoided by replacing the entire
block (lines 222 to 241) by

     if (file_ptr_type == ADIO_INDIVIDUAL) {
         offset = fd->fp_ind - disp; /* in bytes */
         n_filetypes = offset / filetype_extent;  /* no. filetypes */
         offset %= filetype_extent;   /* local offset in a filetype */
         for (i=0; i<flat_file->count; i++)  /* binary search could be better */
             if (flat_file->indices[i] <= offset &&
                 offset < flat_file->indices[i] + flat_file->blocklens[i])
                 break;
         st_index = i;  /* starting index in flat_file->indices[] */
         fwr_size = (int) (flat_file->indices[i] + flat_file->blocklens[i]
                           - offset);
         offset = fd->fp_ind; /* in bytes */
     }

The codes above are very similar to the shared file pointer codes (the 
else statement) and they can also simplify my fix for contiguous buftype 
located entirely within a single flat_file's contiguous block. The fix is

     /* write request is within a single flat_file block */
     if (buftype_is_contig && bufsize <= fwr_size) {
         ADIO_WriteContig(fd, buf, bufsize, MPI_BYTE, ADIO_EXPLICIT_OFFSET,
                          offset, status, error_code);
         return;
     }

This fix should be inserted right after the line of
     start_off = offset;

Wei-keng



On Tue, 10 Jul 2007, Wei-keng Liao wrote:

>
> Here is a revised of the fix I proposed earlier, where I forgot to
> consider the file displacement, fd->disp, defined in the file view.
>
>    if (file_ptr_type == ADIO_INDIVIDUAL && buftype_is_contig &&
>        bufsize + (offset - (fd->disp + flat_file->indices[st_index])) <=
>        flat_file->blocklens[st_index]) {
>        ADIO_WriteContig(fd, buf, bufsize, MPI_BYTE, ADIO_EXPLICIT_OFFSET,
>                         offset, status, error_code);
>        return;
>    }
>
>
> Wei-keng
>
>
> On Tue, 3 Jul 2007, Wei-keng Liao wrote:
>
>> 
>> I come up with a very simple solution for checking this contiguous buftype, 
>> non-contiguous filetype, but the "intersection" is contiguous.
>> In file ad_write_str.c, line 265, insert the followings:
>> 
>>    if (file_ptr_type == ADIO_INDIVIDUAL && buftype_is_contig &&
>>        bufsize + (offset - flat_file->indices[st_index]) <=
>>        flat_file->blocklens[st_index]) {
>>        ADIO_WriteContig(fd, buf, bufsize, MPI_BYTE, ADIO_EXPLICIT_OFFSET,
>>                         offset, status, error_code);
>>        return;
>>    }
>> 
>> The first if condition "file_ptr_type == ADIO_INDIVIDUAL" is because I am 
>> not sure if this is applicable to shared file pointers.
>> 
>> The second condition "buftype_is_contig" is to ensure buffer is contiguous.
>> 
>> The third condition is to ensure the requesting data is within a single 
>> block of flat_file, ie, the st_index block in flat_file.
>> 
>> I tested it with my testing code and it ran OK. Please let me know if this 
>> can cause any problem that I did not think of. I hope it can be 
>> incorporated into ROMIO in the future release.
>> 
>> Wei-keng
>>




More information about the mpich-discuss mailing list