예제 #1
0
void CVestibule::OnRecieve(const char *Buf, int nLen) {
  if (NULL == Buf || nLen < 0 || (size_t)nLen < sizeof(DWORD)) {
    g_pTrace->Logger(Error, "%s:%d (%s) 操作失败, 数据非法!",
           __FILE__, __LINE__, __FUNCTION__);
    m_lState = STATE_CONNECTERR;
    return;
  }

  DWORD dwCmd = *((DWORD*)Buf);

  // 连接数据前置机成功
  if (dwCmd == VESTIBULE_WARN_CONNECTED) {
    if (NULL != g_pTimerAxis) {
      // 开启心跳控制
      g_pTimerAxis->SetTimer(enTimer_ID_KeepAlive, TIME_KEEPALIVE, this,
             INFINITY_CALL,  "CVestibule::OnRecv");
    }

    m_lState = STATE_CONNECTOK;
    m_pVestibuleWarningSink->OnVestibuleWarning(VESTIBULE_WARN_CONNECTED, "已连接上了数据前置机");
  }
  else {
    LPCSTR pResultBuf = Buf + sizeof(DWORD);
    int nResultLen = nLen - sizeof(DWORD);
    RecvResult(pResultBuf, nResultLen);
  }
}
예제 #2
0
void
avtDataObjectInformation::ParallelMerge(const avtDataObjectWriter_p dobw)
{
#ifdef PARALLEL

    int groupSize = 1;
    int myRank, commSize;

    MPI_Comm_size(VISIT_MPI_COMM, &commSize);
    MPI_Comm_rank(VISIT_MPI_COMM, &myRank);
    int mpiResultLenTag = GetUniqueMessageTag();
    int mpiResultStrTag = GetUniqueMessageTag();
    int mpiSwapLenTag   = GetUniqueMessageTag();
    int mpiSwapStrTag   = GetUniqueMessageTag();
    groupSize = 1;

    // walk up the communication tree, swapping and merging infos
    while (groupSize < commSize)
    {
        int swapWithProc = -1;
        int myGroupNum = myRank / groupSize;
        int myGroupIdx = myRank % groupSize;

        // determine processor to swap with
        if (myGroupNum % 2)   // myGroupNum is odd
            swapWithProc = (myGroupNum - 1) * groupSize + myGroupIdx;
        else                  // myGroupNum is even
            swapWithProc = (myGroupNum + 1) * groupSize + myGroupIdx;

        // only do the swap between 0th processors in each group AND only
        // if the processor to swap with is in range of communicator
        if ((myGroupIdx == 0) &&
                (0 <= swapWithProc) && (swapWithProc < commSize))
            SwapAndMerge(dobw, swapWithProc, mpiSwapLenTag, mpiSwapStrTag);

        groupSize <<= 1;
    }

    // At this point the processor(s) at the top of the tree have the
    // merged result. So, now we need to re-distribute it to all
    groupSize >>= 2;

    // walk back down the communication tree, sending results
    while (groupSize >= 1)
    {
        int swapWithProc = -1;
        int myGroupNum = myRank / groupSize;
        int myGroupIdx = myRank % groupSize;

        // determine processor to send to
        if (myGroupNum % 2)   // myGroupNum is odd
        {
            swapWithProc = (myGroupNum - 1) * groupSize + myGroupIdx;
            if ((myGroupIdx == 0) &&
                    (0 <= swapWithProc) && (swapWithProc < commSize))
                RecvResult(dobw, swapWithProc, mpiResultLenTag, mpiResultStrTag);
        }
        else                  // myGroupNum is even
        {
            swapWithProc = (myGroupNum + 1) * groupSize + myGroupIdx;
            if ((myGroupIdx == 0) &&
                    (0 <= swapWithProc) && (swapWithProc < commSize))
                SendResult(dobw, swapWithProc, mpiResultLenTag, mpiResultStrTag);
        }

        groupSize >>= 1;
    }

#endif

    // indicate that it is ok to use this processor's extents as global extents;
    GetAttributes().SetCanUseThisProcsAsOriginalOrActual(true);
}