-/*
- * Copyright (c) 2006-2013. 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-2015. 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. */
- public Task(String name, double computeDuration, double messageSize) {
- create(name, computeDuration, messageSize);
- this.messageSize = messageSize;
- setId(idCpt);
- idCpt++;
+ public Task(String name, double flopsAmount, double bytesAmount) {
+ create(name, flopsAmount, bytesAmount);
+ this.messageSize = bytesAmount;
*
* @param name The name of the parallel task.
* @param hosts The list of hosts implied by the parallel task.
*
* @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);
* to process the task. If 0, then it cannot be executed
* with the execute() method. This value has to be >= 0.
* to process the task. If 0, then it cannot be executed
* with the execute() method. This value has to be >= 0.
* 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,
* 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,
/**
* 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.
/**
* 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.
- double[]computeDurations,
- double[]messageSizes)
- throws NullPointerException, IllegalArgumentException;
+ double[]flopsAmount,
+ double[]bytesAmount)
+ throws NullPointerException, IllegalArgumentException;
- /** 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();
- /**
- * Set the computation amount needed to process the task
- * @param computationAmount the amount of computation needed to process the task
+
+ /** Set the computation amount needed to process the task
+ *
+ * Warning if the execution is already started and ongoing, this call does nothing.
+ * @param flopsAmount the amount of computation needed to process the task
- * Set the data size of the task
- * @param dataSize the size of the task
+ * Set the amount of bytes to exchange the task
+ *
+ * Warning if the communication is already started and ongoing, this call does nothing.
+ * @param bytesAmount the size of the task
- /** Deletes a task.
- *
- * @exception NativeException if the destruction failed.
- */
- protected void finalize() throws NativeException {
- destroy();
+
+ /** Deletes a task once the garbage collector reclaims it */
+ @Override
+ protected void finalize() {
+ try {
+ // Exceptions in finalizers lead to bad situations:
+ // http://stackoverflow.com/questions/7644556/troubleshooting-a-java-memory-leak-finalization
+ nativeFinalize();
+ bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize()
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
* with no way to retrieve whether the communication succeeded or not
*
*/
public native void dsendBounded(String mailbox, double maxrate);
* with no way to retrieve whether the communication succeeded or not
*
*/
public native void dsendBounded(String mailbox, double maxrate);
* with no way to retrieve whether the communication succeeded or not
*
*/
public native void dsend(String mailbox);
* with no way to retrieve whether the communication succeeded or not
*
*/
public native void dsend(String mailbox);
- public void send(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
+ public void send(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException, NativeException {
* @throws TimeoutException
* @throws HostFailureException
* @throws TransferFailureException
*/
* @throws TimeoutException
* @throws HostFailureException
* @throws TransferFailureException
*/
- public native void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException;
- /**
- * Sends the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate)
+ public native void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException, NativeException;
+
+ /** Sends the task on the specified mailbox (capping the sending rate to \a maxrate)
- * @param alias
- * @param maxrate
- * @throws TransferFailureException
- * @throws HostFailureException
- * @throws TimeoutException
+ * @param mailbox where to send the message
+ * @param maxrate
+ * @throws TransferFailureException
+ * @throws HostFailureException
+ * @throws TimeoutException
- public void sendBounded(String alias, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException {
- sendBounded(alias,-1,maxrate);
- }
+ public void sendBounded(String mailbox, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException {
+ sendBounded(mailbox,-1,maxrate);
+ }
- * @param alias
- * @param timeout
- * @param maxrate
- * @throws TransferFailureException
- * @throws HostFailureException
- * @throws TimeoutException
+ * @param mailbox where to send the message
+ * @param timeout
+ * @param maxrate
+ * @throws TransferFailureException
+ * @throws HostFailureException
+ * @throws TimeoutException
- public native void sendBounded(String alias, double timeout, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException;
+ public native void sendBounded(String mailbox, double timeout, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException;
* Sends the task on the mailbox asynchronously (capping the sending rate to \a maxrate)
*/
public native Comm isendBounded(String mailbox, double maxrate);
* Sends the task on the mailbox asynchronously (capping the sending rate to \a maxrate)
*/
public native Comm isendBounded(String mailbox, double maxrate);
*/
public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public static Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException {
return receive(mailbox, timeout, null);
*/
public static Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException {
return receive(mailbox, timeout, null);
*/
public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public native static Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException;
*/
public native static Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException;
*/
public static Task receiveBounded(String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public static Task receiveBounded(String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public static Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
return receiveBounded(mailbox, timeout, null, rate);
*/
public static Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
return receiveBounded(mailbox, timeout, null, rate);
*/
public static Task receiveBounded(String mailbox, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public static Task receiveBounded(String mailbox, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException {
*/
public native static Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException;
*/
public native static Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException;
public native static int listenFrom(String mailbox);
/**
* Listen whether there is a waiting task on the mailbox identified by the specified alias
public native static int listenFrom(String mailbox);
/**
* Listen whether there is a waiting task on the mailbox identified by the specified alias
public native static boolean listen(String mailbox);
/**
* Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host.
public native static boolean listen(String mailbox);
/**
* Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host.