Example #1
0
AmpiMsg*
ampi::winRemoteIget(int orgdisp, int orgcnt, MPI_Datatype orgtype, MPI_Aint targdisp, int targcnt,
                    MPI_Datatype targtype, int winIndex) {
    AMPI_DEBUG("    RemoteIget invoked at Rank[%d:%d]\n", thisIndex, myRank);
// FIX: no need for stargaddr??
// FIX: what is targaddr pointing??
    int orgunit, targunit;
    CkDDT_DataType *oddt = getDDT()->getType(orgtype);
    CkDDT_DataType *tddt = getDDT()->getType(targtype);
    orgunit = oddt->getSize(1);
    targunit = tddt->getSize(1);
    int stargtotalsize = targunit*targcnt;
    char* stargaddr = (char*)new char[stargtotalsize];

    win_obj *winobj = winObjects[winIndex];
    winobj->iget(orgcnt, orgunit, targdisp, targcnt, targunit);

    AMPI_DEBUG("    Rank[%d] iget win  [%d] \n", thisIndex, *(int*)stargaddr);

    AmpiMsg *msg = new (stargtotalsize, 0) AmpiMsg(-1, -1, -1, thisIndex,
            stargtotalsize,myComm.getComm());

    char* targaddr = (char*)(winobj->baseAddr) + targdisp*targunit;
    tddt->serialize(targaddr, (char*)stargaddr, targcnt, 1);
    memcpy(msg->data, stargaddr, stargtotalsize);
    AMPI_DEBUG("    Rank[%d] copy win  [%d] \n", thisIndex, *(int*)msg->data);
    delete [] stargaddr;
    return msg;
}
Example #2
0
int
ampi::winAccumulate(void *orgaddr, int orgcnt, MPI_Datatype orgtype, int rank,
                    MPI_Aint targdisp, int targcnt, MPI_Datatype targtype,
                    MPI_Op op, WinStruct win) {
    // Create a Future object
    AmpiMsg *msg = new AmpiMsg();
    CkFutureID ftHandle = CkCreateAttachedFuture((void*)msg);
    AMPI_DEBUG("    Created Future with handle %d\n", ftHandle);

    // Send the request to data and handle of Future to remote side
    CProxy_ampi pa(thisArrayID);

    CkDDT_DataType *ddt = getDDT()->getType(orgtype);
    int orgtotalsize = ddt->getSize(orgcnt);
    char* sorgaddr = (char*)new char[orgtotalsize];
    ddt->serialize((char*)orgaddr, (char*)sorgaddr, orgcnt, 1);

    AMPI_DEBUG("    Rank[%d:%d] invoke Remote accumulate at [%d]\n", thisIndex, myRank, rank);
    pa[rank].winRemoteAccumulate(orgtotalsize, (char*)orgaddr, orgcnt, orgtype, targdisp, targcnt, targtype,  op, win.index, ftHandle, CkMyPe());

    // Wait on the Future object
    AMPI_DEBUG("    Future [%d] waiting\n", ftHandle);
    msg = (AmpiMsg*)CkWaitFutureID(ftHandle);
    AMPI_DEBUG("    Future [%d] awaken\n", ftHandle);

    return MPI_SUCCESS;
}
Example #3
0
int
ampi::winGet(void *orgaddr, int orgcnt, MPI_Datatype orgtype, int rank,
             MPI_Aint targdisp, int targcnt, MPI_Datatype targtype, WinStruct win) {
    // Create a Future object
    AmpiMsg *msg = new AmpiMsg();
    CkFutureID ftHandle = CkCreateAttachedFuture((void*)msg);
    AMPI_DEBUG("    Created Future with handle %d\n", ftHandle);

    // Send the request to data and handle of Future to remote side
    CProxy_ampi pa(thisArrayID);
    AMPI_DEBUG("    Rank[%d:%d] invoke Remote get at [%d]\n", thisIndex, myRank, rank);
    CkDDT_DataType *ddt = getDDT()->getType(orgtype);
    int orgtotalsize = ddt->getSize(orgcnt);
    char* sorgaddr = (char*)new char[orgtotalsize];

    pa[rank].winRemoteGet(orgcnt, orgtype, targdisp, targcnt, targtype, win.index, ftHandle, CkMyPe());

    // Wait on the Future object
    AMPI_DEBUG("    Future [%d] waiting\n", ftHandle);
    msg = (AmpiMsg*)CkWaitFutureID(ftHandle);
    AMPI_DEBUG("    Future [%d] awaken\n", ftHandle);

    // Process the reply message and copy the data into desired memory position
    memcpy(sorgaddr, msg->data, orgtotalsize);
    ddt->serialize((char*)orgaddr, (char*)sorgaddr, orgcnt, (-1));
    AMPI_DEBUG("    Rank[%d] got win  [%d] \n", thisIndex, *(int*)msg->data);
    AMPI_DEBUG("    Rank[%d] got win  [%d] , size %d\n", thisIndex, *(int*)orgaddr, orgcnt);
    delete [] sorgaddr;
    return MPI_SUCCESS;
}
Example #4
0
int
ampi::winPut(void *orgaddr, int orgcnt, MPI_Datatype orgtype, int rank,
             MPI_Aint targdisp, int targcnt, MPI_Datatype targtype, WinStruct win) {
    // Create a Future object
    AmpiMsg *msg = new AmpiMsg();
    CkFutureID ftHandle = CkCreateAttachedFuture((void*)msg);
    AMPI_DEBUG("    Created Future with handle %d\n", ftHandle);

    CProxy_ampi pa(thisArrayID);

    CkDDT_DataType *ddt = getDDT()->getType(orgtype);
    int orgtotalsize = ddt->getSize(orgcnt);
    char* sorgaddr = (char*)new char[orgtotalsize];
    ddt->serialize((char*)orgaddr, (char*)sorgaddr, orgcnt, 1);

    pa[rank].winRemotePut(orgtotalsize, (char*)sorgaddr, orgcnt, orgtype, targdisp, targcnt, targtype,
                          win.index, ftHandle, CkMyPe());

    // Wait on the Future object
    AMPI_DEBUG("    Future [%d] waiting\n", ftHandle);
    msg = (AmpiMsg*)CkWaitFutureID(ftHandle);
    AMPI_DEBUG("    Future [%d] awaken\n", ftHandle);

    delete [] sorgaddr;
    return MPI_SUCCESS;
}
Example #5
0
int MPI_Pack_size(int incount, MPI_Datatype type, MPI_Comm comm, int *size)
{
  CkDDT_DataType *ddt = getAmpiInstance(comm)->getDDT()->getType(type);
  int typesize = ddt->getSize();
  *size = incount * typesize;
  return MPI_SUCCESS;
}
Example #6
0
void
ampi::winRemoteAccumulate(int orgtotalsize, char* sorgaddr, int orgcnt, MPI_Datatype orgtype, MPI_Aint targdisp,
                          int targcnt, MPI_Datatype targtype,
                          MPI_Op op, int winIndex, CkFutureID ftHandle,
                          int pe_src) {
    win_obj *winobj = winObjects[winIndex];

    CkDDT_DataType *ddt = getDDT()->getType(targtype);
    char* getdata = (char*) new char[orgtotalsize];
    ddt->serialize(getdata, (char*)sorgaddr, targcnt, (-1));

    winobj->accumulate(getdata, targcnt, targtype, targdisp, targcnt, targtype, op);

    int tmp = 0;
    AmpiMsg *msg = new (tmp, 0) AmpiMsg(-1, -1, -1, thisIndex, 0,myComm.getComm());

    AMPI_DEBUG("    Rank[%d] Send to Future [%d] \n", thisIndex, ftHandle);
    CkSendToFutureID(ftHandle, (void *)msg, pe_src);
}
Example #7
0
void
ampi::winRemoteGet(int orgcnt, MPI_Datatype orgtype, MPI_Aint targdisp, int targcnt,
                   MPI_Datatype targtype, int winIndex, CkFutureID ftHandle,
                   int pe_src) {
    AMPI_DEBUG("    RemoteGet invoked at Rank[%d:%d]\n", thisIndex, myRank);

    int orgunit, targunit;
    CkDDT_DataType *oddt = getDDT()->getType(orgtype);
    CkDDT_DataType *tddt = getDDT()->getType(targtype);
    orgunit = oddt->getSize(1);
    targunit = tddt->getSize(1);
    int stargtotalsize = tddt->getSize(targcnt);
    char* stargaddr = (char*)new char[stargtotalsize];

    win_obj *winobj = winObjects[winIndex];
    winobj->get(stargaddr, orgcnt, orgunit, targdisp, targcnt, targunit);

    AMPI_DEBUG("    Rank[%d] get win  [%d] \n", thisIndex, *(int*)stargaddr);

    AmpiMsg *msg = new (stargtotalsize, 0) AmpiMsg(-1, -1, -1, thisIndex, stargtotalsize,myComm.getComm());

    char* targaddr = (char*)(winobj->baseAddr) + targunit*targdisp;
    tddt->serialize(targaddr, (char*)stargaddr, targcnt, 1);
    memcpy(msg->data, stargaddr, stargtotalsize);
    AMPI_DEBUG("    Rank[%d] copy win  [%d] \n", thisIndex, *(int*)msg->data);

    AMPI_DEBUG("    Rank[%d] Send to Future [%d] \n", thisIndex, ftHandle);
    CkSendToFutureID(ftHandle, (void *)msg, pe_src);
    delete [] stargaddr;
}
Example #8
0
void
ampi::winRemotePut(int orgtotalsize, char* sorgaddr, int orgcnt, MPI_Datatype orgtype,
                   MPI_Aint targdisp, int targcnt, MPI_Datatype targtype,
                   int winIndex, CkFutureID ftHandle, int pe_src) {
    win_obj *winobj = winObjects[winIndex];
    int orgunit, targunit;
    CkDDT_DataType *oddt = getDDT()->getType(orgtype);
    CkDDT_DataType *tddt = getDDT()->getType(targtype);
    orgunit = oddt->getSize(1);
    targunit = tddt->getSize(1);
    winobj->put(sorgaddr, orgcnt, orgunit, targdisp, targcnt, targunit);
    char* targaddr = ((char*)(winobj->baseAddr)) + tddt->getSize(targdisp);
    tddt->serialize(targaddr, (char*)sorgaddr, targcnt, (-1));

    int tmp = 0;
    AmpiMsg *msg = new (tmp, 0) AmpiMsg(-1, -1, -1, thisIndex, 0,myComm.getComm());
    AMPI_DEBUG("    Rank[%d] Send to Future [%d] \n", thisIndex, ftHandle);
    CkSendToFutureID(ftHandle, (void *)msg, pe_src);
}
Example #9
0
inline void MPID_Datatype_get_extent_macro(MPI_Datatype &type, MPI_Aint &extent){
  CkDDT_DataType *ddt = getAmpiInstance(MPI_COMM_WORLD)->getDDT()->getType(type);
  extent = ddt->getExtent();
}
Example #10
0
inline void MPID_Datatype_get_size_macro(MPI_Datatype &type, MPI_Aint &size){
  CkDDT_DataType *ddt = getAmpiInstance(MPI_COMM_WORLD)->getDDT()->getType(type);
  size = ddt->getSize();
}