Beispiel #1
0
void VVIS_SetupMPI( int &argc, char **&argv )
{
	if ( !VMPI_FindArg( argc, argv, "-mpi", "" ) && !VMPI_FindArg( argc, argv, VMPI_GetParamString( mpi_Worker ), "" ) )
		return;

	CmdLib_AtCleanup( VMPI_Stats_Term );
	CmdLib_AtCleanup( VMPI_DeletePortalMCSocket );

	VMPI_Stats_InstallSpewHook();

	// Force local mode?
	VMPIRunMode mode;
	if ( VMPI_FindArg( argc, argv, VMPI_GetParamString( mpi_Local ), "" ) )
		mode = VMPI_RUN_LOCAL;
	else
		mode = VMPI_RUN_NETWORKED;

	//
	//  Extract mpi specific arguments
	//
	Msg( "Initializing VMPI...\n" );
	if ( !VMPI_Init( argc, argv, "dependency_info_vvis.txt", HandleMPIDisconnect, mode ) )
	{
		Error( "MPI_Init failed." );
	}

	StatsDB_InitStatsDatabase( argc, argv, "dbinfo_vvis.txt" );
}
void PerfThread_SendSpewText()
{
	// Send the spew text to the database.
	CCriticalSectionLock csLock( &g_SpewTextCS );
	csLock.Lock();
		
		if ( g_SpewText.Count() > 0 )
		{
			g_SpewText.AddToTail( 0 );
			
			if ( g_bMPI_StatsTextOutput )
			{
				g_pDB->AddCommandToQueue( new CSQLDBCommand_TextMessage( g_SpewText.Base() ), NULL );
			}
			else
			{
				// Just show one message in the vmpi_job_watch window to let them know that they need
				// to use a command line option to get the output.
				static bool bFirst = true;
				if ( bFirst )
				{
					char msg[512];
					V_snprintf( msg, sizeof( msg ), "%s not enabled", VMPI_GetParamString( mpi_Stats_TextOutput ) );
					bFirst = false;
					g_pDB->AddCommandToQueue( new CSQLDBCommand_TextMessage( msg ), NULL );
				}
			}
			
			g_SpewText.RemoveAll();
		}

	csLock.Unlock();
}
EWorkUnitDistributor VMPI_GetActiveWorkUnitDistributor()
{
    if ( VMPI_IsParamUsed( mpi_UseSDKDistributor ) )
    {
        Msg( "Found %s.\n", VMPI_GetParamString( mpi_UseSDKDistributor ) );
        return k_eWorkUnitDistributor_SDK;
    }
    else if ( VMPI_IsParamUsed( mpi_UseDefaultDistributor ) )
    {
        Msg( "Found %s.\n", VMPI_GetParamString( mpi_UseDefaultDistributor ) );
        return k_eWorkUnitDistributor_Default;
    }
    else
    {
        if ( VMPI_IsSDKMode() )
            return k_eWorkUnitDistributor_SDK;
        else
            return k_eWorkUnitDistributor_Default;
    }
}
void RunJobWatchApp( char *pCmdLine )
{
	STARTUPINFO si;
	memset( &si, 0, sizeof( si ) );
	si.cb = sizeof( si );

	PROCESS_INFORMATION pi;
	memset( &pi, 0, sizeof( pi ) );

	// Working directory should be the same as our exe's directory.
	char dirName[512];
	if ( GetModuleFileName( NULL, dirName, sizeof( dirName ) ) != 0 )
	{
		char *s1 = V_strrchr( dirName, '\\' );
		char *s2 = V_strrchr( dirName, '/' );
		if ( s1 || s2 )
		{
			// Get rid of the last slash.
			s1 = max( s1, s2 );
			s1[0] = 0;
		
			if ( !CreateProcess( 
				NULL, 
				pCmdLine, 
				NULL,							// security
				NULL,
				TRUE,
				0,			// flags
				NULL,							// environment
				dirName,							// current directory
				&si,
				&pi ) )
			{
				Warning( "%s - error launching '%s'\n", VMPI_GetParamString( mpi_Job_Watch ), pCmdLine );
			}
		}
	}
}