1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/*
* Copyright (c) 2012 Sandia National Laboratories. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "ompi_config.h"
#include <portals4.h>
#include "mtl_portals4.h"
#include "mtl_portals4_request.h"
int
ompi_mtl_portals4_cancel(struct mca_mtl_base_module_t* mtl,
mca_mtl_request_t *mtl_request,
int flag)
{
ompi_mtl_portals4_base_request_t *base_request =
(ompi_mtl_portals4_base_request_t*) mtl_request;
int ret;
switch (base_request->type) {
case portals4_req_isend:
/* can't cancel sends yet */
break;
case portals4_req_recv:
{
ompi_mtl_portals4_recv_request_t *recvreq =
(ompi_mtl_portals4_recv_request_t*) base_request;
/* Cancel receive requests if not yet matched (otherwise,
they are guaranteed to complete and don't need to be
cancelled). If the me_h is already INVALID, that means
that not only has matching occurred, but the
communication end event has been seen. If MEUnlink
fails, that means that either something bad has
happened or the ME is in use (meaning no cancel). Need
to drain queue to make sure there isn't a pending
receive completion event... */
ompi_mtl_portals4_progress();
if (!PtlHandleIsEqual(recvreq->me_h, PTL_INVALID_HANDLE)) {
ret = PtlMEUnlink(recvreq->me_h);
if (PTL_OK == ret) {
recvreq->super.super.ompi_req->req_status._cancelled = true;
recvreq->super.super.completion_callback(&recvreq->super.super);
}
}
}
break;
default:
return OMPI_ERROR;
}
return OMPI_SUCCESS;
}
|