⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 v2run_internals.c

📁 Path MPICH-V for MPICH the MPI Implementation
💻 C
📖 第 1 页 / 共 2 页
字号:
/*MPICH-VCopyright (C) 2002, 2003 Groupe Cluster et Grid, LRI, Universite de Paris SudThis file is part of MPICH-V.MPICH-V is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.MPICH-V is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with MPICH-V; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA$Id: v2run_internals.c,v 1.13 2004/07/22 12:49:16 bouziane Exp $*/#include "v2run.h"#include <dirent.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <sys/stat.h>#include <time.h>#define MAXLINE 8192boolean isV2TempEmpty(char * v2tmp) {  DIR * dd;  DIR * ddIP;  struct dirent *ep;  struct dirent *epIP;  if ((dd = opendir(v2tmp)) != NULL) {    while(ep = readdir(dd)) {      if (strcmp(ep->d_name, ".") && strcmp(ep->d_name, "..")) {      }    }  } else {    printf("Error: cannot read v tmp file %s\n", v2tmp);    exit(1);  }}/*  The following gives a command line which should be performed by rank <rank>*/void nodeCommandLine(char * s, int restart, JS * js, CN node) {  char restartFlag[10];  char ckptFlag[10];  //  char memstat[10];  if (restart == RESTART)    strcpy(restartFlag, "-restart");  else    strcpy(restartFlag, "");  if (js->localckpt)    strcpy(ckptFlag, "-ckptlocal");  else    strcpy(ckptFlag, "");  /*  if (js->memstat)    strcpy(memstat, "-memstat");  else    strcpy(memstat, "");  */  if(strcmp(node.debugString, "") == 0)    {      if (! js->noCkptServer)        {          sprintf(s, "%s %s %s -g %d -r %d -np %d -p %d -el %s:%d -cs %s:%d -sc %s:%d -dispatcher %s:%d %s %s -debug %s -cmd %s",                  js->rshCmd,                  node.ipAddress,                  js->v2dCmd,                  js->jobId,                  node.rank,                  js->nprocs,                  node.communicationPort,                  node.eventLogger, node.eventLoggerPort,                  node.checkpointServer, node.checkpointServerPort,                  node.checkpointScheduler, node.checkpointSchedulerPort,                  //	  js->v2tmp, node.ipAddress,                  js->dispatcherIP, js->dispatcherPort,                  ckptFlag,                  restartFlag,                  //  memstat,                  js->debugCommand,                  js->progCmd);        }      else        {          sprintf(s, "%s %s %s -g %d -r %d -np %d -p %d -el %s:%d -no-ckpt-server -sc %s:%d -dispatcher %s:%d %s %s -debug %s -cmd %s",                  js->rshCmd,                  node.ipAddress,                  js->v2dCmd,                  js->jobId,                  node.rank,                  js->nprocs,                  node.communicationPort,                  node.eventLogger, node.eventLoggerPort,                  node.checkpointScheduler, node.checkpointSchedulerPort,                  //	  js->v2tmp, node.ipAddress,                  js->dispatcherIP, js->dispatcherPort,                  ckptFlag,                  restartFlag,                  //    memstat,                  js->debugCommand,                  js->progCmd);                  }    } else {            if (! js->noCkptServer)        {                    sprintf(s, "%s %s %s -g %d -r %d -np %d -p %d -el %s:%d -cs %s:%d -sc %s:%d -dispatcher %s:%d %s %s %s -cmd %s",                  js->rshCmd,                  node.ipAddress,                  js->v2dCmd,                  js->jobId,                  node.rank,                  js->nprocs,                  node.communicationPort,                  node.eventLogger, node.eventLoggerPort,                  node.checkpointServer, node.checkpointServerPort,                  node.checkpointScheduler, node.checkpointSchedulerPort,                  //	  js->v2tmp, node.ipAddress,                  js->dispatcherIP, js->dispatcherPort,                  ckptFlag,                  restartFlag,                  node.debugString,                  // memstat,                  js->progCmd);        }      else {        sprintf(s, "%s %s %s -g %d -r %d -np %d -p %d -el %s:%d -no-ckpt-server -sc %s:%d -dispatcher %s:%d %s %s %s -cmd %s",                js->rshCmd,                node.ipAddress,                js->v2dCmd,                js->jobId,                node.rank,                js->nprocs,                node.communicationPort,                node.eventLogger, node.eventLoggerPort,                node.checkpointScheduler, node.checkpointSchedulerPort,                //	  js->v2tmp, node.ipAddress,                js->dispatcherIP, js->dispatcherPort,                ckptFlag,                restartFlag,                node.debugString,                // memstat,                js->progCmd);      }          }}void parseCommandsFile(char * commandsFilePath, JS * js) {  FILE * fd;  char * line1;  char * line2;  char * line;  boolean    lastLine;  boolean keepXWFile, testOnly;  testOnly = true;  keepXWFile = false;  lastLine = false;  if ((fd = fopen(commandsFilePath, "r")) != NULL ) {    line  = (char*)malloc(MAXLINE);    line1 = (char*)malloc(MAXLINE);    line2 = (char*)malloc(MAXLINE);    while (fgets(line, MAXLINE, fd) != (char *)NULL) {      sscanf(line, "%[^=]=%[^\n]\n", line1, line2);      if (strcmp(line1, "pwd") == 0) {	 strncpy(js->pwd, line2, PATH_LENGTH);      } else if (strcmp(line1, "rshcmd") == 0) {	 strncpy(js->rshCmd, line2, PATH_LENGTH);      } else if (strcmp(line1, "elcmd") == 0) {	 strncpy(js->elCmd, line2, PATH_LENGTH);      } else if (strcmp(line1, "cscmd") == 0) {	 strncpy(js->csCmd, line2, PATH_LENGTH);      } else if (strcmp(line1, "sccmd") == 0) {	 strncpy(js->scCmd, line2, PATH_LENGTH);      } else if (strcmp(line1, "v2tmp") == 0) {	 strncpy(js->v2tmp, line2, PATH_LENGTH);      } else if (strcmp(line1, "prog") == 0) {	 strncpy(js->progCmd, line2, PATH_LENGTH);      } else if (strcmp(line1, "wrapper") == 0) {	 js->v2dCmd = strdup(line2);      } else if (strcmp(line1, "kill") == 0) {	 strncpy(js->killCmd, line2, PATH_LENGTH);      } else if (strcmp(line1, "just_testing") == 0) {         testOnly = (strcmp(line2,"1") == 0);      } else if (strcmp(line1, "keep_v2file") == 0) {         if(strlen(line2) != 1)            keepXWFile = (strcmp(line2,"1") == 0);	 lastLine = true;      }      if (lastLine) {	 break;      }    }    free(line);    free(line1);    free(line2);    fclose(fd);  } else {    printf("Error: could not read command file %s: aborting\n", commandsFilePath);    exit(1);  }  /*  printf("pwd = %s\n", js->pwd);  printf("rshcmd = %s\n", js->rshCmd);  printf("elcmd = %s\n", js->elCmd);  printf("cscmd = %s\n", js->csCmd);  printf("sccmd = %s\n", js->scCmd);  printf("v2tmp = %s\n", js->v2tmp);  printf("progCmd = %s\n", js->progCmd);  printf("wrapper = %s\n", js->v2dCmd);  printf("kill = %s\n", js->killCmd);  printf("just_testing = %d\n", testOnly);  printf("keep_v2file = %d\n", keepXWFile);  */  return;}void parseProgramFile(JS * js) {  FILE * fd;  char line[4096];  char type[2];  int  rank;  char host[128];  char ip1[15];  char ip2[15];  char ip3[15];  char ip4[15];  int  p0, p1, p2, p3;  char highperfFile[256];  int totalCN, totalEL, totalCS, totalSC;  int i, n, np, group, iPort;  CN * newCN, * lastCN;  EL * newEL, * lastEL;  CS * newCS, * lastCS;  SC * newSC, * lastSC;  CN * ccn;  totalCN = 0;  totalEL = 0;  totalCS = 0;  totalSC = 0;  js->nodeList = (CN *)NULL;  js->elList = (EL *)NULL;  js->csList = (CS *)NULL;  js->scList = (SC *)NULL;  lastCN = (CN *)malloc(sizeof(CN));  lastEL = (EL *)malloc(sizeof(EL));  lastCS = (CS *)malloc(sizeof(CS));  lastSC = (SC *)malloc(sizeof(SC));  ccn    = (CN *)malloc(sizeof(CN));  if ((fd = fopen(js->v2pgFile, "r")) != NULL )    {      while (fgets(line, 4096, fd) )	{	  if (line[1] == 'L')	    {	      newEL = (EL *)malloc(sizeof(EL));	      sscanf(line, "%s %s %s %d",		     type,		     newEL->ipAddress,		     newEL->fastIpAddress,		     &newEL->port);	      newEL->autoLaunch = js->autoLaunch;	      strcpy(newEL->debugString, "");	      if (totalEL == 0)		{		  js->elList = newEL;		  lastEL = js->elList;		}	      else		{		  lastEL->next = newEL;		  lastEL = lastEL->next;		}	      lastEL->next = NULL;	      /* addAuxiliary(newEL->ipAddress, TYPE_EL);*/	      totalEL ++;	    }	  else if (line[1] == 'S')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -