ARSC T3E Users' Newsletter 183, Nov. 24, 1999

HPC Seminars at ARSC: Dec 7-8, Preliminary Schedule

As noted in the last issue, On Dec. 7-8, ARSC is sponsoring a number of seminars on the future of high performance computing. These will occur on the UAF campus.

Here is the preliminary schedule of speakers and talks:

Tuesday, Dec. 7

  • 2:00 Seminar - "Managing Tape Based Archives" Gene Harano, National Center for Atmospheric Research, Boulder, CO
  • 3:00 Seminar - "Computational Science and Engineering Research at the California Institute of Technology" Jim Poole

Wednesday, Dec. 8

  • 2:00 Seminar - "The state of HPF, OpenMP and MPI" Prof. Barbara Chapman, U of Houston
  • 3:00 Seminar - "Effective Parallel Programming in Advanced ZPL" Prof. Larry Snyder, U of Washington

Check: http://www.arsc.edu/ for the location and final schedule, and feel free to attend all or some of the talks.

Eurotools Request

The main objective of EuroTools is to identify new trends in computational and data-intensive applications and to increase the development and use of tools in these emerging domains.

Eurotools is at:

http://www.eurotools.org

The annual report and a new survey are available. You are kindly requested to complete the on-line questionnaire. Follow the User Needs and Requirements On HPC Software Tools link on the home page.

Top500 List

The TOP500 list is revised twice a year, the latest having just be released at SC99. It makes interesting reading and a browse through the list shows some interesting sites. The list, plus some analysis, can be found at http://www.top500.org/ . Comments:
  • The top 3 systems are all part of the ASCI project, with ASCI Red just taking the top position from IBM and SGI ASCI Blue.
  • In the top 20 it is a mixture of government laboratory work and weather/climate centers. Although Charles-Schwab makes an interesting entry at 12 in the 'Industry Finance' category.
  • The top100 is mostly MPP systems and a number of bigger SMP clusters with a few of the bigger vectors keeping pace. Oak Ridge National Laboratory still gets a mention for the Intel XP/S-MP 150 3000 processor system at 70.
  • The bottom parts of the list are full of various SMP systems supporting a diverse range of needs from industries such as eBay, various airlines, numerous banks and trading houses, and image rendering companies such as Industrial Light & Magic.
In case you wonder, ARSC is placed at 56 in the list.

New Paper on PEMCS site: Communication and Scalability

At:

http://hpc-journals.ecs.soton.ac.uk/PEMCS/Papers/

you'll find:

Comparing the Communication Performance and Scalability of a SGI Origin 2000, a Cluster of Origin 2000's and a Cray T3E-1200 using SHMEM and MPI Routines, Glenn R. Luecke, Bruno Raffin and James J. Coyle, Iowa State University, Ames, Iowa, USA, October, 1999.

Quick-Tip Q & A


