doc/msg-tuto-src/masterworker4
examples/msg/actions-comm/actions-comm
examples/msg/actions-storage/actions-storage
-examples/msg/async-yield/async-yield
examples/msg/async-wait/async-wait
examples/msg/async-waitall/async-waitall
examples/msg/async-waitany/async-waitany
examples/msg/process-migration/process-migration
examples/msg/process-startkilltime/process-startkilltime
examples/msg/process-suspend/process-suspend
+examples/msg/process-yield/process-yield
examples/msg/app-masterworker/app-masterworker
examples/msg/mc/bugged1
examples/msg/mc/bugged1_liveness
teshsuite/mc/random-bug/random-bug
teshsuite/mc/mutex-handling/mutex-handling
teshsuite/mc/mutex-handling/without-mutex-handling
+teshsuite/msg/cloud-sharing/cloud-sharing
teshsuite/msg/concurrent_rw/concurrent_rw
teshsuite/msg/get_sender/get_sender
teshsuite/msg/host_on_off/host_on_off
teshsuite/msg/process/process
teshsuite/msg/storage_client_server/storage_client_server
teshsuite/msg/task_destroy_cancel/task_destroy_cancel
+teshsuite/msg/task_listen_from/task_listen_from
teshsuite/msg/trace_integration/trace_integration
teshsuite/simdag/availability/availability
teshsuite/simdag/basic-link-test/basic-link-test
message(FATAL_ERROR "Please install Python (version 3 or higher).")
endif()
-if (APPLE)
- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-endif()
SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
### Compute the include paths
Portability status:
- FreeBSD: Disable SMPI mmap privatization, switch automatically to dlopen.
- Mac, BSD: dlopen+thread broken, switch automatically to raw contexts.
+ - Java JAR file should be finally fully working on Mac OSX too.
XML platforms: Switch to platform v4.1 format.
* This is (mainly) a backward compatible change: v4 are valid v4.1 files
simulation round, s/he has to allocate and free a dynar and use it as argument
to this function. The former SD_simulate (double how_long) now returns void.
+ Virtual Machines
+ - Allow multicore VMs, along with the correct sharing computations
+
MSG
- The netzone are now available from the MSG API.
The old names still work, but are now deprecated.
// Performs a find successor request to a random id.
private void randomLookup() {
- int id = 1337;
- //Msg.info("Making a lookup request for id " + id);
- findSuccessor(id);
+ int dest = 1337;
+ //Msg.info("Making a lookup request for id " + dest);
+ findSuccessor(dest);
}
/**
/* Returns if the destination has been found */
public boolean destinationFound() {
- if (nodes.size() < 1) {
+ if (nodes.isEmpty()) {
return false;
}
Contact tail = nodes.get(0);
void update_pieces_count_from_bitfield(peer_t peer, unsigned int bitfield)
{
for (int i = 0; i < FILE_PIECES; i++) {
- if ((bitfield & (1U << i))) {
+ if (bitfield & (1U << i)) {
peer->pieces_count[i]++;
}
}
launch_computation_worker(vm0);
while(MSG_get_clock()<100) {
- if (atask != NULL)
- XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask));
- MSG_process_sleep(1);
+ if (atask != NULL)
+ XBT_INFO("aTask remaining duration: %g", MSG_task_get_flops_amount(atask));
+ MSG_process_sleep(1);
}
MSG_process_sleep(10000);
return 1;
}
-static void launch_master(msg_host_t host)
-{
- const char *pr_name = "master_";
- char **argv = xbt_new(char *, 2);
- argv[0] = xbt_strdup(pr_name);
- argv[1] = NULL;
-
- MSG_process_create_with_arguments(pr_name, master_main, NULL, host, 1, argv);
-}
-
int main(int argc, char *argv[]){
MSG_init(&argc, argv);
xbt_assert(argc == 2);
MSG_create_environment(argv[1]);
- launch_master(MSG_host_by_name("Fafard"));
+ MSG_process_create("master_", master_main, NULL, MSG_host_by_name("Fafard"));
int res = MSG_main();
XBT_INFO("Bye (simulation time %g)", MSG_get_clock());
/* Host 1 */
XBT_INFO("Creating and starting two VMs");
- msg_vm_t vm_host1 = MSG_vm_create(host1, "vm_host1", 2048, 10, 50);
+ msg_vm_t vm_host1 = MSG_vm_create(host1, "vm_host1", 1, 2048, 10, 50);
MSG_vm_start(vm_host1);
- msg_vm_t vm_host3 = MSG_vm_create(host3, "vm_host3", 2048, 10, 50);
+ msg_vm_t vm_host3 = MSG_vm_create(host3, "vm_host3", 1, 2048, 10, 50);
MSG_vm_start(vm_host3);
XBT_INFO("Create two tasks on Host1: one inside a VM, the other directly on the host");
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2017. 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. */
-/* Copyright (c) 2012-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2012-2017. 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. */
-/***************** Centralized Mutual Exclusion Algorithm *********************/
-/* This example implements a centralized mutual exclusion algorithm. */
-/* Bug : CS requests of client 1 not satisfied */
-/* LTL property checked : G(r->F(cs)); (r=request of CS, cs=CS ok) */
-/******************************************************************************/
+/***************** Centralized Mutual Exclusion Algorithm *******************/
+/* This example implements a centralized mutual exclusion algorithm. */
+/* Bug : CS requests of client 1 not satisfied */
+/* LTL property checked : G(r->F(cs)); (r=request of CS, cs=CS ok) */
+/****************************************************************************/
#ifdef GARBAGE_STACK
#include <sys/stat.h>
static int coordinator(int argc, char *argv[])
{
- int CS_used = 0;
- msg_task_t task = NULL, answer = NULL;
+ int CS_used = 0;
+ msg_task_t task = NULL;
+ msg_task_t answer = NULL;
xbt_dynar_t requests = xbt_dynar_new(sizeof(char *), NULL);
char *req;
int my_pid = MSG_process_get_PID(MSG_process_self());
char *my_mailbox = xbt_strdup(argv[1]);
- msg_task_t grant = NULL, release = NULL;
+ msg_task_t grant = NULL;
+ msg_task_t release = NULL;
while(1){
XBT_INFO("Ask the request");
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-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. */
{
msg_task_t task1 = NULL;
msg_task_t task2 = NULL;
- long val1, val2;
MSG_task_receive(&task1, "mymailbox");
- val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
+ long val1 = xbt_str_parse_int(MSG_task_get_name(task1), "Task name is not a numerical ID: %s");
MSG_task_destroy(task1);
task1 = NULL;
XBT_INFO("Received %lu", val1);
MSG_task_receive(&task2, "mymailbox");
- val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
+ long val2 = xbt_str_parse_int(MSG_task_get_name(task2), "Task name is not a numerical ID: %s");
MSG_task_destroy(task2);
task2 = NULL;
XBT_INFO("Received %lu", val2);
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2010-2017. 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. */
static int server(int argc, char *argv[])
{
- msg_task_t task1,task2;
+ msg_task_t task1 = NULL;
+ msg_task_t task2 = NULL;
msg_comm_t comm1 = MSG_task_irecv(&task1, "mymailbox1");
msg_comm_t comm2 = MSG_task_irecv(&task2, "mymailbox2");
#ifdef __cplusplus
+#include "s4u/forward.hpp"
#include "xbt/base.h"
#include <boost/intrusive_ptr.hpp>
namespace simgrid {
-namespace s4u {
-class Actor;
-class Comm;
-class Host;
-class Link;
-class Mailbox;
-class NetZone;
-
-XBT_PUBLIC(void) intrusive_ptr_release(Comm* c);
-XBT_PUBLIC(void) intrusive_ptr_add_ref(Comm* c);
-}
namespace kernel {
namespace activity {
class ActivityImpl;
// TODO add VDI later
XBT_PUBLIC(msg_vm_t) MSG_vm_create_core(msg_host_t location, const char *name);
+XBT_PUBLIC(msg_vm_t) MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount);
XBT_PUBLIC(msg_vm_t)
-MSG_vm_create(msg_host_t ind_pm, const char* name, int ramsize, int mig_netspeed, int dp_intensity);
+MSG_vm_create(msg_host_t ind_pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity);
XBT_PUBLIC(void) MSG_vm_destroy(msg_vm_t vm);
/** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */
kernel::routing::NetPoint* pimpl_netpoint = nullptr;
- /*** Called on each newly created object */
+ /*** Called on each newly created host */
static simgrid::xbt::signal<void(Host&)> onCreation;
- /*** Called just before destructing an object */
+ /*** Called just before destructing an host */
static simgrid::xbt::signal<void(Host&)> onDestruction;
- /*** Called when the machine is turned on or off */
+ /*** Called when the machine is turned on or off (called AFTER the change) */
static simgrid::xbt::signal<void(Host&)> onStateChange;
- /*** Called when the speed of the machine is changed
+ /*** Called when the speed of the machine is changed (called AFTER the change)
* (either because of a pstate switch or because of an external load event coming from the profile) */
static simgrid::xbt::signal<void(Host&)> onSpeedChange;
};
friend ConditionVariable;
friend simgrid::simix::MutexImpl;
simgrid::simix::MutexImpl* mutex_;
- Mutex(simgrid::simix::MutexImpl * mutex) : mutex_(mutex) {}
+ explicit Mutex(simgrid::simix::MutexImpl * mutex) : mutex_(mutex) {}
/* refcounting of the intrusive_ptr is delegated to the implementation object */
friend void intrusive_ptr_add_ref(Mutex* mutex)
{
public:
- explicit VirtualMachine(const char* name, s4u::Host* hostPm);
+ explicit VirtualMachine(const char* name, s4u::Host* hostPm, int coreAmount);
// No copy/move
VirtualMachine(VirtualMachine const&) = delete;
-/* Copyright (c) 2016. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2016-2017. 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. */
#define SIMGRID_S4U_FORWARD_HPP
#include <boost/intrusive_ptr.hpp>
+#include <xbt/base.h>
namespace simgrid {
namespace s4u {
using CommPtr = boost::intrusive_ptr<Comm>;
class Engine;
class Host;
+class Link;
class Mailbox;
using MailboxPtr = boost::intrusive_ptr<Mailbox>;
class Mutex;
+class NetZone;
class Storage;
+XBT_PUBLIC(void) intrusive_ptr_release(Comm* c);
+XBT_PUBLIC(void) intrusive_ptr_add_ref(Comm* c);
}
}
/* Process creation/destruction callbacks */
typedef void (*void_pfn_smxprocess_t) (smx_actor_t);
-/* for auto-restart function */
-typedef void (*void_pfn_sghost_t) (sg_host_t);
extern int smx_context_stack_size;
extern int smx_context_stack_size_was_set;
XBT_PUBLIC(int) SIMIX_comm_has_send_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
XBT_PUBLIC(int) SIMIX_comm_has_recv_match(smx_mailbox_t mbox, int (*match_fun)(void*, void*), void* data);
XBT_PUBLIC(void) SIMIX_comm_finish(smx_activity_t synchro);
-XBT_PUBLIC(smx_activity_t) SIMIX_comm_ref(smx_activity_t comm);
-XBT_PUBLIC(void) SIMIX_comm_unref(smx_activity_t comm);
/******************************************************************************/
/* SIMIX simcalls */
#include <stdarg.h>
#include <xbt/dynar.h>
-SG_BEGIN_DECL()
-
/** @addtogroup XBT_config
* @brief Changing the configuration of SimGrid components (grounding feature)
*
typedef void* xbt_cfg_t;
#endif
+SG_BEGIN_DECL()
+
XBT_PUBLIC(void) xbt_cfg_set_parse(const char *options);
/* Set the value of the cell \a name in \a cfg with the provided value.*/
MSG_vm_set_bound(vm, bound);
}
-JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jvm, jobject jhost, jstring jname,
- jint jramsize, jint jmig_netspeed, jint jdp_intensity)
+JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jVm, jobject jHost, jstring jname,
+ jint coreAmount, jint jramsize, jint jmig_netspeed,
+ jint jdp_intensity)
{
- msg_host_t host = jhost_get_native(env, jhost);
+ msg_host_t host = jhost_get_native(env, jHost);
const char* name = env->GetStringUTFChars(jname, 0);
- msg_vm_t vm = MSG_vm_create(host, name, static_cast<int>(jramsize), static_cast<int>(jmig_netspeed),
- static_cast<int>(jdp_intensity));
+ msg_vm_t vm = MSG_vm_create(host, name, static_cast<int>(coreAmount), static_cast<int>(jramsize),
+ static_cast<int>(jmig_netspeed), static_cast<int>(jdp_intensity));
env->ReleaseStringUTFChars(jname, name);
- jvm_bind(env, jvm, vm);
- jvm = env->NewWeakGlobalRef(jvm);
+ jvm_bind(env, jVm, vm);
+ jVm = env->NewWeakGlobalRef(jVm);
// We use the extension level of the host, even if that's somehow disturbing
- vm->extension_set(JAVA_HOST_LEVEL, (void*)jvm);
+ vm->extension_set(JAVA_HOST_LEVEL, (void*)jVm);
}
JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg)
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_setBound(JNIEnv* env, jobject jvm, jdouble bound);
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jvm, jobject jhost, jstring jname,
- jint jramsize, jint dprate, jint mig_netspeed);
+ jint coreAmount, jint jramsize, jint dprate, jint mig_netspeed);
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_VM_getVMByName(JNIEnv* env, jclass cls, jstring jname);
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_nativeFinalize(JNIEnv* env, jobject jvm);
JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_start(JNIEnv* env, jobject jvm);
// No need to declare a new bind variable: we use the one inherited from the super class Host
private Host currentHost;
+ private int coreAmount = 1;
/** Create a `basic' VM (i.e. 1GB of RAM, other values are not taken into account). */
public VM(Host host, String name) {
- this(host,name,1024, 0, 0);
+ this(host,name, /*coreAmount*/1, 1024, 0, 0);
+ }
+
+ public VM(Host host, String name, int coreAmount) {
+ this(host,name, coreAmount, 1024, 0, 0);
+ }
+ public VM(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity){
+ this(host, name, /*coreAmount*/1, ramSize, migNetSpeed, dpIntensity);
}
/**
* @param migNetSpeed (network bandwith allocated for migrations in MB/s, if you don't know put zero ;))
* @param dpIntensity (dirty page percentage according to migNetSpeed, [0-100], if you don't know put zero ;))
*/
- public VM(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity){
+ public VM(Host host, String name, int coreAmount, int ramSize, int migNetSpeed, int dpIntensity){
super();
super.name = name;
this.currentHost = host;
- create(host, name, ramSize, migNetSpeed, dpIntensity);
+ this.coreAmount = coreAmount;
+ create(host, name, coreAmount, ramSize, migNetSpeed, dpIntensity);
}
/** Retrieve the list of all existing VMs */
/** Returns whether the given VM is currently suspended */
public native int isSuspended();
+ /** Returns the amount of virtual CPUs provided */
+ public int getCoreAmount() {
+ return coreAmount;
+ }
+
/**
* Natively implemented method create the VM.
* @param ramSize size of the RAM that should be allocated (in MB)
* @param migNetSpeed (network bandwith allocated for migrations in MB/s, if you don't know put zero ;))
* @param dpIntensity (dirty page intensity, a percentage of migNetSpeed [0-100], if you don't know put zero ;))
*/
- private native void create(Host host, String name, int ramSize, int migNetSpeed, int dpIntensity);
+ private native void create(Host host, String name, int coreAmount, int ramSize, int migNetSpeed, int dpIntensity);
/**
void simgrid::kernel::activity::ActivityImpl::ref()
{
- refcount++;
+ // Atomic operation! Do not split in two instructions!
+ xbt_assert(refcount_ != 0);
+ refcount_++;
}
-bool simgrid::kernel::activity::ActivityImpl::unref()
+void simgrid::kernel::activity::ActivityImpl::unref()
{
- xbt_assert(refcount > 0,
- "This activity has a negative refcount! You can only call test() or wait() once per activity.");
-
- refcount--;
- if (refcount>0)
- return false;
- delete this;
-
- return true;
+ xbt_assert(refcount_ > 0,
+ "This activity has a negative refcount! You can only call test() or wait() once per activity.");
+ refcount_--;
+ if (refcount_ == 0)
+ delete this;
}
// boost::intrusive_ptr<Activity> support:
friend void intrusive_ptr_add_ref(ActivityImpl * activity)
{
- // Atomic operation! Do not split in two instructions!
- auto previous = (activity->refcount_)++;
- xbt_assert(previous != 0);
- (void)previous;
+ activity->ref();
}
friend void intrusive_ptr_release(ActivityImpl * activity)
{
- // Atomic operation! Do not split in two instructions!
- auto count = --(activity->refcount_);
- if (count == 0)
- delete activity;
+ activity->unref();
}
- /** @brief Increase the refcount */
+ /** @brief Increases the refcount */
void ref();
- /** @brief Reduce the refcount; returns true if the object was destroyed */
- bool unref();
+ /** @brief Reduces the refcount */
+ void unref();
private:
std::atomic_int_fast32_t refcount_{1};
- int refcount = 1;
};
}}} // namespace simgrid::kernel::activity
if (state == SIMIX_WAITING) {
mbox->remove(this);
state = SIMIX_CANCELED;
- SIMIX_comm_unref(this);
+ this->unref();
} else if (not MC_is_active() /* when running the MC there are no surf actions */
&& not MC_record_replay_is_active() && (state == SIMIX_READY || state == SIMIX_RUNNING)) {
/* if there are simcalls associated with the synchro, then answer them */
if (not simcalls.empty()) {
SIMIX_comm_finish(this);
- SIMIX_comm_unref(this);
+ this->unref();
}
}
simcall_comm_recv(MSG_process_self()->getImpl(), mailbox->getImpl(), task, nullptr, nullptr, nullptr, nullptr, timeout, rate);
XBT_DEBUG("Got task %s from %s",(*task)->name,mailbox->name());
(*task)->simdata->setNotUsed();
- SIMIX_comm_unref((*task)->simdata->comm);
}
catch (xbt_ex& e) {
switch (e.category) {
if (finished && comm->task_received != nullptr) {
/* I am the receiver */
(*comm->task_received)->simdata->setNotUsed();
- SIMIX_comm_unref(comm->s_comm);
+ comm->s_comm->unref();
}
}
catch (xbt_ex& e) {
if (status == MSG_OK && comm->task_received != nullptr) {
/* I am the receiver */
(*comm->task_received)->simdata->setNotUsed();
- SIMIX_comm_unref(comm->s_comm);
+ comm->s_comm->unref();
}
}
{
try {
simcall_comm_wait(comm->s_comm, timeout);
- SIMIX_comm_unref(comm->s_comm);
+ comm->s_comm->unref();
if (comm->task_received != nullptr) {
/* I am the receiver */
if (comm->task_received != nullptr) {
/* I am the receiver */
(*comm->task_received)->simdata->setNotUsed();
- SIMIX_comm_unref(comm->s_comm);
+ comm->s_comm->unref();
}
return finished_index;
simcall_set_category(comm, task->category);
t_simdata->comm = static_cast<simgrid::kernel::activity::CommImpl*>(comm);
simcall_comm_wait(comm, timeout);
- SIMIX_comm_unref(comm);
+ comm->unref();
}
catch (xbt_ex& e) {
switch (e.category) {
if (not comm)
return -1;
- return MSG_process_get_PID( static_cast<msg_task_t>(comm->src_data)->simdata->sender );
+ return MSG_process_get_PID(static_cast<msg_task_t>(comm->src_buff)->simdata->sender);
}
/** \ingroup msg_task_usage
/* **** Check state of a VM **** */
static inline int __MSG_vm_is_state(msg_vm_t vm, e_surf_vm_state_t state)
{
- return static_cast<simgrid::s4u::VirtualMachine*>(vm)->pimpl_vm_->getState() == state;
+ simgrid::s4u::VirtualMachine* castedVm = static_cast<simgrid::s4u::VirtualMachine*>(vm);
+ return castedVm->pimpl_vm_ != nullptr && castedVm->pimpl_vm_->getState() == state;
}
/** @brief Returns whether the given VM has just created, not running.
* @ingroup msg_VMs*
* @param pm Physical machine that will host the VM
* @param name Must be unique
+ * @param coreAmount Must be >= 1
* @param ramsize [TODO]
* @param mig_netspeed Amount of Mbyte/s allocated to the migration (cannot be larger than net_cap). Use 0 if unsure.
* @param dp_intensity Dirty page percentage according to migNetSpeed, [0-100]. Use 0 if unsure.
*/
-msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int ramsize, int mig_netspeed, int dp_intensity)
+msg_vm_t MSG_vm_create(msg_host_t pm, const char* name, int coreAmount, int ramsize, int mig_netspeed, int dp_intensity)
{
simgrid::vm::VmHostExt::ensureVmExtInstalled();
double host_speed = MSG_host_get_speed(pm);
double update_speed = (static_cast<double>(dp_intensity)/100) * mig_netspeed;
- msg_vm_t vm = MSG_vm_create_core(pm, name);
+ msg_vm_t vm = MSG_vm_create_multicore(pm, name, coreAmount);
s_vm_params_t params;
memset(¶ms, 0, sizeof(params));
params.ramsize = static_cast<sg_size_t>(ramsize) * 1024 * 1024;
return vm;
}
-/** @brief Create a new VM object. The VM is not yet started. The resource of the VM is allocated upon MSG_vm_start().
+/** @brief Create a new VM object with the default parameters
* @ingroup msg_VMs*
*
* A VM is treated as a host. The name of the VM must be unique among all hosts.
xbt_assert(sg_host_by_name(name) == nullptr,
"Cannot create a VM named %s: this name is already used by an host or a VM", name);
- return new simgrid::s4u::VirtualMachine(name, pm);
+ return new simgrid::s4u::VirtualMachine(name, pm, 1);
+}
+/** @brief Create a new VM object with the default parameters, but with a specified amount of cores
+ * @ingroup msg_VMs*
+ *
+ * A VM is treated as a host. The name of the VM must be unique among all hosts.
+ */
+msg_vm_t MSG_vm_create_multicore(msg_host_t pm, const char* name, int coreAmount)
+{
+ xbt_assert(sg_host_by_name(name) == nullptr,
+ "Cannot create a VM named %s: this name is already used by an host or a VM", name);
+
+ return new simgrid::s4u::VirtualMachine(name, pm, coreAmount);
}
/** @brief Destroy a VM. Destroy the VM object from the simulation.
if (MSG_vm_is_running(vm))
MSG_vm_shutdown(vm);
- xbt_assert(MSG_vm_is_created(vm) || __MSG_vm_is_state(vm, SURF_VM_STATE_DESTROYED),
- "shutdown the given VM before destroying it");
-
/* Then, destroy the VM object */
simgrid::simix::kernelImmediate([vm]() {
vm->destroy();
/** @brief Start a vm (i.e., boot the guest operating system)
* @ingroup msg_VMs
*
- * If the VM cannot be started (because of memory overprovisionning), an exception is generated.
+ * If the VM cannot be started (because of memory over-provisioning), an exception is generated.
*/
void MSG_vm_start(msg_vm_t vm)
{
std::deque<s4u::VirtualMachine*> VirtualMachineImpl::allVms_;
/* In the real world, processes on the guest operating system will be somewhat degraded due to virtualization overhead.
- * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system. */
+ * The total CPU share these processes get is smaller than that of the VM process gets on a host operating system.
+ * FIXME: add a configuration flag for this
+ */
// const double virt_overhead = 0.95;
const double virt_overhead = 1;
*
* Equation 1 was solved in the physical machine layer.
* Equation 2 is solved in the virtual machine layer (here).
- * X1 must be passed to the virtual machine laye as a constraint value.
+ * X1 must be passed to the virtual machine layer as a constraint value.
**/
/* iterate for all virtual machines */
surf::Cpu* cpu = ws_vm->pimpl_cpu;
xbt_assert(cpu, "cpu-less host");
- double solved_value = ws_vm->pimpl_vm_->action_->getVariable()->value;
+ double solved_value = ws_vm->pimpl_vm_->action_->getVariable()
+ ->value; // this is X1 in comment above, what this VM got in the sharing on the PM
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws_vm->cname(), ws_vm->pimpl_vm_->getPm()->cname());
// TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
}
/* 2. Calculate resource share at the virtual machine layer. */
- adjustWeightOfDummyCpuActions();
+ ignoreEmptyVmInPmLMM();
- /* 3. Ready. Get the next occuring event */
+ /* 3. Ready. Get the next occurring event */
return surf_cpu_model_vm->nextOccuringEvent(now);
}
* Resource *
************/
-VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM)
- : HostImpl(piface), hostPM_(host_PM)
+VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM,
+ int coreAmount)
+ : HostImpl(piface), hostPM_(host_PM), coreAmount_(coreAmount)
{
/* Register this VM to the list of all VMs */
allVms_.push_back(piface);
/* We create cpu_action corresponding to a VM process on the host operating system. */
/* TODO: we have to periodically input GUESTOS_NOISE to the system? how ? */
- action_ = host_PM->pimpl_cpu->execution_start(0);
+ action_ = host_PM->pimpl_cpu->execution_start(0, coreAmount);
/* Initialize the VM parameters */
params_.ramsize = 0;
case SURF_VM_STATE_DESTROYED:
stateName = "destroyed";
break;
- case SURF_VM_STATE_RUNNING:
+ default: /* SURF_VM_STATE_RUNNING or unexpected values */
THROW_IMPOSSIBLE;
break;
}
/* Update vcpu's action for the new pm */
/* create a cpu action bound to the pm model at the destination. */
- surf::CpuAction* new_cpu_action = static_cast<surf::CpuAction*>(destination->pimpl_cpu->execution_start(0));
+ surf::CpuAction* new_cpu_action =
+ static_cast<surf::CpuAction*>(destination->pimpl_cpu->execution_start(0, this->coreAmount_));
if (action_->getRemainsNoUpdate() > 0)
XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->getRemainsNoUpdate());
friend simgrid::s4u::VirtualMachine;
public:
- explicit VirtualMachineImpl(s4u::VirtualMachine* piface, s4u::Host* host);
+ explicit VirtualMachineImpl(s4u::VirtualMachine * piface, s4u::Host * host, int coreAmount);
~VirtualMachineImpl();
/** @brief Suspend the VM */
private:
s_vm_params_t params_;
+ int coreAmount_;
protected:
e_surf_vm_state_t vmState_ = SURF_VM_STATE_CREATED;
*/
class VMModel : public surf::HostModel {
public:
- void adjustWeightOfDummyCpuActions() override{};
+ void ignoreEmptyVmInPmLMM() override{};
double nextOccuringEvent(double now) override;
void updateActionsState(double /*now*/, double /*delta*/) override{};
namespace simgrid {
namespace s4u {
-VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm) : Host(name)
+VirtualMachine::VirtualMachine(const char* name, s4u::Host* pm, int coreAmount)
+ : Host(name), pimpl_vm_(new vm::VirtualMachineImpl(this, pm, coreAmount))
{
XBT_DEBUG("Create VM %s", name);
- pimpl_vm_ = new vm::VirtualMachineImpl(this, pm);
/* Currently, a VM uses the network resource of its physical host */
pimpl_netpoint = pm->pimpl_netpoint;
// Create a VCPU for this VM
bool VirtualMachine::isMigrating()
{
- return pimpl_vm_->isMigrating;
+ return pimpl_vm_ && pimpl_vm_->isMigrating;
}
double VirtualMachine::getRamsize()
{
xbt_backtrace_display_current();
}
if (pimpl_)
- SIMIX_comm_unref(pimpl_);
+ pimpl_->unref();
}
s4u::CommPtr Comm::send_init(s4u::MailboxPtr chan)
if (comm->detached)
XBT_DEBUG("Don't destroy it since it's a detached comm and I'm the sender");
else
- SIMIX_comm_unref(comm);
+ comm->unref();
} else if (comm->dst_proc == process) {
XBT_DEBUG("Found an unfinished recv comm %p, state %d, src = %p, dst = %p",
comm, (int)comm->state, comm->src_proc, comm->dst_proc);
/* the comm will be freed right now, remove it from the sender */
comm->src_proc->comms.remove(comm);
}
- // SIMIX_comm_unref(comm);
} else {
xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro);
}
auto i = boost::range::find(process->waiting_synchro->simcalls, &process->simcall);
if (i != process->waiting_synchro->simcalls.end())
process->waiting_synchro->simcalls.remove(&process->simcall);
- SIMIX_comm_unref(comm);
+ comm->unref();
} else if (sleep != nullptr) {
SIMIX_process_sleep_destroy(process->waiting_synchro);
XBT_DEBUG("Found a matching communication synchro %p", comm);
if (remove_matching)
deque->erase(it);
- SIMIX_comm_ref(comm);
+ comm->ref();
#if SIMGRID_HAVE_MC
comm->mbox_cpy = comm->mbox;
#endif
//this mailbox is for small messages, which have to be sent right now
other_comm->state = SIMIX_READY;
other_comm->dst_proc=mbox->permanent_receiver.get();
- other_comm = static_cast<simgrid::kernel::activity::CommImpl*>(SIMIX_comm_ref(other_comm));
+ other_comm->ref();
mbox->done_comm_queue.push_back(other_comm);
- XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, &(other_comm));
+ XBT_DEBUG("pushing a message into the permanent receive list %p, comm %p", mbox, other_comm);
}else{
mbox->push(this_comm);
}
} else {
XBT_DEBUG("Receive already pushed");
- SIMIX_comm_unref(this_comm);
+ this_comm->unref();
+ this_comm->unref();
other_comm->state = SIMIX_READY;
other_comm->type = SIMIX_COMM_READY;
//communication already done, get it inside the list of completed comms
if (mbox->permanent_receiver != nullptr && not mbox->done_comm_queue.empty()) {
+ this_synchro->unref();
XBT_DEBUG("We have a comm that has probably already been received, trying to match it, to skip the communication");
//find a match in the list of already received comms
other_comm = _find_matching_comm(&mbox->done_comm_queue, SIMIX_COMM_SEND, match_fun, data, this_synchro,
other_comm->state = SIMIX_DONE;
other_comm->type = SIMIX_COMM_DONE;
other_comm->mbox = nullptr;
+ other_comm->unref();
}
- SIMIX_comm_unref(other_comm);
- SIMIX_comm_unref(this_synchro);
+ other_comm->unref();
+ this_synchro->unref();
}
} else {
/* Prepare a comm describing us, so that it gets passed to the user-provided filter of other side */
other_comm->state = SIMIX_READY;
other_comm->type = SIMIX_COMM_READY;
- SIMIX_comm_unref(this_synchro);
- SIMIX_comm_unref(this_synchro);
+ this_synchro->unref();
+ this_synchro->unref();
}
dst_proc->comms.push_back(other_comm);
}
}
if(other_synchro)
- SIMIX_comm_unref(other_synchro);
+ other_synchro->unref();
- SIMIX_comm_unref(this_comm);
+ this_comm->unref();
return other_synchro;
}
/* (this function might be called from both communication ends) */
comm->copied = 1;
}
-
-/** Increase the refcount for this comm */
-smx_activity_t SIMIX_comm_ref(smx_activity_t comm)
-{
- if (comm != nullptr)
- intrusive_ptr_add_ref(comm);
- return comm;
-}
-
-/** Decrease the refcount for this comm */
-void SIMIX_comm_unref(smx_activity_t comm)
-{
- if (comm != nullptr)
- intrusive_ptr_release(comm);
-}
friend void intrusive_ptr_add_ref(MutexImpl* mutex)
{
// Atomic operation! Do not split in two instructions!
- auto previous = (mutex->refcount_)++;
+ XBT_ATTRIB_UNUSED auto previous = (mutex->refcount_)++;
xbt_assert(previous != 0);
- (void) previous;
}
friend void intrusive_ptr_release(MutexImpl* mutex)
{
* constraint (capacity) of the VM in the PM layer. If the VM does not have any
* active task, the dummy CPU action must be deactivated, so that the VM does
* not get any CPU share in the PM layer. */
-void HostModel::adjustWeightOfDummyCpuActions()
+void HostModel::ignoreEmptyVmInPmLMM()
{
/* iterate for all virtual machines */
for (s4u::VirtualMachine* ws_vm : vm::VirtualMachineImpl::allVms_) {
/* some tasks exist on this VM */
XBT_DEBUG("set the weight of the dummy CPU action on PM to 1");
- /* FIXME: we should use lmm_update_variable_weight() ? */
/* FIXME: If we assign 1.05 and 0.05, the system makes apparently wrong values. */
ws_vm->pimpl_vm_->action_->setPriority(1);
} else {
- /* no task exits on this VM */
+ /* no task exist on this VM */
XBT_DEBUG("set the weight of the dummy CPU action on PM to 0");
ws_vm->pimpl_vm_->action_->setPriority(0);
public:
HostModel() : Model() {}
- virtual void adjustWeightOfDummyCpuActions();
+ virtual void ignoreEmptyVmInPmLMM();
virtual Action* executeParallelTask(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount,
double rate);
};
while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
- lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
+ lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(),
+ action->requestedCore() * speed_.scale * speed_.peak);
}
Cpu::onSpeedChange();
}
}
+/** @brief Start a new execution on this CPU lasting @size flops and using one core */
CpuAction *CpuCas01::execution_start(double size)
{
return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint());
}
+CpuAction* CpuCas01::execution_start(double size, int requestedCores)
+{
+ return new CpuCas01Action(model(), size, isOff(), speed_.scale * speed_.peak, constraint(), requestedCores);
+}
CpuAction *CpuCas01::sleep(double duration)
{
/**********
* Action *
**********/
-
-CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint)
- : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1))
+CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint,
+ int requestedCore)
+ : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, speed, 1))
+ , requestedCore_(requestedCore)
{
if (model->getUpdateMechanism() == UM_LAZY) {
indexHeap_ = -1;
lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0);
}
+CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint)
+ : CpuCas01Action(model, cost, failed, speed, constraint, 1)
+{
+}
+
+int CpuCas01Action::requestedCore()
+{
+ return requestedCore_;
+}
+
CpuCas01Action::~CpuCas01Action()=default;
}
~CpuCas01() override;
void apply_event(tmgr_trace_event_t event, double value) override;
CpuAction *execution_start(double size) override;
+ CpuAction* execution_start(double size, int requestedCore) override;
CpuAction *sleep(double duration) override;
bool isUsed() override;
friend CpuAction *CpuCas01::execution_start(double size);
friend CpuAction *CpuCas01::sleep(double duration);
public:
+ CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint, int coreAmount);
CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint);
~CpuCas01Action() override;
+ int requestedCore();
+
+private:
+ int requestedCore_ = 1;
};
}
*/
virtual simgrid::surf::Action *execution_start(double size)=0;
+ /**
+ * @brief Execute some quantity of computation on more than one core
+ *
+ * @param size The value of the processing amount (in flop) needed to process
+ * @param requestedCores The desired amount of cores. Must be >= 1
+ * @return The CpuAction corresponding to the processing
+ */
+ virtual simgrid::surf::Action* execution_start(double size, int requestedCores)
+ {
+ THROW_UNIMPLEMENTED;
+ return nullptr;
+ }
+
/**
* @brief Make a process sleep for duration (in seconds)
*
namespace surf {
double HostCLM03Model::nextOccuringEvent(double now){
- adjustWeightOfDummyCpuActions();
+ ignoreEmptyVmInPmLMM();
double min_by_cpu = surf_cpu_model_pm->nextOccuringEvent(now);
double min_by_net = surf_network_model->nextOccuringEventIsIdempotent() ? surf_network_model->nextOccuringEvent(now) : -1;
int LinkImpl::linksCount()
{
return links->size();
+ }
+ /** @brief Returns a list of all existing links */
+ LinkImpl** LinkImpl::linksList()
+ {
+ LinkImpl** res = xbt_new(LinkImpl*, (int)links->size());
+ int i = 0;
+ for (auto kv : *links) {
+ res[i] = kv.second;
+ i++;
}
- /** @brief Returns a list of all existing links */
- LinkImpl** LinkImpl::linksList()
- {
- LinkImpl** res = xbt_new(LinkImpl*, (int)links->size());
- int i = 0;
- for (auto kv : *links) {
- res[i] = kv.second;
- i++;
- }
- return res;
- }
- /** @brief destructor of the static data */
- void LinkImpl::linksExit()
- {
- for (auto kv : *links)
- (kv.second)->destroy();
- delete links;
- }
+ return res;
+ }
+ /** @brief destructor of the static data */
+ void LinkImpl::linksExit()
+ {
+ for (auto kv : *links)
+ (kv.second)->destroy();
+ delete links;
+ }
}
}
simgrid::kernel::routing::NetPoint::onCreation.connect([](simgrid::kernel::routing::NetPoint* pt) {
pt->extension_set<NetPointNs3>(new NetPointNs3());
-
+ XBT_VERB("SimGrid's %s is known as node %d within NS3", pt->cname(), pt->extension<NetPointNs3>()->node_num);
});
simgrid::surf::on_cluster.connect(&clusterCreation_cb);
simgrid::s4u::onPlatformCreated.connect(&postparse_cb);
std::list<LinkImpl*> NetworkNS3Action::links()
{
THROW_UNIMPLEMENTED;
+ return nullptr;
}
/* Test whether a flow is suspended */
double previous_energy = this->total_energy;
double instantaneous_consumption;
- if (host->isOff())
+ if (this->pstate == -1) // The host was off at the beginning of this time interval
instantaneous_consumption = this->watts_off;
else
instantaneous_consumption = this->getCurrentWattsValue(cpu_load);
this->total_energy = previous_energy + energy_this_step;
this->last_updated = finish_time;
- this->pstate = host->pstate();
+
XBT_DEBUG(
"[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
host->cname(), start_time, finish_time, host->pimpl_cpu->speed_.peak, previous_energy, energy_this_step);
+
+ /* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */
+ this->pstate = host->isOn() ? host->pstate() : -1;
}
HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host(ptr), last_updated(surf_get_clock())
Action* action = static_cast<Action*>(lmm_variable_id(var));
lmm_update_variable_bound(model()->getMaxminSystem(), action->getVariable(), speed_.scale * speed_.peak);
- }
+ }
Cpu::onSpeedChange();
}
xbt_free(dir);
surf_file_to_parse = surf_fopen(file, "r");
- xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", file);
+ xbt_assert(surf_file_to_parse != nullptr, "Unable to open '%s'\n", file);
surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
surf_parse__switch_to_buffer(surf_input_buffer);
surf_parse_lineno = 1;
# C examples
-foreach(x get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration)
+foreach(x cloud-sharing get_sender host_on_off host_on_off_recv host_on_off_processes trace_integration)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
endforeach()
# CPP examples
-foreach(x task_destroy_cancel)
+foreach(x task_destroy_cancel task_listen_from)
add_executable (${x} ${x}/${x}.cpp)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp1-c1s1-c3s2.xml
${CMAKE_CURRENT_SOURCE_DIR}/trace_integration/test-hbp2.5-hbp1.5.xml PARENT_SCOPE)
-foreach(x get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel trace_integration)
+foreach(x cloud-sharing get_sender host_on_off host_on_off_processes host_on_off_recv task_destroy_cancel task_listen_from trace_integration)
ADD_TESH_FACTORIES(tesh-msg-${x} "thread;boost;ucontext;raw" --setenv srcdir=${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x} --cd ${CMAKE_BINARY_DIR}/teshsuite/msg/${x} ${CMAKE_HOME_DIRECTORY}/teshsuite/msg/${x}/${x}.tesh)
endforeach()
--- /dev/null
+/* Copyright (c) 2007-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. */
+
+#include "simgrid/msg.h"
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int computation_fun(int argc, char* argv[])
+{
+ msg_task_t task = MSG_task_create("Task", 100000000, 0, NULL);
+
+ double clock_sta = MSG_get_clock();
+ MSG_task_execute(task);
+ double clock_end = MSG_get_clock();
+
+ XBT_INFO("Task took %gs to execute", clock_end - clock_sta);
+
+ MSG_task_destroy(task);
+
+ return 0;
+}
+
+static int master_main(int argc, char* argv[])
+{
+ msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
+ msg_host_t pm1 = MSG_host_by_name("node-1.acme.org");
+ xbt_assert(pm0, "Host node-0.acme.org does not seem to exist");
+
+ XBT_INFO("## Test 1 (started): check computation on normal PMs");
+
+ XBT_INFO("### Put a task on a PM");
+ MSG_process_create("compute", computation_fun, NULL, pm0);
+ MSG_process_sleep(2);
+
+ XBT_INFO("### Put two tasks on a PM");
+ MSG_process_create("compute", computation_fun, NULL, pm0);
+ MSG_process_create("compute", computation_fun, NULL, pm0);
+ MSG_process_sleep(2);
+
+ XBT_INFO("### Put a task on each PM");
+ MSG_process_create("compute", computation_fun, NULL, pm0);
+ MSG_process_create("compute", computation_fun, NULL, pm1);
+ MSG_process_sleep(2);
+
+ XBT_INFO("## Test 1 (ended)");
+
+ XBT_INFO("## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)");
+
+ XBT_INFO("### Put a VM on a PM, and put a task to the VM");
+ msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0");
+ MSG_vm_start(vm0);
+ MSG_process_create("compute", computation_fun, NULL, vm0);
+ MSG_process_sleep(2);
+ MSG_vm_destroy(vm0);
+
+ XBT_INFO("## Test 2 (ended)");
+
+ XBT_INFO(
+ "## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)");
+
+ XBT_INFO("### Put a VM on a PM, and put a task to the PM");
+ vm0 = MSG_vm_create_core(pm0, "VM0");
+ MSG_vm_start(vm0);
+ MSG_process_create("compute", computation_fun, NULL, pm0);
+ MSG_process_sleep(2);
+ MSG_vm_destroy(vm0);
+
+ XBT_INFO("## Test 3 (ended)");
+
+ XBT_INFO("## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for"
+ " the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1");
+
+ XBT_INFO("### Put two VMs on a PM, and put a task to each VM");
+ vm0 = MSG_vm_create_core(pm0, "VM0");
+ msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1");
+ MSG_vm_start(vm0);
+ MSG_vm_start(vm1);
+ MSG_process_create("compute", computation_fun, NULL, vm0);
+ MSG_process_create("compute", computation_fun, NULL, vm1);
+ MSG_process_sleep(2);
+ MSG_vm_destroy(vm0);
+ MSG_vm_destroy(vm1);
+
+ XBT_INFO("### Put a VM on each PM, and put a task to each VM");
+ vm0 = MSG_vm_create_core(pm0, "VM0");
+ vm1 = MSG_vm_create_core(pm1, "VM1");
+ MSG_vm_start(vm0);
+ MSG_vm_start(vm1);
+ MSG_process_create("compute", computation_fun, NULL, vm0);
+ MSG_process_create("compute", computation_fun, NULL, vm1);
+ MSG_process_sleep(2);
+ MSG_vm_destroy(vm0);
+ MSG_vm_destroy(vm1);
+ XBT_INFO("## Test 4 (ended)");
+
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ /* Get the arguments */
+ MSG_init(&argc, argv);
+
+ /* load the platform file */
+ const char* platform = "../../platforms/cluster.xml";
+ if (argc == 2)
+ platform = argv[1];
+ MSG_create_environment(platform);
+
+ msg_host_t pm0 = MSG_host_by_name("node-0.acme.org");
+ xbt_assert(pm0, "Host 'node-0.acme.org' not found");
+ MSG_process_create("master", master_main, NULL, pm0);
+
+ return MSG_main() != MSG_OK;
+}
--- /dev/null
+#! ./tesh
+
+$ $SG_TEST_EXENV ${bindir:=.}/cloud-sharing$EXEEXT --log=no_loc ${srcdir:=.}/../../../examples/platforms/cluster.xml
+> [node-0.acme.org:master:(1) 0.000000] [msg_test/INFO] ## Test 1 (started): check computation on normal PMs
+> [node-0.acme.org:master:(1) 0.000000] [msg_test/INFO] ### Put a task on a PM
+> [node-0.acme.org:compute:(2) 0.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 2.000000] [msg_test/INFO] ### Put two tasks on a PM
+> [node-0.acme.org:compute:(4) 2.200000] [msg_test/INFO] Task took 0.2s to execute
+> [node-0.acme.org:compute:(3) 2.200000] [msg_test/INFO] Task took 0.2s to execute
+> [node-0.acme.org:master:(1) 4.000000] [msg_test/INFO] ### Put a task on each PM
+> [node-0.acme.org:compute:(5) 4.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-1.acme.org:compute:(6) 4.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ## Test 1 (ended)
+> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ## Test 2 (started): check impact of running a task inside a VM (there is no degradation for the moment)
+> [node-0.acme.org:master:(1) 6.000000] [msg_test/INFO] ### Put a VM on a PM, and put a task to the VM
+> [VM0:compute:(7) 6.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ## Test 2 (ended)
+> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ## Test 3 (started): check impact of running a task collocated with a VM (there is no VM noise for the moment)
+> [node-0.acme.org:master:(1) 8.000000] [msg_test/INFO] ### Put a VM on a PM, and put a task to the PM
+> [node-0.acme.org:compute:(8) 8.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ## Test 3 (ended)
+> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ## Test 4 (started): compare the cost of running two tasks inside two different VMs collocated or not (for the moment, there is no degradation for the VMs. Hence, the time should be equals to the time of test 1
+> [node-0.acme.org:master:(1) 10.000000] [msg_test/INFO] ### Put two VMs on a PM, and put a task to each VM
+> [VM0:compute:(9) 10.200000] [msg_test/INFO] Task took 0.2s to execute
+> [VM1:compute:(10) 10.200000] [msg_test/INFO] Task took 0.2s to execute
+> [node-0.acme.org:master:(1) 12.000000] [msg_test/INFO] ### Put a VM on each PM, and put a task to each VM
+> [VM0:compute:(11) 12.100000] [msg_test/INFO] Task took 0.1s to execute
+> [VM1:compute:(12) 12.100000] [msg_test/INFO] Task took 0.1s to execute
+> [node-0.acme.org:master:(1) 14.000000] [msg_test/INFO] ## Test 4 (ended)
msg_vm_t vm0;
msg_process_t daemon;
- vm0 = MSG_vm_create(jupiter, "vm0", 2048, 125, dpRate);
+ vm0 = MSG_vm_create(jupiter, "vm0", 1, 2048, 125, dpRate);
MSG_vm_start(vm0);
argvF = xbt_new(char*, 2);
--- /dev/null
+/* Copyright (c) 2017. 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. */
+
+/* This is the test case of GitHub's #121 */
+
+#include "simgrid/msg.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example");
+
+static int tester(int argc, char* argv[])
+{
+ msg_task_t task = MSG_task_create("name", 0, 10, NULL);
+ msg_comm_t comm = MSG_task_isend(task, "mailbox");
+
+ XBT_INFO("MSG_task_listen_from returns() %d (should return my pid, which is %d)", MSG_task_listen_from("mailbox"),
+ MSG_process_get_PID(MSG_process_self()));
+ XBT_INFO("MSG_task_listen returns() %d (should return true, i.e. 1)", MSG_task_listen("mailbox"));
+
+ MSG_comm_destroy(comm);
+ MSG_task_destroy(task);
+
+ return 0;
+}
+
+int main(int argc, char* argv[])
+{
+ MSG_init(&argc, argv);
+ xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);
+ MSG_create_environment(argv[1]);
+
+ MSG_process_create("tester", tester, NULL, MSG_get_host_by_name("Tremblay"));
+
+ return MSG_main();
+}
--- /dev/null
+$ ./task_listen_from ${srcdir:=.}/../../../examples/platforms/small_platform.xml
+> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen_from returns() 1 (should return my pid, which is 1)
+> [Tremblay:tester:(1) 0.000000] [msg_test/INFO] MSG_task_listen returns() 1 (should return true, i.e. 1)
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_SO} ${JAVA_NATIVE_PATH}/${LIBSIMGRID_SO}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/lib/${LIBSIMGRID_JAVA_SO} ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO}
+ )
+
+if(WIN32)
+ add_custom_command(
+ TARGET simgrid-java_jar POST_BUILD
+ COMMENT "Add the windows-specific native libs into simgrid.jar..."
+ DEPENDS simgrid simgrid-java ${JAVALIBS}
+
# There is no way to disable the dependency of mingw-64 on that lib, unfortunately nor to script cmake -E properly
# So let's be brutal and copy it in any case (even on non-windows builds) from the location where chocolatey installs it.
# The copy is only expected to work on the appveyor builder, but that's all we need right now
# since our users are directed to download that file as nightly build.
COMMAND ${CMAKE_COMMAND} -E copy_if_different C:/tools/mingw64/bin/libwinpthread-1.dll ${JAVA_NATIVE_PATH}/libwinpthread-1.dll || true
+ )
+endif()
+
+if(APPLE)
+ add_custom_command(
+ TARGET simgrid-java_jar POST_BUILD
+ COMMENT "Add the apple-specific native libs into simgrid.jar..."
+ DEPENDS simgrid simgrid-java ${JAVALIBS}
+
+ # We need to fix the rpath of the simgrid-java library so that it
+ # searches the simgrid library in the right location
+ #
+ # Since we don't officially install the lib before copying it in
+ # the jarfile, the lib is searched for where it was built. Given
+ # how we unpack it, we need to instruct simgrid-java to forget
+ # about the build path, and search in its current directory
+ # instead.
+ #
+ # This has to be done with the classical Apple tools, as follows:
+
+ COMMAND install_name_tool -change ${CMAKE_BINARY_DIR}/lib/libsimgrid.${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}${CMAKE_SHARED_LIBRARY_SUFFIX} @loader_path/libsimgrid.dylib ${JAVA_NATIVE_PATH}/${LIBSIMGRID_JAVA_SO}
+ )
+endif()
+
+ add_custom_command(
+ TARGET simgrid-java_jar POST_BUILD
+ COMMENT "Packing back the simgrid.jar with the native libs..."
+ DEPENDS simgrid simgrid-java ${JAVALIBS}
COMMAND ${JAVA_ARCHIVE} -uvf ${SIMGRID_JAR} ${JAVA_NATIVE_PATH}
# See https://cmake.org/Wiki/CMake_RPATH_handling and Java.cmake
set(MACOSX_RPATH ON)
if(APPLE)
+ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # When installed, use system path
+ set(CMAKE_SKIP_BUILD_RPATH FALSE) # When executing from build tree, take the lib from the build path if exists
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # When executing from build tree, take the lib from the system path if exists
+
# add the current location of libsimgrid-java.dynlib as a location for libsimgrid.dynlib
# (useful when unpacking the native libraries from the jarfile)
- set(CMAKE_INSTALL_RPATH "@loader_path/.")
- SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+ set(CMAKE_INSTALL_RPATH "@loader_path/.;@rpath/.")
endif()
###############################
Memcheck:Addr8
fun:_Ux86_64_setcontext
}
+
+# Java cruft
+{
+ JavaCruft 1
+ Memcheck:Addr4
+ ...
+ fun:_ZN9JavaCalls11call_helperEP9JavaValueP12methodHandleP17JavaCallArgumentsP6Thread
+ fun:JVM_DoPrivileged
+ ...
+}
+{
+ JavaCruft 2
+ Memcheck:Cond
+ ...
+ fun:_ZN13CompileBroker25invoke_compiler_on_methodEP11CompileTask
+ ...
+}
+
+{
+ Somewhere within the Java conditions and monitors
+ Memcheck:Cond
+ fun:MarsagliaXORV
+ ...
+}