com.multicorebsp.core
Class BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>

java.lang.Object
  extended by com.multicorebsp.core.BSP_GLOBAL_COMM<T,BSP_REGISTER<T>>
      extended by com.multicorebsp.core.BSP_REGISTER<T>
Type Parameters:
T - Class of the elements to be stored in the array.

public class BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>
extends BSP_GLOBAL_COMM<T,BSP_REGISTER<T>>

This class represents a global variable definition.

Apart from the general read / write methods, bulk-synchronous message passing (BSMP) and direct remote memory access (DRMA) methods are available.

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

Since:
0.1 , 17th of April 2008
See Also:
BSP_ARRAY, BSP_PROGRAM

Field Summary
protected  com.multicorebsp.core.BSP_GLOBAL_VAR<T> global
          Reference to global instance.
protected  int pid
          Processor ID corresponding to this instance.
 
Constructor Summary
  BSP_REGISTER(BSP_PROGRAM thread, T init)
          Base constructor.
protected BSP_REGISTER(int P, java.util.ArrayList<java.util.ArrayList<com.multicorebsp.core.BSP_COMMUNICATION_REQUEST<?>>> buffer, T init)
          Constructor wrapper.
 
Method Summary
 void bsp_direct_get(BSP_REGISTER<T> source, int pid)
          Direct get instruction.
 void bsp_direct_get(int pid)
          Get instruction.
 void bsp_get(BSP_REGISTER<T> source, int from)
          Get instruction.
 void bsp_get(int from)
          Get instruction.
 void bsp_move()
          Move a BSMP message from this global variable's queue.
 void bsp_put(BSP_REGISTER<T> source, int destination_processor)
          Put instruction.
 void bsp_put(int destination_processor)
          Put instruction.
 void bsp_put(T source, int destination_processor)
          Put instruction.
 int bsp_qsize()
          Returns the number of messages waiting in the local message queue.
 void bsp_send(BSP_REGISTER<T> source, int to)
          BSMP Send instruction.
 void bsp_send(int to)
          BSMP Send instruction.
 void bsp_send(T source, int to)
          BSMP Send instruction.
 T read()
          Gets the current variable's value.
 void unregister()
          Removes all shared references.
 void write(T x)
          Sets the current variable to a given value.
 
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_VAR<T extends CompulsaryCloneable<? extends T>> global
Reference to global instance.


pid

protected int pid
Processor ID corresponding to this instance.

Constructor Detail

BSP_REGISTER

protected BSP_REGISTER(int P,
                       java.util.ArrayList<java.util.ArrayList<com.multicorebsp.core.BSP_COMMUNICATION_REQUEST<?>>> buffer,
                       T init)
Constructor wrapper. Only to-be used internally.

Parameters:
P - Total number of processors.
buffer - Reference to the global request buffer.
init - Initial value of this global variable.

BSP_REGISTER

public BSP_REGISTER(BSP_PROGRAM thread,
                    T init)
Base constructor.

Parameters:
thread - Thread from which this global variable will be accessed.
init - Initial value of this global variable (at each processor).
Method Detail

read

public T read()
Gets the current variable's value.

Returns:
The current value of this variable.

write

public void write(T x)
Sets the current variable to a given value.

Parameters:
x - The value current variable will be set to.

bsp_qsize

public int bsp_qsize()
Returns the number of messages waiting in the local message queue.

Specified by:
bsp_qsize in class BSP_GLOBAL_COMM<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Returns:
the number of messages waiting in queue.

bsp_move

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

Specified by:
bsp_move in class BSP_GLOBAL_COMM<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>

bsp_send

public void bsp_send(int to)
BSMP Send instruction. Sends the current variable to target global message queue.

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

Specified by:
bsp_send in class BSP_GLOBAL_COMM<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
to - Destination processor.

bsp_send

public void bsp_send(T source,
                     int to)
BSMP Send instruction. Sends the given object to target global message queue.

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

Specified by:
bsp_send in class BSP_GLOBAL_COMM<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
source - Object to send.
to - Destination processor.

bsp_send

public void bsp_send(BSP_REGISTER<T> source,
                     int to)
BSMP Send instruction. Sends the given object to target global message queue.

Note that the sent element will be available at the destination only after synchronisation. This will send the current object in the source variable; it will not read out this variable during synchronisation.

Specified by:
bsp_send in class BSP_GLOBAL_COMM<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
source - Variable containing the object to send.
to - Destination processor.

bsp_put

public void bsp_put(int destination_processor)
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<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
destination_processor - The destination processor.

bsp_put

public void bsp_put(BSP_REGISTER<T> 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<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
source - Source global variable.
destination_processor - Destination processor.

bsp_put

public void bsp_put(T 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<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
source - Source variable.
destination_processor - Destination processor.

bsp_get

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

Specified by:
bsp_get in class BSP_GLOBAL_COMM<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
from - From which processor to get its variable.

bsp_get

public void bsp_get(BSP_REGISTER<T> source,
                    int from)
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<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
source - From which global variable to get its contents.
from - 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<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>

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<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
pid - From which processor to get its variable.

bsp_direct_get

public void bsp_direct_get(BSP_REGISTER<T> 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<T extends CompulsaryCloneable<? extends T>,BSP_REGISTER<T extends CompulsaryCloneable<? extends T>>>
Parameters:
source - From which global variable to get its contents.
pid - From which processor to get its variable.