/*********************************************************************** * * * The JIAJIA Software Distributed Shared Memory System * * * * Copyright (C) 1997 the Center of High Performance Computing * * of Institute of Computing Technology, Chinese Academy of * * Sciences. All rights reserved. * * * * Permission to use, copy, modify and distribute this software * * is hereby granted provided that (1) source code retains these * * copyright, permission, and disclaimer notices, and (2) redistri- * * butions including binaries reproduce the notices in supporting * * documentation, and (3) all advertising materials mentioning * * features or use of this software display the following * * acknowledgement: ``This product includes software developed by * * the Center of High Performance Computing, Institute of Computing * * Technology, Chinese Academy of Sciences." * * * * This program 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. * * * * Center of High Performance Computing requests users of this * * software to return to dsm@water.chpc.ict.ac.cn any * * improvements that they make and grant CHPC redistribution rights. * * * * Author: Weiwu Hu, Weisong Shi, Zhimin Tang * * =================================================================== * * This software is ported to SP2 by * * * * M. Rasit Eskicioglu * * University of Alberta * * Dept. of Computing Science * * Edmonton, Alberta T6G 2H1 CANADA * * =================================================================== * **********************************************************************/ #ifndef NULL_LIB #include "global.h" #include "init.h" #include "mem.h" extern void initmem(); extern void initsyn(); extern void initcomm(); extern void initmsg(); extern void inittools(); extern void initload(); extern void disable_sigio(); extern void enable_sigio(); extern unsigned long jia_current_time(); extern float jia_clock(); int getline(int *wordc, char wordv[Maxwords][Wordsize]); void gethosts(); int mypid(); void copyfiles(int argc, char **argv); int startprocs(int argc, char **argv); void jiacreat(int argc, char **argv); void barrier0(); void redirstdio(int argc, char **argv); void jia_init(int argc, char **argv); void clearstat(); extern char errstr[Linesize]; extern long Startport; FILE *config, *fopen(); int jia_pid; host_t hosts[Maxhosts+1]; int hostc; /*host counter*/ char argv0[Wordsize]; sigset_t startup_mask; /* used by Shi.*/ int jia_lock_index; #ifdef DOSTAT jiastat_t jiastat; int statflag; #endif int getline(int *wordc, char wordv[Maxwords][Wordsize]) {char line[Linesize]; int ch; int linei,wordi1,wordi2; int note; linei=0; note=0; ch=getc(config); if (ch=='#') note=1; while ((ch!='\n')&&(ch!=EOF)){ if ((linei0){ wordv[wordi1][wordi2]='\0'; wordi1++; } } *wordc=wordi1; return(ch==EOF); } void gethosts() {int endoffile; int wordc,linec,uniquehost; char wordv[Maxwords][Wordsize]; struct hostent *hostp; int i; char tmp[1000],*tmpptr; // added by NM tmpptr = getenv("HOME"); // added by NM strcpy(tmp,tmpptr); // added by NM strcat(tmp,"/.jiahosts"); // added by NM // if ((config=fopen(".jiahosts","r")) == 0) { deleted by NM if ((config=fopen(tmp,"r")) == 0) { // added by NM printf("Cannot open .jiahosts file\n"); system("echo $HOST"); printf("%s\n",tmp); exit(1); } endoffile=0; hostc=0; linec=0; while(!endoffile){ endoffile=getline(&wordc,wordv); linec++; sprintf(errstr,"Line %4d: incorrect host specification!",linec); assert0(((wordc==Wordnum)||(wordc==0)),errstr); if (wordc!=0){ hostp=gethostbyname(wordv[0]); printf("Host[%d]: %s [%s]\n", hostc, hostp->h_name, inet_ntoa(*(struct in_addr*)hostp->h_addr_list[0])); sprintf(errstr,"Line %4d: incorrect host %s!",linec,wordv[0]); assert0((hostp!=NULL),errstr); strcpy(hosts[hostc].name,hostp->h_name); memcpy(hosts[hostc].addr,hostp->h_addr,hostp->h_length); hosts[hostc].addrlen=hostp->h_length; strcpy(hosts[hostc].user,wordv[1]); strcpy(hosts[hostc].passwd,wordv[2]); for (i=0;is_port, NULL, NULL, cmd,&(hosts[hosti].rerrfd)); #else /* NFS */ hosts[hosti].riofd=rexec(&hostname,sp->s_port,hosts[hosti].user, hosts[hosti].passwd,cmd,&(hosts[hosti].rerrfd)); #endif /* NFS */ #endif sprintf(errstr,"Fail to start process on %s!",hosts[hosti].name); assert0((hosts[hosti].riofd!=-1),errstr); } } int mypid() { char hostname[Wordsize]; uid_t uid; struct passwd *userp; struct hostent *hostp; int i; assert0((gethostname(hostname,Wordsize)==0), "Cannot get host name!"); hostp=gethostbyname(hostname); assert0((hostp!=NULL),"Cannot get host address!"); uid=getuid(); userp=getpwuid(uid); assert0((userp!=NULL),"Cannot get user name!"); i=0; strtok(hostname,"."); while ((ipw_name)==0)))) #endif /* NFS */ i++; assert0((i int jia_pid = 0; int hostc = 1; void jia_init(int argc, char **argv) { printf("This is JIAJIA-NULL\n"); } #endif /* NULL_LIB */ unsigned int t_start, t_stop=0; unsigned int jia_startstat() { #ifdef DOSTAT clearstat(); statflag=1; #endif t_start = get_usecs(); return t_start; } unsigned int jia_stopstat() { #ifdef DOSTAT statflag=0; #endif t_stop = get_usecs(); return t_stop; }