A: {{ Can you write a program (C or Fortran) that prints the path, 
   {{ relative or absolute, to its executable?
   {{
   {{ It should work whether you type the path to the executable
   {{ explicitly or if you type its name, and the system must search the
   {{ PATH variable to locate it.  (In other words, argv[0] won't always
   {{ hold the answer.)
Many thanks (and prizes!) go to three readers:
  • Richard Griswold sent the only shell independent solution. If argv[0] doesn't contain the path, it searches all directories in the PATH environment variable for the executable.
  • Brad Chamberlain's version uses argv[0], when it contains the path, and csh's "which" function, when it doesn't. (It could be extended to check the caller's shell, and use "whence" if found to be ksh.)
  • Derek Bastille's version uses a nifty Korn shell feature. The ksh environment variable, "_", is set to the absolute or relative path of a command when it is executed (and re-used later for other things). Derek's version doesn't worry about argv[0] at all, but simply grabs "_".

Here are the solutions: Richard's:


#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <unistd.h>

#define PATH_MAX 1024

int checkpath( char *path, char *exec ) {
  int            rc;   /* Return code for strlen and access      */
  char          *str;  /* Temporary string for access()          */
  DIR           *dir;  /* Dir struct for opendir() and readdir() */
  struct dirent *ent;  /* Dir entry struct from readdir()        */

  /* Find an executable file in path that has same name as exec */
  dir = opendir( path );
  while ( ( ent = readdir( dir ) ) != NULL )
    if ( strcmp( ent->d_name, exec ) == 0 ) {
      str = ( char * ) malloc( PATH_MAX * sizeof( char ) );
      rc  = strlen( path );
      strncpy( str, path, rc );
      str[rc] = '/'; str[rc+1] = '\0';
      rc = access( strcat( str, ent->d_name ), X_OK );
      free( str ); closedir( dir );
      return rc == 0 ? 1 : 0;
    }
  closedir( dir ); return 0;
}

void printrelative( char *path, char *exec ) {
  int   len,  /* Length of cwd             */
        i;    /* Index                     */
  char *cwd;  /* Current working directory */

  cwd = ( char * ) malloc( PATH_MAX * sizeof( char ) );
  cwd = getcwd( cwd, PATH_MAX );
  len = strlen( cwd );

  if ( strcmp( cwd, path ) == 0 ) {          /* Are cwd and path the same?  */
    path[0] = '.'; path[1] = '\0';
  } else if ( len < strlen( path ) ) {       /* Remove CWD from path        */
    for ( i = 0; i < len; i++ )
      if ( cwd[i] != path[i] ) break;
    if ( i == len )                          /* CWD is in beginning of path */
      if ( i == 1 ) { path = path + i;     } /* Fix up path if cwd == '/'   */
      else          { path = path + i + 1; }
  }
  printf( "\"%s\" is in directory: %s\n", exec, path );
  free( cwd  );
}

int main( int argc, char *argv[] ) {
  int   s,    /* Start of a path in PATH envvar */
        len,  /* Length of PATH envvar          */
        i;    /* Index                          */
  char *str;  /* PATH envvar or executable name */

  if ( ( str = rindex( argv[0], '/' ) ) != NULL ) {
    str[0] = '\0';
    printf( "\"%s\" is in directory: %s\n", str+1, argv[0] );
  } else {
    str = getenv( "PATH" ); len = strlen( str );
    for ( i = 0, s = 0; i < len; i++ )
      if ( str[i] == ':' ) {
        str[i] = '\0';
        if ( checkpath( str + s, argv[0] ) ) break;
        else                                 s = i + 1;
      }
    printrelative( str + s, argv[0] );
  }
  return 0;
}
Brad's:

// A few assumptions:
//
//  * /tmp/.findme.pathname can be written to
//  * path names will not be longer than 255 characters
//  * executable's name will not be longer than ~220 characters


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// someplace to store the output of a shell "which" command
static const char* const tmpfilename = "/tmp/.findme.pathname";

void main(int argc,char* argv[]) {
  char* lastslash;    // pointer to rightmost slash in string
  char* progname;     // pointer to program name
  char* pathname;     // pointer to path name
  char command[256];  // buffer for sprintf()ing commands
  FILE* infile;       // file pointer for reading shell "which" command output
  char fullpath[256]; // buffer for storing full path

  lastslash = strrchr(argv[0],'/');  // see if path is on argv[0]
  if (lastslash != NULL) {           // if so...
    *lastslash = '\0';               // cap string there
    progname = lastslash + 1;        // set pointers to filename, pathname
    pathname = argv[0];
  } else {
    progname = argv[0];              // else argv[0] holds program name

    sprintf(command,"which %s > %s",argv[0],tmpfilename); // setup a which
    system(command);                                      // & execute it

    infile = fopen(tmpfilename,"r");                      // read the output
    fscanf(infile,"%s",fullpath);
    fclose(infile);

    sprintf(command,"rm %s",tmpfilename);                 // remove tmp file
    system(command);

    pathname = fullpath;                                  // search for slash
    lastslash = strrchr(pathname,'/');                    // cap string
    *lastslash = '\0';
  }
  printf("\"%s\" is in directory: %s\n",progname,pathname);  // output results
}
Derek's:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[]) {

/*
 * This code is ksh specific.  It works because ksh keeps a reference to the
 * last command in the "_" environment variable.  Since it does this after
 * doing aliases and pattern matching, "_" happens to hold the path to
 * whatever was executed.
 */

        char *myPath;  // holds ptr to the "_" variable contents
        char *myName;  // holds ptr to name of executable
        char *temp;    // holds temporary stuff (D'oh :-)

        temp = strrchr(argv[0],'/');  // set temp to last occur. of '/'
        if (temp != NULL) {           // if '/'s exist
                myName = temp + 1;    // set myName to remainder of string
        } else {                      // otherwise
                myName = argv[0];     // set myName to first arg.
        }

        myPath = getenv("_");        // get "_" variable from environment
        temp = strrchr(myPath,'/');  // set temp to last occur. of '/'
        *temp = '\0';                // strip off the executable name

        printf("\"%s\" is in directory: %s\n",myName,myPath);  // print

        return 0;
}


Q: My colleague finally sent me some critical files, but now he's off
   to Roswell for a millennium vigil, and I can't untar them!

   It looks like he gave absolute paths when he tar'ed the files, 
   but the system won't let me recreate the paths:

     c-yukon<36> tar tf progs.tar
     /tmp/vgt_tmp/progs/ellips.c
     /tmp/vgt_tmp/progs/genseq.c

     c-yukon<37> tar xf progs.tar
     cmd-3749 tar: mkdir '/tmp/vgt_tmp/progs' failed: Permission denied
     cmd-1004 tar: Cannot create '/tmp/vgt_tmp/progs/ellips.c'.
     cmd-3749 tar: mkdir '/tmp/vgt_tmp/progs' failed: Permission denied
     cmd-1004 tar: Cannot create '/tmp/vgt_tmp/progs/genseq.c'.

   How can I extract these files?

[ Answers, questions, and tips graciously accepted. ]


Current Editors:
Ed Kornkven ARSC HPC Specialist ph: 907-450-8669
Kate Hedstrom ARSC Oceanographic Specialist ph: 907-450-8678
Arctic Region Supercomputing Center
University of Alaska Fairbanks
PO Box 756020
Fairbanks AK 99775-6020
E-mail Subscriptions: Archives:
    Back issues of the ASCII e-mail edition of the ARSC T3D/T3E/HPC Users' Newsletter are available by request. Please contact the editors.
Back to Top