com.multicorebsp.core
Class BSP_INTEGER

java.lang.Object
  extended by com.multicorebsp.core.BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
      extended by com.multicorebsp.core.BSP_INTEGER

public class BSP_INTEGER
extends BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>

This class represents a shared integer type.

Apart from the general read / write methods, bulk-synchronous message passing (BSMP) and direct remote memory access (DRMA) methods are available. Note this class would be functionally equivalent to BSP_REGISTER<Integer>, except that Integer does not extend CompulsaryCloneable, and cannot be extended to implement it (Integer is a final class).

This class is to be used within the parallel part of an instance of a BSP_PROGRAM.

Since:
2nd of December 2010
See Also:
BSP_REGISTER, BSP_DOUBLE_ARRAY, BSP_PROGRAM

Field Summary
protected  com.multicorebsp.core.BSP_GLOBAL<com.multicorebsp.core.BSP_INTEGER.Wrapper> global
          Reference to global instance.
protected  int pid
          Processor ID corresponding to this array instance.
 
Constructor Summary
BSP_INTEGER(BSP_PROGRAM thread, int init)
          Base constructor.
 
Method Summary
 void bsp_direct_get(BSP_INTEGER source, int pid)
          Direct get instruction.
 void bsp_direct_get(int pid)
          Get instruction.
 void bsp_get(BSP_INTEGER source, int source_processor)
          Get instruction.
 void bsp_get(int pid)
          Get instruction.
 void bsp_move()
          Move a BSMP message from this global variable's queue.
 void bsp_put(BSP_INTEGER source, int destination_processor)
          Put instruction.
 void bsp_put(int pid)
          Put instruction.
 void bsp_put(java.lang.Integer data, int destination_processor)
          Put instruction.
 void bsp_put(int data, int destination_processor)
          DRMA Put instruction.
 int bsp_qsize()
          BSMP instruction.
 void bsp_send(com.multicorebsp.core.BSP_INTEGER.Wrapper source, int to)
          BSMP send instruction.
 void bsp_send(BSP_INTEGER source, int to)
          BSMP send instruction.
 void bsp_send(int to)
          BSMP send instruction.
 void bsp_send(java.lang.Integer source, int to)
          BSMP send instruction.
 void bsp_send(int source, int to)
          BSMP send instruction.
 int read()
          Method to get the raw array.
 void unregister()
          Removes all shared references.
 BSP_INTEGER write(int x)
          Method to set a new raw array source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

global

protected com.multicorebsp.core.BSP_GLOBAL<com.multicorebsp.core.BSP_INTEGER.Wrapper> global
Reference to global instance.


pid

protected int pid
Processor ID corresponding to this array instance.

Constructor Detail

BSP_INTEGER

public BSP_INTEGER(BSP_PROGRAM thread,
                   int init)
Base constructor.

Parameters:
thread - Instance of BSP_PROGRAM corresponding to this global array.
init - Initial array.
Method Detail

read

public int read()
Method to get the raw array.

Returns:
The raw array local to the calling thread.

write

public BSP_INTEGER write(int x)
Method to set a new raw array source.

Parameters:
x - The new array.
Returns:
A handle to this array (method chaining).

bsp_move

public void bsp_move()
              throws EmptyQueueException
Move a BSMP message from this global variable's queue.

Specified by:
bsp_move in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Throws:
EmptyQueueException

bsp_qsize

public int bsp_qsize()
Description copied from class: BSP_GLOBAL_COMM
BSMP instruction. Reports the number of messages waiting in the local queue.

Specified by:
bsp_qsize in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Returns:
The number of messages in queue.

bsp_send

public void bsp_send(int to)
BSMP send instruction. Sends this array to this global array's queue at the target processor.

Note that the enqueued element will be available at the destination only after synchronisation.

Specified by:
bsp_send in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
to - At which processor to perform the enqueue operation.

bsp_send

public void bsp_send(int source,
                     int to)
BSMP send instruction. Sends a given array to this global array's queue, at the given processor.

Note that the enqueued element will be available at the destination only after synchronisation.

Parameters:
source - The array to be enqueued.
to - At which processor to perform the enqueue operation.

bsp_send

public void bsp_send(java.lang.Integer source,
                     int to)
BSMP send instruction. Sends a given array to this global array's queue, at the given processor.

Note that the enqueued element will be available at the destination only after synchronisation.

