create();
joinSuccess = true;
} else {
- int knownId = Integer.valueOf(args[1]);
- deadline = Integer.valueOf(args[3]);
+ int knownId = Integer.parseInt(args[1]);
+ deadline = Integer.parseInt(args[3]);
Msg.debug("Hey! Let's join the system with the id " + id + ".");
joinSuccess = join(knownId);
}
catch (MsgException e) {
commReceive = null;
- stop = true;
}
}
catch (MsgException e) {
xbt_dynar_free(&hosts);
int res = MSG_main();
- XBT_INFO("Simulation time %g", MSG_get_clock());
+ XBT_INFO("Simulation time %.6f", MSG_get_clock());
return res != MSG_OK;
}
> [ 0.008326] (3:host@carl) Have written 110000 in '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'. Size now is: 110000
> [ 0.008326] (3:host@carl) Capacity of the storage element '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml' is stored on: 37020686 / 536870912000
> [ 0.008326] (3:host@carl) Close file '/home/doc/simgrid/examples/platforms/g5k_cabinets.xml'
-> [ 0.008326] (0:maestro@) Simulation time 0.00832645
+> [ 0.008326] (0:maestro@) Simulation time 0.008326
simgrid::s4u::Mailbox::byName(args[0])->put(payload, 1);
/* - ... then wait for the (large) pong */
- double sender_time =
- *(static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get()));
+ double* sender_time =
+ static_cast<double*>(simgrid::s4u::Mailbox::byName(simgrid::s4u::this_actor::getHost()->getName())->get());
- double communication_time = simgrid::s4u::Engine::getClock() - sender_time;
+ double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
XBT_INFO("Task received : large communication (bandwidth bound)");
XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time);
+ delete sender_time;
}
static void ponger(std::vector<std::string> args)
double communication_time = simgrid::s4u::Engine::getClock() - *sender_time;
XBT_INFO("Task received : small communication (latency bound)");
XBT_INFO(" Ping time (latency bound) %f", communication_time);
+ delete sender_time;
/* - ... Then send a 1GB pong back (bandwidth bound) */
double* payload = new double();
/** Simulates a write action. Returns the size of data actually written. */
sg_size_t write(sg_size_t size);
- sg_size_t write(sg_size_t size, sg_host_t host);
/** Allows to store user data on that host */
void setUserdata(void* data) { userdata_ = data; }
XBT_PUBLIC(int) simcall_sem_get_capacity(smx_sem_t sem);
/***************************** File **********************************/
-XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PUBLIC(sg_size_t) simcall_file_read(surf_file_t fd, sg_size_t size);
+XBT_PUBLIC(sg_size_t) simcall_file_write(surf_file_t fd, sg_size_t size);
/************************** MC simcalls **********************************/
XBT_PUBLIC(int) simcall_mc_random(int min, int max);
/* Actually build the MSG process */
jstring jname = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
const char* name = env->GetStringUTFChars(jname, 0);
- msg_process_t process = MSG_process_create_from_stdfunc(
- name, [jprocess]() -> void { simgrid::kernel::context::java_main_jprocess(jprocess); },
- /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
+ msg_process_t process =
+ MSG_process_create_from_stdfunc(name, [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); },
+ /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
env->ReleaseStringUTFChars(jname, name);
/* bind the java process instance to the native process */
/* Create file on remote host, write it and close it */
msg_file_t fd = new simgrid::s4u::File(fullpath, dst_host, nullptr);
- fd->write(read_size, dst_host);
+ fd->write(read_size);
delete fd;
return MSG_OK;
}
sg_size_t File::read(sg_size_t size)
{
- return simcall_file_read(pimpl_, size, Host::current());
+ return simcall_file_read(pimpl_, size);
}
sg_size_t File::write(sg_size_t size)
{
- return simcall_file_write(pimpl_,size, Host::current());
-}
-
-sg_size_t File::write(sg_size_t size, sg_host_t host)
-{
- return simcall_file_write(pimpl_, size, host);
+ return simcall_file_write(pimpl_, size);
}
sg_size_t File::size()
* \ingroup simix_file_management
*
*/
-sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size, sg_host_t host)
+sg_size_t simcall_file_read(surf_file_t fd, sg_size_t size)
{
- return simcall_BODY_file_read(fd, size, host);
+ return simcall_BODY_file_read(fd, size);
}
/**
* \ingroup simix_file_management
*
*/
-sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size, sg_host_t host)
+sg_size_t simcall_file_write(surf_file_t fd, sg_size_t size)
{
- return simcall_BODY_file_write(fd, size, host);
+ return simcall_BODY_file_write(fd, size);
}
void simcall_run_kernel(std::function<void()> const& code)
{
simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
}
-static inline sg_host_t simcall_file_read__get__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]);
-}
-static inline sg_host_t simcall_file_read__getraw__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[2]);
-}
-static inline void simcall_file_read__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
- simgrid::simix::marshal<sg_host_t>(simcall->args[2], arg);
-}
static inline sg_size_t simcall_file_read__get__result(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
{
simgrid::simix::marshal<sg_size_t>(simcall->args[1], arg);
}
-static inline sg_host_t simcall_file_write__get__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]);
-}
-static inline sg_host_t simcall_file_write__getraw__host(smx_simcall_t simcall)
-{
- return simgrid::simix::unmarshal_raw<sg_host_t>(simcall->args[2]);
-}
-static inline void simcall_file_write__set__host(smx_simcall_t simcall, sg_host_t arg)
-{
- simgrid::simix::marshal<sg_host_t>(simcall->args[2], arg);
-}
static inline sg_size_t simcall_file_write__get__result(smx_simcall_t simcall)
{
return simgrid::simix::unmarshal<sg_size_t>(simcall->result);
XBT_PRIVATE void simcall_HANDLER_sem_acquire(smx_simcall_t simcall, smx_sem_t sem);
XBT_PRIVATE void simcall_HANDLER_sem_acquire_timeout(smx_simcall_t simcall, smx_sem_t sem, double timeout);
XBT_PRIVATE int simcall_HANDLER_sem_get_capacity(smx_simcall_t simcall, smx_sem_t sem);
-XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PRIVATE void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
+XBT_PRIVATE void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size);
XBT_PRIVATE int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max);
\ No newline at end of file
return simcall<int, smx_sem_t>(SIMCALL_SEM_GET_CAPACITY, sem);
}
- inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size, sg_host_t host)
+ inline static sg_size_t simcall_BODY_file_read(surf_file_t fd, sg_size_t size)
{
/* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size, host);
- return simcall<sg_size_t, surf_file_t, sg_size_t, sg_host_t>(SIMCALL_FILE_READ, fd, size, host);
+ if (0)
+ simcall_HANDLER_file_read(&SIMIX_process_self()->simcall, fd, size);
+ return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_READ, fd, size);
}
- inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size, sg_host_t host)
+ inline static sg_size_t simcall_BODY_file_write(surf_file_t fd, sg_size_t size)
{
/* Go to that function to follow the code flow through the simcall barrier */
- if (0) simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size, host);
- return simcall<sg_size_t, surf_file_t, sg_size_t, sg_host_t>(SIMCALL_FILE_WRITE, fd, size, host);
+ if (0)
+ simcall_HANDLER_file_write(&SIMIX_process_self()->simcall, fd, size);
+ return simcall<sg_size_t, surf_file_t, sg_size_t>(SIMCALL_FILE_WRITE, fd, size);
}
inline static int simcall_BODY_mc_random(int min, int max) {
case SIMCALL_FILE_READ:
simcall_HANDLER_file_read(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
- simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]),
- simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]));
+ simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
break;
case SIMCALL_FILE_WRITE:
simcall_HANDLER_file_write(simcall, simgrid::simix::unmarshal<surf_file_t>(simcall->args[0]),
- simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]),
- simgrid::simix::unmarshal<sg_host_t>(simcall->args[2]));
+ simgrid::simix::unmarshal<sg_size_t>(simcall->args[1]));
break;
case SIMCALL_MC_RANDOM:
void sem_acquire_timeout(smx_sem_t sem, double timeout) [[block]];
int sem_get_capacity(smx_sem_t sem);
-sg_size_t file_read(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
-sg_size_t file_write(surf_file_t fd, sg_size_t size, sg_host_t host) [[block]];
+sg_size_t file_read(surf_file_t fd, sg_size_t size) [[block]];
+sg_size_t file_write(surf_file_t fd, sg_size_t size) [[block]];
int mc_random(int min, int max);
void set_category(boost::intrusive_ptr<simgrid::kernel::activity::ActivityImpl> synchro, const char* category) [[nohandler]];
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
//SIMIX FILE READ
-void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host)
+void simcall_HANDLER_file_read(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
{
- smx_activity_t synchro = SIMIX_file_read(fd, size, host);
+ smx_activity_t synchro = SIMIX_file_read(fd, size);
synchro->simcalls.push_back(simcall);
simcall->issuer->waiting_synchro = synchro;
}
-smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size, sg_host_t host)
+smx_activity_t SIMIX_file_read(surf_file_t file, sg_size_t size)
{
- /* check if the host is active */
- if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->getCname());
-
simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
synchro->surf_io = file->read(size);
}
//SIMIX FILE WRITE
-void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size, sg_host_t host)
+void simcall_HANDLER_file_write(smx_simcall_t simcall, surf_file_t fd, sg_size_t size)
{
- smx_activity_t synchro = SIMIX_file_write(fd, size, host);
+ smx_activity_t synchro = SIMIX_file_write(fd, size);
synchro->simcalls.push_back(simcall);
simcall->issuer->waiting_synchro = synchro;
}
-smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size, sg_host_t host)
+smx_activity_t SIMIX_file_write(surf_file_t file, sg_size_t size)
{
- if (host->isOff())
- THROWF(host_error, 0, "Host %s failed, you cannot call this function", host->getCname());
-
simgrid::kernel::activity::IoImpl* synchro = new simgrid::kernel::activity::IoImpl();
synchro->surf_io = file->write(size);
synchro->surf_io->setData(synchro);
#include "simgrid/simix.h"
#include "popping_private.h"
-XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size, sg_host_t host);
-XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size, sg_host_t host);
+XBT_PRIVATE smx_activity_t SIMIX_file_read(surf_file_t fd, sg_size_t size);
+XBT_PRIVATE smx_activity_t SIMIX_file_write(surf_file_t fd, sg_size_t size);
XBT_PRIVATE void SIMIX_io_destroy(smx_activity_t synchro);
XBT_PRIVATE void SIMIX_io_finish(smx_activity_t synchro);
/**********
* Action *
**********/
-StorageAction::StorageAction(Model* model, double cost, bool failed, StorageImpl* storage,
- e_surf_action_storage_type_t type)
- : Action(model, cost, failed), type_(type), storage_(storage), file_(nullptr)
-{
- progress_ = 0;
-};
-
-StorageAction::StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage,
- e_surf_action_storage_type_t type)
- : Action(model, cost, failed, var), type_(type), storage_(storage), file_(nullptr)
-{
- progress_ = 0;
-}
-
void StorageAction::setState(Action::State state)
{
Action::State old = getState();
* @param storage The Storage associated to this StorageAction
* @param type [description]
*/
- StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type);
+ StorageAction(Model* model, double cost, bool failed, StorageImpl* storage, e_surf_action_storage_type_t type)
+ : Action(model, cost, failed), type_(type), storage_(storage){};
/**
* @brief StorageAction constructor
* @param type [description]
*/
StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage,
- e_surf_action_storage_type_t type);
+ e_surf_action_storage_type_t type)
+ : Action(model, cost, failed, var), type_(type), storage_(storage){};
void setState(simgrid::surf::Action::State state) override;
e_surf_action_storage_type_t type_;
StorageImpl* storage_;
- FileImpl* file_;
- double progress_;
+ FileImpl* file_ = nullptr;
};
}
}
StorageAction *action = static_cast<StorageAction*>(&*it);
- if (action->type_ == WRITE) {
- // Update the disk usage
- // Update the file size
- // For each action of type write
- double current_progress = delta * lmm_variable_getvalue(action->getVariable());
- long int incr = current_progress;
-
- XBT_DEBUG("%s:\n\t progress = %.2f, current_progress = %.2f, incr = %ld, lrint(1) = %ld, lrint(2) = %ld",
- action->file_->cname(), action->progress_, current_progress, incr,
- lrint(action->progress_ + current_progress), lrint(action->progress_) + incr);
-
- /* take care of rounding error accumulation */
- if (lrint(action->progress_ + current_progress) > lrint(action->progress_) + incr)
- incr++;
+ double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
- action->progress_ += current_progress;
-
- action->storage_->usedSize_ += incr; // disk usage
- action->file_->incrPosition(incr); // current_position
- // which becomes the new file size
+ action->updateRemains(current_progress);
+ if (action->type_ == WRITE) {
+ action->storage_->usedSize_ += current_progress;
+ action->file_->incrPosition(current_progress);
action->file_->setSize(action->file_->tell());
action->storage_->getContent()->erase(action->file_->cname());
action->storage_->getContent()->insert({action->file_->cname(), action->file_->size()});
}
- action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
-
if (action->getMaxDuration() > NO_MAX_DURATION)
action->updateMaxDuration(delta);
StorageN11(StorageModel* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
const char* type_id, char* content_name, sg_size_t size, char* attach);
virtual ~StorageN11() = default;
- StorageAction *open(const char* mount, const char* path);
- StorageAction *ls(const char *path);
StorageAction* read(sg_size_t size);
StorageAction* write(sg_size_t size);
- void rename(const char *src, const char *dest);
};
/**********
/* Return memory to the heap. */
void mfree(struct mdesc *mdp, void *ptr)
{
- int type;
- size_t block, frag_nb;
+ size_t frag_nb;
size_t i;
int it;
if (ptr == NULL)
return;
- block = BLOCK(ptr);
+ size_t block = BLOCK(ptr);
if ((char *) ptr < (char *) mdp->heapbase || block > mdp->heapsize) {
fprintf(stderr,"Ouch, this pointer is not mine, I refuse to free it. Give me valid pointers, or give me death!!\n");
abort();
}
- type = mdp->heapinfo[block].type;
+ int type = mdp->heapinfo[block].type;
switch (type) {
case MMALLOC_TYPE_HEAPINFO:
mdp -> heapstats.bytes_free +=
mdp -> heapinfo[block].busy_block.size * BLOCKSIZE;
- if(MC_is_active()){
- if(mdp->heapinfo[block].busy_block.ignore > 0)
- MC_remove_ignore_heap(ptr, mdp -> heapinfo[block].busy_block.busy_size);
- }
+ if (MC_is_active() && mdp->heapinfo[block].busy_block.ignore > 0)
+ MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_block.busy_size);
/* Find the free cluster previous to this one in the free list.
Start searching at the last block referenced; this may benefit
THROWF(system_error, 0, "Asked to free a fragment that is already free. I'm puzzled\n");
}
- if(MC_is_active()){
- if(mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
- MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
- }
+ if (MC_is_active() && mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
+ MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
/* Set size used in the fragment to -1 */
mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = -1;
unsuccessful for some reason. */
struct mdesc newmd;
- struct mdesc *mdptr = NULL, *mdptemp = NULL;
+ struct mdesc* mdptr = NULL;
+ struct mdesc* mdptemp = NULL;
if (lseek(fd, 0L, SEEK_SET) != 0)
return NULL;
}
}
- /* NULL is not a valid baseaddr as we cannot map anything there.
- C'mon, user. Think! */
+ /* NULL is not a valid baseaddr as we cannot map anything there. C'mon, user. Think! */
if (baseaddr == NULL)
return (NULL);
- /* We start off with the malloc descriptor allocated on the stack, until
- we build it up enough to call _mmalloc_mmap_morecore() to allocate the
- first page of the region and copy it there. Ensure that it is zero'd and
- then initialize the fields that we know values for. */
+ /* We start off with the malloc descriptor allocated on the stack, until we build it up enough to
+ * call _mmalloc_mmap_morecore() to allocate the first page of the region and copy it there. Ensure that it is
+ * zero'd and then initialize the fields that we know values for. */
mdp = &mtemp;
memset((char *) mdp, 0, sizeof(mtemp));
/* If we have not been passed a valid open file descriptor for the file
to map to, then open /dev/zero and use that to map to. */
- /* Now try to map in the first page, copy the malloc descriptor structure
- there, and arrange to return a pointer to this new copy. If the mapping
- fails, then close the file descriptor if it was opened by us, and arrange
- to return a NULL. */
+ /* Now try to map in the first page, copy the malloc descriptor structure there, and arrange to return a pointer to
+ * this new copy. If the mapping fails, then close the file descriptor if it was opened by us, and arrange to return
+ * a NULL. */
if ((mbase = mmorecore(mdp, sizeof(mtemp))) != NULL) {
memcpy(mbase, mdp, sizeof(mtemp));
}
}
-/** Terminate access to a mmalloc managed region by unmapping all memory pages
- associated with the region, and closing the file descriptor if it is one
- that we opened.
+/** Terminate access to a mmalloc managed region by unmapping all memory pages associated with the region, and closing
+ * the file descriptor if it is one that we opened.
Returns NULL on success.
- Returns the malloc descriptor on failure, which can subsequently be used
- for further action, such as obtaining more information about the nature of
- the failure.
+ Returns the malloc descriptor on failure, which can subsequently be used for further action, such as obtaining more
+ information about the nature of the failure.
- Note that the malloc descriptor that we are using is currently located in
- region we are about to unmap, so we first make a local copy of it on the
- stack and use the copy. */
+ Note that the malloc descriptor that we are using is currently located in region we are about to unmap, so we first
+ make a local copy of it on the stack and use the copy. */
void *xbt_mheap_destroy(xbt_mheap_t mdp)
{
- struct mdesc mtemp, *mdptemp;
-
if (mdp != NULL) {
/* Remove the heap from the linked list of heaps attached by mmalloc */
- mdptemp = __mmalloc_default_mdp;
+ struct mdesc* mdptemp = __mmalloc_default_mdp;
while(mdptemp->next_mdesc != mdp )
mdptemp = mdptemp->next_mdesc;
mdptemp->next_mdesc = mdp->next_mdesc;
xbt_mheap_destroy_no_free(mdp);
- mtemp = *mdp;
+ struct mdesc mtemp = *mdp;
/* Now unmap all the pages associated with this region by asking for a
negative increment equal to the current size of the region. */
if (mmorecore(&mtemp, (char *)mtemp.base - (char *)mtemp.breakval) == NULL) {
- /* Deallocating failed. Update the original malloc descriptor
- with any changes */
+ /* Deallocating failed. Update the original malloc descriptor with any changes */
*mdp = mtemp;
} else {
if (mtemp.flags & MMALLOC_DEVZERO) {
}
/* Safety gap from the heap's break address.
- * Try to increase this first if you experience strange errors under
- * valgrind. */
+ * Try to increase this first if you experience strange errors under valgrind. */
#define HEAP_OFFSET (128UL<<20)
xbt_mheap_t mmalloc_get_default_md(void)