-/*
- * Copyright 2006-2012 The SimGrid Team.
- * All right reserved.
- *
- * This program is free software; you can redistribute
- * it and/or modify it under the terms of the license
- * (GNU LGPL) which comes with this package.
- */
+/* Copyright (c) 2006-2014. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
package org.simgrid.msg;
*
* @param name Task's name
*
- * @param computeDuration A value of the processing amount (in flop) needed to process the task.
+ * @param flopsAmount 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.
*
- * @param messageSize A value of amount of data (in bytes) needed to transfert this task.
+ * @param 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.
*/
- public Task(String name, double computeDuration, double messageSize) {
- create(name, computeDuration, messageSize);
- this.messageSize = messageSize;
+ public Task(String name, double flopsAmount, double bytesAmount) {
+ create(name, flopsAmount, bytesAmount);
+ this.messageSize = bytesAmount;
setId(idCpt);
idCpt++;
}
*
* @param name The name of the parallel task.
* @param hosts The list of hosts implied by the parallel task.
- * @param computeDurations The amount of operations to be performed by each host of \a hosts.
- * @param messageSizes A matrix describing the amount of data to exchange between hosts.
+ * @param flopsAmount The amount of operations to be performed by each host of \a hosts.
+ * @param bytesAmount A matrix describing the amount of data to exchange between hosts.
*/
- public Task(String name, Host[]hosts, double[]computeDurations, double[]messageSizes) {
- parallelCreate(name, hosts, computeDurations, messageSizes);
+ public Task(String name, Host[]hosts, double[]flopsAmount, double[]bytesAmount) {
+ parallelCreate(name, hosts, flopsAmount, bytesAmount);
}
/**
* The natively implemented method to create a MSG task.
*
* @param name The name of th task.
- * @param computeDuration A value of the processing amount (in flop) needed
+ * @param flopsAmount 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.
- * @param messageSize A value of amount of data (in bytes) needed to transfert
+ * @param bytesAmount A value of amount of data (in bytes) needed to transfert
* this task. If 0, then it cannot be transfered this task.
* If 0, then it cannot be transfered with the get() and put()
* methods. This value has to be >= 0.
* @exception IllegalArgumentException if compute duration <0 or message size <0
*/
private final native void create(String name,
- double computeDuration,
- double messageSize)
+ double flopsAmount,
+ double bytesAmount)
throws IllegalArgumentException;
/**
* The natively implemented method to create a MSG parallel task.
*
* @param name The name of the parallel task.
* @param hosts The list of hosts implied by the parallel task.
- * @param computeDurations The total number of operations that have to be performed
+ * @param flopsAmount The total number of operations that have to be performed
* on the hosts.
- * @param messageSizes An array of doubles
+ * @param bytesAmount An array of doubles
*
*/
private final native void parallelCreate(String name,
Host[]hosts,
- double[]computeDurations,
- double[]messageSizes)
+ double[]flopsAmount,
+ double[]bytesAmount)
throws NullPointerException, IllegalArgumentException;
/* * * *
* * Getters / Setters * *
* Returns null if the task hasn't been sent yet.
*/
public native Host getSource();
- /** Gets the computing amount of the task
- * FIXME: Cache it !
- */
- public native double getComputeDuration();
- /** Gets the remaining computation of the task
- */
- public native double getRemainingDuration();
+
+ /** 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.
+ */
+ public native double getFlopsAmount();
/**
* Sets the name of the task
* @param name the new task name.c
* @throws TaskCancelledException
*/
public native void execute() throws HostFailureException,TaskCancelledException;
+ /**
+ * Bound a computation to a certain load
+ *
+ */
+ public native void setBound(double load);
/**
* Cancels a task.
*
* @throws HostFailureException
* @throws TimeoutException
*/
- public void sendBounded(String alias, double timeout, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException {
- sendBounded(alias,timeout,maxrate);
- }
+ public native void sendBounded(String alias, double timeout, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException;
/**
* @param host
*/
public native static Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException;
+
+ /**
+ * Starts listening for receiving a task from an asynchronous communication with a capped rate
+ * @param mailbox
+ */
+ public static native Comm irecvBounded(String mailbox, double rate);
+ /**
+ * Retrieves next task from the mailbox identified by the specified name with a capped rate
+ *
+ * @param mailbox
+ */
+
+ public static Task receiveBounded(String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
+ return receiveBounded(mailbox, -1.0, null, rate);
+ }
+
+ /**
+ * Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds) with a capped rate
+ *
+ * @param mailbox
+ * @param timeout
+ */
+ public static Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
+ return receiveBounded(mailbox, timeout, null, rate);
+ }
+
+ /**
+ * Retrieves next task sent by a given host on the mailbox identified by the specified alias with a capped rate
+ *
+ * @param mailbox
+ * @param host
+ */
+
+ public static Task receiveBounded(String mailbox, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
+ return receiveBounded(mailbox, -1.0, host, rate);
+ }
+
+ /**
+ * Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
+ * with a capped rate
+ *
+ * @param mailbox
+ * @param timeout
+ * @param host
+ */
+ public native static Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException;
+
+
+
/**
* Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
*/