bsp.c File Reference

Implements the BSPlib primitives. More...

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include "bsp.h"
#include "bsp_memreg.h"
#include "bsp_mesgqueue.h"
#include "bsp_delivtable.h"
#include "bsp_reqtable.h"
#include "bsp_private.h"
#include "bsp_alloc.h"
#include "bsp_abort.h"
#include <config.h>

Include dependency graph for bsp.c:

Go to the source code of this file.

Initialisation

void bsp_init (void(*spmd_part)(void), int argc, char *argv[])
 Initializes BSPonMPI.
void bsp_begin (int maxprocs)
 Marks the start of the SPMD code.
void bsp_end ()
 Ends the SPMD code.

Halt

void bsp_abort (const char *format,...)
 Aborts the program printing a message to the standard error output.

Enquiry

int bsp_nprocs ()
 Returns the number of processors available / allocated.
int bsp_pid ()
 Returns the rank of the processor.
double bsp_time ()
 The time in seconds since bsp_begin().

Superstep

void bsp_sync ()
 Seperates two supersteps.

DRMA

void bsp_push_reg (const void *ident, int size)
 Makes the memory location with specified size available for DRMA operations at the next and additional supersteps.
void bsp_pop_reg (const void *ident)
 Deregisters the memory location.
void bsp_put (int pid, const void *src, void *dst, int offset, int nbytes)
 Puts a block of data in the memory of some other processor at the next superstep.
void bsp_get (int pid, const void *src, int offset, void *dst, int nbytes)
 Gets a block of data from the memory of some other processor at the next superstep.

BSMP

void bsp_send (int pid, const void *tag, const void *payload, int payload_nbytes)
 Sends message to a processor.
void bsp_qsize (int *restrict nmessages, int *restrict accum_nbytes)
 Gives the number of messages and the sum of the payload sizes in queue.
void bsp_get_tag (int *restrict status, void *restrict tag)
 Retrieves the tag and payload size of the current message in queue.
void bsp_move (void *payload, int reception_nbytes)
 Dequeue the current message.
void bsp_set_tagsize (int *tag_nbytes)
 Sets the tag size at the next superstep.

High Performace

void bsp_hpput (int pid, const void *src, void *dst, int offset, int nbytes)
 Puts a block of data in the memory of some other processor at then next superstep.
void bsp_hpget (int pid, const void *src, int offset, void *dst, int nbytes)
 Gets a block of data from the memory of some other processor at the next superstep.
int bsp_hpmove (void **tag_ptr, void **payload_ptr)
 Dequeue the current message in an unbuffered way.

Defines

#define DELIVTAB_SIZE   1
#define REQTAB_SIZE   1
#define MEMREG_SIZE   1


Detailed Description

Implements the BSPlib primitives.

Author:
Wijnand Suijlen

Definition in file bsp.c.


Define Documentation

#define DELIVTAB_SIZE   1
 

Definition at line 353 of file bsp.c.

Referenced by bsp_begin().

#define MEMREG_SIZE   1
 

Definition at line 355 of file bsp.c.

Referenced by bsp_begin().

#define REQTAB_SIZE   1
 

Definition at line 354 of file bsp.c.

Referenced by bsp_begin().


Function Documentation

void bsp_abort const char *  format,
  ...
 

Aborts the program printing a message to the standard error output.

Parameters:
format uses the same format as printf()

Definition at line 511 of file bsp.c.

References bsp_intern_abort(), and ERR_BSP_ABORT.

Here is the call graph for this function:

void bsp_begin int  maxprocs  ) 
 

Marks the start of the SPMD code.

The code following the call to this function will be executed in parallel with at most maxprocs processors. The SPMD code must end with a call to bsp_end()

Parameters:
maxprocs Denotes the requested number of processors. The actual allocated number of processors may be less. Calling allocates the maximum number of processors.
See also:
bsp_nprocs()

bsp_end()

Definition at line 427 of file bsp.c.

References _BSPObject::begintime, bsp, bsp_free(), bsp_malloc, _BSPObject::communicator, _BSPObject::delivery_received_table, _BSPObject::delivery_table, deliveryTable_initialize(), DELIVTAB_SIZE, _BSPObject::memory_register, memoryRegister_initialize(), MEMREG_SIZE, _BSPObject::message_queue, messageQueue_initialize(), MIN, _BSPObject::nprocs, _BSPObject::rank, REQTAB_SIZE, _BSPObject::request_received_table, _BSPObject::request_table, and requestTable_initialize().

Here is the call graph for this function:

void bsp_end  ) 
 

Ends the SPMD code.

This function must be called after all SPMD code has been executed. The code after this call is executed by processor 0 only.

Definition at line 489 of file bsp.c.

