Beispiel #1
0
/**
 * @brief This function is called immediately after the main Jacobi loop
 *
 * @param[in]	cartComm		The carthesian communicator
 * @param[in]	rank			The rank of the calling MPI process
 * @param[in]	topSize			The size of the topology
 * @param[in]	domSize			The size of the local domain
 * @param[in]	iterations		The number of successfully completed Jacobi iterations
 * @param[in]	useFastSwap		The flag indicating if fast pointer swapping was used to exchange blocks
 * @param[in]	timerStart		The Jacobi loop starting moment (measured as wall-time)
 * @param[in]	avgTransferTime	The average time spent performing MPI transfers (per process)
 */
void PostRunJacobi(MPI_Comm cartComm, int rank, int size, const int2 * topSize, const int2 * domSize, int iterations, int useFastSwap, 
			double timerStart, double avgTransferTime)
{
	double elapsedTime;
	double lattUpdates = 0.0, flops = 0.0, bandWidth = 0.0;

	MPI_Barrier(cartComm);
	elapsedTime = MPI_Wtime() - timerStart;
		
	// Show the performance counters
	if (rank == MPI_MASTER_RANK)
	{
		printf("Total Jacobi run time: %.4lf sec.\n", elapsedTime);
		printf("Average per-process communication time: %.4lf sec.\n", avgTransferTime);

		// Compute the performance counters over all MPI processes
		UpdatePerfCounters(topSize, domSize, iterations, useFastSwap, &lattUpdates, &flops, &bandWidth);
	
		PrintPerfCounter("Measured lattice updates", "LU/s", lattUpdates, elapsedTime, size);
		PrintPerfCounter("Measured FLOPS", "FLOPS", flops, elapsedTime, size);
		PrintPerfCounter("Measured device bandwidth", "B/s", bandWidth, elapsedTime, size);
	}
}
int CLobbyApp::Run()
{
  const DWORD c_dwUpdateInterval = 200; // milliseconds
  DWORD dwSleep = c_dwUpdateInterval;
  DWORD dwWait = WAIT_TIMEOUT;
  InitializeCriticalSectionAndSpinCount(&HttpCriticalSection, 0x00000400);
  InitializeCriticalSectionAndSpinCount(GetLogonCS(), 0x00000400);
  m_plas->LogEvent(EVENTLOG_INFORMATION_TYPE, LE_Running);
  puts("---------Press Q to exit---------");
   printf("Ready for clients/servers.\n");
  CTempTimer timerIterations("between iterations", .25f);
  timerIterations.Start();
  CTempTimer timerReceiveClientsMessages("in clients ReceiveMessages()", .05f);
  CTempTimer timerReceiveServersMessages("in servers ReceiveMessages()", .05f);
  Time timeLastQueueCheck = Time::Now();
  Time timeLastGameInfo = Time::Now();

  while (true)
  {
    timerIterations.Stop();
    timerIterations.Start();

    if (ProcessMsgPump() || (_kbhit() && toupper(_getch()) == 'Q')) {
		//Imago #111 7/10
		if(g_pAutoUpdate)
		{ 
			char szFileName[MAX_PATH+16];
			strcpy(szFileName, _Module.GetModulePath());
			Strcat(szFileName, "FileList.txt");
			g_pAutoUpdate->LoadCRC(szFileName);
			FedMessaging * pfm = &g_pLobbyApp->GetFMClients();
			int count = pfm->GetConnectionCount();
			ListConnections::Iterator iterCnxn(*pfm->GetConnections());
			while (!iterCnxn.End()) {
				BEGIN_PFM_CREATE(*pfm, pfmAutoUpdate, L, AUTO_UPDATE_INFO)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPServer(), CB_ZTS)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPInitialDir(), CB_ZTS)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPAccount(), CB_ZTS)
				  FM_VAR_PARM(g_pAutoUpdate->GetFTPPassword(), CB_ZTS)
				END_PFM_CREATE
				pfmAutoUpdate->crcFileList = g_pAutoUpdate->GetFileListCRC();
				pfmAutoUpdate->nFileListSize = g_pAutoUpdate->GetFileListSize();
				pfm->SendMessages(iterCnxn.Value(), FM_GUARANTEED, FM_FLUSH);
				iterCnxn.Next();
			}
		}
      return 0;
	}

    SetNow();

    m_pCounters->timeInnerLoop = timerIterations.LastInterval();

    // receive any messages in the queue
    timerReceiveClientsMessages.Start();
    m_fmClients.ReceiveMessages();
    timerReceiveClientsMessages.Stop();

    timerReceiveServersMessages.Start();
    m_fmServers.ReceiveMessages();
    timerReceiveServersMessages.Stop();

    if (GetNow() - timeLastQueueCheck >= 1.0f)
    {
      // count the fairly expensive stuff no more than once a second
      UpdatePerfCounters();
      timeLastQueueCheck = GetNow();
      if (GetNow() - timeLastGameInfo >= (float) m_sGameInfoInterval)
      {
        SendGameInfo();
        timeLastGameInfo = GetNow();
      }

      // Do a periodic roll call. If we haven't heard from anyone for two roll calls in a row, waste 'em
      static Time timeRollCall = Time::Now();
      if (GetNow() - timeRollCall >= 5.0f)
      {
        RollCall();
        timeRollCall = GetNow();
      }
    }
    Sleep(1);
  }
  DeleteCriticalSection(GetLogonCS());
  DeleteCriticalSection(&HttpCriticalSection);
  return 0;
}