/* progresses a request * * to be called *only* from the progress thread !!! */ int NBC_Progress(NBC_Handle *handle) { int flag, res, ret=NBC_CONTINUE; unsigned long size; char *delim; /* the handle is done if there is no schedule attached */ if (NULL == handle->schedule) { return NBC_OK; } if ((handle->req_count > 0) && (handle->req_array != NULL)) { NBC_DEBUG(50, "NBC_Progress: testing for %i requests\n", handle->req_count); #ifdef NBC_TIMING Test_time -= MPI_Wtime(); #endif res = ompi_request_test_all(handle->req_count, handle->req_array, &flag, MPI_STATUSES_IGNORE); if(res != OMPI_SUCCESS) { NBC_Error ("MPI Error in MPI_Testall() (%i)", res); return res; } #ifdef NBC_TIMING Test_time += MPI_Wtime(); #endif } else { flag = 1; /* we had no open requests -> proceed to next round */ } /* a round is finished */ if (flag) { /* adjust delim to start of current round */ NBC_DEBUG(5, "NBC_Progress: going in schedule %p to row-offset: %li\n", handle->schedule, handle->row_offset); delim = handle->schedule->data + handle->row_offset; NBC_DEBUG(10, "delim: %p\n", delim); nbc_get_round_size(delim, &size); NBC_DEBUG(10, "size: %li\n", size); /* adjust delim to end of current round -> delimiter */ delim = delim + size; if (NULL != handle->req_array) { /* free request array */ free (handle->req_array); handle->req_array = NULL; } handle->req_count = 0; if (*delim == 0) { /* this was the last round - we're done */ NBC_DEBUG(5, "NBC_Progress last round finished - we're done\n"); NBC_Free(handle); return NBC_OK; } NBC_DEBUG(5, "NBC_Progress round finished - goto next round\n"); /* move delim to start of next round */ /* initializing handle for new virgin round */ handle->row_offset = (intptr_t) (delim + 1) - (intptr_t) handle->schedule->data; /* kick it off */ res = NBC_Start_round(handle); if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { NBC_Error ("Error in NBC_Start_round() (%i)", res); return res; } } return ret; }
/* progresses a request * * to be called *only* from the progress thread !!! */ int NBC_Progress(NBC_Handle *handle) { int flag, res, ret=NBC_CONTINUE; long size; char *delim; /* the handle is done if there is no schedule attached */ if(handle->schedule != NULL) { if((handle->req_count > 0) && (handle->req_array != NULL)) { NBC_DEBUG(50, "NBC_Progress: testing for %i requests\n", handle->req_count); #ifdef NBC_TIMING Test_time -= MPI_Wtime(); #endif res = ompi_request_test_all(handle->req_count, handle->req_array, &flag, MPI_STATUSES_IGNORE); if(res != OMPI_SUCCESS) { printf("MPI Error in MPI_Testall() (%i)\n", res); ret=res; goto error; } #ifdef NBC_TIMING Test_time += MPI_Wtime(); #endif } else { flag = 1; /* we had no open requests -> proceed to next round */ } /* a round is finished */ if(flag) { /* adjust delim to start of current round */ NBC_DEBUG(5, "NBC_Progress: going in schedule %p to row-offset: %li\n", *handle->schedule, handle->row_offset); delim = (char*)*handle->schedule + handle->row_offset; NBC_DEBUG(10, "delim: %p\n", delim); NBC_GET_ROUND_SIZE(delim, size); NBC_DEBUG(10, "size: %li\n", size); /* adjust delim to end of current round -> delimiter */ delim = delim + size; if(handle->req_array != NULL) { /* free request array */ free((void*)handle->req_array); handle->req_array = NULL; } handle->req_count = 0; if(*delim == 0) { /* this was the last round - we're done */ NBC_DEBUG(5, "NBC_Progress last round finished - we're done\n"); res = NBC_Free(handle); if((NBC_OK != res)) { printf("Error in NBC_Free() (%i)\n", res); ret=res; goto error; } return NBC_OK; } else { NBC_DEBUG(5, "NBC_Progress round finished - goto next round\n"); /* move delim to start of next round */ delim = delim+1; /* initializing handle for new virgin round */ handle->row_offset = (long)delim - (long)*handle->schedule; /* kick it off */ res = NBC_Start_round(handle); if(NBC_OK != res) { printf("Error in NBC_Start_round() (%i)\n", res); ret=res; goto error; } } } } else { ret= NBC_OK; } error: return ret; }