1
1

fix some zero byte allocation scenarios.

This commit was SVN r32689.
Этот коммит содержится в:
Edgar Gabriel 2014-09-09 16:25:44 +00:00
родитель 63209eac5b
Коммит 6a607caed8

Просмотреть файл

@ -142,6 +142,7 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
goto exit; goto exit;
} }
if ( iov_size > 0 ) {
local_iov_array = (local_io_array *)malloc (iov_size * sizeof(local_io_array)); local_iov_array = (local_io_array *)malloc (iov_size * sizeof(local_io_array));
if ( NULL == local_iov_array){ if ( NULL == local_iov_array){
ret = OMPI_ERR_OUT_OF_RESOURCE; ret = OMPI_ERR_OUT_OF_RESOURCE;
@ -156,10 +157,21 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
local_iov_array[j].process_id = fh->f_rank; local_iov_array[j].process_id = fh->f_rank;
} }
/* io_array datatype for using in communication*/ }
types[0] = &ompi_mpi_long.dt; else {
types[1] = &ompi_mpi_long.dt; /* Allocate at least one element to correctly create the derived
types[2] = &ompi_mpi_int.dt; data type */
local_iov_array = (local_io_array *)malloc (sizeof(local_io_array));
if ( NULL == local_iov_array){
ret = OMPI_ERR_OUT_OF_RESOURCE;
goto exit;
}
local_iov_array[0].offset = (OMPI_MPI_OFFSET_TYPE)(intptr_t) 0;
local_iov_array[0].length = (size_t) 0;
local_iov_array[0].process_id = fh->f_rank;
}
d[0] = (OPAL_PTRDIFF_TYPE)&local_iov_array[0]; d[0] = (OPAL_PTRDIFF_TYPE)&local_iov_array[0];
d[1] = (OPAL_PTRDIFF_TYPE)&local_iov_array[0].length; d[1] = (OPAL_PTRDIFF_TYPE)&local_iov_array[0].length;
@ -168,6 +180,12 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
for (i=0 ; i<3 ; i++) { for (i=0 ; i<3 ; i++) {
d[i] -= base; d[i] -= base;
} }
/* io_array datatype for using in communication*/
types[0] = &ompi_mpi_long.dt;
types[1] = &ompi_mpi_long.dt;
types[2] = &ompi_mpi_int.dt;
ompi_datatype_create_struct (3, ompi_datatype_create_struct (3,
blocklen, blocklen,
d, d,
@ -283,7 +301,8 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
} }
if (fh->f_procs_in_group[fh->f_aggregator_index] == fh->f_rank) { if ( (fh->f_procs_in_group[fh->f_aggregator_index] == fh->f_rank) &&
(global_iov_count > 0 )) {
global_iov_array = (local_io_array *) malloc (global_iov_count * global_iov_array = (local_io_array *) malloc (global_iov_count *
sizeof(local_io_array)); sizeof(local_io_array));
if (NULL == global_iov_array){ if (NULL == global_iov_array){
@ -315,7 +334,8 @@ mca_fcoll_static_file_read_all (mca_io_ompio_file_t *fh,
local_iov_array = NULL; local_iov_array = NULL;
} }
if (fh->f_procs_in_group[fh->f_aggregator_index] == fh->f_rank) { if ( ( fh->f_procs_in_group[fh->f_aggregator_index] == fh->f_rank) &&
( global_iov_count > 0 )) {
sorted = (int *)malloc (global_iov_count * sizeof(int)); sorted = (int *)malloc (global_iov_count * sizeof(int));
if (NULL == sorted) { if (NULL == sorted) {
opal_output (1, "OUT OF MEMORY\n"); opal_output (1, "OUT OF MEMORY\n");
@ -968,6 +988,10 @@ int read_local_heap_sort (local_io_array *io_array,
unsigned char done = 0; unsigned char done = 0;
int* temp_arr = NULL; int* temp_arr = NULL;
if ( 0 == num_entries ) {
return OMPI_SUCCESS;
}
temp_arr = (int*)malloc(num_entries*sizeof(int)); temp_arr = (int*)malloc(num_entries*sizeof(int));
if (NULL == temp_arr) { if (NULL == temp_arr) {
opal_output (1, "OUT OF MEMORY\n"); opal_output (1, "OUT OF MEMORY\n");