Path: blob/devel/ElmerGUI/Application/src/checkmpi.cpp
3203 views
/*****************************************************************************1* *2* Elmer, A Finite Element Software for Multiphysical Problems *3* *4* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *5* *6* This program is free software; you can redistribute it and/or *7* modify it under the terms of the GNU General Public License *8* as published by the Free Software Foundation; either version 2 *9* of the License, or (at your option) any later version. *10* *11* This program is distributed in the hope that it will be useful, *12* but WITHOUT ANY WARRANTY; without even the implied warranty of *13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *14* GNU General Public License for more details. *15* *16* You should have received a copy of the GNU General Public License *17* along with this program (in file fem/GPL-2); if not, write to the *18* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *19* Boston, MA 02110-1301, USA. *20* *21*****************************************************************************/2223/*****************************************************************************24* *25* ElmerGUI checkmpi *26* *27*****************************************************************************28* *29* Authors: Mikko Lyly, Juha Ruokolainen and Peter R�back *30* Email: [email protected] *31* Web: http://www.csc.fi/elmer *32* Address: CSC - IT Center for Science Ltd. *33* Keilaranta 14 *34* 02101 Espoo, Finland *35* *36* Original Date: 15 Mar 2008 *37* *38*****************************************************************************/3940#include <iostream>41#include "checkmpi.h"4243using namespace std;4445CheckMpi::CheckMpi()46{47}4849CheckMpi::~CheckMpi()50{51}5253int CheckMpi::findSmpd()54{55// Check if there is an instance of smpd running:5657#ifdef WIN325859unsigned int i;60TCHAR szProcessName[50] = TEXT("");61DWORD ProcessesIDs[MAX_PROCIDS], cbNeeded, cProcesses;62bool found = false;6364cout << "Checking whether smpd is running... ";6566if(!EnumProcesses(ProcessesIDs, sizeof(ProcessesIDs), &cbNeeded)) {67cout << "unable to enumerate processes - disabling parallel features" << endl;68return -1;69}7071cProcesses = cbNeeded / sizeof(DWORD);7273for(i = 0; i < cProcesses; i++) {74HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |75PROCESS_VM_READ, FALSE,76ProcessesIDs[i] );7778if(hProcess != NULL)79GetModuleBaseName(hProcess, NULL, szProcessName,80sizeof(szProcessName)/sizeof(TCHAR));81//if(!wcscmp(szProcessName, TEXT("smpd.exe"))) {82if(!_tcscmp(szProcessName, TEXT("smpd.exe"))) {83found = true;84cout << "yes (PID " << ProcessesIDs[i] << ")" << endl;85}8687CloseHandle(hProcess);88}8990if(!found) {91cout << "no - disabling parallel features" << endl;92return -1;93}9495#endif9697return 0;98}99100101