File: mtl_mxm_probe.c

package info (click to toggle)
openmpi 3.1.3-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,572 kB
  • sloc: ansic: 628,972; f90: 17,993; makefile: 13,761; sh: 7,051; java: 6,360; perl: 3,215; cpp: 2,225; python: 1,350; lex: 988; fortran: 52; tcl: 12
file content (115 lines) | stat: -rw-r--r-- 3,416 bytes parent folder | download | duplicates (2)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (C) Mellanox Technologies Ltd. 2001-2011.  ALL RIGHTS RESERVED.
 * Copyright (c) 2013      The University of Tennessee and The University
 *                         of Tennessee Research Foundation.  All rights
 *                         reserved.
 * Copyright (c) 2015      Los Alamos National Security, LLC.  All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "ompi_config.h"
#include "mtl_mxm.h"
#include "mtl_mxm_types.h"

#include "ompi/message/message.h"
#include "ompi/communicator/communicator.h"

int ompi_mtl_mxm_iprobe(struct mca_mtl_base_module_t* mtl,
                        struct ompi_communicator_t *comm, int src, int tag,
                        int *flag, struct ompi_status_public_t *status)
{
    mxm_error_t err;
    mxm_recv_req_t req;

    req.base.state = MXM_REQ_NEW;
    ompi_mtl_mxm_set_recv_envelope(&req, comm, src, tag);

    err = mxm_req_probe(&req);
    if (MXM_OK == err) {
        *flag = 1;
        if (MPI_STATUS_IGNORE != status) {
            ompi_mtl_mxm_to_mpi_status(err, status);
            status->MPI_SOURCE = req.completion.sender_imm;
            status->MPI_TAG    = req.completion.sender_tag;
            status->_ucount    = req.completion.sender_len;
        }
        return OMPI_SUCCESS;
    } else if (MXM_ERR_NO_MESSAGE == err) {
        *flag = 0;
        return OMPI_SUCCESS;
    } else {
        return OMPI_ERROR;
    }
}


int ompi_mtl_mxm_improbe(struct mca_mtl_base_module_t *mtl,
                         struct ompi_communicator_t *comm,
                         int src,
                         int tag,
                         int *matched,
                         struct ompi_message_t **message,
                         struct ompi_status_public_t *status)
{
    mxm_error_t err;
    mxm_recv_req_t req;

    opal_free_list_item_t *item;
    ompi_mtl_mxm_message_t *msgp;

    item = opal_free_list_wait (&mca_mtl_mxm_component.mxm_messages);
    if (OPAL_UNLIKELY(NULL == item)) {
        return OMPI_ERR_OUT_OF_RESOURCE;
    }

    msgp = (ompi_mtl_mxm_message_t *) item;

    req.base.state = MXM_REQ_NEW;
    ompi_mtl_mxm_set_recv_envelope(&req, comm, src, tag);

    msgp->mq       = req.base.mq;
    msgp->conn     = req.base.conn;
    msgp->tag      = req.tag;
    msgp->tag_mask = req.tag_mask;

    err = mxm_req_mprobe(&req, &msgp->mxm_msg);
    if (MXM_OK == err) {
        if (MPI_STATUS_IGNORE != status) {
            *matched = 1;
            ompi_mtl_mxm_to_mpi_status(err, status);
            status->MPI_SOURCE = req.completion.sender_imm;
            status->MPI_TAG    = req.completion.sender_tag;
            status->_ucount    = req.completion.sender_len;
        } else{
			*matched = 0;
			*message = MPI_MESSAGE_NULL;
			return OMPI_SUCCESS;
		}
    } else if (MXM_ERR_NO_MESSAGE == err) {
        *matched = 0;
        *message = MPI_MESSAGE_NULL;
        return OMPI_SUCCESS;
    } else {
        return OMPI_ERROR;
    }

	(*message) = ompi_message_alloc();
	if (OPAL_UNLIKELY(NULL == (*message))) {
        *matched = 0;
		*message = MPI_MESSAGE_NULL;
		return OMPI_ERR_OUT_OF_RESOURCE;
	}

	(*message)->comm = comm;
	(*message)->req_ptr = msgp;
	(*message)->peer = status->MPI_SOURCE;
	(*message)->count = status->_ucount;

    return OMPI_SUCCESS;
}