Example #1
0
psm2_error_t
ips_am_short_request(psm2_epaddr_t epaddr,
		     psm2_handler_t handler, psm2_amarg_t *args, int nargs,
		     void *src, size_t len, int flags,
		     psm2_am_completion_fn_t completion_fn,
		     void *completion_ctxt)
{
	struct ips_proto_am *proto_am = &epaddr->proto->proto_am;
	psm2_error_t err;
	ips_scb_t *scb;
	ips_epaddr_t *ipsaddr;
	int pad_bytes = calculate_pad_bytes(len);
	int payload_sz = (nargs << 3);

	if_pt(!(flags & PSM2_AM_FLAG_ASYNC))
	    payload_sz += len;

	if (payload_sz > (IPS_AM_HDR_NARGS << 3)) {
		/* Payload can't fit in header, allocate buffer to carry data */
		int arg_sz = (nargs > IPS_AM_HDR_NARGS) ?
		    ((nargs - IPS_AM_HDR_NARGS) << 3) : 0;

		/* len + pad_bytes + overflow_args */
		PSMI_BLOCKUNTIL(epaddr->ptlctl->ep,
				err,
				((scb = ips_scbctrl_alloc(
				      &proto_am->scbc_request,
				      1,
				      len + pad_bytes + arg_sz,
				      IPS_SCB_FLAG_ADD_BUFFER)) != NULL));
	} else {
		PSMI_BLOCKUNTIL(epaddr->ptlctl->ep,
				err,
				((scb = ips_scbctrl_alloc_tiny(
				      &proto_am->scbc_request)) != NULL));
	}

	psmi_assert_always(scb != NULL);
	ips_am_scb_init(scb, handler, nargs, pad_bytes,
			completion_fn, completion_ctxt);

	/* Select the next ipsaddr for multi-rail */
	ipsaddr = ((ips_epaddr_t *)epaddr)->msgctl->ipsaddr_next;
	ipsaddr->msgctl->ipsaddr_next = ipsaddr->next;

	return am_short_reqrep(scb, ipsaddr, args,
			       nargs,
			       (flags & PSM2_AM_FLAG_NOREPLY) ?
			       OPCODE_AM_REQUEST_NOREPLY : OPCODE_AM_REQUEST,
			       src, len, flags, pad_bytes);
}
Example #2
0
static inline void gasnetc_PostSend(mxm_send_req_t * mxm_sreq,
                                    uint8_t is_request,
                                    uint8_t block,
                                    uint8_t msg_num)
{
    mxm_error_t mxm_res;

#if GASNET_DEBUG_AM
    MXM_LOG("[pid %d] calling mxm_req_send()...\n", getpid());
#endif

    mxm_res = mxm_req_send(mxm_sreq);

#if GASNET_DEBUG_AM
    MXM_LOG("[pid %d] mxm_req_send() returned %d\n", getpid(), (int)mxm_res);
#endif

    if_pf (mxm_res != MXM_OK)
    gasneti_fatalerror("Error posting send request - %s\n",
                       mxm_error_string(mxm_res));

    if_pt (block)
    gasnetc_ReqRepWait(mxm_sreq, is_request, msg_num);
}
Example #3
0
extern void gasnetc_barrier_fence(void)
{
    gasnet_mxm_send_req_t * sreqs;
    mxm_send_req_t * mxm_sreq;
    mxm_error_t mxm_res;
    int dest;

    sreqs = (gasnet_mxm_send_req_t *)
            alloca(sizeof(gasnet_mxm_send_req_t) * gasneti_nodes);

    for (dest = 0; dest < gasneti_nodes; dest++) {
        if (!gasnet_mxm_module.need_fence[dest])
            continue;
        if_pf (dest == gasneti_mynode)
        continue;
#if GASNET_PSHM
        if_pf (gasneti_pshm_in_supernode(dest))
        continue;
#endif
        mxm_sreq = &sreqs[dest].mxm_sreq;
#if MXM_API < MXM_VERSION(2,0)
        mxm_sreq->opcode = MXM_REQ_OP_FENCE;
        mxm_sreq->base.flags = MXM_REQ_FLAG_SEND_SYNC;
#else
        mxm_sreq->opcode = MXM_REQ_OP_PUT_SYNC;
        mxm_sreq->flags  = MXM_REQ_SEND_FLAG_FENCE;
        mxm_sreq->op.mem.remote_vaddr = 0;
        mxm_sreq->op.mem.remote_mkey  = &mxm_empty_mem_key;
#endif

        mxm_sreq->base.state = MXM_REQ_NEW;
        mxm_sreq->base.conn = gasnet_mxm_module.connections[dest];
        mxm_sreq->base.mq = gasnet_mxm_module.mxm_mq;

        mxm_sreq->base.data.buffer.ptr = NULL;
        mxm_sreq->base.data.buffer.length = 0;

#if MXM_API < MXM_VERSION(1,5)
        mxm_sreq->base.data.buffer.mkey = MXM_MKEY_NONE;
#else
        mxm_sreq->base.data.buffer.memh = NULL;
#endif
        mxm_sreq->base.data_type = MXM_REQ_DATA_BUFFER;

        mxm_sreq->base.completed_cb = NULL;
        mxm_sreq->base.context = NULL;

        mxm_res = mxm_req_send(mxm_sreq);
        if_pt (MXM_OK != mxm_res)
        gasneti_fatalerror("Error posting send request - %s\n",
                           mxm_error_string(mxm_res));
    }

    for (dest = 0; dest < gasneti_nodes; dest++) {
        if (!gasnet_mxm_module.need_fence[dest])
            continue;
        if_pf (dest == gasneti_mynode)
        continue;
#if GASNET_PSHM
        if_pf (gasneti_pshm_in_supernode(dest))
        continue;
#endif
        mxm_sreq = &sreqs[dest].mxm_sreq;

        /* we are waiting for real completion, not just for SENT state */
        while (!mxm_req_test(&mxm_sreq->base))
            gasnetc_AMPoll();

        gasnet_mxm_module.need_fence[dest] = 0;
    }
}