Add optimization (i.e., avoid malloc(0)) in the (count==0) case. Just
set the correct return values and return. This commit was SVN r27133.
Этот коммит содержится в:
родитель
b08eaae9a2
Коммит
dd5876f74e
@ -76,6 +76,14 @@ void ompi_testall_f(MPI_Fint *count, MPI_Fint *array_of_requests, ompi_fortran_l
|
||||
int i, c_ierr;
|
||||
OMPI_LOGICAL_NAME_DECL(flag);
|
||||
|
||||
/* Shortcut to avoid malloc(0) if *count==0. We're intentionally
|
||||
skipping other parameter error checks. */
|
||||
if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*count))) {
|
||||
*flag = OMPI_FORTRAN_VALUE_TRUE;
|
||||
*ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*count) *
|
||||
(sizeof(MPI_Request) + sizeof(MPI_Status)));
|
||||
if (NULL == c_req){
|
||||
|
@ -78,6 +78,16 @@ void ompi_testany_f(MPI_Fint *count, MPI_Fint *array_of_requests, MPI_Fint *indx
|
||||
OMPI_LOGICAL_NAME_DECL(flag);
|
||||
OMPI_SINGLE_NAME_DECL(indx);
|
||||
|
||||
/* Shortcut to avoid malloc(0) if *count==0. We're intentionally
|
||||
skipping other parameter error checks. */
|
||||
if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*count))) {
|
||||
*flag = OMPI_FORTRAN_VALUE_TRUE;
|
||||
*indx = OMPI_INT_2_FINT(MPI_UNDEFINED);
|
||||
MPI_Status_c2f(&ompi_status_empty, status);
|
||||
*ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*count) * sizeof(MPI_Request));
|
||||
if (c_req == NULL) {
|
||||
c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD,
|
||||
|
@ -80,6 +80,14 @@ void ompi_testsome_f(MPI_Fint *incount, MPI_Fint *array_of_requests,
|
||||
OMPI_SINGLE_NAME_DECL(outcount);
|
||||
OMPI_ARRAY_NAME_DECL(array_of_indices);
|
||||
|
||||
/* Shortcut to avoid malloc(0) if *count==0. We're intentionally
|
||||
skipping other parameter error checks. */
|
||||
if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*incount))) {
|
||||
*outcount = OMPI_INT_2_FINT(MPI_UNDEFINED);
|
||||
*ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*incount) *
|
||||
(sizeof(MPI_Request) + sizeof(MPI_Status)));
|
||||
if (NULL == c_req) {
|
||||
|
@ -77,6 +77,13 @@ void ompi_waitall_f(MPI_Fint *count, MPI_Fint *array_of_requests,
|
||||
MPI_Status *c_status;
|
||||
int i, c_ierr;
|
||||
|
||||
/* Shortcut to avoid malloc(0) if *count==0. We're intentionally
|
||||
skipping other parameter error checks. */
|
||||
if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*count))) {
|
||||
*ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*count) *
|
||||
(sizeof(MPI_Request) + sizeof(MPI_Status)));
|
||||
if (NULL == c_req) {
|
||||
|
@ -78,6 +78,15 @@ void ompi_waitany_f(MPI_Fint *count, MPI_Fint *array_of_requests,
|
||||
int i, c_ierr;
|
||||
OMPI_SINGLE_NAME_DECL(indx);
|
||||
|
||||
/* Shortcut to avoid malloc(0) if *count==0. We're intentionally
|
||||
skipping other parameter error checks. */
|
||||
if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*count))) {
|
||||
*indx = OMPI_INT_2_FINT(MPI_UNDEFINED);
|
||||
MPI_Status_c2f(&ompi_status_empty, status);
|
||||
*ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*count) * sizeof(MPI_Request));
|
||||
if (NULL == c_req) {
|
||||
c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
|
||||
|
@ -81,6 +81,14 @@ void ompi_waitsome_f(MPI_Fint *incount, MPI_Fint *array_of_requests,
|
||||
OMPI_SINGLE_NAME_DECL(outcount);
|
||||
OMPI_ARRAY_NAME_DECL(array_of_indices);
|
||||
|
||||
/* Shortcut to avoid malloc(0) if *count==0. We're intentionally
|
||||
skipping other parameter error checks. */
|
||||
if (OPAL_UNLIKELY(0 == OMPI_FINT_2_INT(*incount))) {
|
||||
*outcount = OMPI_INT_2_FINT(MPI_UNDEFINED);
|
||||
*ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
c_req = (MPI_Request *) malloc(OMPI_FINT_2_INT(*incount) *
|
||||
(sizeof(MPI_Request) + sizeof(MPI_Status)));
|
||||
if (NULL == c_req) {
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user