com.multicorebsp.core
Class BSP_DOUBLE_MATRIX

java.lang.Object
  extended by com.multicorebsp.core.BSP_DOUBLE_MATRIX

public class BSP_DOUBLE_MATRIX
extends java.lang.Object

This class represents a global double[][] type.

Bulk-synchronous message passing (BSMP) and direct remote memory access (DRMA) methods are available. Data access is achieved by retrieving a reference to the local raw double[][] matrix with the getData() method.

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

Since:
26th of November 2008
See Also:
BSP_PROGRAM, BSP_REGISTER, BSP_ARRAY

Field Summary
protected  com.multicorebsp.core.BSP_GLOBAL<com.multicorebsp.core.BSP_DOUBLE_MATRIX.Wrapper> global
          Reference to global instance.
protected  int pid
          Processor ID corresponding to this array instance.
 
Constructor Summary
BSP_DOUBLE_MATRIX(BSP_PROGRAM thread, double[][] init)
          Base constructor.
 
Method Summary
 void bsp_get(int source_processor, BSP_DOUBLE_MATRIX source, int isource_offset, int jsource_offset, int idestination_offset, int jdestination_offset, int ilength, int jlength)
          DRMA Get instruction.
 void bsp_move()
          Move a BSMP message from this global variable's queue.
 void bsp_put(double[][] data, int destination_processor, int idestination_offset, int jdestination_offset)
          DRMA Put instruction.
 void bsp_put(int isource_offset, int jsource_offset, int destination_processor, BSP_DOUBLE_MATRIX destination, int idestination_offset, int jdestination_offset, int ilength, int jlength)
          DRMA Put instruction.
 int bsp_qsize()
           
 void bsp_send(com.multicorebsp.core.BSP_DOUBLE_MATRIX.Wrapper source, int to)
          BSMP send instruction.
 void bsp_send(BSP_DOUBLE_MATRIX source, int to)
          BSMP send instruction.
 void bsp_send(double[][] source, int to)
          BSMP send instruction.
 double[][] getData()
          Method to get the raw matrix.
 BSP_DOUBLE_MATRIX setData(double[][] x)
          Method to set a new raw matrix 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_DOUBLE_MATRIX.Wrapper> global
Reference to global instance.


pid

protected int pid
Processor ID corresponding to this array instance.

Constructor Detail

BSP_DOUBLE_MATRIX

public BSP_DOUBLE_MATRIX(BSP_PROGRAM thread,
                         double[][] init)
Base constructor.

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

getData

public double[][] getData()
Method to get the raw matrix.

Returns:
The raw matrix.

setData

public BSP_DOUBLE_MATRIX setData(double[][] x)
Method to set a new raw matrix source.

Parameters:
x - The new matrix.
Returns:
A handle to this matrix (method chaining). TODO test if this function works properly (maybe the old reference is maintained somewhere)

bsp_move

public void bsp_move()
Move a BSMP message from this global variable's queue. Warning: Since this is a raw matrix, items put in queue also represent matrices.


bsp_qsize

public int bsp_qsize()

bsp_send

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

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

Parameters:
to - At which processor to perform the enqueue operation.
source - The matrix to be sent.

bsp_send

public void bsp_send(double[][] source,
                     int to)
BSMP send instruction. Sends a given matrix to this global matrix queue, at the given processor.

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

Parameters:
to - At which processor to perform the enqueue operation.
source - The matrix to be sent.

bsp_send

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

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

Parameters:
to - At which processor to perform the enqueue operation.
source - The matrix to be sent.

bsp_put

public void bsp_put(int isource_offset,
                    int jsource_offset,
                    int destination_processor,
                    BSP_DOUBLE_MATRIX destination,
                    int idestination_offset,
                    int jdestination_offset,
                    int ilength,
                    int jlength)
DRMA Put instruction. Copies
this[ isource_offset, isource_offset+1, ..., isource_offset+ilength-1 ] [ jsource_offset, jsource_offset+1, ..., jsource_offset+jlength-1 ] (local to current processor)
to destination[ idestination_offset, ..., idestination_offset+ilength-1 ] [ jdestination_offset, ..., jdestination_offset+jlength-1 ] (local to destination_processor)
This instruction buffers the to-be copied current elements here; array elements thus are free to change after calling this put operation.

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

Parameters:
isource_offset - Copy ilength items beginning at this[ isource_offset ][..].
jsource_offset - Copy jlength items beginning at this[..][ jsource_offset ].
destination_processor - Target processor ID of this put instruction.
destination - Destination global matrix.
idestination_offset - Put items into destination starting at destination[ idestination_offset ][..].
jdestination_offset - Put items into destination starting at destination[..][ jdestination_offset ].
ilength - Put a total of length items in the row direction.
jlength - Put a total of length items in the column direction.

bsp_put

public void bsp_put(double[][] data,
                    int destination_processor,
                    int idestination_offset,
                    int jdestination_offset)
DRMA Put instruction. Copies a given value to this[ idestination_index ][ jdestination_offset ], at destination_processor. 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 matrix to put.
destination_processor - At which processor to put the current variable.
idestination_offset - Put items into destination starting at destination[ idestination_offset ][..].
jdestination_offset - Put items into destination starting at destination[..][ jdestination_offset ].

bsp_get

public void bsp_get(int source_processor,
                    BSP_DOUBLE_MATRIX source,
                    int isource_offset,
                    int jsource_offset,
                    int idestination_offset,
                    int jdestination_offset,
                    int ilength,
                    int jlength)
DRMA Get instruction. Gets
source [ isource_offset, isource_offset+1, ..., isource_offset+ilength-1 ] [ jsource_offset, jsource_offset+1, ..., jsource_offset+jlength-1 ] (local to source_processor)
and puts those contents in
this [ idestination_offset, ..., idestination_offset+ilength-1 ] [ jdestination_offset, ..., jdestination_offset+jlength-1 ] (local to current processor)
This instruction does not buffer the elements to be got as they are generally unavailable from this processor's perspective. Hence, those elements in the source vector at synchronisation time are the elements which will be copied to this array.

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

Parameters:
source_processor - Processor to get the (partial) matrix from.
source - From which global variable to get data.
isource_offset - Get elements starting from source[ isource_offset ][..].
jsource_offset - Get elements starting from source[..][ jsource_offset ].
idestination_offset - Copy elements into sub-array starting from destination[ idestination_offset ][..].
jdestination_offset - Copy elements into sub-array starting from destination[..][ jdestination_offset ].
ilength - Number of elements to retrieve in the row direction.
jlength - Number of elements to retrieve in the column direction.