public static void main(String[] args) throws MsgException, NativeException {
Msg.init(args);
if(args.length < 1) {
- Msg.info("Usage : TracingTest platform_file");
- Msg.info("example : TracingTest ../platforms/platform.xml");
+ Msg.info("Usage : Main platform_file");
+ Msg.info("example : Main ../platforms/platform.xml");
System.exit(1);
}
import org.simgrid.trace.Trace;
public class Sender extends Process {
- private final double commSizeLat = 1;
- private final double commSizeBw = 100000000;
+ private static final double commSizeLat = 1;
+ private static final double commSizeBw = 100000000;
+ private static final String PM_STATE = "PM_STATE";
public Sender(String hostname, String name, String[] args) throws HostNotFoundException, NativeException {
super(hostname,name,args);
public void main(String[] args) throws MsgException {
Msg.info("hello !");
- Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPing");
+ Trace.hostPushState (getHost().getName(), PM_STATE, "sendingPing");
int hostCount = args.length;
Msg.info("host count: " + hostCount);
String mailboxes[] = new String[hostCount];
double time;
double computeDuration = 0;
- PingPongTask ping, pong;
+ PingPongTask ping;
for(int pos = 0; pos < args.length ; pos++) {
- try {
- mailboxes[pos] = Host.getByName(args[pos]).getName();
- } catch (HostNotFoundException e) {
- Msg.info("Invalid deployment file: " + e.toString());
- System.exit(1);
- }
+ mailboxes[pos] = Host.getByName(args[pos]).getName();
}
for (int pos = 0; pos < hostCount; pos++) {
ping.setTime(time);
ping.send(mailboxes[pos]);
- Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPong");
- pong = (PingPongTask)Task.receive(getHost().getName());
+ Trace.hostPushState (getHost().getName(), PM_STATE, "waitingPong");
+ PingPongTask pong = (PingPongTask)Task.receive(getHost().getName());
double timeGot = Msg.getClock();
double timeSent = ping.getTime();
- double communicationTime=0;
+ double communicationTime;
Msg.info("Got at time "+ timeGot);
Msg.info("Was sent at time "+timeSent);
- time=timeSent;
+ time = timeSent;
communicationTime=timeGot - time;
Msg.info("Communication time : " + communicationTime);
Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
/* Pop the last state (going back to sending ping) */
- Trace.hostPopState (getHost().getName(), "PM_STATE");
+ Trace.hostPopState (getHost().getName(), PM_STATE);
}
/* Pop the sendingPong state */
- Trace.hostPopState (getHost().getName(), "PM_STATE");
+ Trace.hostPopState (getHost().getName(), PM_STATE);
Msg.info("goodbye!");
}
}
/** Locks on the semaphore object until the provided timeout expires
* @exception TimeoutException if the timeout expired before
* the semaphore could be acquired.
+ * @param timeout the duration of the lock
*/
public native void acquire(double timeout) throws TimeoutException;
/** Locks on the semaphore object with no timeout
try {
acquire(-1);
} catch (TimeoutException e) {
- // This should not happen.
- assert(false);
+ e.printStackTrace(); // This should not happen.
+ assert false ;
}
}
/** Releases the semaphore object
# libsmx.c simcall_BODY_
if self.simcalls_BODY is None:
f = open('libsmx.cpp')
- self.simcalls_BODY = set(
- re.findall('simcall_BODY_(.*?)\(', f.read()))
+ self.simcalls_BODY = set(re.findall('simcall_BODY_(.*?)\(', f.read()))
f.close()
if self.name not in self.simcalls_BODY:
- print '# ERROR: No function calling simcall_BODY_%s' % self.name
- print '# Add something like this to libsmx.c:'
- print '%s simcall_%s(%s) {' % (self.res.rettype(), self.name, ', '.join('%s %s' % (arg.rettype(), arg.name) for arg in self.args))
- print ' return simcall_BODY_%s(%s);' % (self.name, "...")
- print '}'
+ print ('# ERROR: No function calling simcall_BODY_%s' % self.name)
+ print ('# Add something like this to libsmx.c:')
+ print ('%s simcall_%s(%s) {' % (self.res.rettype(), self.name, ', '.
+ join('%s %s' % (arg.rettype(), arg.name) for arg in self.args)))
+ print (' return simcall_BODY_%s(%s);' % (self.name, "..."))
+ print ('}')
return False
# smx_*.c void simcall_HANDLER_host_on(smx_simcall_t simcall,
self.simcalls_PRE = set()
for fn in glob.glob('smx_*') + glob.glob('../mc/*'):
f = open(fn)
- self.simcalls_PRE |= set(
- re.findall('simcall_HANDLER_(.*?)\(', f.read()))
+ self.simcalls_PRE |= set(re.findall('simcall_HANDLER_(.*?)\(', f.read()))
f.close()
if self.need_handler:
- if (self.name not in self.simcalls_PRE):
- print '# ERROR: No function called simcall_HANDLER_%s' % self.name
- print '# Add something like this to the relevant C file (like smx_io.c if it\'s an IO call):'
- print '%s simcall_HANDLER_%s(smx_simcall_t simcall%s) {' % (self.res.rettype(), self.name, ''.join(', %s %s' % (arg.rettype(), arg.name)
- for arg in self.args))
- print ' // Your code handling the simcall'
- print '}'
+ if self.name not in self.simcalls_PRE:
+ print ('# ERROR: No function called simcall_HANDLER_%s' % self.name)
+ print ('# Add something like this to the relevant C file (like smx_io.c if it\'s an IO call):')
+ print ('%s simcall_HANDLER_%s(smx_simcall_t simcall%s) {' % (self.res.rettype(), self.name, ''.
+ join(', %s %s' % (arg.rettype(), arg.name)for arg in self.args)))
+ print (' // Your code handling the simcall')
+ print ('}')
return False
else:
- if (self.name in self.simcalls_PRE):
- print '# ERROR: You have a function called simcall_HANDLER_%s, but that simcall is not using any handler' % self.name
- print '# Either change your simcall definition, or kill that function'
+ if self.name in self.simcalls_PRE:
+ print ('# ERROR: You have a function called simcall_HANDLER_%s, but that simcall is not using any handler' % self.name)
+ print ('# Either change your simcall definition, or kill that function')
return False
return True
def case(self):
res = []
- args = [ ("simgrid::simix::unmarshal<%s>(simcall->args[%d])" % (arg.rettype(), i))
+ args = [ "simgrid::simix::unmarshal<%s>(simcall->args[%d])" % (arg.rettype(), i)
for i, arg in enumerate(self.args) ]
res.append('case SIMCALL_%s:' % (self.name.upper()))
if self.need_handler:
#include "surf/surf.h"
#include "src/surf/surf_interface.hpp"
#include "src/surf/cpu_interface.hpp"
+#include "src/surf/network_interface.hpp"
#include "xbt/log.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
XBT_DEBUG("%s : %p", sg_host_get_name(hostB), hostB);
/* Let's do something on it */
- surf_action_t actionA = hostA->pimpl_cpu->execution_start(1000.0);
- surf_action_t actionB = hostB->pimpl_cpu->execution_start(1000.0);
- surf_action_t actionC = surf_host_sleep(hostB, 7.32);
+ simgrid::surf::Action *actionA = hostA->pimpl_cpu->execution_start(1000.0);
+ simgrid::surf::Action *actionB = hostB->pimpl_cpu->execution_start(1000.0);
+ simgrid::surf::Action *actionC = surf_host_sleep(hostB, 7.32);
/* Use whatever calling style you want... */
simgrid::surf::Action::State stateActionA = actionA->getState(); /* When you know actionA model type */
surf_solve(-1.0);
do {
- surf_action_t action = nullptr;
+ simgrid::surf::ActionList *action_list = nullptr;
now = surf_get_clock();
XBT_INFO("Next Event : %g", now);
XBT_DEBUG("\t CPU actions");
- while ((action = surf_model_extract_failed_action_set((surf_model_t)surf_cpu_model_pm))) {
+
+ action_list = surf_cpu_model_pm->getFailedActionSet();
+ for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+ it != itend ; it=itNext) {
+ ++itNext;
+ simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
XBT_INFO(" CPU Failed action");
XBT_DEBUG("\t * Failed : %p", action);
action->unref();
}
- while ((action = surf_model_extract_done_action_set((surf_model_t)surf_cpu_model_pm))) {
+
+ action_list = surf_cpu_model_pm->getDoneActionSet();
+ for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+ it != itend ; it=itNext) {
+ ++itNext;
+ simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
XBT_INFO(" CPU Done action");
XBT_DEBUG("\t * Done : %p", action);
action->unref();
}
- XBT_DEBUG("\t Network actions");
- while ((action = surf_model_extract_failed_action_set((surf_model_t)surf_network_model))) {
- XBT_INFO(" Network Failed action");
- XBT_DEBUG("\t * Failed : %p", action);
- action->unref();
+
+ action_list = surf_network_model->getFailedActionSet();
+ for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+ it != itend ; it=itNext) {
+ ++itNext;
+ simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
+ XBT_INFO(" Network Failed action");
+ XBT_DEBUG("\t * Failed : %p", action);
+ action->unref();
}
- while ((action = surf_model_extract_done_action_set((surf_model_t)surf_network_model))) {
- XBT_INFO(" Network Failed action");
+
+ action_list = surf_network_model->getDoneActionSet();
+ for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
+ it != itend ; it=itNext) {
+ ++itNext;
+ simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
+ XBT_INFO(" Network Done action");
XBT_DEBUG("\t * Done : %p", action);
action->unref();
}
- } while ((surf_model_running_action_set_size((surf_model_t)surf_network_model) ||
- surf_model_running_action_set_size((surf_model_t)surf_cpu_model_pm)) && surf_solve(-1.0) >= 0.0);
+ } while ((surf_network_model->getRunningActionSet()->size() ||
+ surf_cpu_model_pm->getRunningActionSet()->size()) && surf_solve(-1.0) >= 0.0);
XBT_DEBUG("Simulation Terminated");
> [0.000000] [surf_test/INFO] CPU Failed action
> [0.200000] [surf_test/INFO] Next Event : 0.2
> [0.200016] [surf_test/INFO] Next Event : 0.200016
-> [0.200016] [surf_test/INFO] Network Failed action
+> [0.200016] [surf_test/INFO] Network Done action
> [7.320000] [surf_test/INFO] Next Event : 7.32
> [7.320000] [surf_test/INFO] CPU Done action
> [10.000000] [surf_test/INFO] Next Event : 10