1
+ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
1
2
/*
2
3
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3
4
* University Research and Technology
11
12
* All rights reserved.
12
13
* Copyright (c) 2008-2014 University of Houston. All rights reserved.
13
14
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
15
+ * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
16
+ * reserved.
14
17
* $COPYRIGHT$
15
18
*
16
19
* Additional copyrights may follow
@@ -186,7 +189,7 @@ mca_fcoll_two_phase_file_read_all (mca_io_ompio_file_t *fh,
186
189
two_phase_num_io_procs ,
187
190
max_data );
188
191
if (OMPI_SUCCESS != ret ){
189
- return ret ;
192
+ goto exit ;
190
193
}
191
194
192
195
two_phase_num_io_procs = fh -> f_final_num_aggrs ;
@@ -497,21 +500,19 @@ mca_fcoll_two_phase_file_read_all (mca_io_ompio_file_t *fh,
497
500
if (flat_buf -> indices != NULL ){
498
501
free (flat_buf -> indices );
499
502
}
500
- free (flat_buf );
501
503
flat_buf = NULL ;
502
504
}
503
- if (start_offsets != NULL ){
504
- free (start_offsets );
505
- start_offsets = NULL ;
506
- }
507
- if (end_offsets != NULL ){
508
- free (end_offsets );
509
- end_offsets = NULL ;
510
- }
511
- if (aggregator_list != NULL ){
512
- free (aggregator_list );
513
- aggregator_list = NULL ;
514
- }
505
+
506
+ free (start_offsets );
507
+ free (end_offsets );
508
+ free (aggregator_list );
509
+ free (fd_start );
510
+ free (decoded_iov );
511
+ free (buf_indices );
512
+ free (count_my_req_per_proc );
513
+ free (my_req );
514
+ free (others_req );
515
+ free (fd_end );
515
516
516
517
return ret ;
517
518
}
@@ -634,8 +635,8 @@ static int two_phase_read_and_exch(mca_io_ompio_file_t *fh,
634
635
635
636
start_pos = (int * ) calloc (fh -> f_size , sizeof (int ));
636
637
if ( NULL == start_pos ){
637
- ret = OMPI_ERR_OUT_OF_RESOURCE ;
638
- return ret ;
638
+ ret = OMPI_ERR_OUT_OF_RESOURCE ;
639
+ goto exit ;
639
640
}
640
641
641
642
done = 0 ;
@@ -717,7 +718,8 @@ static int two_phase_read_and_exch(mca_io_ompio_file_t *fh,
717
718
(1 ,sizeof (mca_io_ompio_io_array_t ));
718
719
if (NULL == fh -> f_io_array ) {
719
720
opal_output (1 , "OUT OF MEMORY\n" );
720
- return OMPI_ERR_OUT_OF_RESOURCE ;
721
+ ret = OMPI_ERR_OUT_OF_RESOURCE ;
722
+ goto exit ;
721
723
}
722
724
fh -> f_io_array [0 ].offset = (IOVBASE_TYPE * )(intptr_t )off ;
723
725
fh -> f_io_array [0 ].length = len ;
@@ -728,7 +730,8 @@ static int two_phase_read_and_exch(mca_io_ompio_file_t *fh,
728
730
if (fh -> f_num_of_io_entries ){
729
731
if ( 0 > fh -> f_fbtl -> fbtl_preadv (fh )) {
730
732
opal_output (1 , "READ FAILED\n" );
731
- return OMPI_ERROR ;
733
+ ret = OMPI_ERROR ;
734
+ goto exit ;
732
735
}
733
736
}
734
737
@@ -797,40 +800,17 @@ static int two_phase_read_and_exch(mca_io_ompio_file_t *fh,
797
800
flat_buf , others_req , m , buf_idx ,
798
801
buftype_extent , striping_unit , two_phase_num_io_procs ,
799
802
aggregator_list );
800
- if (ntimes ){
801
- free (read_buf );
802
- read_buf = NULL ;
803
- }
804
- if (NULL != curr_offlen_ptr ){
805
- free (curr_offlen_ptr );
806
- curr_offlen_ptr = NULL ;
807
- }
808
- if (NULL != count ){
809
- free (count );
810
- count = NULL ;
811
- }
812
- if (NULL != partial_send ){
813
- free (partial_send );
814
- partial_send = NULL ;
815
- }
816
- if (NULL != send_size ){
817
- free (send_size );
818
- send_size = NULL ;
819
- }
820
- if (NULL != recv_size ){
821
- free (recv_size );
822
- recv_size = NULL ;
823
- }
824
- if (NULL != recd_from_proc ){
825
- free (recd_from_proc );
826
- recd_from_proc = NULL ;
827
- }
828
- if (NULL != start_pos ){
829
- free (start_pos );
830
- start_pos = NULL ;
831
- }
832
803
833
804
exit :
805
+ free (read_buf );
806
+ free (curr_offlen_ptr );
807
+ free (count );
808
+ free (partial_send );
809
+ free (send_size );
810
+ free (recv_size );
811
+ free (recd_from_proc );
812
+ free (start_pos );
813
+
834
814
return ret ;
835
815
836
816
}
@@ -919,7 +899,7 @@ static int two_phase_exchange_data(mca_io_ompio_file_t *fh,
919
899
}
920
900
else {
921
901
922
- recv_buf = (char * * )malloc (fh -> f_size * sizeof (char * ));
902
+ recv_buf = (char * * ) calloc (fh -> f_size , sizeof (char * ));
923
903
if (NULL == recv_buf ){
924
904
ret = OMPI_ERR_OUT_OF_RESOURCE ;
925
905
goto exit ;
@@ -983,7 +963,9 @@ static int two_phase_exchange_data(mca_io_ompio_file_t *fh,
983
963
ret = ompi_request_wait_all (nprocs_recv ,
984
964
requests ,
985
965
MPI_STATUS_IGNORE );
986
-
966
+ if (OMPI_SUCCESS != ret ) {
967
+ goto exit ;
968
+ }
987
969
988
970
if (! (fh -> f_flags & OMPIO_CONTIGUOUS_MEMORY )) {
989
971
@@ -1001,26 +983,23 @@ static int two_phase_exchange_data(mca_io_ompio_file_t *fh,
1001
983
requests + nprocs_recv ,
1002
984
MPI_STATUS_IGNORE );
1003
985
1004
- if (NULL != requests ){
1005
- free (requests );
1006
- requests = NULL ;
1007
- }
986
+ #if OMPIO_FCOLL_WANT_TIME_BREAKDOWN
987
+ end_rcomm_time = MPI_Wtime ();
988
+ rcomm_time += (end_rcomm_time - start_rcomm_time );
989
+ #endif
990
+
991
+ exit :
1008
992
1009
- if (! ( fh -> f_flags & OMPIO_CONTIGUOUS_MEMORY )) {
993
+ if (recv_buf ) {
1010
994
for (i = 0 ; i < fh -> f_size ; i ++ ){
1011
- if (recv_size [i ]){
1012
- free (recv_buf [i ]);
1013
- }
995
+ free (recv_buf [i ]);
1014
996
}
997
+
1015
998
free (recv_buf );
1016
999
}
1017
1000
1018
- #if OMPIO_FCOLL_WANT_TIME_BREAKDOWN
1019
- end_rcomm_time = MPI_Wtime ();
1020
- rcomm_time += (end_rcomm_time - start_rcomm_time );
1021
- #endif
1001
+ free (requests );
1022
1002
1023
- exit :
1024
1003
return ret ;
1025
1004
1026
1005
}
0 commit comments