Programming the CS2


INTRODUCTION TO PROGRAMMING ON THE MEIKO CS-2

HPCC

Workshop

Friday
22nd April 1994

PROGRAMMING MEIKO CS-2: TOPICS

AIMS

After completing the workshop you should be able to:

ACCESS TO CS-2 & COURSE MATERIAL

        No access via colour-book.
As compressed PostScript files.
PARMACS manual (28 pages) is in PARMACS.5.1.ps.Z Use Mosaic or lynx WWW viewers on DV systems for course notes on-line, plus other HPC information.
HPCC URL:  http://cs1.soton.ac.uk/homepage.html
 

PORTLAND GROUP COMPILER

Compiles code to run the 2 uVP processors.
For on-line information:
             man pgf77
Example invocation:
             pgf77 -Mvect -Minfo=opt,loop prog.f
Some Options:
      -Munroll
      -Mvect
      -novpu
      -Minfo=all

Many other options.

Can embed directives in source code. Example:

                cpgi$l smallvect

STRENGTHS & WEAKNESSES

             Sophisticated Optimisation, loop transformations, etc.
             Routine Inlining
             Loop Unrolling
             Most Intrinsic functions now written for uVP
             Scalar or vector code chosen at execution time
             Early version of compiler
             Information on vectorisation is poor
             Some intrinsics prevent vectorisation, eg: A(I)**3
Weak on conditional code

RESOURCE MANAGEMENT

      - handles all I/O, logged in sessions, etc.
      - no uVP processors
      - for compute-intensive work
      - cannot login to these
      - will have vector processors
      - single user nodes
      At night may be one partition of 8 nodes
      During day may be two partitions of 4 nodes each
      May have partition for a single vector board
For information on current configuration:
      rinfo -acjlpt
      rinfo -h
To run PARMACS program in partition parallel:
      setenv RMS_PARTITION parallel

PRACTICAL SESSION 1

To access the CS-2 and access the hands-on part of this course:

Login to Indigo as course1 (password: hpcc!SUCS), then:

     xterm &
     rlogin cs2 -l yourid
     cp -r ~dja/course .

Move to directory course/pgcompiler

Compilation using Portland Group Compiler:

pgf77 -c exam1.f -Mvect -Minfo=loop,opt

Use vi or MicroEMACS to edit files:

ue exam1.f


SESSION FILES


PARMACS PROGRAMMING

                  host runs on CS2-0: initialisation and control
                  node runs on one or more of the other nodes
             - for portability
             - host.u and node.u files
             - directory must contain:
                  host.u, node.u & makefile
             first step of make is expansion:
                  host.u -> host.f
                  node.u -> node.f

ELEMENTARY HOST.U

(in directory course/parmacs/A)

      program A
      ENVHOST
      integer pid, type
      INITHOST
      REMOTE_CREATE('config',nodeid)
      n = 1
      print *, 'N = ', n
      SEND(nodeid,n,4,1)
      RECV(n,4,nb,pid,type,MATCH_TYPE(2))
      print *, 'N = ', n
      ENDHOST
      stop
      end

ELEMENTARY NODE.U

(in directory course/parmacs/A)

      program Anode
      integer pid, type
      ENVNODE
      INITNODE
      RECV(n,4,nb,pid,type,MATCH_TYPE(1))
      n = n + 1
      SEND(pid,n,4,2)
      ENDNODE
      stop
      end


ASYNCHRONOUS MESSAGE PASSING

Have a number of processes, each on a different processor, which need to send commands and exchange data with each other. Each process is given a number to identify it.

Analogous to sending and receiving Email:

SEND

- sends message to a particular process.
- each message is given an INTEGER `type'.
- program continues as soon as message is sent.
- generates a pool of messages waiting to be received.
- messages might not be received in the order sent.

RECV

- asks for a message.
- can specify particular process and/or message type.
- waits indefinitely for it to arrive.
PROBE

- finds out if there is a message waiting.


MESSAGE PASSING MACROS

SEND(target_id,buffer,length,type)
    target_id   =    id-number of destination process (INTEGER)
buffer  =    the message, typically an array name (not CHARACTER)
length =     message length in bytes (INTEGER)
type    =    label for message (INTEGER)
PROBE(flag,condition)
flag          =     INTEGER variable, is set
condition     =    macro for message selection:
              MATCH_ANY
              MATCH_ID(id number)
              MATCH_TYPE(type)
              MATCH_ID_AND_TYPE(id number,type)
RECV(buffer,buffer_length,length,sender,type,condition)
buffer  =    to receive message, typically array of length buffer_length
length =     to receive length of message
sender =     to receive id number of sending process
type    =    to receive label of the message

SYNCHRONOUS MESSAGE PASSING

SENDR
   - sends message and waits until it has been received
RECVR
   - similar to RECV, but sends acknowledgement
   - use this when SENDR is used, else sending process may remain hung

OTHER MACROS

TORUS(nx,ny,nz,'node','file')
nx*ny*nz    =     total number of node processors
'node'       =     path name of node program
'file'         =    path name of file read by REMOTE_CREATE
REMOTE_CREATE('file',procid)
'file'         =    path name of configuration file
procid =     INTEGER array to hold id numbers of processors
MYPROC  = id number of own process
HOSTID  = id number of host process

SIMPLE NODE.U

(in directory /course/parmacs/B/)
      program Bnode
      integer pid, type
      parameter (num = 1000)
      double precision b(num)
      ENVNODE
      INITNODE
 100  continue
      RECVR(b,8*num,nb,pid,type,MATCH_ANY)
      if (type .eq. 1) then
        call comput(b,nb/8)
        SENDR(pid,b,nb,2)
        goto 100
        endif
      ENDNODE
      stop
      end
      subroutine comput(a,n)
      double precision a(n)
      do i=1,n
        a(i) = a(i) + 1
      enddo
      return
      end

SIMPLE HOST.U

(in directory /course/parmacs/B/)
      program B
      parameter (nprocs = 2, num = 1000)
      ENVHOST
      integer pid, type, nodeid(nprocs)
      double precision b(num)
      INITHOST
      do 100, i=1,num
      b(i) = 0d0
 100  continue
      print *, b(num)
      TORUS(nprocs,1,1,'node','config')
      REMOTE_CREATE('config',nodeid)
      do 101, i=1,nprocs
      j = (i-1)*num/nprocs + 1
      SENDR(nodeid(i),b(j),8*num/nprocs,1)
 101  continue
      do 102, i=1,nprocs
      j = (i-1)*num/nprocs + 1
      RECVR(b(j),8*num/nprocs,nb,pid,type,MATCH_ID(nodeid(i)))
 102  continue
      print *, b(num)
      ENDHOST
      stop
      end

PRACTICAL SESSION 2

PARMACS

Compile and run the elementary host.u and node.u
Make changes to the code and see the results. Compile and run the simple host.u and node.u
Try changing the number of processors.
Modify the code so that the host signals the node processes to close themselves down. so that it can be run using the vector board, using the makefile in course/parmacs/C

START OF DOCUMENT

UP


Submitted by David zAdams,
last updated on 22 April 1994.