NCSA TMC CONNECTION MACHINES CM-5
MASSIVELY PARALLEL PROCESSOR
Version 4.02
Department of Mathematics, Statistics, and Computer Science
University of Illinois at Chicago
851 S. Morgan; Room 322 SEO, MC 249
Chicago, IL 60607-7045
Electronic addresses:
Introduction to NCSA Connection Machine CM-5
This User's Guide is intended to be a minimal, hands-on introduction to the University of Illinois at Urbana, National Center for Supercomputing Applications massively parallel Connection Machine CM-5 system.
The Massively Parallel Processor CM-5
The CM-5 are made by the Thinking Machines Corporation of Cambridge, Massachusetts. The CM-5 is the new generation model after the CM-2, so new that it the model names CM-3 and CM-4 were skipped over. The CM-5 has many SPARC based nodes with four proprietary vector units attached per node, using a ``Fat Tree'' architecture. The CM-5 was first installed in April 1992, but has been upgraded since.
Sample Login to the NCSA CM-5 from UIC
rlogin Login from UNIX to CM-5)
For those students who have accounts on a Unix or other workstation
computer,
the remote login command `rlogin' will be a better way to access
the NCSA CM-5 Compile Server `cm5', because using `rlogin' gives a
better terminal emulation than `telnet'
The format of the command is
PC telnet Login from the PC-Labs to the NCSA CM-5
The UIC computer center has PC-Labs in 2249f SEL, BGRC, BSB, SRC or
in the Dorms (the latter with longer hours; in CMS type
inform schedule consulting introduction phone for further
information). The PCs in the PC-Labs
have a PC version of telnet that will allow the user to communicate
directly with NCSA or the ACRF and avoid the 3270 bottleneck on the
IBM 3090 mainframe. Assuming that the PC is turned on and you
have the DOS (Disk Operating System) hard disk drive (C) prompt and
you want to access the NCSA CM-5 Compile Server (cm5) then enter:
Go next to Annotated NCSA CM-5 Sample Session.
IBM Telnet Login from CMS to the NCSA CM-5
The logon
procedure assumes you are successfully logged onto the CMS system on the
UIC IBM 3090-300J Vector Facility running CMS/SP and MVS/SP under VM/XA.
A fast and convenient
line to the National Center for Supercomputing Applications (NCSA) in
Urbana is the NSFNET (56K Baud speed) connection between UIC and UIUC using
IBM TELNET (currently the IBMNET version) communications.
This IBM Telnet
connection will be in line edit mode rather than full screen
transparent mode, because the connection is between an IBM/VM machine
and an non-VM UNIX 4.3 BSD machine without a IBM 3270 type display
terminal. The 3270 problem is complex:
IBM places the non-universal
terminal requirement on its system and the university or computer center
does not have the resources to offer a 3270 telnet, called `tn3270',
or proper terminals on the IBM system to solve the IBM created problem.
This means that the UNIX full screen editor vi will not
work, but that the UNIX line editor ex will work. Also, certain
control sequences have to be modified (e.g. use
\c (CR)
and not Ctrl-c for UNIX interrupt; use the BACKSPACE
key and not the Delete key).
Follow this procedure:
Annotated NCSA CM-5 Sample Session
Login to the CM-5 Compile Server as before, for example,
program laplace
code: LaPlace solver sample program
code: From "getting Started in CM Fortran".
code: Solution of LaPlace's equation on unit square.
code: BC: f(x,1)=1, f(0,y)=f(x,0)=f(1,y)=2, 0<{x,y}>1.
code: Initial interior starting iterate: f(x,y) = 0.
comment: Need to include CMF timer utilities:
include '/usr/include/cm/timer-fort.h'
parameter(maxx=32,maxy=maxx)
real f(maxx,maxy),df(maxx,maxy)
real rms_error,max_error
logical cmask(maxx,maxy)
integer iteration
comment: Clear and start timer 0.
call cm_timer_clear(0)
call cm_timer_start(0)
comment: Initialize the mask for the interior points.
cmask = .false.
cmask(2:maxx-1,2:maxy-1) = .true.
comment: Initialize f
f = 2.
f(:,maxy) = 1.
where (cmask) f = 0.
comment: Set dummy value for max_error.
max_error = 1.
iteration = 0
comment: Iterate until max_error < 1.e-3 stopping criterion.
do while (max_error.gt.1.e-3)
iteration = iteration + 1
comment: Compute df, the change at each iteration, and udate.
df = 0.
where (cmask)
df = 0.25*(cshift(f,1,1) + cshift(f,1,-1)
& + cshift(f,2,1) + cshift(f,2,-1)) - f
f = f + df
endwhere
comment: Compute RMS and Maximum errors.
rms_error = sqrt(sum(df*df)/((maxx-2)*(maxy-2)))
max_error = maxval(df,mask=cmask)
comment: Output errors every 10th iteration
if(mod(iteration,10).eq.0) then
write(6,*) iteration,rms_error,max_error
endif
enddo
comment: Stop and Print timer
call cm_timer_stop(0)
print*,'total CM5 time'
call cm_timer_print(0)
comment: Output final iteration count and errors (stopping criteria).
write(6,*) iteration,rms_error,max_error
stop
end
#!/bin/csh #JSUB-nproc 32 #JSUB-cpu 16sec #JSUB-mem 32m #JSUB-project rnk #JSUB-stdout pgm.out # # CAUTION: JOB MUST BE SUBMITTED FROM A SRATCH DIRIECTORY # HOME DIRECTORY IS NOT BIG ENOUGH FOR *.o OR EXECUTABLE run # This runs executable run from scratch directory in batch by DJM run # Look for stdout output pgm.out in scratch directory where submitted
ftp File Transfer between NCSA CM-5 and UIC
The fastest way to transfer files between UIC and NCSA is using
the file transfer protocol, FTP, for transfers from UIC.
The CM-5 Compile Server shares the same scratch Hard Disk file systems.
ftp File Transfers at UIC
At UIC the IBMNET version of FTP is used on CMS and it uses the
following commands:
UNIX and CM SUNs Command Dictionaries
The CM Suns (UNIX+) manual is mostly on line
`man - [command] (CR)'
will yield information.
This abridged CM Suns (UNIX+) dictionary
is only intended to be a short enough list to get you started
without being bewildered by the enormous UNIX manuals, but
with enough commands to be able
to do something useful. For more information use the `man'
command or refer to the CM Suns manuals or refer to some
of the UNIX texts. This guide assumes that the UNIX shell used is the common
user shell called the C-SHELL or Command Shell
with resource configuration file `.cshrc'. For other shells like `sh', 'ksh'
and `bash' please refer to the man pages to verify that listed commands
actually exist in those shells.
Many of the following commands will work in UNIX.
UNIX is a trademark of Bell Laboratories.
The format is ``[command] [generic operand] : [Definition.]'',
along with a carriage return {(CR)} for each command.
DO NOT FORGET that almost all UNIX commands must be in
lower case.
Do not attempt to learn all of this at once, but read some
of it and try it out at an actual computer session.
UNIX Log In and Out Commands
The EX Editor
`Ex' is the UNIX line editor (`ed' is another UNIX line editor)
and `vi' is the
full screen editor that is disabled by IBM TELNET.
The prompt is `:', but
the user enters input at the bottom of the screen with IBM TELNET
line mode.
In `ex' `.' means the current line, `$' means the last line,
and `%' means the whole range of lines `1,$'.
`[L1],[L2]' denotes the range from line `[L1]' to line `[L2]'.
The user may want to do major editing on the CMS multi-line editor XEDIT
and send the file to the CM Suns using the FTP file transfer protocol.
Some students may have had experience with this editor (or the similar
`ed' editor) from EECS courses. These `ex' commands can be used within
the `vi' editor by typing a colon `:' in front of the `ex' command,
which is another reason for learning `ex' with `vi' when you have
an account where `vi' can be used.
The VI Editor
The UNIX full screen editor vi is a tightly designed editing
system in which almost every letter has a function and the function is
different for lower and upper case. However, a letter and its actual
function are usually closely related. It is important to remember that
the `Esc' escape key ends most functions and a `Esc,Esc'
double application certainly ends the function with the ring of a bell.
The subcommand `u' undoes the last function (presumably an error).
Use `:q! (CR)' to end with out saving, especially in hopeless
situations. Use `:wq (CR)' to resave and end {`ZZ' also
resaves and ends, but will not resave if the file has been saved in
another file and no further changes have been made}, or `:w (CR)'
to only resave. The character `:' prompts the UNIX line editor `ex'
which you can think of as being embedded in `vi'. Some of the above
critical `vi' subcommands are repeated below with others. Most `vi'
subcommands are not displayed when used and do not take a carriage
return `(CR)'. The fact that most keys have a meaning both as
single characters and as concatenations of several characters has many
benefits, but has disadvantages in that mistakes can turn
out to be catastrophic {remember that `Esc, Esc, u' key
sequence!}.
Interrupts Dictionaries for CMS and IBM Telnet
When you get `hung up' in a session it is extremely helpful
to know which interrupts or mode change commands that can most
effectively get you back to a normal session. Part of developing good
skills for working with supercomputers is becoming ``super-killer'' of
errant processes. This is particularly true for the
IBM TELNET `pass-through' when most CMS terminal properties
pass through in a top-down hierarchy from CMS to IBM TELNET to UNIX.
CMS Interrupts Dictionary
Distributed Job Manager DJM for CM Batch Scheduling
The Distributed Job Manager (DJM) is a new job control system used for
running batch or background job and also for interactive job management.
It was developed by the AHPCRC and the Minnesota Supercomputing Center.
It supercede the older and difficult to use Network Queuing System
(NQS). With DJM, the user no longer has to figure out which queue to use.
Batch scheduling is VERY IMPORTANT, because ordinary development
runs are allowed weekdays from 9am to 7am and 12pm to 5pm on Saturdays. At
other times you must use batch. For more information user `man [command]' or
consult
laplace.fcm
for any user submitting from a scratch disk after copying it to the scratch
disk:
--------------- cm5% jsub cm5jsub.run ---------------on the CM-5 Compile Server, `cm5'. In this script all the lines with a leading `#' not followed by a blank are shell commands, while the lines with `# ' denote lines of comments (blank alert!). The first line, with the `!' shell activator, identifies that the C-Shell will be used to interpret the shell. Lines 2-4 specify the `jsub' options of `32' sparc processors, a 5 minute CPU time limit, `128'MB of memory, that the accounrnk `rnk' should be charged, and that the output will be directed to the scratch disk of user `hanson' into the file `pgm.out'. The next 3 lines are comments, because a blank follows each leading `#'. The last line is gives the executable command for the job. The script can be converted to your use, by changing the user scratch directory `/scratch2/hanson' to your own scratch directory and the user account `rnk' to your own NCSA account, along with the output name `pgm.out' and executable name `run' to your own names. You can also change the options to any legitimate options. The user can also place the statement `setenv PSN [ncsa-account-number]' near the `alias' statements in the user's C-SHell resource configuration file `~/.cshrc'.
CM Fortran CMF Compile and Execution
The CM-5 has its own extended version of the UNIX
CM Fortran command called `cmf' rather than the standard SunOS
UNIX `f77'. See the CM-5 manuals for more extensions, standard options
and examples. See the manuals for complete information.
To use CM timing subroutines and CM Utilities, you must
include the following `include' statement in each CM
Fortran program unit:
include '/usr/include/cm/timer-fort.h'
If CMF utilities will also be used, then the user must also
include '/usr/include/cm/CMF_defs.h'
CMF C
real R float* r
double precision D double* d
integer I int* i
complex C struct(float real, imag;)* c
double complex CD struc(double real, imag;)* cd
call _SUB sub
c --------------------
integer, parameter :: m=64,n=256 ! integer declaration with parameter
! attribute, i.e., 2 statements in one.
! a `!' in a CMF statement implies an inline comment to its right;
! except when in column 6 when it is the usual continuation character.
real, array(m,n) :: a,b,p ! real declaration with array attribute;
! the arrays declared to have the same shape.
integer, array(5) :: c,d
integer, array(3), data :: v=[-3,4,-5] ! array, data and constructor
! a(1,2) is a scalar element, to be computed on the FE.
! a(1,2:2) is an array section with shape [1], however.
! a(2,1:n) is an array section with shape [n].
! a(2:2,1:n) is an array section with shape [1,n].
! ****assume that the following areas are initialized.****
b=a(1:m,1:n) ! a full array with shape [m,n], `a' is same as `a(1:m,1:n)'.
a = 3.8*b + 5.7 ! conformable array expression => a(i,j)=3.8*b(i,j)+5.7
! for all i,j.
p = a**2 + 3*b ! conformable expression => p(i,j)=a(i,j)**2+3*b(i,j)
! for all i,j.
p = a*b ! conformable array expression => p(i,j)=a(i,j)*b(i,j)
! for all i,j; note the element, not matrix, multiplication.
do 1 i=1,m
do 1 j=1,n
1 a(i,j)=i+2*j !subscript reference => Front-End calculation, entirely.
c=[1,5,3,6,7] ! array constructor gives elements of c values 1,5,3,6,7.
d=[1:10:2] ! array constructor gives elements of d values 1,3,5,7,9.
d=[1,[7:9],3] ! array constructors give elements of d values 1,7,8,9,3.
d=[1,v,3] ! array constructors give elements of d values 1,-3,4,-5,3.
c=[1,2[3,5]] ! constructor with multiple giving d values 1,3,5,3,5.
c=a(51:55,83) ! array c set equal to same shape array section of a.
a = 5.1 ! Broadcast 5.1 from Front End to all elements of a.
call subr(a(1:20,v)) ! Call subroutine `subr' with section a(1:20,v)
! as subroutine arguments (note vector subscript).
print*,c ! => print*,(c(i),i=1,5)
c --------------------
c --------------------
real, array(256,512) :: a,b ! real declaration with array attribute;
! assume that a and b are initialized
b = sin(2.*a) + 4.5*exp(3*b) ! b(i,j)=sin(2.*a(i,j))+4.5*exp(3*b(i,j))
! for all i,j.
b = sqrt(a) ! b(i,j)=sqrt(a(i,j)) for all i,j.
c --------------------
Note that expressions and their left-hand-sides must be conformable.
[Ans]=ALL([MASK],[DIM]) ! Determine if all values are .true. in
! [MASK] along dimension [DIM].
[Ans]=ANY([MASK],[DIM]) ! Determine if any value is .true. in
! [MASK] along dimension [DIM].
[Ans]=DOTPRODUCT([VECTOR_1],[VECTOR_2]) ! Dotproduct of two vectors.
[Ans]=MAXVAL([ARRAY],[DIM],[MASK]) ! Computes the maximum value of the
! elements of [ARRAY] along dimension
! [DIM] corresponding to the true
! elements of the [MASK].
[Ans]=MINVAL([ARRAY],[DIM],[MASK]) ! Computes the minimum value of the
! elements of [ARRAY] along dimension
! [DIM] corresponding to the true of
! elements the [MASK.]
[Ans]=PRODUCT([ARRAY],[DIM],[MASK]) ! Product of all the elements of
! [ARRAY] along dimension [DIM]
! corresponding to the true elements
! of [MASK].
[Ans]=SUM([ARRAY],[DIM],[MASK]) ! Sum of all the elements of [ARRAY] along
! dimension [DIM] corresponding to the
! true elements of [MASK].
In the above, the answer `[Ans]' must be declared as the same shape and type as
the expected output of the CM function.
For 2D arrays or array sections,
`DIM=1' is the vertical dimension (i.e., variation of the first array subscript)
and `DIM=2' is the horizontal dimension (i.e., variation of the second array
subscript).
The `MASK=[MASK]' is an array conditional that must be compatible with the
shape of array `[ARRAY]'. In these array reduction functions, the dimension
and mask arguments are optional. CAUTIONS: keywords `DIM=', `MASK=', etc.,
must be used for all keyword arguments or for none; keyword and non-keyword
arguments can not be mixed in any function; if no keywords are used then the
arguments should follow the default order; Cray CF77v6.0 array intrinsic
functions do not take keywords.
The type of communication used in functions
like SUM is yet another type of communication on the CM, called Scan
Communication. Here are some examples (note: these examples
are much too small for the CM and are just for illustration):
c --------------------
integer b(2,3),s2(2),s3(3)
b(1,1:3) = [1, 3, 5] ! initialize first row, along dimension 2.
b(2,1:3) = [2, 4, 6] ! initialize second row, along dimension 2.
c --------------------
isum = sum(b) ! => isum = 21; i.e., Front-End scalar.
isum = sum(b(:,1:3:2)) ! => isum = 14; sole `:' means all values `1:2'.
s2 = sum(b,dim=2) ! => s2 = [9,12]; row sums; note result must be
! declared with the correct array section shape.
s3 = sum(b,dim=1) ! => s3 = [3,7,11]; column sums.
isum = sum(b,mask=b.gt.3) ! =>isum = 18; i.e., add only elements
! that are greater than three.
s3 = sum(b,dim=1,mask=b.gt.3) ! => s3 = [0,4,11]; conditional col. sum.
c --------------------
imax = maxval(b) ! => imax = 6; array maximum value.
s3 = maxval(b,dim=1) ! => s3 = [2,4,6]; column maximums.
s2 = maxval(b,dim=2) ! => s2 = [5,6]; row maximums.
c --------------------
imin = minval(b) ! => imin = 1; array minimum value.
c --------------------
s2 = product(b,dim=2) ! => s2 = [15,48]; products of column elements.
c --------------------
idot = dotproduct(b(1,:),b(2,:)) ! => idot = 44; dot product of row
! vectors of b.
c --------------------
c --------------------
integer c(2,2),ct(3,2)
! assuming array b of the previous section.
![Ans] = matmul([Array_1],[Array_2]) ! computes matrix multiplication
! of two rank two matrices.
c = matmul(b(:,1:2),b(:,2:3)) ! => c(1,:)=[15,23];c(2,:)=[22,34].
![Ans] = transpose([Array]) ! transforms an array to its transpose.
ct = transpose(b) ! => ct(1,:)=[1,2];ct(2,:)=[3,4];ct(3,:)=[5,6].
! a useful application of transpose is for printing arrays properly:
print66,c ! prints out the transpose of c since Fortran is column-wise.
print66,transpose(c) ! prints out matmul output c properly, row by row:
66 format(1x,2i6) ! format repeats last top level group for each row.
c --------------------
c --------------------
integer, array(2,3) :: a,b,c
! assume b is again initialized as
! b = 1 3 5
! 2 4 6
a = cshift(a,dim=2,shift=1) ! => a = 3 5 1
! 4 6 2
! i.e., b(i,j+shift) -> a(i,j) for j=1:2, etc.;
! i.e., the result is computed from shifting subscript in specified
! dimension of the source array by the specified shift.
a = cshift(b,dim=2,shift=-1) ! => a = 5 1 3
! 6 2 4
! i.e., b(i,j+shift) -> a(i,j) for j=2:3, etc.
a = cshift(b,2,[1,2]) ! a = 3 5 1
! 6 2 4
! i.e., an array-valued shift, or shift per row.
c --------------------
logical inmask(64,64)
real u(64,64),du(64,64),us(8,8),diffav
! Jacobi Iteration for a 5-star discretization of
! 2D Laplace's equation:
u = 0
u(1,:)=2
u(64,:)=2
u(:,1)=2
u(:,64)=1
inmask = .FALSE.
inmask(2:63,2:63) = .TRUE.
diffav = 1
iter=0
do while (diffav.gt.5.e-3.and.iter.lt.100)
iter=iter+1
du = 0
where(inmask)
du = 0.25*(cshift(u,1,1)+cshift(u,1,-1)+cshift(u,2,1)
& +cshift(u,2,-1)) - u
u = u + du
end where
du = du*du
diffav = sqrt(sum(du)/(62*62))
end do
! which is the main program fragment of laplace.fcm.
us = u(1:64:9,1:64:9)
us=transpose(us)
print66,'u = laplace-shift(u)= ; iter=',iter,'; av-diff ='
& ,diffav,us
66 format(1x,a36,i3,a7,e10.3/(8f7.3))
c --------------------
a = eoshift(b,1,-1) ! a = 0 0 0 ! note default boundary value is 0.
! 1 3 5
a = eoshift(b,dim=2,shift=[-1,0],boundary=[7,8]) ! => a = 7 1 3
! 2 4 6
a = eoshift(b,2,2) ! => a = 5 0 0
! => 6 0 0
c --------------------
respectively.
In contrast, General communications are either performed by FORALL
statement, mentioned previously, such as
c --------------------
integer, parameter :: m=128,n=256
integer array(m,n) :: b,c
integer a(7),v(7),x(m),y(n)
a=[1,2,3,4,5,6,7] ! initialize vector a by a constructor.
v=[2,3,4,4,1,4,5] ! initialize vector v by a constructor.
a=a(v) ! new a=[a(2),a(3),a(4),a(4),a(1),a(4),a(5)]=[2,3,4,4,1,4,5]
! note the vector subscript duplications above.
! assume appropriate array initializations for b,c,x,y:
forall(i=1:m,j=1:n) c(i,j) = b(x(i,j),y(i,j)) ! vector-valued subscripts.
c --------------------
See the sample program `laplace.fcm' on the CM
Suns for an illustration of using the
`cshift' Circular Shift for solving Laplace's equation. Similarly,
the CM code `FE-util.fcm' gives an application of the `eoshift'
End-Off shift.
[Ans]=SPREAD([ARRAY],[DIM],[NCOPIES]) ! Replicate an array by adding a
! dimension before [DIM].
[Ans]=REPLICATE([ARRAY],[DIM],[NCOPIES]) ! Replicate an array by
! increasing the size of a dimension [DIM].
[Ans]=MERGE([T-Array],[F-Array],[MASK]) ! Merges arrays two arrays
! using an element of `[T-Array]' if that element of `[MASK]'
! is `.true.' and that of `[F-Array]' if it is `.false.'.
! All three arrays must have the same shape, `[T-Array]' and
! must have the same type, while `[MASK]' must be logical.
The arguments `[ARRAY]', `[DIM]' and `[MASK]' have the same meaning as before,
but `[NCOPIES]' is the number of copies to be replicated.
Suppose that array a=[2,3,4], then the following example
CM Fortran statements give the following array shapes:
c -------------------- |c --------------------
integer b(2,3),cst(3,4) | integer b(2,3),d(2,9)
b(1,:) = [1,3,5] | b(1,:) = [1,3,5]
b(2,:) = [2,4,6] | b(2,:) = [2,4,6]
cst=replicate(b,dim=1,ncopies=2) | d=replicate(b,DIM=2,NCOPIES=3)
! contents of cst: | ! contents of d:
! 1 3 5 | ! 1 3 5 1 3 5 1 3 5
! 2 4 6 | ! 2 4 6 2 4 6 2 4 6
! 1 3 5 | d(:,2:4) = replicate(b,2,1)
! 2 4 6 | ! contents of d(:,2:4) is b
c ---------------------------------------------------------------------------
! i.e., b=replicate(a,d,c) =>
! a(n_1,n_2,...,n_(d-1),n_d,...,n_r) -> b(n_1,n_2,...,n_(d-1),c*n_d,...,n_r)
! where r is the rank of source array a and n_i is the size of dimension i;
! noting that only the size of dimension d changes: n_d -> c*n_d.
c -------------------- |c --------------------
integer as(4),cs(4,4) | integer at(3),cs(4,4)
as=[2,3,4,5] | at=[2,3,4]
cs=spread(as,DIM=1,ncopies=3) | cs=spread(at,DIM=2,NCOPIES=4)
! contents of cs: | ! contents of cs:
! 2 3 4 5 | ! 2 2 2 2
! 2 3 4 5 | ! 3 3 3 3
! 2 3 4 5 | ! 4 4 4 4
c ---------------------------------------------------------------------------
! i.e., b=spread(a,d,c) =>
! a(n_1,n_2,...,n_(d-1),n_d,...,n_r) -> b(n_1,n_2,...,n_(d-1),c,n_d,...,n_r)
! where r is the rank of source array a and n_i is the size of dimension i;
! noting that a new dimension of size c is added before dimension d.
c ---------------------------------------------------------------------------
See also the application of the Spread function to the elemental matrix
multiplication for Forward Gaussian Elimination
in the Getting Started in CM Fortran document.
where ([MASK]) [Array] = [Array-Expression]
and the `where-elsewhere' block:
where ([MASK])
[Array-1] = [Array-Expression-1] ! compute if [MASK]_i=.true.
elsewhere
[Array-2] = [Array-Expression-2] ! compute if .not.[MASK]_i=.true.
end where
The `[MASK]', arrays and array-expressions must have the same shape, but
the computation is done element by element according to the mask or inverse
mask. The `[MASK]_i' is meant to denote an element of the mask.
The `where-elsewhere' block constructs can be nested.
c --------------------
integer, parameter :: m=256,n=512
real, array (m,n) :: a, b, c
real d(m,m)
:
comment: assume that a, b and c are initialized.
:
FORALL (i=1:m,j=1:m,i.gt.j) d(i,j) = 0.0 ! Clear lower triangular part
! of array d in parallel.
FORALL (i=1:m) a(i,:)=i ! Elements on ith column get value i.
c --------------------
WHERE (a.ne.0.0) c = b/a ! c(i,j)=b(i,j)/a(i,j), if a(i,j).ne.0.
! for each i,j; caution: a.ne.0. is not
! wise for reals; see next example.
! You can also use a logical array mask,
! i.e., with statement `where ([mask])', where [mask]=a.ne.0.0
WHERE (abs(b).gt.0.5e-5) ! block where-elsewhere construct.
c = a/b ! c(i,j)=a(i,j)/b(i,j), if abs(b(i,j)).gt..5e-5
ELSEWHERE
c = 1.0e30 ! c(i,j)=1.0e30 if .not.(abs(b(i,j)).gt..5e-5)
END WHERE
c --------------------
Remember that the IF statement only allows scalar logical expressions.
CSTAR (cs) Options for the CM-5 Data Parallel Extension of C
Option Function
-cm5 Execute on CM-5 hardware.
-cmdebug Compile for debugging; faster then -g option, but less precise.
-cmprofile Produce peformance analysis, viewable using Prism.
-dirs Form "cs -cm5 -dirs" produces a list of directories where the
compiler searches for binary, include and temporary files.
-force Force "cc" *.c files to be compiled with C* compiler.
-h Print summary of available command line switches without compiling,
i.e., "cs -h"; synonym for -help.
-keep Form "cs -cm5 -keep [tempfile] [file].cs", for instance causes
assembly ([file].s), object ([file].o) and DPEAC ([file].pe.dp)
files when "[tempfile]" = "s", "o" and "dp", repectively.
-node Copies of code are executed on each node; serial instructions on
node; parallel instructions on vector units of node; necessary
when using the CMMD message passing mode; only supported when
options -cm5 -vu are also used.
-O Enable code optimizations in all compilers.
-sparc Compile to run on sparc nodes, and without vector units; same as
-cm5 -sparc option.
-veccode Produce DPEAC assembly code with extension *.pe.dp for
execution on vector units.
-version Print C* compiler version number.
-vu Compile to run on vector units; synonym for -vecunit; same as -cm5
-vu option; typical default for -cm5 option without -sparc.
Options in common with standard cc compiler.
-c Compile only; produce object file; suppress linking phase.
-g Produce symbol table for debugging, for Prism on CM-5.
-I[dir] Seek #include file in this directory.
-l[X] Look for library lib[X].a.
-o[exec] Name excutable file [exec].
-pg Produce gprof profile code.
-S Produce rough assembly code [file].s for partition manager code
and [file].pe.s for node code; can not be used with -c or -o
options.
For more information on compiling C* code, see the CM-5 C* User's Guide,
Chapter 3 Compiling a C* Program.
The chapter also explains how to combine CMF and C* programs.
shape [16384]ShapeB;
int:ShapeB p1,p2,p3,p4,p5,p6;
int sum_p = 0;
main()
{
/* Some Initialization Code */
p1 = 1; /* assigns all elements of p1 to 1 */
p2 = 3; /* assigns all elements of p2 to 3 */
p3 = p2; /* assigns each element of p2 to element of p3 */
p4 = p1 + p2; /* adds elements of p1 and p2 to p3 */
sum_p += p3; /* sums all elements of p3 into scalar sum_p */
p5 += p2; /* adds element of p2 to corresponding element of p5 */
p6 = (p3 >= p1); /* assigns an element of p3 to p4 only
if it is bigger than that of p1; else 0 */
p5 = (p4 < 3) ? p2 : p1; /* element of p2 is assigned to p5
if corresponding element of p4 is less than 3,
else element of p1 is assigned to p5 */
}
shape [16384]ShapeW;
int:ShapeW worker wage;
main()
{with(ShapeW)
where(wage > 999) {
/* Some Parallel Code if condition true */
}
else {
/* Some other Parallel Code if condition false */
}
}
include '/usr/include/cm/timer-fort.h'
If CMF utilities will also be used, then the user must also
include '/usr/include/cm/CMF_defs.h'
In particular, the latter `include' statement is needed for special
CM utilities, so it is essential to have both near the
beginning of each program unit that references both the CM-Timers and
CMF-Utilities. In fact, it is good practice to put them in all or most
program unit, just in case.
program timing ! sample timing template
! `!' can be used for inline comments, except in column 6.
include '/usr/include/cm/timer-fort.h'
:
call cm_timer_clear(0) ! clear outer timer 0 (optional)
call cm_timer_start(0) ! start outer timer 0
: ! do some computations
call cm_timer_start(1) ! start inner timer 1
: ! do some more computations
call cm_timer_stop(1) ! stop inner timer 1
print*, 'first inner time:'
call cm_timer_print(1) ! print inner timer 1 results
: ! do some more computations
call cm_timer_clear(1) ! clear inner timer 1
call cm_timer_start(1) ! restart inner timer 1
: ! do some more computations
call cm_timer_stop(1) ! re-stop inner timer 1
print*, 'second inner time:'
call cm_timer_print(1) ! print inner timer 1 results
: ! do some more computations
call cm_timer_stop(0) ! stop outer timer 0
print*, 'total outer time:'
call cm_timer_print(0) ! print outer timer 0 results
: ! do some more computations
stop
end
The best way to learn these commands is to use them in an actual computer session. Please report to Professor Hanson (e-address: u12688 at uicvm.cc.uic.edu or Hanson@uic.edu or hanson@math.uic.edu) any problems or inaccuracies. Good luck.