Download Global Programming Interface (GPI) - GPI-2
Transcript
4.1
Starting/stopping the GPI
Before any GPI operation can be executed a call to startGPI has to be performed. This function
constructs the interconnections between all participating nodes and allocates the memory used by the
GPI application (GPI memory). While a GPI application can make use of heap and stack memory like
any other application, only the GPI memory can be the source or destination of a DMA operation.
Except for this difference GPI memory is identical to a large continuous block of heap memory.
// ! S t a r t GPI
/∗ !
\param a r g c Argument count
\param a r g v Command l i n e arguments
\param c m d l i n e The command l i n e t o be used t o s t a r t t h e b i n a r i e s
\param gpiMemSize The memory s p a c e a l l o c a t e d f o r GPI
\ r e t u r n an i n t where −1 i s o p e r a t i o n f a i l e d , −42 i s t i m e o u t and 0 i s s u c c e s s .
\ warning The command l i n e arguments ( a r g c , a r g v ) won ' t be f o r w a r d t o t h e worker nodes
∗/
i n t startGPI ( i n t argc , c h a r ∗ argv [ ] , c o n s t c h a r ∗ cmdline , c o n s t u n s i g n e d l o n g gpiMemSize )
After a successful GPI start, the application may query the current values on the node where it is
running.
The function getDmaMemPtrGPI returns the address of the GPI memory block on the calling
node. This address is guaranteed to be page-size aligned.
v o i d ∗ g et Dm aM e mP tr GP I ( v o i d )
The binary executed is usually the same for all nodes. To distinguish between nodes in the source
code a rank number is associated with every node. The rank of the master node is always zero, while
the worker nodes are assigned integral numbers from one to the number of participating nodes minus
one. After the GPI has been successfully started the rank of a node can be queried with getRankGPI
whereas the number of nodes is given by getNodeCountGPI.
i n t getRankGPI ( v o i d )
i n t g et No de C ount GP I ( v o i d )
At the end of an GPI application all resources associated with the GPI need to be released with
a call to shutdownGPI.
v o i d shutdownGPI ( )
The following commented code example shows a simple start and stop of GPI:
#i n c l u d e <GPI . h>
#i n c l u d e <GpiLogger . h>
#d e f i n e GB 1073741824
i n t main ( i n t argc , c h a r ∗ argv [ ] )
{
// s t a r t GPI with 1 GB memory
i f ( startGPI ( argc , argv , ” ” , GB ) != 0 )
{
gpi_printf ( ”GPI s t a r t −up f a i l e d \n” ) ;
killProcsGPI ( ) ;
shutdownGPI ( ) ;
6