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