Cypress CSC-1200T Uživatelská příručka Strana 76

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 124
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 75
76 Cray T3E User’s Guide
7.4.5 Other important routines
There are two very important routines which a parallel program on T3E
will almost certainly call, namely shmem_my_pe and shmem_n_pes.The
former reveals the calling PE its identity, while the latter returns the
total number of PEs in use. Their syntaxes are as follows:
int shmem_my_pe(void);
int shmem_n_pes(void);
For Fortran 90 the syntax is
INTEGER :: mype, npes
INTEGER, EXTERNAL :: SHMEM_MY_PE, SHMEM_N_PES
mype = SHMEM_MY_PE()
npes = SHMEM_N_PES()
In some cases it may be necessary to stop the execution of a program
and wait until all other PEs have performed some critical tasks. For
these situations, there is a routine called shmem_barrier. However, on
the T3E there is a simpler (and faster!) routine for this purpose called
simply barrier:
void barrier()
In Fortran 90 the call is
CALL BARRIER()
The most important difference between shmem_barrier and barrier
is that with shmem_barrier it is possible to interrupt temporarily the
action of just some of the PEs in use. Because of its speed, we suggest
that the barrier routine be preferred whenever all PEs are halted. See
man shmem_barrier for more information.
7.4.6 Example of using SHMEM
The following simple code illustrates the use of some of the routines
discussed above. Each PE has two four-component vectors of integers,
called source and target, and PE number 0 copies its source vector
into the location of target vector of PE number 1. Finally, target vector
is used to compute the values of vector c.
Note that in the Fortran 90 version the attribute SAVE is assigned to
both source and target vectors in order to make them symmetric data
objects. The call to barrier routine is necessary, because without it,
PE number 1 might use the original target vector while computing the
value of c, not the one passed by PE number 0.
Here is the example program in Fortran 90:
PROGRAM shmemex
IMPLICIT NONE
Zobrazit stránku 75
1 2 ... 71 72 73 74 75 76 77 78 79 80 81 ... 123 124

Komentáře k této Příručce

Žádné komentáře