Notes for second evening session (Tue Jan 30)

This file is:

1. CM5

How to log in, compile and run "hello world".
  1. Machine names
    rodin : front end to 32 nodes
    moore: front end to 64 nodes (will be shipped back to TMC on February 1)
    If you have CM-5 related questions, send mail to cm5-questions@rodin
    add to PATH /usr/cm5/bin:/usr/cm5/local/bin
    add to MANPATH /usr/cm5/man:/usr/cm5/local/man
  2. Basic Architecture (will be covered in class, also see
    Lots of on-line Connection Machine documentation: use cmview (CM5 hypertext documentation)
  3. CM5 executables:
    consists of a host program to run on the
    host, and a node program.
    Sometimes the host program is invisible to you (split-C, cm-fortran). Each program is a separate normal object file, each with it's own 'main()' routine.
  4. Programs:
          cmview: view Connection Machine on-line documentation
          cmps: display the status of current CM processes (memory usage,
    	    number of active processes, etc.)
                Useful to tell how loaded the machine is.
                *'d pid tells which one is currently running.
          djm: distributed job manager
             Method to submit batch jobs. Does a nice
             job with redireting I/O appropriately.
               -help to get options
             Main interface 'job'
             Useful Commands:
                 status  Show the status of all running jobs   
                 submit  Submit a background job
                 run     run an interactive job
                 signal  send a signal to a running job
                 kill    kill a running job
          cmjoin: produce a CM5 executable from
             two standard executable files.
          cmld: CM5 link editor for object files.
              This is what you use in a Makefile.
  5. Things to be aware of:
         ts-daemon: Liaison process between host and nodes
           Sometimes goes down.
         If the thing is down, send mail to tsd-down@rodin. If it persists, 
         send mail to fraser@cs.
  6. Compiling and linking:
         - host/node programs
         - sometimes it's hidden from you.
         - Standard .o files.
         - Use an already working makefile (take the one we supply)

  7. hello-host.c
    #include <stdio.h> #include <cm/cmmd.h> main() { CMMD_enable(); printf("Hello world from host.\n"); }
  8. hello-node.c
    #include <stdio.h> #include <cm/cmmd.h> main() { int myaddress; CMMD_fset_io_mode(stdout, CMMD_independent); myaddress = CMMD_self_address(); printf("Node %d: Hello world\n",myaddress); CMMD_enable_host(); }
  9. Makefile
    TARGET          = hello
    HOST_SRCS       = hello-host.c
    HOST_OBJS       = $(HOST_SRCS:%.c=%.o)
    NODE_SRCS       = hello-node.c
    NODE_OBJS       = $(NODE_SRCS:%.c=%.o)
    INCDIRS         = /usr/cm5/include
    HOST_LIBDIRS    = /usr/cm5/lib
    NODE_LIBDIRS    = /usr/cm5/lib
    HOST_LIBS       =
    NODE_LIBS       =
    CC              = gcc
    %-host.o: %-host.c
            $(CC) -DCP_CODE $(CFLAGS) $(INCDIRS:%=-I%) -c $<
    %-node.o: %-node.c
            $(CC) $(CFLAGS) $(INCDIRS:%=-I%) -c $<
    $(TARGET):      $(NODE_OBJS) $(HOST_OBJS)
            /usr/cm5/bin/cmmd-ld \
            -comp $(CC) -o $(TARGET) \
            -node $(NODE_OBJS) $(NODE_LIBDIRS:%=-L%) $(NODE_LIBS:%=-l%) \
            -host $(HOST_OBJS) $(HOST_LIBDIRS:%=-L%) $(HOST_LIBS:%=-l%)
            rm -f $(TARGET) $(NODE_OBJS) $(HOST_OBJS) *~ .make.state .nse_depinfo

See document 'CMMD User's Guide' underneath

2. Solaris Threads

Machine: one of ICSI 4 processing SS10 machines (will be announced later)


  • Thread - a sequence of instructions executed within the context of a process.
  • Lightweight processes (LWP) - "virtual cpus"
  • Bound vs unbound threads
  • Major thread operations: thr_create, thr_self, thr_yield, thr_suspend, thr_continue, thr_kill, thr_exit
  • Also, check out Solaris Thread Page

    /* gcc -D_REENTRANT hello.c -o hello -lthread */ #include <stdio.h> #include <thread.h> #define NUM_THREADS 10 void* hello(void* result); mutex_t mutex; main() { thread_t my_threads[NUM_THREADS]; int result; int i; for(i=0; i<NUM_THREADS; i++){ thr_create(0, 0, hello, &result, 0, &my_threads[i]); } /* wait for all child threads to terminate */ for(i=0; i<NUM_THREADS; i++){ thr_join(my_threads[i], NULL, NULL); } printf("All children terminated\n"); } void* hello(void* result) { /* avoid interleaving of messages */ mutex_lock(&mutex); printf("Thread id [%u]: hello\n", thr_self()); mutex_unlock(&mutex); return NULL; }