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

📄 mpirun_protocol.c

📁 Path MPICH-V for MPICH the MPI Implementation
💻 C
字号:
/*  MPICH-V  Copyright (C) 2002, 2003 Groupe Cluster et Grid, LRI, Universite de Paris Sud  This file is part of MPICH-V.  MPICH-V is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the 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 of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with MPICH-V; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  $Id: mpirun_protocol.c,v 1.11 2005/12/14 23:13:15 herault Exp $*/#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>#include <sys/types.h>#include <sys/socket.h>#include "v2run.h"#include "vrun_protocol.h"#include "debug.h"#define MAX_MSG 10#define BUFF_SIZE 4096/* This file contains the protocol specific actions */void launchAuxiliaryPrograms(JS * js, int *nbAuxTotal) {/* No auxiliary programs to launch for Vdummy! */  *nbAuxTotal = 0;}void waitConnectionFromAuxiliaries(JS * js, int nbAuxTotal, pid_t *auxiliariesPid, int listenSocket) {/* No auxiliaries, so nothing to do! */}void launchComputingNodes(JS * js) {  CN * auxCN;  char commandLine[BUFF_SIZE];  char log[BUFF_SIZE];  pid_t forked;  auxCN = js->nodeList;  while(auxCN != NULL) {    nodeCommandLine(commandLine, CHECKPOINT, js, *auxCN);    sprintf(log, "launching rank %d on host %s", auxCN->rank, auxCN->hostName);    v2logMessage(log);    if (js->testOnly || (strcmp(auxCN->debugString, "") != 0))      printf("%s\n", commandLine);    if (!js->testOnly) {      if (auxCN->autoLaunch) {        if ((forked = fork()) != -1) {          if (forked == 0) {            system(commandLine);            _exit(0);          }        } else {          printf("Error: could not fork(): aborting\n");          exit(1);        }      } else	printf("#*** You need to launch the following command:\n%s\n", commandLine);    }    auxCN = auxCN->next;  }}void waitConnectionFromComputingNodes(JS * js, int listenSocket, pid_t *pid) {  int acceptSocket;  int rank;  struct sockaddr_in pin;  socklen_t addrlen;  pid_t pid1;  int i;  for (i = 0; i< js->nprocs; i++) {    addrlen = sizeof(struct sockaddr);    if ( (acceptSocket = accept(listenSocket, (struct sockaddr *)&pin, &addrlen)) < 0 ) {      printf("Could not accept socket connection from client\n");    }  else {      read(acceptSocket, &rank, sizeof(int));      rank = ntohl(rank);      read(acceptSocket, &pid1, sizeof(pid_t));      pid[rank] = ntohl(pid1);      addConnectedNode(rank, acceptSocket);      /*        We then send the node list to that node, with the following form:	int[5]: ip1.ip2.ip3.ip4:port -> ip1ip2ip3ip4port      */            write(acceptSocket, js->nodeListArray, js->nprocs*sizeof(struct sockaddr_in));      /*close(acceptSocket);*/    }  } }

⌨️ 快捷键说明

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