Specified by:
bsp_send in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
source - The array to be enqueued.
to - At which processor to perform the enqueue operation.

bsp_send

public void bsp_send(com.multicorebsp.core.BSP_INTEGER.Wrapper source,
                     int to)
BSMP send instruction. Sends a given array to this global array's queue, at the given processor.

Note that the enqueued element will be available at the destination only after synchronisation.

Parameters:
source - The array to be enqueued.
to - At which processor to perform the enqueue operation.

bsp_send

public void bsp_send(BSP_INTEGER source,
                     int to)
BSMP send instruction. Sends a given array to this global array's queue, at the given processor.

Note that the enqueued element will be available at the destination only after synchronisation.

Specified by:
bsp_send in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
source - The array to be enqueued.
to - At which processor to perform the enqueue operation.

bsp_put

public void bsp_put(int pid)
Description copied from class: BSP_GLOBAL_COMM
Put instruction. Copies the current variable (local to the current processor) to the current variable local to destination processor pid. This instruction buffers the to-be copied current elements here; this variable thus is free to change after calling this method.

Note that the copied element will be available at the destination only after synchronisation.

Specified by:
bsp_put in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
pid - The destination processor.

bsp_put

public void bsp_put(BSP_INTEGER source,
                    int destination_processor)
Description copied from class: BSP_GLOBAL_COMM
Put instruction. Copies the source variable (local to the current processor) to the this variable local to destination processor pid. This instruction buffers the to-be copied current elements here; this variable thus is free to change after calling this method.

Note that the copied element will be available at the destination only after synchronisation.

Specified by:
bsp_put in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
source - Source global variable.
destination_processor - Destination processor.

bsp_put

public void bsp_put(java.lang.Integer data,
                    int destination_processor)
Description copied from class: BSP_GLOBAL_COMM
Put instruction. Copies the source variable (local to the current processor) to the this variable local to destination processor pid. This instruction buffers the to-be copied current elements here; this variable thus is free to change after calling this method.

Note that the copied element will be available at the destination only after synchronisation.

Specified by:
bsp_put in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
data - Source variable.
destination_processor - Destination processor.

bsp_put

public void bsp_put(int data,
                    int destination_processor)
DRMA Put instruction. Copies
source (local to current processor)
to
this (local to destination processor 'pid')
This instruction buffers the to-be copied current elements here; the value variable thus is free to change after calling this put operation.

Note that the copied element will be available at the destination only after synchronisation.

Parameters:
data - The array to put.
destination_processor - At which processor to put the current variable.

bsp_get

public void bsp_get(int pid)
Description copied from class: BSP_GLOBAL_COMM
Get instruction. Short for bsp_get( this, from );

Specified by:
bsp_get in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
pid - From which processor to get its variable.

bsp_get

public void bsp_get(BSP_INTEGER source,
                    int source_processor)
Description copied from class: BSP_GLOBAL_COMM
Get instruction. Gets target source variable local to source processor pid, and puts those contents in this variable (local to current processor).

This instruction does not buffer the element to be got as those are generally unavailable from this processor's perspective. Hence, the element at the source variable's processor at synchronisation time is the element which will be copied to the current variable.

Note that gets and puts are not necessarily freely interchangeable. Note that the retrieved element will be available at the destination only after synchronisation.

Specified by:
bsp_get in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
source - From which global variable to get its contents.
source_processor - From which processor to get its variable.

bsp_direct_get

public void bsp_direct_get(int pid)
Description copied from class: BSP_GLOBAL_COMM
Get instruction. Short for bsp_direct_get( this, from );

Specified by:
bsp_direct_get in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
pid - From which processor to get its variable.

bsp_direct_get

public void bsp_direct_get(BSP_INTEGER source,
                           int pid)
Description copied from class: BSP_GLOBAL_COMM
Direct get instruction. Gets target source variable local to source processor pid, and puts those contents in this variable (local to current processor).
Does this immediately; communication does not wait for a sync, and this method blocks.

Specified by:
bsp_direct_get in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>
Parameters:
source - From which global variable to get its contents.
pid - From which processor to get its variable.

unregister

public void unregister()
Description copied from class: BSP_GLOBAL_COMM
Removes all shared references. Cannot be used afterwards.

Specified by:
unregister in class BSP_GLOBAL_COMM<java.lang.Integer,BSP_INTEGER>