References bsp, _BSPObject::delivery_received_table, _BSPObject::delivery_table, deliveryTable_destruct(), _BSPObject::memory_register, memoryRegister_destruct(), _BSPObject::request_received_table, _BSPObject::request_table, and requestTable_destruct().

Here is the call graph for this function:

void bsp_get int  pid,
const void *  src,
int  offset,
void *  dst,
int  nbytes
 

Gets a block of data from the memory of some other processor at the next superstep.

This function is buffered, i.e.: The data is retrieved from the destionation processor at the start of the next bsp_sync(). Translation of the src pointer is performed with help of earlier calls to bsp_push_reg()

Parameters:
pid Ranks of the source (remote) processor
src Pointer to source location using a pointer to a local memory region
offset offset from src in bytes
dst Pointer to destination location
nbytes Number of bytes to be received
See also:
bsp_push_reg()

Definition at line 716 of file bsp.c.

References bsp, ReqElement::dst, _BSPObject::memory_register, memoryRegister_memoized_find(), ReqElement::offset, _BSPObject::request_table, requestTable_push(), ReqElement::size, and ReqElement::src.

Referenced by bsp_hpget().

Here is the call graph for this function:

void bsp_get_tag int *restrict  status,
void *restrict  tag
 

Retrieves the tag and payload size of the current message in queue.

Parameters:
status the size of the payload of the current message, or when the queue is empty -1
tag a pointer to a memory location big enough to contain a tag.

Definition at line 774 of file bsp.c.

References ALIGNED_TYPE, bsp, MessageQueue::head, _BSPObject::message_queue, MessageQueue::n_mesg, no_slots(), MessageQueue::recv_tag_size, and restrict.

Here is the call graph for this function:

void bsp_hpget int  pid,
const void *  src,
int  offset,
void *  dst,
int  nbytes
 

Gets a block of data from the memory of some other processor at the next superstep.

This should be the high performance unbuffered version of bsp_get(). However currently it is the same as bsp_get()

Parameters:
pid Ranks of the source (remote) processor
src Pointer to source location using a pointer to a local memory region
offset offset from src in bytes
dst Pointer to destination location
nbytes Number of bytes to be received
See also:
bsp_push_reg()

Definition at line 862 of file bsp.c.

References bsp_get().

Here is the call graph for this function:

int bsp_hpmove void **  tag_ptr,
void **  payload_ptr
 

Dequeue the current message in an unbuffered way.

Parameters:
tag_ptr a pointer to reference of memory location which will contain the tag
payload_ptr a pointer to a reference of a memory location which will contain the pyload
Returns:
the payload size of the dequeued message

Definition at line 875 of file bsp.c.

References MessageQueue::accum_size, ALIGNED_TYPE, bsp, MessageQueue::head, _BSPObject::message_queue, MessageQueue::n_mesg, no_slots(), MessageQueue::recv_tag_size, and restrict.

Here is the call graph for this function:

void bsp_hpput int  pid,
const void *  src,
void *  dst,
int  offset,
int  nbytes
 

Puts a block of data in the memory of some other processor at then next superstep.

This should be de high perfomance unbuffered version of bsp_put, but currently these two functions are the same

Parameters:
pid rank of destination (remote) processor
src pointer to source location on source ( local ) processor
dst pointer to destination location on source processor. Translation of addresses is performed with help of earlier calls to bsp_push_reg()
offset offset from dst in bytes (comes in handy when working with arrays)
nbytes number of bytes to be copied
See also:
bsp_put()

Definition at line 845 of file bsp.c.

References bsp_put().

Here is the call graph for this function:

void bsp_init void(*)(void)  spmd_part,
int  argc,
char *  argv[]
 

Initializes BSPonMPI.

Bug:
Because several MPI implementations require that command line arguments are supplied, a call to this function at the start of the program is mandatory
Example
    void do_something()
    {
      bsp_begin(bsp_nprocs())
      ... a parallel program ...
      bsp_end()
    }  
      
    int main(int argc, char *argv[])
    {
      bsp_init( &do_something, argc, argv);
      ... optional sequential code ...
      do_something();
      ... optional sequential code ...
    }  
Parameters:
spmd_part reference to the SPMD function
argc obtained from function main()
argv obtained from function main()
See also:
bsp_begin()

bsp_end()

bsp_nprocs()

Definition at line 397 of file bsp.c.

References bsp, _BSPObject::nprocs, and _BSPObject::rank.

void bsp_move void *  payload,
int  reception_nbytes
 

Dequeue the current message.

Parameters:
payload A pointer to a memory location big enough to contain the payload or reception_nbytes
reception_nbytes The maximum number of bytes to copy

Definition at line 795 of file bsp.c.

References MessageQueue::accum_size, ALIGNED_TYPE, bsp, MessageQueue::head, _BSPObject::message_queue, MIN, MessageQueue::n_mesg, no_slots(), MessageQueue::recv_tag_size, and restrict.

