Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 98bc218

Browse files
committed
fix the get_byte_offset code
1 parent 971f697 commit 98bc218

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

ompi/mca/io/ompio/io_ompio_file_open.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -768,35 +768,36 @@ mca_io_ompio_file_get_byte_offset (ompi_file_t *fh,
768768
{
769769
mca_io_ompio_data_t *data;
770770
int i, k, index;
771-
size_t position;
772-
size_t total_bytes;
773771
size_t temp_offset;
774772

775773
data = (mca_io_ompio_data_t *) fh->f_io_selected_data;
776774

777775
temp_offset = data->ompio_fh.f_view_extent *
778776
(offset*data->ompio_fh.f_etype_size / data->ompio_fh.f_view_size);
777+
779778

780-
position = 0;
781-
total_bytes = (offset*data->ompio_fh.f_etype_size) % data->ompio_fh.f_view_size;
779+
i = (offset*data->ompio_fh.f_etype_size) % data->ompio_fh.f_view_size;
782780
index = 0;
783-
i = total_bytes;
784781
k = 0;
785782

786783
while (1) {
787-
k += data->ompio_fh.f_decoded_iov[index].iov_len;
784+
k = data->ompio_fh.f_decoded_iov[index].iov_len;
788785
if (i >= k) {
789-
i = i - data->ompio_fh.f_decoded_iov[index].iov_len;
790-
position += data->ompio_fh.f_decoded_iov[index].iov_len;
791-
index = index+1;
786+
i -= k;
787+
index++;
788+
if ( 0 == i ) {
789+
k=0;
790+
break;
791+
}
792792
}
793793
else {
794+
k=i;
794795
break;
795796
}
796797
}
797798

798799
*disp = data->ompio_fh.f_disp + temp_offset +
799-
(OMPI_MPI_OFFSET_TYPE)(intptr_t)data->ompio_fh.f_decoded_iov[index].iov_base;
800+
(OMPI_MPI_OFFSET_TYPE)(intptr_t)data->ompio_fh.f_decoded_iov[index].iov_base + k;
800801

801802
return OMPI_SUCCESS;
802803
}

0 commit comments

Comments
 (0)