Esempio n. 1
0
File: lapi.c Progetto: bcernohous/ga
/* LAPI Put RDMA */
void armci_client_direct_send(int p, void *src_buf, void *dst_buf,
        int len, void** contextptr, int nbtag,
        ARMCI_MEMHDL_T *lochdl,ARMCI_MEMHDL_T *remhdl) {

    lapi_xfer_t      xfer_struct;   /* Data structure for the xfer call */
    lapi_rdma_tag_t  lapi_rdma_tag; /* RDMA notification tag */
    uint src_offset, tgt_offset;
    int  val, rc;

    /* can be any number that fits in ushort */
    lapi_rdma_tag = 22;

    /* CHECK: offset problem. what if client and server attached (shmat) at
       diff address */ 
    src_offset = (char *)src_buf- (char *)lochdl->start;
    tgt_offset = (char *)dst_buf - (char *)remhdl->start;

#if DEBUG_
    printf("%d: Doing LAPI_Xfer (RDMA Put): dst=%d srchdl_start=%p remhdl_start=%p (bytes=%ld src_off=%d tgt_off=%d)\n", armci_me, p, lochdl->start, remhdl->start, len, src_offset, tgt_offset); fflush(stdout);
#endif

    bzero(&xfer_struct, sizeof(xfer_struct));
    xfer_struct.HwXfer.Xfer_type    = LAPI_RDMA_XFER;
    xfer_struct.HwXfer.tgt          = p;
    /*xfer_struct.HwXfer.op         = LAPI_RDMA_PUT|LAPI_RCNTR_UPDATE;*/
    xfer_struct.HwXfer.op           = LAPI_RDMA_PUT;
    xfer_struct.HwXfer.rdma_tag     = lapi_rdma_tag;
    xfer_struct.HwXfer.remote_cxt   = lapi_remote_cxt[p];
    xfer_struct.HwXfer.src_pvo      = lochdl->pvo;
    xfer_struct.HwXfer.tgt_pvo      = remhdl->pvo;
    xfer_struct.HwXfer.src_offset   = src_offset;
    xfer_struct.HwXfer.tgt_offset   = tgt_offset;
    xfer_struct.HwXfer.len          = (ulong) (len);  
    xfer_struct.HwXfer.shdlr        = (scompl_hndlr_t *) NULL;
    xfer_struct.HwXfer.sinfo        = (void *) NULL;
    xfer_struct.HwXfer.org_cntr     = &(ack_cntr->cntr);

    /* Initiate RDMA Xfer */
    if((rc = LAPI_Xfer(lapi_handle, &xfer_struct)) != LAPI_SUCCESS) {
        LAPI_Msg_string(rc, err_msg_buf);
        fprintf(stderr, "LAPI ERROR: %s, rc = %d\n", err_msg_buf, rc);
        armci_die("LAPI_Xfer (RDMA Put) failed", 0);
    }

    /* wait for RDMA completion */
    rc = LAPI_Waitcntr(lapi_handle, &(ack_cntr->cntr),1,&val);
    if(rc != LAPI_SUCCESS) {
        LAPI_Msg_string(rc, err_msg_buf);
        fprintf(stderr, "LAPI ERROR: %s, rc = %d\n", err_msg_buf, rc);
        armci_die("LAPI_Waitcntr (RDMA Put) failed", 0);
    }

    /* CHECK((LAPI_Fence(lapi_handle))); */

#if DEBUG_
    printf("%d: Completed LAPI_Xfer RDMA (Put): dst=%d\n", armci_me, p);
#endif
}
Esempio n. 2
0
static void lapi_err_hndlr(lapi_handle_t *hndl, int *error_code,
                           lapi_err_t *err_type, int *task_ID, int *src) {
    char errstr[LAPI_MAX_ERR_STRING];
    LAPI_Msg_string(*error_code, errstr);
    fprintf(stderr, "ERROR IN LAPI: %s for task %d at src %d\n", errstr, *task_ID, *src);
    LAPI_Term(*hndl);
    exit(1);
}
Esempio n. 3
0
static void check_lapi_err(int returnCode,const char *routine,int line) {
    if (returnCode!=LAPI_SUCCESS) {
        char errMsg[LAPI_MAX_ERR_STRING];
        LAPI_Msg_string(returnCode,errMsg);
        fprintf(stderr,"Fatal LAPI error while executing %s at %s:%d\n"
                "  Description: %s\n", routine, __FILE__, line, errMsg);
        CmiAbort("Fatal LAPI error");
    }
}