Here is the call graph for this function:

int bsp_nprocs  ) 
 

Returns the number of processors available / allocated.

Returns:

Definition at line 533 of file bsp.c.

References bsp, and _BSPObject::nprocs.

int bsp_pid  ) 
 

Returns the rank of the processor.

Returns:
The rank of the processor

Definition at line 544 of file bsp.c.

References bsp, and _BSPObject::rank.

void bsp_pop_reg const void *  ident  ) 
 

Deregisters the memory location.

Parameters:
ident pointer to memory location
See also:
bsp_push_reg()

Definition at line 669 of file bsp.c.

References PopRegObject::address, bsp, _BSPObject::delivery_table, deliveryTable_push(), DelivElement::info, _DInfo::pop, popreg, _BSPObject::rank, and DelivElement::size.

Here is the call graph for this function:

void bsp_push_reg const void *  ident,
int  size
 

Makes the memory location with specified size available for DRMA operations at the next and additional supersteps.

Parameters:
ident pointer to memory location
size of memory block
Note:
In this version of BSPonMPI the parameter size is ignored
See also:
bsp_pop_reg()

Definition at line 654 of file bsp.c.

References PushRegObject::address, bsp, _BSPObject::delivery_table, deliveryTable_push(), DelivElement::info, _BSPObject::nprocs, _DInfo::push, pushreg, and DelivElement::size.

Here is the call graph for this function:

void bsp_put int  pid,
const void *  src,
void *  dst,
int  offset,
int  nbytes
 

Puts a block of data in the memory of some other processor at the next superstep.

This function is buffered, i.e.: the contents of src is copied to a buffer and transmitted at the next bsp_sync()

Parameters:
pid rank of destination (remote) processor
src pointer to source location on source (local) processor
dst pointer to destination location on source processor. Translation of addresses is performed with help of earlier calls to bsp_push_reg()
offset offset from dst in bytes (comes in handy when working with arrays)
nbytes number of bytes to be copied
See also:
bsp_push_reg()

Definition at line 689 of file bsp.c.

References bsp, _BSPObject::delivery_table, deliveryTable_push(), PutObject::dst, DelivElement::info, _BSPObject::memory_register, memoryRegister_memoized_find(), _DInfo::put, put, restrict, and DelivElement::size.

Referenced by bsp_hpput().

Here is the call graph for this function:

void bsp_qsize int *restrict  nmessages,
int *restrict  accum_nbytes
 

Gives the number of messages and the sum of the payload sizes in queue.

Parameters:
nmessages pointer to an int. The value of this integer will be set to the number of messages in queue
accum_nbytes pointer to an int. The value of this integer will be set to the sum of payload sizes in all messages.

Definition at line 760 of file bsp.c.

References MessageQueue::accum_size, bsp, _BSPObject::message_queue, and MessageQueue::n_mesg.

void bsp_send int  pid,
const void *  tag,
const void *  payload,
int  payload_nbytes
 

Sends message to a processor.

You may supply a tag and and a payload. The default size of the tag is 0. To change the tag size you can use bsp_set_tagsize().

Parameters:
pid Rank of the destination processor
tag pointer to the tag
payload pointer to the payload
payload_nbytes size of the payload

Definition at line 742 of file bsp.c.

References bsp, _BSPObject::delivery_table, deliveryTable_push(), DelivElement::info, _BSPObject::message_queue, SendObject::payload_size, restrict, _DInfo::send, send, MessageQueue::send_tag_size, and DelivElement::size.

Here is the call graph for this function:

void bsp_set_tagsize int *  tag_nbytes  ) 
 

Sets the tag size at the next superstep.

Parameters:
tag_nbytes pointer to an int which should contain the size of the tag in bytes. It becomes current tag size.

Definition at line 816 of file bsp.c.

References bsp, _BSPObject::delivery_table, deliveryTable_push(), DelivElement::info, _BSPObject::message_queue, _BSPObject::rank, MessageQueue::send_tag_size, _DInfo::settag, settag, DelivElement::size, and SetTagObject::tag_size.

Here is the call graph for this function:

void bsp_sync  ) 
 

Seperates two supersteps.

Definition at line 564 of file bsp.c.

References bsp, _BSPObject::delivery_received_table, _BSPObject::delivery_table, deliveryTable_reset(), _BSPObject::message_queue, messageQueue_sync(), _BSPObject::nprocs, _BSPObject::request_received_table, _BSPObject::request_table, requestTable_reset(), and _ExpandableTable::used_slot_count.

Here is the call graph for this function:

double bsp_time  ) 
 

The time in seconds since bsp_begin().

Returns:
The time in seconds since bsp_begin()

Definition at line 553 of file bsp.c.

References _BSPObject::begintime, and bsp.


Generated on Sat Apr 8 20:12:47 2006 for BSPonMPI by  doxygen 1.4.6