Exemple #1
0
static void move_construct_f(t_comm_dummies *dummycomm, rvec f[], t_commrec *cr)
{
    int i;

    /* Spread forces to nonlocal constructing atoms.
     */
    /* package forces to send right */
    for(i=0; i<dummycomm->nnextconstr; i++)
        copy_rvec(f[dummycomm->idxnextconstr[i]],nextbuf[i]);

    /* send them off, and recieve from the right */
    if(dummycomm->nnextconstr>0)
        gmx_tx(cr->right,nextbuf,sizeof(rvec)*dummycomm->nnextconstr);

    if(dummycomm->nprevconstr>0)
        gmx_rx(cr->left,prevbuf,sizeof(rvec)*dummycomm->nprevconstr);

    if(dummycomm->nnextconstr>0)
        gmx_tx_wait(cr->right);

    if(dummycomm->nprevconstr>0)
        gmx_rx_wait(cr->left);

    /* Add them where they belong */
    for(i=0; i<dummycomm->nprevconstr; i++)
        rvec_inc(f[dummycomm->idxprevconstr[i]],prevbuf[i]);

    /* Zero nonlocal dummies */
    for(i=0; i<dummycomm->nprevdum; i++)
        clear_rvec(f[dummycomm->idxprevdum[i]]);

    /* All forces are on the home processor now */
}
Exemple #2
0
static void move_dummy_f(t_comm_dummies *dummycomm, rvec f[], t_commrec *cr)
{
    int i;

    /* package dummy particle forces to send left */
    for(i=0; i<dummycomm->nprevdum; i++)
        copy_rvec(f[dummycomm->idxprevdum[i]],prevbuf[i]);

    /* off they go! - but only if there is something to send! */
    if(dummycomm->nprevdum>0)
        gmx_tx(cr->left,prevbuf,sizeof(rvec)*dummycomm->nprevdum);

    /* Get our share from the right, if there is anything to have */
    if(dummycomm->nnextdum>0)
        gmx_rx(cr->right,nextbuf,sizeof(rvec)*dummycomm->nnextdum);

    if(dummycomm->nprevdum>0)
        gmx_tx_wait(cr->left);

    if(dummycomm->nnextdum>0)
        gmx_rx_wait(cr->right);

    /* Put them where they belong */
    for(i=0; i<dummycomm->nnextdum; i++)
        copy_rvec(nextbuf[i],f[dummycomm->idxnextdum[i]]);

    /* Zero forces on nonlocal constructing atoms.
     * This is necessary since dummy force spreading is done
     * after the normal force addition, and we don't want
     * to include them twice.
     * (They have already been added on the home node).
     */
    for(i=0; i<dummycomm->nnextconstr; i++)
        clear_rvec(f[dummycomm->idxnextconstr[i]]);
}
Exemple #3
0
void mv_grid(t_commrec *cr, t_grid *grid)
{
    int  i, start, nr;
    int  cur = cr->nodeid;
    int *ci, *cgindex;
#define next ((cur+1) % (cr->nnodes-cr->npmenodes))

    ci      = grid->cell_index;
    cgindex = pd_cgindex(cr);
    for (i = 0; (i < cr->nnodes-1); i++)
    {
        start = cgindex[cur];
        nr    = cgindex[cur+1] - start;
        gmx_tx(cr, GMX_LEFT, &(ci[start]), nr*sizeof(*ci));

        start = cgindex[next];
        nr    = cgindex[next+1] - start;
        gmx_rx(cr, GMX_RIGHT, &(ci[start]), nr*sizeof(*ci));

        gmx_tx_wait(cr);
        gmx_rx_wait(cr);

        cur = next;
    }
}
Exemple #4
0
static void move_dummy_xv(t_comm_dummies *dummycomm, rvec x[], rvec v[],t_commrec *cr)
{
    int i;
    int sendsize,recvsize;

    sendsize=sizeof(rvec)*dummycomm->nnextdum;
    recvsize=sizeof(rvec)*dummycomm->nprevdum;

    if(v!=NULL) {
        sendsize=sendsize*2;
        recvsize=recvsize*2;
    }

    /* Package nonlocal constructed dummies */
    for(i=0; i<dummycomm->nnextdum; i++)
        copy_rvec(x[dummycomm->idxnextdum[i]],nextbuf[i]);

    if(v!=NULL)
        for(i=0; i<dummycomm->nnextdum; i++)
            copy_rvec(v[dummycomm->idxnextdum[i]],nextbuf[dummycomm->nnextdum+i]);

    /* send them off, and recieve from the right */
    if(dummycomm->nnextdum>0)
        gmx_tx(cr->right,nextbuf,sendsize);

    if(dummycomm->nprevdum>0)
        gmx_rx(cr->left,prevbuf,recvsize);

    if(dummycomm->nnextdum>0)
        gmx_tx_wait(cr->right);

    if(dummycomm->nprevdum>0)
        gmx_rx_wait(cr->left);

    /* Put them where they belong */
    for(i=0; i<dummycomm->nprevdum; i++)
        copy_rvec(prevbuf[i],x[dummycomm->idxprevdum[i]]);

    if(v!=NULL)
        for(i=0; i<dummycomm->nprevdum; i++)
            copy_rvec(prevbuf[dummycomm->nprevdum+i],v[dummycomm->idxprevdum[i]]);

    /* All coordinates are in place on the respective home node now */
}
Exemple #5
0
static void move_construct_x(t_comm_dummies *dummycomm, rvec x[], t_commrec *cr)
{
    static bool bFirst=TRUE;
    int i;

    if (bFirst) {
        /* Make the larger than necessary to avoid cache sharing */
        snew(nextbuf,2*(dummycomm->nnextdum+dummycomm->nnextconstr)+100);
        snew(prevbuf,2*(dummycomm->nprevdum+dummycomm->nprevconstr)+100);
        bFirst=FALSE;
    }

    /* package coords to send left. Dummy coords are needed to create v */
    for(i=0; i<dummycomm->nprevconstr; i++)
        copy_rvec(x[dummycomm->idxprevconstr[i]],prevbuf[i]);
    for(i=0; i<dummycomm->nprevdum; i++)
        copy_rvec(x[dummycomm->idxprevdum[i]],prevbuf[dummycomm->nprevconstr+i]);

    /* send them off, and recieve from the right */
    if(dummycomm->nprevconstr>0 || dummycomm->nprevdum>0)
        gmx_tx(cr->left,prevbuf,
               sizeof(rvec)*(dummycomm->nprevconstr+dummycomm->nprevdum));

    if(dummycomm->nnextconstr>0 || dummycomm->nnextdum>0)
        gmx_rx(cr->right,nextbuf,
               sizeof(rvec)*(dummycomm->nnextconstr+dummycomm->nnextdum));

    if(dummycomm->nprevconstr>0 || dummycomm->nprevdum>0)
        gmx_tx_wait(cr->left);

    if(dummycomm->nnextconstr>0 || dummycomm->nnextdum>0)
        gmx_rx_wait(cr->right);

    /* Put them where they belong */
    for(i=0; i<dummycomm->nnextconstr; i++)
        copy_rvec(nextbuf[i],x[dummycomm->idxnextconstr[i]]);
    for(i=0; i<dummycomm->nnextdum; i++)
        copy_rvec(nextbuf[dummycomm->nnextconstr+i],
                  x[dummycomm->idxnextdum[i]]);

    /* Now we are ready to do the constructing business ! */
}