Package org.simgrid.msg
Class Task
- java.lang.Object
-
- org.simgrid.msg.Task
-
public class Task extends java.lang.Object
A task is either something to compute somewhere, or something to exchange between two hosts (or both). It is defined by a computing amount and a message size.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
name
Task name
-
Constructor Summary
Constructors Constructor Description Task()
Default constructor (all fields to 0 or null)Task(java.lang.String name, double flopsAmount, double bytesAmount)
Construct a new task with the specified processing amount and amount of data needed.Task(java.lang.String name, Host[] hosts, double[] flopsAmount, double[] bytesAmount)
Construct a new parallel task with the specified processing amount and amount for each host implied.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels a task.void
dsend(java.lang.String mailbox)
Send the task asynchronously on the specified mailbox, with no way to retrieve whether the communication succeeded or notvoid
dsendBounded(java.lang.String mailbox, double maxrate)
Send the task asynchronously on the specified mailbox, with no way to retrieve whether the communication succeeded or notvoid
execute()
Executes a task on the location on which the current process is running.protected void
finalize()
Deletes a task once the garbage collector reclaims itdouble
getFlopsAmount()
Gets the remaining amount of flops to execute in this task If it's ongoing, you get the exact amount at the present time.double
getMessageSize()
java.lang.String
getName()
Gets the name of the taskProcess
getSender()
Gets the sender of the task (or null if not sent yet)Host
getSource()
Gets the source of the task (or null if not sent yet).static Comm
irecv(java.lang.String mailbox)
Starts listening for receiving a task from an asynchronous communicationstatic Comm
irecvBounded(java.lang.String mailbox, double rate)
Starts listening for receiving a task from an asynchronous communication with a capped rateComm
isend(java.lang.String mailbox)
Sends the task on the mailbox asynchronouslyComm
isendBounded(java.lang.String mailbox, double maxrate)
Sends the task on the mailbox asynchronously (capping the sending rate to \a maxrate)static boolean
listen(java.lang.String mailbox)
Listen whether there is a task waiting (either for a send or a recv) on the mailbox identified by the specified aliasstatic int
listenFrom(java.lang.String mailbox)
Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent itprotected void
nativeFinalize()
static void
nativeInit()
Class initializer, to initialize various JNI stuffstatic Task
receive(java.lang.String mailbox)
Retrieves next task on the mailbox identified by the specified aliasstatic Task
receive(java.lang.String mailbox, double timeout)
Retrieves next task on the mailbox identified by the specified alias (wait at most \a timeout seconds)static Task
receiveBounded(java.lang.String mailbox, double rate)
Retrieves next task from the mailbox identified by the specified name with a capped ratestatic Task
receiveBounded(java.lang.String mailbox, double timeout, double rate)
Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds) with a capped ratevoid
send(java.lang.String mailbox)
Sends the task on the specified mailboxvoid
send(java.lang.String mailbox, double timeout)
Sends the task on the specified mailbox (wait at most \a timeout seconds)void
sendBounded(java.lang.String mailbox, double maxrate)
Sends the task on the specified mailbox (capping the sending rate to \a maxrate)void
sendBounded(java.lang.String mailbox, double timeout, double maxrate)
Sends the task on the specified mailbox (capping the sending rate to \a maxrate) with a timeoutvoid
setBound(double bound)
Changes the maximum CPU utilization of a computation task.void
setBytesAmount(double bytesAmount)
Set the amount of bytes to exchange the task Warning if the communication is already started and ongoing, this call does nothing.void
setFlopsAmount(double flopsAmount)
Set the computation amount needed to process the task Warning if the execution is already started and ongoing, this call does nothing.void
setName(java.lang.String name)
Sets the name of the taskvoid
setPriority(double priority)
This method sets the priority of the computation of the task.
-
-
-
Constructor Detail
-
Task
public Task()
Default constructor (all fields to 0 or null)
-
Task
public Task(java.lang.String name, double flopsAmount, double bytesAmount)
Construct a new task with the specified processing amount and amount of data needed.- Parameters:
name
- Task's nameflopsAmount
- A value of the processing amount (in flop) needed to process the task. If 0, then it cannot be executed with the execute() method. This value has to be ≥ 0.bytesAmount
- A value of amount of data (in bytes) needed to transfert this task. If 0, then it cannot be transfered with the get() and put() methods. This value has to be ≥ 0.
-
Task
public Task(java.lang.String name, Host[] hosts, double[] flopsAmount, double[] bytesAmount)
Construct a new parallel task with the specified processing amount and amount for each host implied.- Parameters:
name
- The name of the parallel task.hosts
- The list of hosts implied by the parallel task.flopsAmount
- The amount of operations to be performed by each host of hosts. flopsAmount[i] is the total number of operations that have to be performed on hosts[i].bytesAmount
- A matrix describing the amount of data to exchange between hosts. The length of this array must be hosts.length * hosts.length. It is actually used as a matrix with the lines being the source and the columns being the destination of the communications.
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the name of the task
-
getSender
public Process getSender()
Gets the sender of the task (or null if not sent yet)
-
getSource
public Host getSource()
Gets the source of the task (or null if not sent yet).
-
getFlopsAmount
public double getFlopsAmount()
Gets the remaining amount of flops to execute in this task If it's ongoing, you get the exact amount at the present time. If it's already done, it's 0.
-
setName
public void setName(java.lang.String name)
Sets the name of the task- Parameters:
name
- the new task name
-
setPriority
public void setPriority(double priority)
This method sets the priority of the computation of the task. The priority doesn't affect the transfer rate. For example a priority of 2 will make the task receive two times more cpu than the other ones.- Parameters:
priority
- The new priority of the task.
-
setFlopsAmount
public void setFlopsAmount(double flopsAmount)
Set the computation amount needed to process the task Warning if the execution is already started and ongoing, this call does nothing.- Parameters:
flopsAmount
- the amount of computation needed to process the task
-
setBytesAmount
public void setBytesAmount(double bytesAmount)
Set the amount of bytes to exchange the task Warning if the communication is already started and ongoing, this call does nothing.- Parameters:
bytesAmount
- the size of the task
-
execute
public void execute() throws HostFailureException, TaskCancelledException
Executes a task on the location on which the current process is running.
-
setBound
public void setBound(double bound)
Changes the maximum CPU utilization of a computation task. Unit is flops/s.
-
cancel
public void cancel()
Cancels a task.
-
finalize
protected void finalize() throws java.lang.Throwable
Deletes a task once the garbage collector reclaims it- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
nativeFinalize
protected void nativeFinalize()
-
dsendBounded
public void dsendBounded(java.lang.String mailbox, double maxrate)
Send the task asynchronously on the specified mailbox, with no way to retrieve whether the communication succeeded or not
-
dsend
public void dsend(java.lang.String mailbox)
Send the task asynchronously on the specified mailbox, with no way to retrieve whether the communication succeeded or not
-
send
public void send(java.lang.String mailbox) throws TransferFailureException, HostFailureException, TimeoutException
Sends the task on the specified mailbox- Parameters:
mailbox
- where to send the message- Throws:
TimeoutException
HostFailureException
TransferFailureException
-
send
public void send(java.lang.String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException
Sends the task on the specified mailbox (wait at most \a timeout seconds)- Parameters:
mailbox
- where to send the messagetimeout
-- Throws:
TimeoutException
HostFailureException
TransferFailureException
-
sendBounded
public void sendBounded(java.lang.String mailbox, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException
Sends the task on the specified mailbox (capping the sending rate to \a maxrate)- Parameters:
mailbox
- where to send the messagemaxrate
-- Throws:
TransferFailureException
HostFailureException
TimeoutException
-
sendBounded
public void sendBounded(java.lang.String mailbox, double timeout, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException
Sends the task on the specified mailbox (capping the sending rate to \a maxrate) with a timeout- Parameters:
mailbox
- where to send the messagetimeout
-maxrate
-- Throws:
TransferFailureException
HostFailureException
TimeoutException
-
isend
public Comm isend(java.lang.String mailbox)
Sends the task on the mailbox asynchronously
-
isendBounded
public Comm isendBounded(java.lang.String mailbox, double maxrate)
Sends the task on the mailbox asynchronously (capping the sending rate to \a maxrate)
-
irecv
public static Comm irecv(java.lang.String mailbox)
Starts listening for receiving a task from an asynchronous communication- Parameters:
mailbox
-- Returns:
- a Comm handler
-
receive
public static Task receive(java.lang.String mailbox) throws TransferFailureException, HostFailureException, TimeoutException
Retrieves next task on the mailbox identified by the specified alias- Parameters:
mailbox
-- Returns:
- a Task
- Throws:
TransferFailureException
HostFailureException
TimeoutException
-
receive
public static Task receive(java.lang.String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException
Retrieves next task on the mailbox identified by the specified alias (wait at most \a timeout seconds)- Parameters:
mailbox
-timeout
-- Returns:
- a Task
- Throws:
TransferFailureException
HostFailureException
TimeoutException
-
irecvBounded
public static Comm irecvBounded(java.lang.String mailbox, double rate)
Starts listening for receiving a task from an asynchronous communication with a capped rate- Parameters:
mailbox
-- Returns:
- a Comm handler
-
receiveBounded
public static Task receiveBounded(java.lang.String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException
Retrieves next task from the mailbox identified by the specified name with a capped rate- Parameters:
mailbox
-- Returns:
- a Task
- Throws:
TransferFailureException
HostFailureException
TimeoutException
-
receiveBounded
public static Task receiveBounded(java.lang.String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException
Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds) with a capped rate- Parameters:
mailbox
-timeout
-- Returns:
- a Task
- Throws:
TransferFailureException
HostFailureException
TimeoutException
-
listenFrom
public static int listenFrom(java.lang.String mailbox)
Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
-
listen
public static boolean listen(java.lang.String mailbox)
Listen whether there is a task waiting (either for a send or a recv) on the mailbox identified by the specified alias
-
nativeInit
public static void nativeInit()
Class initializer, to initialize various JNI stuff
-
getMessageSize
public double getMessageSize()
-
-