|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
edu.rit.pj.replica.ReplicatedByte
public class ReplicatedByte
Class ReplicatedByte provides a replicated, shared reduction variable for a value of type byte.
A replicated, shared reduction variable is intended to be used in a cluster or hybrid parallel program for a data item shared among all the processes in the program and all the threads in each process. To use a replicated, shared reduction variable, do the following in each process of the parallel program:
Whenever one of the aforementioned flooded messages arrives, a separate thread performs an atomic reduction on the local process's variable with the received value.
An atomic reduction consists of these steps, performed atomically: Call the reduction operator's op() method, passing in the current value of the local process's replicated variable and the new value (either the new value specified as an argument of reduce(), or the new value received in a flooded message). Then store the op() method's return value back into the local process's replicated variable.
Class ReplicatedByte does not itself guarantee consistency of the replicas' values. This is to avoid the message passing overhead of a distributed state update protocol. Instead, the parallel program must be written to operate correctly when the variable is updated as described above. Note that the value of a process's local replica can change asynchronously at any time, either because a thread in the current process updated the variable, or because a flooded message updated the variable.
Class ReplicatedByte is multiple thread safe. The methods use lock-free atomic compare-and-set.
Note: Class ReplicatedByte is implemented using class java.util.concurrent.atomic.AtomicInteger.
| Constructor Summary | |
|---|---|
ReplicatedByte(ByteOp op)
Construct a new replicated, shared byte reduction variable with the given reduction operator. |
|
ReplicatedByte(ByteOp op,
byte initialValue)
Construct a new replicated, shared byte reduction variable with the given reduction operator and initial value. |
|
ReplicatedByte(ByteOp op,
byte initialValue,
int tag)
Construct a new replicated, shared byte reduction variable with the given reduction operator, initial value, and message tag. |
|
ReplicatedByte(ByteOp op,
byte initialValue,
int tag,
Comm comm)
Construct a new replicated, shared byte reduction variable with the given reduction operator, initial value, message tag, and communicator. |
|
| Method Summary | |
|---|---|
double |
doubleValue()
Returns this reduction variable's current value converted to type double. |
float |
floatValue()
Returns this reduction variable's current value converted to type float. |
byte |
get()
Returns this replicated, shared reduction variable's current value. |
int |
intValue()
Returns this reduction variable's current value converted to type int. |
long |
longValue()
Returns this reduction variable's current value converted to type long. |
byte |
reduce(byte value)
Update this replicated, shared reduction variable's current value. |
String |
toString()
Returns a string version of this reduction variable. |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ReplicatedByte(ByteOp op)
op - Reduction operator.
NullPointerException - (unchecked exception) Thrown if op is null.
public ReplicatedByte(ByteOp op,
byte initialValue)
op - Reduction operator.initialValue - Initial value.
NullPointerException - (unchecked exception) Thrown if op is null.
public ReplicatedByte(ByteOp op,
byte initialValue,
int tag)
op - Reduction operator.initialValue - Initial value.tag - Message tag.
NullPointerException - (unchecked exception) Thrown if op is null. Thrown if
comm is null.
public ReplicatedByte(ByteOp op,
byte initialValue,
int tag,
Comm comm)
op - Reduction operator.initialValue - Initial value.tag - Message tag.comm - Communicator.
NullPointerException - (unchecked exception) Thrown if op is null. Thrown if
comm is null.| Method Detail |
|---|
public byte get()
public byte reduce(byte value)
throws IOException
value - Value.
IOException - Thrown if an I/O error occurred.public String toString()
toString in class Objectpublic int intValue()
intValue in class Numberpublic long longValue()
longValue in class Numberpublic float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Number
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||