#include "simgrid/plugins/energy.h"
#include "simgrid/s4u/Host.hpp"
+#include "simgrid/s4u/Storage.hpp"
#include "jmsg.h"
#include "jmsg_host.h"
int index = 0;
jobjectArray jtable;
- xbt_dict_t dict = MSG_host_get_mounted_storage_list(host);
- int count = xbt_dict_length(dict);
+ std::unordered_map<std::string, msg_storage_t> mounted_storages = host->getMountedStorages();
+ int count = mounted_storages.size();
jclass cls = env->FindClass("org/simgrid/msg/Storage");
jtable = env->NewObjectArray((jsize) count, cls, nullptr);
return nullptr;
}
- xbt_dict_cursor_t cursor=nullptr;
- const char* mount_name;
- const char* storage_name;
-
- xbt_dict_foreach(dict,cursor,mount_name,storage_name) {
- jname = env->NewStringUTF(storage_name);
+ for (auto elm : mounted_storages) {
+ jname = env->NewStringUTF(elm.second->getName());
jstorage = Java_org_simgrid_msg_Storage_getByName(env,cls,jname);
env->SetObjectArrayElement(jtable, index, jstorage);
index++;
}
- xbt_dict_free(&dict);
return jtable;
}
}
int console_AS_open(lua_State *L) {
- const char *id;
- const char *mode;
- int type;
-
XBT_DEBUG("Opening AS");
lua_ensure(lua_istable(L, 1), "Bad Arguments to AS_open, Should be a table with named arguments");
lua_pushstring(L, "id");
- type = lua_gettable(L, -2);
+ int type = lua_gettable(L, -2);
lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for any AS and must be a string.");
- id = lua_tostring(L, -1);
+ const char* id = lua_tostring(L, -1);
lua_pop(L, 1);
lua_pushstring(L, "mode");
lua_gettable(L, -2);
- mode = lua_tostring(L, -1);
+ const char* mode = lua_tostring(L, -1);
lua_pop(L, 1);
int mode_int = A_surfxml_AS_routing_None;
sg_host_t host = sg_host_by_name(name);
lua_ensure(host, "no host '%s' found",name);
- xbt_dict_t props = sg_host_get_properties(host);
- xbt_dict_set(props,prop_id,xbt_strdup(prop_value),nullptr);
+ host->setProperty(prop_id, prop_value);
return 0;
}
/**
* @brief Get the content of the current Storage
*
- * @return A xbt_dict_t with path as keys and size in bytes as values
+ * @return A map with path as keys and size in bytes as values
*/
virtual std::map<std::string, sg_size_t>* getContent();
std::vector<s_smpi_factor_t> smpi_bw_factor;
std::vector<s_smpi_factor_t> smpi_lat_factor;
-xbt_dict_t gap_lookup = nullptr;
-
/*********
* Model *
*********/
}
namespace simgrid {
- namespace surf {
-
- NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model()
- {
- haveGap_ = true;
- }
-
- NetworkSmpiModel::~NetworkSmpiModel()
- {
- xbt_dict_free(&gap_lookup);
- }
-
- double NetworkSmpiModel::bandwidthFactor(double size)
- {
- if (smpi_bw_factor.empty())
- smpi_bw_factor = parse_factor(xbt_cfg_get_string("smpi/bw-factor"));
-
- double current = 1.0;
- for (const auto& fact : smpi_bw_factor) {
- if (size <= fact.factor) {
- XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
- return current;
- } else
- current = fact.values.front();
- }
- XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current);
+namespace surf {
- return current;
- }
-
- double NetworkSmpiModel::latencyFactor(double size)
- {
- if (smpi_lat_factor.empty())
- smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor"));
-
- double current=1.0;
- for (const auto& fact : smpi_lat_factor) {
- if (size <= fact.factor) {
- XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
- return current;
- }else
- current=fact.values.front();
- }
- XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current);
+NetworkSmpiModel::NetworkSmpiModel() : NetworkCm02Model()
+{
+ haveGap_ = true;
+}
+
+NetworkSmpiModel::~NetworkSmpiModel() = default;
+double NetworkSmpiModel::bandwidthFactor(double size)
+{
+ if (smpi_bw_factor.empty())
+ smpi_bw_factor = parse_factor(xbt_cfg_get_string("smpi/bw-factor"));
+
+ double current = 1.0;
+ for (const auto& fact : smpi_bw_factor) {
+ if (size <= fact.factor) {
+ XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
return current;
- }
+ } else
+ current = fact.values.front();
+ }
+ XBT_DEBUG("%f > %zu return %f", size, smpi_bw_factor.back().factor, current);
+
+ return current;
+}
- double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size)
- {
- return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size));
- }
+double NetworkSmpiModel::latencyFactor(double size)
+{
+ if (smpi_lat_factor.empty())
+ smpi_lat_factor = parse_factor(xbt_cfg_get_string("smpi/lat-factor"));
- /************
- * Resource *
- ************/
+ double current = 1.0;
+ for (const auto& fact : smpi_lat_factor) {
+ if (size <= fact.factor) {
+ XBT_DEBUG("%f <= %zu return %f", size, fact.factor, current);
+ return current;
+ } else
+ current = fact.values.front();
+ }
+ XBT_DEBUG("%f > %zu return %f", size, smpi_lat_factor.back().factor, current);
+ return current;
+}
+double NetworkSmpiModel::bandwidthConstraint(double rate, double bound, double size)
+{
+ return rate < 0 ? bound : std::min(bound, rate * bandwidthFactor(size));
+}
- /**********
- * Action *
- **********/
+/************
+ * Resource *
+ ************/
- }
+/**********
+ * Action *
+ **********/
+}
}
std::map<std::string, std::string>* current_model_property_set = nullptr;
int ZONE_TAG = 0; // Whether we just opened a zone tag (to see what to do with the properties)
-/* dictionary of random generator data */
-xbt_dict_t random_data_list = nullptr;
-
YY_BUFFER_STATE surf_input_buffer;
FILE *surf_file_to_parse = nullptr;
static void dump_platform()
{
int version = 4;
- xbt_dict_t props = nullptr;
- xbt_dict_cursor_t cursor = nullptr;
- char* key;
- char* data;
+ std::map<std::string, std::string>* props = nullptr;
std::printf("<?xml version='1.0'?>\n");
std::printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\">\n");
for (unsigned int i = 0; i < totalHosts; i++) {
std::printf(" <host id=\"%s\" speed=\"%.0f\"", hosts[i]->getCname(), sg_host_speed(hosts[i]));
- props = sg_host_get_properties(hosts[i]);
+ props = hosts[i]->getProperties();
if (hosts[i]->getCoreCount() > 1) {
std::printf(" core=\"%d\"", hosts[i]->getCoreCount());
}
- if (props && not xbt_dict_is_empty(props)) {
+ if (props && not props->empty()) {
std::printf(">\n");
- xbt_dict_foreach (props, cursor, key, data) {
- std::printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data);
+ for (auto kv : *props) {
+ std::printf(" <prop id=\"%s\" value=\"%s\"/>\n", kv.first.c_str(), kv.second.c_str());
}
std::printf(" </host>\n");
} else {
std::printf("/>\n");
}
- xbt_dict_free(&props);
}
// Routers