Class SharedDoubleArrayBuf

java.lang.Object
edu.rit.mp.Buf
edu.rit.mp.DoubleBuf
edu.rit.mp.buf.SharedDoubleArrayBuf
Direct Known Subclasses:
SharedDoubleArrayBuf_1

public class SharedDoubleArrayBuf extends DoubleBuf
Class SharedDoubleArrayBuf provides a buffer for a multiple thread safe array of double items sent or received using the Message Protocol (MP). The array element stride may be 1 or greater than 1. While an instance of class SharedDoubleArrayBuf may be constructed directly, normally you will use a factory method in class DoubleBuf. See that class for further information.
Version:
26-Oct-2007
Author:
Alan Kaminsky
  • Constructor Details

    • SharedDoubleArrayBuf

      public SharedDoubleArrayBuf(SharedDoubleArray theArray, Range theRange)
      Construct a new shared double array buffer.
      Parameters:
      theArray - Shared array.
      theRange - Range of array elements to include in the buffer.
  • Method Details

    • get

      public double get(int i)
      Obtain the given item from this buffer.

      The get() method must not block the calling thread; if it does, all message I/O in MP will be blocked. Obtain the given item from this buffer.

      The get() method must not block the calling thread; if it does, all message I/O in MP will be blocked.

      Specified by:
      get in class DoubleBuf
      Parameters:
      i - Item index in the range 0 .. length()-1.
      Returns:
      Item at index i.
    • put

      public void put(int i, double item)
      Store the given item in this buffer.

      The put() method must not block the calling thread; if it does, all message I/O in MP will be blocked. Store the given item in this buffer.

      The put() method must not block the calling thread; if it does, all message I/O in MP will be blocked.

      Specified by:
      put in class DoubleBuf
      Parameters:
      i - Item index in the range 0 .. length()-1.
      item - Item to be stored at index i.
    • getReductionBuf

      public Buf getReductionBuf(Op op)
      Create a buffer for performing parallel reduction using the given binary operation. The results of the reduction are placed into this buffer.

      Operations performed on the returned reduction buffer have the same effect as operations performed on this buffer, except whenever a source item S is put into a destination item D in this buffer, D is set to D op S, that is, the reduction of D and S using the given binary operation (rather than just setting D to S). Create a buffer for performing parallel reduction using the given binary operation. The results of the reduction are placed into this buffer.

      Specified by:
      getReductionBuf in class Buf
      Parameters:
      op - Binary operation.
      Returns:
      a Buf object.
      Throws:
      ClassCastException - (unchecked exception) Thrown if this buffer's element data type and the given binary operation's argument data type are not the same.
    • sendItems

      protected int sendItems(int i, ByteBuffer buffer)
      Send as many items as possible from this buffer to the given byte buffer.

      The sendItems() method must not block the calling thread; if it does, all message I/O in MP will be blocked. Send as many items as possible from this buffer to the given byte buffer.

      The sendItems() method must not block the calling thread; if it does, all message I/O in MP will be blocked.

      Specified by:
      sendItems in class Buf
      Parameters:
      i - Index of first item to send, in the range 0 .. length-1.
      buffer - Byte buffer.
      Returns:
      Number of items sent.
    • receiveItems

      protected int receiveItems(int i, int num, ByteBuffer buffer)
      Receive as many items as possible from the given byte buffer to this buffer.

      The receiveItems() method must not block the calling thread; if it does, all message I/O in MP will be blocked. Receive as many items as possible from the given byte buffer to this buffer.

      The receiveItems() method must not block the calling thread; if it does, all message I/O in MP will be blocked.

      Specified by:
      receiveItems in class Buf
      Parameters:
      i - Index of first item to receive, in the range 0 .. length-1.
      num - Maximum number of items to receive.
      buffer - Byte buffer.
      Returns:
      Number of items received.