public Node(Host host, String name, String[]args) {
super(host,name,args);
}
- public void request(double CStime) throws MsgException {
+ public void request(double csTime) throws MsgException {
RequestTask req = new RequestTask(getName());
Msg.info("Send a request to the coordinator");
req.send("coordinator");
Msg.info("Wait for a grant from the coordinator");
GrantTask.receive(getName());
- Task compute = new Task("CS", CStime, 0);
+ Task compute = new Task("CS", csTime, 0);
compute.execute();
ReleaseTask release = new ReleaseTask();
release.send("coordinator");
public static final int RANDOM_LOOKUP_INTERVAL = 100;
- public static final int alpha = 3;
+ public static final int ALPHA = 3;
public static final int IDENTIFIER_SIZE = 32;
/* Maximum size of the buckets */
}
public void mainLoop() {
- double next_lookup_time = Msg.getClock() + Common.RANDOM_LOOKUP_INTERVAL;
+ double nextLookupTime = Msg.getClock() + Common.RANDOM_LOOKUP_INTERVAL;
while (Msg.getClock() < this.deadline) {
try {
if (comm == null) {
comm = Task.irecv(Integer.toString(id));
}
if (!comm.test()) {
- if (Msg.getClock() >= next_lookup_time) {
+ if (Msg.getClock() >= nextLookupTime) {
randomLookup();
- next_lookup_time += Common.RANDOM_LOOKUP_INTERVAL;
+ nextLookupTime += Common.RANDOM_LOOKUP_INTERVAL;
} else {
waitFor(1);
}
public int sendFindNodeToBest(Answer nodeList) {
int destination = nodeList.getDestinationId();
int i;
- for (i = 0; i < Common.alpha && i < nodeList.size(); i++) {
+ for (i = 0; i < Common.ALPHA && i < nodeList.size(); i++) {
Contact node = nodeList.getNodes().get(i);
if (node.getId() != this.id) {
this.sendFindNode(node.getId(),destination);
import org.simgrid.msg.MsgException;
public class Main {
- public static final double task_comp_size = 10;
- public static final double task_comm_size = 10;
- public static final int hostNB = 2 ;
private Main() {
throw new IllegalAccessError("Utility class");
}
import org.simgrid.msg.MsgException;
public class Node extends Process {
- private static String FILENAME1 = "/doc/simgrid/examples/platforms/g5k.xml";
- private static String FILENAME2 = "\\Windows\\setupact.log";
- private static String FILENAME3 = "/doc/simgrid/examples/platforms/g5k_cabinets.xml";
- private static String FILENAME4 = "/doc/simgrid/examples/platforms/nancy.xml";
+ private static String file1 = "/doc/simgrid/examples/platforms/g5k.xml";
+ private static String file2 = "\\Windows\\setupact.log";
+ private static String file3 = "/doc/simgrid/examples/platforms/g5k_cabinets.xml";
+ private static String file4 = "/doc/simgrid/examples/platforms/nancy.xml";
protected int rank;
public void main(String[] args) throws MsgException {
String mount;
- String filename;
+ String fileName;
switch (rank) {
case 4:
mount = "/home";
- filename = mount + FILENAME1;
+ fileName = mount + file1;
break;
case 0:
mount = "c:";
- filename = mount + FILENAME2;
+ fileName = mount + file2;
break;
case 2:
mount = "/home";
- filename = mount + FILENAME3;
+ fileName = mount + file3;
break;
case 1:
mount = "/home";
- filename = mount + FILENAME4;
+ fileName = mount + file4;
break;
default:
mount = "/home";
- filename = mount + FILENAME1;
+ fileName = mount + file1;
}
- Msg.info("Open file " + filename);
- File file = new File(filename);
+ Msg.info("Open file " + fileName);
+ File file = new File(fileName);
long read = file.read(10000,1);
- Msg.info("Having read " + read + " on " + filename);
+ Msg.info("Having read " + read + " on " + fileName);
long write = file.write(100000,1);
- Msg.info("Having write " + write + " on " + filename);
+ Msg.info("Having write " + write + " on " + fileName);
- Msg.info("Seek back to the beginning of " + filename);
+ Msg.info("Seek back to the beginning of " + fileName);
file.seek(0,File.SEEK_SET);
read = file.read(150000,1);
- Msg.info("Having read " + read + " on " + filename);
+ Msg.info("Having read " + read + " on " + fileName);
}
}
import org.simgrid.trace.Trace;
public class Sender extends Process {
- private static final double commSizeLat = 1;
- private static final double commSizeBw = 100000000;
+ private static final double COMM_SIZE_LAT = 1;
+ private static final double COMM_SIZE_BW = 100000000;
private static final String PM_STATE = "PM_STATE";
public Sender(String hostname, String name, String[] args) throws HostNotFoundException {
for (int pos = 0; pos < hostCount; pos++) {
time = Msg.getClock();
Msg.info("sender time: " + time);
- ping = new PingPongTask("no name",computeDuration,commSizeLat);
+ ping = new PingPongTask("no name",computeDuration,COMM_SIZE_LAT);
ping.setTime(time);
ping.send(mailboxes[pos]);
communicationTime=timeGot - time;
Msg.info("Communication time : " + communicationTime);
- Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
+ Msg.info(" --- bw "+ COMM_SIZE_BW/communicationTime + " ----");
/* Pop the last state (going back to sending ping) */
Trace.hostPopState (getHost().getName(), PM_STATE);
XBT_PUBLIC(int) simcall_file_move(smx_file_t fd, const char* fullpath);
/***************************** Storage **********************************/
XBT_PUBLIC(xbt_dict_t) simcall_storage_get_properties(smx_storage_t storage);
-XBT_PUBLIC(const char*) SIMIX_storage_get_name(smx_storage_t storage);
-
/************************** MC simcalls **********************************/
XBT_PUBLIC(int) simcall_mc_random(int min, int max);
// FIXME: this header file should die
-XBT_PUBLIC_DATA(int) SIMIX_STORAGE_LEVEL; //Simix storage level
-
XBT_PUBLIC_DATA(xbt_lib_t) storage_lib;
XBT_PUBLIC_DATA(int) ROUTING_STORAGE_LEVEL; //Routing storage level
XBT_PUBLIC_DATA(int) SURF_STORAGE_LEVEL; // Surf storage level
-XBT_PUBLIC_DATA(xbt_lib_t) storage_type_lib;
-XBT_PUBLIC_DATA(int) ROUTING_STORAGE_TYPE_LEVEL; //Routing storage_type level
SG_END_DECL()
SG_BEGIN_DECL()
int JAVA_HOST_LEVEL = -1;
-int JAVA_STORAGE_LEVEL = -1;
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(java);
MSG_init(&argc, argv);
JAVA_HOST_LEVEL = simgrid::s4u::Host::extension_create(__JAVA_host_priv_free);
- JAVA_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, __JAVA_storage_priv_free);
for (index = 0; index < argc - 1; index++) {
env->SetObjectArrayElement(jargs, index, (jstring)env->NewStringUTF(argv[index + 1]));
xbt_dynar_free(&hosts);
/* Cleanup java storages */
- xbt_dynar_t storages = MSG_storages_as_dynar();
- if(!xbt_dynar_is_empty(storages)){
- for (unsigned long index = 0; index < xbt_dynar_length(storages) - 1; index++) {
- jobject jstorage = (jobject) xbt_lib_get_level(xbt_dynar_get_as(storages,index,msg_storage_t), JAVA_STORAGE_LEVEL);
- if (jstorage)
- jstorage_unref(env, jstorage);
- }
- }
- xbt_dynar_free(&storages);
+ for (auto elm : java_storage_map)
+ jstorage_unref(env, elm.second);
}
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_createEnvironment(JNIEnv * env, jclass cls, jstring jplatformFile)
#ifndef MSG4JAVA_H
#define MSG4JAVA_H
-#include <simgrid/msg.h>
#include <jni.h>
+#include <simgrid/msg.h>
+#include <unordered_map>
SG_BEGIN_DECL()
/* end of eclipse-mandated pimple */
extern int JAVA_HOST_LEVEL;
-extern int JAVA_STORAGE_LEVEL;
+static std::unordered_map<char*, jobject> java_storage_map;
JavaVM *get_java_VM();
JNIEnv *get_current_thread_env();
jstorage_name = env->NewStringUTF(storage_name);
env->SetObjectArrayElement(jtable, index, jstorage_name);
}
-
+ xbt_dynar_free_container(&dyn);
return jtable;
}
JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Storage_getByName(JNIEnv * env, jclass cls, jstring jname) {
msg_storage_t storage;
- jobject jstorage;
+ jobject jstorage = nullptr;
/* get the C string from the java string */
if (jname == nullptr) {
}
env->ReleaseStringUTFChars(jname, name);
- if (!xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL)) { /* native host not associated yet with java host */
-
+ if (java_storage_map.find(storage->key) == java_storage_map.end()) {
/* Instantiate a new java storage */
jstorage = jstorage_new_instance(env);
/* the native storage data field is set with the global reference to the
* java storage returned by this function
*/
- xbt_lib_set(storage_lib, storage->key, JAVA_STORAGE_LEVEL, (void *) jstorage);
- }
+ java_storage_map.insert({storage->key, jstorage});
+ } else
+ jstorage = java_storage_map.at(storage->key);
/* return the global reference to the java storage instance */
- return (jobject) xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL);
+ return (jobject)jstorage;
}
JNIEXPORT jlong JNICALL Java_org_simgrid_msg_Storage_getSize(JNIEnv * env,jobject jstorage) {
for (index = 0; index < count; index++) {
storage = xbt_dynar_get_as(table,index,msg_storage_t);
- jstorage = (jobject) (xbt_lib_get_level(storage, JAVA_STORAGE_LEVEL));
-
- if (!jstorage) {
+ if (java_storage_map.find(storage->key) != java_storage_map.end()) {
+ jstorage = java_storage_map.at(storage->key);
+ } else {
jname = env->NewStringUTF(MSG_storage_get_name(storage));
jstorage = Java_org_simgrid_msg_Storage_getByName(env, cls_arg, jname);
}
* may not exist.
*/
XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
+XBT_PUBLIC(const char * ) surf_storage_get_name(surf_resource_t resource);
/** @} */
}
/* compose route path with links */
- NetPoint *gw_src = nullptr;
- NetPoint *gw_dst;
- NetPoint *prev_gw_src;
- NetPoint *first_gw = nullptr;
- NetPoint *gw_dst_net_elm = nullptr, *prev_gw_src_net_elm = nullptr;
+ NetPoint* gw_src = nullptr;
+ NetPoint* gw_dst;
+ NetPoint* prev_gw_src;
+ NetPoint* first_gw = nullptr;
+ NetPoint* gw_dst_net_elm = nullptr;
+ NetPoint* prev_gw_src_net_elm = nullptr;
for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) {
xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t);
/* Initialize MSG storages */
xbt_lib_foreach(storage_lib, cursor, name, data) {
- if(data[SIMIX_STORAGE_LEVEL])
- __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
+ __MSG_storage_create(xbt_dict_cursor_get_elm(cursor));
}
}
{
msg_storage_priv_t storage_private = xbt_new0(s_msg_storage_priv_t, 1);
- storage_private->name = SIMIX_storage_get_name(storage);
+ storage_private->name = surf_storage_get_name(storage);
storage_private->hostname = surf_storage_get_host(storage);
storage_private->size = surf_storage_get_size(storage);
void sg_host_dump(sg_host_t host)
{
xbt_dict_t props;
- xbt_dict_cursor_t cursor=nullptr;
- char *key,*data;
XBT_INFO("Displaying host %s", host->cname());
XBT_INFO(" - speed: %.0f", host->speed());
if (!xbt_dict_is_empty(props)){
XBT_INFO(" - properties:");
+ xbt_dict_cursor_t cursor = nullptr;
+ char* key;
+ char* data;
xbt_dict_foreach(props,cursor,key,data) {
XBT_INFO(" %s->%s",key,data);
static void sg_config_cmd_line(int *argc, char **argv)
{
int shall_exit = 0;
- int i, j;
+ int i;
+ int j;
for (j = i = 1; i < *argc; i++) {
if (!strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
// TODO, create sg_storage_by_name
sg_storage_t s = xbt_lib_get_elm_or_null(storage_lib, name);
xbt_assert(s != nullptr, "Storage not found for name %s", name);
-
- SIMIX_storage_create(name, s, nullptr);
});
-
- SIMIX_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, SIMIX_storage_destroy);
}
if (!simix_timers)
simix_timers = xbt_heap_new(8, [](void* p) {
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_io, simix, "Logging specific to SIMIX (io)");
-/**
- * \brief Internal function to create a SIMIX storage.
- * \param name name of the storage to create
- * \param storage the SURF storage to encapsulate
- * \param data some user data (may be nullptr)
- */
-smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data)
-{
- smx_storage_priv_t smx_storage = xbt_new0(s_smx_storage_priv_t, 1);
-
- smx_storage->data = data;
-
- /* Update global variables */
- xbt_lib_set(storage_lib,name,SIMIX_STORAGE_LEVEL,smx_storage);
- return xbt_lib_get_elm_or_null(storage_lib, name);
-}
-
-/**
- * \brief Internal function to destroy a SIMIX storage.
- *
- * \param s the host to destroy (a smx_storage_t)
- */
-void SIMIX_storage_destroy(void *s)
-{
- smx_storage_priv_t storage = static_cast<smx_storage_priv_t>(s);
-
- xbt_assert((storage != nullptr), "Invalid parameters");
- if (storage->data)
- free(storage->data);
-
- /* Clean storage structure */
- free(storage);
-}
-
//SIMIX FILE READ
void simcall_HANDLER_file_read(smx_simcall_t simcall, smx_file_t fd, sg_size_t size, sg_host_t host)
{
return surf_storage_get_properties(storage);
}
-const char* SIMIX_storage_get_name(smx_storage_t storage){
- return sg_storage_name(storage);
-}
-
void SIMIX_io_destroy(smx_activity_t synchro)
{
simgrid::kernel::activity::Io *io = static_cast<simgrid::kernel::activity::Io*>(synchro);
#include "simgrid/simix.h"
#include "popping_private.h"
-/** @brief Storage datatype */
-typedef struct s_smx_storage_priv {
- void *data; /**< @brief user data */
-} s_smx_storage_priv_t;
-
-
-static inline smx_storage_priv_t SIMIX_storage_priv(smx_storage_t storage){
- return (smx_storage_priv_t) xbt_lib_get_level(storage, SIMIX_STORAGE_LEVEL);
-}
-
-XBT_PRIVATE smx_storage_t SIMIX_storage_create(const char *name, void *storage, void *data);
-XBT_PRIVATE void SIMIX_storage_destroy(void *s);
XBT_PRIVATE smx_activity_t SIMIX_file_read(smx_file_t fd, sg_size_t size, sg_host_t host);
XBT_PRIVATE smx_activity_t SIMIX_file_write(smx_file_t fd, sg_size_t size, sg_host_t host);
XBT_PRIVATE smx_activity_t SIMIX_file_open(const char* fullpath, sg_host_t host);
static char *str_tolower (const char *str)
{
- char *ret = xbt_strdup (str);
- int i, n = strlen (ret);
- for (i = 0; i < n; i++)
+ char* ret = xbt_strdup(str);
+ int n = strlen(ret);
+ for (int i = 0; i < n; i++)
ret[i] = tolower (str[i]);
return ret;
}
static const char *instr_find_color (const char *state)
{
- char *target = str_tolower (state);
- const char *ret = nullptr;
- unsigned int i = 0;
- const char *current = smpi_colors[i];
- while ((current != nullptr)){
+ char* target = str_tolower(state);
+ const char* ret = nullptr;
+ unsigned int i = 0;
+ const char* current = smpi_colors[i];
+ while (current != nullptr) {
if (strcmp (state, current) == 0 //exact match
|| strstr(target, current) != 0 ){//as substring
ret = smpi_colors[i+1];
XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
smpi_switch_data_segment(
- (static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->src_proc->data)->data))->index()));
+ static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->src_proc->data)->data))
+ ->index());
tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
memcpy_private(tmpbuff, buff, private_blocks);
}
&& ((char*)comm->dst_buff < smpi_start_data_exe + smpi_size_data_exe )){
XBT_DEBUG("Privatization : We are copying to a zone inside global memory - Switch data segment");
smpi_switch_data_segment(
- (static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->dst_proc->data)->data))->index()));
+ static_cast<simgrid::smpi::Process*>((static_cast<simgrid::MsgActorExt*>(comm->dst_proc->data)->data))
+ ->index());
}
XBT_DEBUG("Copying %zu bytes from %p to %p", buff_size, tmpbuff,comm->dst_buff);
memcpy_private(comm->dst_buff, tmpbuff, private_blocks);
}
}
int count = smpi_process_count();
- int i, ret=0;
- for (i = 0; i < count; i++) {
+ int ret = 0;
+ for (int i = 0; i < count; i++) {
if(process_data[i]->return_value()!=0){
ret=process_data[i]->return_value();//return first non 0 value
break;
std::vector<std::pair<size_t, size_t>> merge_private_blocks(std::vector<std::pair<size_t, size_t>> src, std::vector<std::pair<size_t, size_t>> dst) {
std::vector<std::pair<size_t, size_t>> result;
- unsigned i_src=0, i_dst=0;
+ unsigned i_src = 0;
+ unsigned i_dst = 0;
while(i_src < src.size() && i_dst < dst.size()) {
std::pair<size_t, size_t> block;
if(src[i_src].second <= dst[i_dst].first) {
// FIXME: sleep variables should not consume 1.0 in lmm_expand
action->maxDuration_ = duration;
action->suspended_ = 2;
- if (duration == NO_MAX_DURATION) {
+ if (duration < 0) { // NO_MAX_DURATION
/* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */
action->getStateSet()->erase(action->getStateSet()->iterator_to(*action));
action->stateSet_ = static_cast<CpuCas01Model*>(model())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
/* 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 "xbt/sysdep.h"
-#include "xbt/log.h"
#include "maxmin_private.hpp"
-#include <stdlib.h>
+#include "xbt/log.h"
+#include "xbt/sysdep.h"
+#include <float.h>
#include <math.h>
+#include <stdlib.h>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_maxmin);
#define SHOW_EXPR_G(expr) XBT_DEBUG(#expr " = %g",expr);
xbt_swag_foreach_safe(_var, _var_next, var_list) {
var = static_cast<lmm_variable_t>(_var);
- double min_inc = var->cnsts[0].constraint->usage / var->cnsts[0].value;
- for (int i = 1; i < var->cnsts_number; i++) {
+ double min_inc = DBL_MAX;
+ for (int i = 0; i < var->cnsts_number; i++) {
lmm_element_t elm = &var->cnsts[i];
- min_inc = MIN(min_inc, elm->constraint->usage / elm->value);
+ if (elm->value > 0)
+ min_inc = MIN(min_inc, elm->constraint->usage / elm->value);
}
if (var->bound > 0)
min_inc = MIN(min_inc, var->bound - var->value);
if (surf_network_model)
return;
- surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
+ surf_network_model = new simgrid::surf::NetworkCm02Model(&lagrange_solve);
all_existing_models->push_back(surf_network_model);
lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi);
if (surf_network_model)
return;
- surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
+ surf_network_model = new simgrid::surf::NetworkCm02Model(&lagrange_solve);
all_existing_models->push_back(surf_network_model);
lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi);
if (surf_network_model)
return;
- surf_network_model = new simgrid::surf::NetworkCm02Model(lagrange_solve);
+ surf_network_model = new simgrid::surf::NetworkCm02Model(&lagrange_solve);
all_existing_models->push_back(surf_network_model);
lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi);
double_update(&(deltap), action->latency_, sg_surf_precision);
action->latency_ = 0.0;
}
- if (action->latency_ == 0.0 && !(action->isSuspended()))
+ if (action->latency_ <= 0.0 && !(action->isSuspended()))
lmm_update_variable_weight(maxminSystem_, action->getVariable(), action->weight_);
}
if (TRACE_is_enabled()) {
}
}
if (!lmm_get_number_of_cnst_from_var (maxminSystem_, action->getVariable())) {
- /* There is actually no link used, hence an infinite bandwidth.
- * This happens often when using models like vivaldi.
- * In such case, just make sure that the action completes immediately.
+ /* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
+ * vivaldi. In such case, just make sure that the action completes immediately.
*/
action->updateRemains(action->getRemains());
}
action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
-
- if (action->getMaxDuration() != NO_MAX_DURATION)
+
+ if (action->getMaxDuration() > NO_MAX_DURATION)
action->updateMaxDuration(delta);
-
+
if (((action->getRemains() <= 0) && (lmm_get_variable_weight(action->getVariable()) > 0)) ||
((action->getMaxDuration() > NO_MAX_DURATION) && (action->getMaxDuration() <= 0))) {
action->finish();
void NetworkCm02Link::apply_event(tmgr_trace_iterator_t triggered, double value)
{
-
/* Find out which of my iterators was triggered, and react accordingly */
if (triggered == bandwidth_.event) {
setBandwidth(value);
}
}
-NetworkCm02Link::~NetworkCm02Link() {}
-
/**********
* Action *
**********/
-NetworkCm02Action::~NetworkCm02Action() {}
-
void NetworkCm02Action::updateRemainingLazy(double now)
{
if (suspended_ != 0)
XBT_DEBUG("Updating action(%p): remains is now %f", this, remains_);
}
- if (maxDuration_ != NO_MAX_DURATION)
+ if (maxDuration_ > NO_MAX_DURATION)
double_update(&maxDuration_, delta, sg_surf_precision);
if ((remains_ <= 0 && (lmm_get_variable_weight(getVariable()) > 0)) ||
- (((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0)))){
+ ((maxDuration_ > NO_MAX_DURATION) && (maxDuration_ <= 0))) {
finish();
setState(Action::State::done);
heapRemove(getModel()->getActionHeap());
public:
NetworkCm02Link(NetworkCm02Model* model, const char* name, double bandwidth, double latency,
e_surf_link_sharing_policy_t policy, lmm_system_t system);
- ~NetworkCm02Link() override;
+ virtual ~NetworkCm02Link() = default;
void apply_event(tmgr_trace_iterator_t event, double value) override;
void setBandwidth(double value) override;
void setLatency(double value) override;
public:
NetworkCm02Action(Model *model, double cost, bool failed)
: NetworkAction(model, cost, failed) {};
- ~NetworkCm02Action() override;
+ virtual ~NetworkCm02Action() = default;
void updateRemainingLazy(double now) override;
protected:
double senderGap_;
LinkImpl** LinkImpl::linksList()
{
LinkImpl** res = xbt_new(LinkImpl*, (int)links->size());
- int i=0;
+ int i = 0;
for (auto kv : *links) {
- res[i++] = kv.second;
+ res[i] = kv.second;
+ i++;
}
return res;
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_storage, surf, "Logging specific to the SURF storage module");
xbt_lib_t storage_lib;
-int SIMIX_STORAGE_LEVEL = -1; // Simix storage level
int MSG_STORAGE_LEVEL = -1; // Msg storage level
int ROUTING_STORAGE_LEVEL = -1; // Routing for storage level
int SURF_STORAGE_LEVEL = -1;
return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->attach_;
}
+const char* surf_storage_get_name(surf_resource_t resource){
+ return static_cast<simgrid::surf::Storage*>(surf_storage_resource_priv(resource))->cname();
+}
+
void surf_cpu_action_set_bound(surf_action_t action, double bound) {
static_cast<simgrid::surf::CpuAction*>(action)->setBound(bound);
}
int XBT_PRIVATE __surf_is_absolute_file_path(const char *file_path);
-static inline char* sg_storage_name(sg_storage_t storage) {
- return storage->key;
-}
-
/***********
* Classes *
***********/
/* connect all traces relative to hosts */
xbt_dict_cursor_t cursor = nullptr;
- char *trace_name, *elm;
+ char* trace_name;
+ char* elm;
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
#include <unwind.h>
struct trace_arg {
- void **array;
- int cnt, size;
+ void** array;
+ int cnt;
+ int size;
};
static _Unwind_Reason_Code
}
/* To read the output of addr2line */
- char line_func[1024], line_pos[1024];
+ char line_func[1024];
+ char line_pos[1024];
for (std::size_t i = 0; i < count; i++) {
XBT_DEBUG("Looking for symbol %zd, addr = '%s'", i, addrs[i].c_str());
if (fgets(line_func, 1024, pipe)) {
char maps_buff[512];
long int offset = 0;
- char *p, *p2;
+ char* p;
+ char* p2;
int found = 0;
/* let's look for the offset of this library in our addressing space */
addrs[i].c_str(), addr);
while (!found) {
- long int first, last;
+ long int first;
+ long int last;
if (fgets(maps_buff, 512, maps) == nullptr)
break;
xbt_dynar_t tests; /* of xbt_test_test_t */
int nb_tests;
- int test_failed, test_ignore, test_expect;
+ int test_failed;
+ int test_ignore;
+ int test_expect;
};
static void xbt_test_unit_dump(xbt_test_unit_t unit)
char *title;
xbt_dynar_t units; /* of xbt_test_unit_t */
- int nb_tests, nb_units;
- int test_failed, test_ignore, test_expect;
- int unit_failed, unit_ignore, unit_disabled;
+ int nb_tests;
+ int nb_units;
+ int test_failed;
+ int test_ignore;
+ int test_expect;
+ int unit_failed;
+ int unit_ignore;
+ int unit_disabled;
};
/* destroy test suite */
const char *file;
int line;
char *cp;
- unsigned int it_unit, it_test, it_log;
+ unsigned int it_unit;
+ unsigned int it_test;
+ unsigned int it_log;
int first = 1; /* for result pretty printing */
return 0;
/* suite title pretty-printing */
- {
- char suite_title[81];
- int suite_len = strlen(suite->title);
- int i;
-
- xbt_assert(suite_len < 68, "suite title \"%s\" too long (%d should be less than 68", suite->title, suite_len);
-
- suite_title[0] = ' ';
- for (i = 1; i < 80; i++)
- suite_title[i] = '=';
- suite_title[i++] = '\n';
- suite_title[80] = '\0';
-
- snprintf(suite_title + 40 - (suite_len + 4) / 2, 81-(40 - (suite_len + 4)/ 2), "[ %s ]", suite->title);
- suite_title[40 + (suite_len + 5) / 2] = '=';
- if (!suite->enabled)
- snprintf(suite_title + 70, 11, " DISABLED ");
- fprintf(stderr, "\n%s\n", suite_title);
- }
+ char suite_title[81];
+ int suite_len = strlen(suite->title);
+
+ xbt_assert(suite_len < 68, "suite title \"%s\" too long (%d should be less than 68", suite->title, suite_len);
+
+ suite_title[0] = ' ';
+ for (int i = 1; i < 79; i++)
+ suite_title[i] = '=';
+ suite_title[79] = '\n';
+ suite_title[80] = '\0';
+
+ snprintf(suite_title + 40 - (suite_len + 4) / 2, 81 - (40 - (suite_len + 4) / 2), "[ %s ]", suite->title);
+ suite_title[40 + (suite_len + 5) / 2] = '=';
+ if (!suite->enabled)
+ snprintf(suite_title + 70, 11, " DISABLED ");
+ fprintf(stderr, "\n%s\n", suite_title);
if (suite->enabled) {
/* iterate through all tests */
xbt_dynar_t xbt_str_split(const char *s, const char *sep)
{
xbt_dynar_t res = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
- const char *p, *q;
- int done;
const char *sep_dflt = " \t\n\r\x0B";
char is_sep[256] = { 1, 0 };
while (*sep)
is_sep[(unsigned char) *sep++] = 1;
}
- is_sep[0] = 1; /* End of string is also separator */
+ is_sep[0] = 1; /* End of string is also separator */
/* Do the job */
- p = s;
- q = s;
- done = 0;
+ const char* p = s;
+ const char* q = s;
+ int done = 0;
if (s[0] == '\0')
return res;
xbt_dynar_t xbt_str_split_str(const char *s, const char *sep)
{
xbt_dynar_t res = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
- int done;
- const char *p, *q;
- p = s;
- q = s;
- done = 0;
+ const char* p = s;
+ const char* q = s;
+ int done = 0;
if (s[0] == '\0')
return res;
*/
xbt_dynar_t xbt_str_split_quoted_in_place(char *s) {
xbt_dynar_t res = xbt_dynar_new(sizeof(char *), nullptr);
- char *beg, *end; /* pointers around the parsed chunk */
- int in_simple_quote = 0, in_double_quote = 0;
- int done = 0;
- int ctn = 0; /* Got something in this block */
+ char* beg;
+ char* end; /* pointers around the parsed chunk */
+ int in_simple_quote = 0;
+ int in_double_quote = 0;
+ int done = 0;
+ int ctn = 0; /* Got something in this block */
if (s[0] == '\0')
return res;
{
int len = 1, dyn_len = xbt_dynar_length(dyn);
unsigned int cpt;
- char *cursor;
- char *res, *p;
+ char* cursor;
if (!dyn_len)
return xbt_strdup("");
}
len += strlen(sep) * dyn_len;
/* Do the job */
- res = (char*) xbt_malloc(len);
- p = res;
+ char* res = (char*)xbt_malloc(len);
+ char* p = res;
xbt_dynar_foreach(dyn, cpt, cursor) {
if ((int) cpt < dyn_len - 1)
p += snprintf(p,len, "%s%s", cursor, sep);
*/
char *xbt_str_join_array(const char *const *strs, const char *sep)
{
- char *res,*q;
int amount_strings=0;
int len=0;
- int i;
if ((!strs) || (!strs[0]))
return xbt_strdup("");
/* compute the length before malloc */
- for (i=0;strs[i];i++) {
+ for (int i = 0; strs[i]; i++) {
len += strlen(strs[i]);
amount_strings++;
}
len += strlen(sep) * amount_strings;
/* Do the job */
- res = (char*) xbt_malloc(len);
- q = res;
- for (i=0;strs[i];i++) {
- if (i!=0) { // not first loop
+ char* res = (char*)xbt_malloc(len);
+ char* q = res;
+ for (int i = 0; strs[i]; i++) {
+ if (i != 0) { // not first loop
q += snprintf(q,len, "%s%s", sep, strs[i]);
} else {
q += snprintf(q,len, "%s",strs[i]);
*/
long int xbt_str_parse_int(const char* str, const char* error_msg)
{
- char *endptr;
+ char* endptr;
if (str == nullptr || str[0] == '\0')
THROWF(arg_error, 0, error_msg, str);
int version = 4;
xbt_dict_t props = nullptr;
xbt_dict_cursor_t cursor = nullptr;
- char *key, *data;
+ char* key;
+ char* data;
std::printf("<?xml version='1.0'?>\n");
std::printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");