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

📄 v2arg.c

📁 Path MPICH-V for MPICH the MPI Implementation
💻 C
字号:
/*  MPICH-V2  Copyright (C) 2002, 2003 Groupe Cluster et Grid, LRI, Universite de Paris Sud  This file is part of MPICH-V2.  MPICH-V2 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-V2 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-V2; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  $Id: v2arg.c,v 1.1.1.1 2004/01/30 15:49:38 lemarini Exp $*/#include "v2arg.h"#include "debug.h"#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>void print_usage(char *prog_name){  fprintf(stderr,"Use: %s -f <configfile> -g <group> -r <rank> [-d <debuglevel>] [-h]where      <config_file> - the name of the host map used by mpirun             <port> - the port number of the server, on which it accepts                      connections from other MPI peers            <group> - the ID of the application which the worker wants to                      participate in (ID should be set according to (or by)                      the mpirun)            <rank>  - the MPI rank of this node       <debuglevel> - the highest level of debugging messages to be displayed\n", prog_name);}/**  * @param ipArgc [IN/OUT] number of strings in the cpppArgv * @param cpppArgv [IN/OUT] argv like string array * @param num [IN] number of parameters that have to be removed *  * @return 1 if there are enough parameters to remove and 0 otherwise */static int remove_param( piArgc, ppcArgv, num )int *piArgc;char **ppcArgv;int num;{  int i = 0;  char **argv;    argv = ppcArgv;      if( *piArgc > num )  {  	for( i = 0; i <= ((*piArgc) - num); i++) ppcArgv[i] = argv[i+num];    *piArgc -= num;    return 1;  }  else return 0;}void pop_args(int *argc, char **argv[], void (*print_usage)(char *argv0), char **configfile, int *group, int *rank, int *debug){  char *strtolchk;  int i;  *configfilename = NULL;  *group = *rank = *debug = -1;  for(i = 1; i < *argc; )  {    if(strcmp("-f",(*argv)[i]) == 0)    {      (*configfile = strdup((*argv)[i + 1]);      remove_param(argc, &((*argv)[i]), 2);    }    else if(strcmp("-g", (*argv)[i]) == 0)    {      *group = strtol((*argv)[i + 1],&strtolchk,0);      if(*strtolchk != '\0')      {        printw("Parsing argv: group number is invalid\n");        print_usage(*argv[0]);        exit(-1);      }      remove_param(argc, &((*argv)[i]), 2);    }    else if(strcmp("-r", (*argv)[i]) == 0)    {      *rank = strtol((*argv)[i + 1],&strtolchk,0);      if(*strtolchk != '\0')      {        printw("Parsing argv: rank number is invalid\n");        print_usage(*argv[0]);        exit(-1);      }      remove_param(argc, &((*argv)[i]), 2);    }    else if(strcmp("-d", (*argv)[i]) == 0)    {      *debug = strtol((*argv)[i + 1],&strtolchk,0);      if(*strtolchk != '\0')       {        printw("Parsing argv: debug level is invalid\n");        print_usage(*argv[0]);        exit(-1);      }       remove_param(argc, &((*argv)[i]), 2);    }    else if(strcmp("-h", (*argv)[i]) == 0)    {      print_usage(*argv[0]);      exit(0);    }    else     {      printi("PARAMS", "Passing command line parameter \"%s\" to MPI without modification.\n",*argv[i]);      i++;    }  }  if((*configfile == NULL) || (*group == -1) || (*rank == -1))  {    printw("Parsing argv : missing non optional parameters\n");    print_usage(*argv[0]);    exit(-1);  }}/*int readCommServTable( np, sock, psaMyServ )int np,sock;struct sockaddr_in* psaMyServ;{    int i, n, j, nb = 0;    XW_SrvAddrPort_t readServ;    XW_CommServ_t** paRankFd_temp;    XW_CommServ_t* paSrvAddrPort_temp;        xwInfo(20,"Reading comm.serv. table...\n");    paRankFd_temp      = (XW_CommServ_t**)calloc(np, sizeof(XW_CommServ_t*));    paSrvAddrPort_temp = (XW_CommServ_t*)calloc(np, sizeof(XW_CommServ_t));    for(i = 0; i < np; i++ ){        n = _xwread( sock, &readServ, sizeof(XW_SrvAddrPort_t) );        if(n<=0) xwFatal("readCommServTable: ERROR on reading: %s\n",strerror(errno));        xwInfo( 20, "\tEntry (%s:%d) (%d bytes) read\n", inet_ntoa( *(struct in_addr *)readServ.cSrvAddr ),                ntohs(readServ.iSrvPort), n );        /* ok now we have the server. Check if it's always in our list *//*        for( j = 0; j < nb; j++ ) {            if( memcmp( &(readServ.cSrvAddr), &(paSrvAddrPort_temp[j].commServ.cSrvAddr), 4 ) == 0 ) break;        }        if( j == nb ) { /* new server */  /*          xwInfo( 20, "New comm serv\n" );            memcpy( &(paSrvAddrPort_temp[nb].commServ), &(readServ), sizeof(XW_SrvAddrPort_t) );            if( memcmp( &(paSrvAddrPort_temp[nb].commServ), &(psaMyServ->sin_addr.s_addr), 4 ) == 0 ) {                xwInfo( 20, "It's my server\n" );                paSrvAddrPort_temp[nb].fd = sock;            } else                paSrvAddrPort_temp[nb].fd = -1; /* not yet initialized */  /*          j = nb;            nb++;        } else            xwInfo( 20, "Always in our table (like node %d)\n", j );        paRankFd_temp[i] = &(paSrvAddrPort_temp[j]);    }    xwInfo( 20, "From %d servers found %d differents\n", np, nb );    if( paRankFd != NULL ) free( paRankFd );    paRankFd = paRankFd_temp;    if( paSrvAddrPort != NULL ) {	if( memcmp( paSrvAddrPort, paSrvAddrPort_temp, sizeof(XW_CommServ_t) * np ) != 0 ) {	    xwWarning( "The communication servers table has changed!!!\n" );	}	free( paSrvAddrPort );    }    paSrvAddrPort = paSrvAddrPort_temp;    return nb;}*/

⌨️ 快捷键说明

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