gras_datadesc_type_t
gras_datadesc_ref_pop_arr(gras_datadesc_type_t element_type)
{
-
+ int cpt=0;
gras_datadesc_type_t res,ddt2;
char *name = (char *) xbt_malloc(strlen(element_type->name) + 4);
sprintf(name, "%s[]", element_type->name);
/* Make sure we are not trying to redefine a ddt with the same name */
ddt2 = gras_datadesc_by_name_or_null(name);
- int cpt=0;
+
while (ddt2) {
free(name);
name=bprintf("%s[]_%d",element_type->name,cpt++);
static int MSG_action_runner(int argc, char *argv[]) {
xbt_dynar_t evt=NULL;
+ char *line = NULL;
+ size_t line_len = 0;
+ FILE *fp = NULL;
+ char *comment = NULL;
+ char *evtname = NULL;
+ ssize_t read;
if (action_fp) { // A unique trace file
while ((evt = action_get_action(argv[0]))) {
"and no process-wide trace file provided in deployment file. Aborting.",argv[0]
);
- char *line = NULL;
- size_t line_len = 0;
- FILE *fp = fopen(argv[1], "r");
+ fp = fopen(argv[1], "r");
xbt_assert2(fp != NULL, "Cannot open %s: %s", argv[1], strerror(errno));
- ssize_t read;
// Read lines and execute them until I reach the end of file
while ((read = getline(&line, &line_len, fp)) != -1) {
// cleanup and split the string I just read
- char *comment = strchr(line, '#');
+ comment = strchr(line, '#');
if (comment != NULL)
*comment = '\0';
xbt_str_trim(line, NULL);
continue;
evt = xbt_str_split_quoted(line);
- char *evtname = xbt_dynar_get_as(evt, 0, char *);
+ evtname = xbt_dynar_get_as(evt, 0, char *);
if (!strcmp(argv[0],evtname)) {
msg_action_fun function =
xbt_dict_get(action_funs, xbt_dynar_get_as(evt, 1, char *));
static xbt_dynar_t action_get_action(char *name) {
ssize_t read;
xbt_dynar_t evt=NULL;
-
+ char *evtname = NULL;
xbt_dynar_t myqueue = xbt_dict_get_or_null(action_queues,name);
if (myqueue==NULL || xbt_dynar_length(myqueue)==0) { // nothing stored for me. Read the file further
evt = xbt_str_split_quoted(action_line);
// if it's for me, I'm done
- char *evtname = xbt_dynar_get_as(evt, 0, char *);
+ evtname = xbt_dynar_get_as(evt, 0, char *);
if (!strcmp(name,evtname)) {
return evt;
} else {
MSG_error_t MSG_action_trace_run(char *path)
{
MSG_error_t res;
+ char *name;
+ xbt_dynar_t todo;
+ xbt_dict_cursor_t cursor;
if (path) {
action_fp = fopen(path, "r");
if (xbt_dict_size(action_queues)) {
WARN0("Not all actions got consumed. If the simulation ended successfully (without deadlock), you may want to add new processes to your deployment file.");
- xbt_dict_cursor_t cursor;
- char *name;
- xbt_dynar_t todo;
+
xbt_dict_foreach(action_queues,cursor,name,todo) {
WARN2("Still %lu actions for %s",xbt_dynar_length(todo),name);
*/
xbt_main_func_t SIMIX_get_registered_function(const char *name)
{
+ xbt_main_func_t res = NULL;
xbt_assert0(simix_global,
"SIMIX_global_init has to be called before SIMIX_get_registered_function.");
- xbt_main_func_t res =
- xbt_dict_get_or_null(simix_global->registered_functions, name);
+ res = xbt_dict_get_or_null(simix_global->registered_functions, name);
return res ? res : default_function;
}
void SIMIX_process_change_host(smx_process_t process, char *source,
char *dest)
{
+ smx_host_t h1 = NULL;
+ smx_host_t h2 = NULL;
xbt_assert0((process != NULL), "Invalid parameters");
- smx_host_t h1 = SIMIX_host_get_by_name(source);
- smx_host_t h2 = SIMIX_host_get_by_name(dest);
+ h1 = SIMIX_host_get_by_name(source);
+ h2 = SIMIX_host_get_by_name(dest);
process->smx_host = h2;
xbt_swag_remove(process, h1->process_list);
xbt_swag_insert(process, h2->process_list);
}
/** @brief Destroys a semaphore */
void SIMIX_sem_destroy(smx_sem_t sem) {
+ smx_action_t action = NULL;
DEBUG1("Destroy semaphore %p", sem);
if (sem == NULL)
return;
- smx_action_t action = NULL;
-
xbt_assert0(xbt_swag_size(sem->sleeping) == 0,
"Cannot destroy semaphore since someone is still using it");
xbt_swag_free(sem->sleeping);
static surf_action_t net_communicate(const char *src_name, const char *dst_name,
int src, int dst, double size, double rate)
{
+ unsigned int i;
+ link_CM02_t link;
+ int failed = 0;
surf_action_network_CM02_t action = NULL;
/* LARGE PLATFORMS HACK:
Add a link_CM02_t *link and a int link_nb to network_card_CM02_t. It will represent local links for this node
xbt_dynar_t route = used_routing->get_route(src, dst);
/* LARGE PLATFORMS HACK:
total_route_size = route_size + src->link_nb + dst->nb */
- unsigned int i;
XBT_IN4("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
/* LARGE PLATFORMS HACK:
"You're trying to send data from %s to %s but there is no connection between these two hosts.",
src_name, dst_name);
- link_CM02_t link;
- int failed = 0;
xbt_dynar_foreach(route, i, link) {
if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
failed = 1;
static surf_action_t netviva_communicate(const char *src_name, const char *dst_name,
int src, int dst, double size, double rate)
{
+ surf_action_network_Vivaldi_t action = NULL;
netviva_coords_t c1,c2;
c1 = xbt_dict_get(coords,src_name);
c2 = xbt_dict_get(coords,dst_name);
- surf_action_network_Vivaldi_t action = NULL;
-
- action =
- surf_action_new(sizeof(s_surf_action_network_Vivaldi_t), size,
- surf_network_model, 0);
+ action = surf_action_new(sizeof(s_surf_action_network_Vivaldi_t), size,surf_network_model, 0);
action->suspended = 0;
/* create the config set, register what should be and parse the command line*/
void surf_config_init(int *argc, char **argv)
{
-
- /* Create the configuration support */
- if (_surf_init_status == 0) { /* Only create stuff if not already inited */
- _surf_init_status = 1;
-
char *description = xbt_malloc(1024), *p = description;
char *default_value;
double double_default_value;
int default_value_int;
int i;
+ /* Create the configuration support */
+ if (_surf_init_status == 0) { /* Only create stuff if not already inited */
+ _surf_init_status = 1;
+
sprintf(description, "The model to use for the CPU. Possible values: ");
p = description;
while (*(++p) != '\0');
{
char *workstation_model_name;
int workstation_id = -1;
-
+ char *network_model_name = NULL;
+ char *cpu_model_name = NULL;
surf_timer_model_init(platform_file);
workstation_model_name =
xbt_cfg_get_string(_surf_cfg_set, "workstation/model");
- char *network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
- char *cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
+ network_model_name = xbt_cfg_get_string(_surf_cfg_set, "network/model");
+ cpu_model_name = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
if ((strcmp(network_model_name,"LV08") || strcmp(cpu_model_name,"Cas01"))
&& !strcmp(workstation_model_name, "CLM03")){
char *cluster_bb_bw = A_surfxml_cluster_bb_bw;
char *cluster_bb_lat = A_surfxml_cluster_bb_lat;
char *backbone_name;
-
+ unsigned int it1,it2;
+ char *name1,*name2;
+ xbt_dynar_t names = NULL;
surfxml_bufferstack_push(1);
/* Make set a set to parse the prefix/suffix/radical into a neat list of names */
SURFXML_START_TAG(set);
SURFXML_END_TAG(set);
- xbt_dynar_t names = xbt_dict_get(set_list,cluster_id);
+ names = xbt_dict_get(set_list,cluster_id);
- unsigned int it1,it2;
- char *name1,*name2;
xbt_dynar_foreach(names,it1,name1) {
/* create the host */
routing_full_parse_change_cpu_data(name1, cluster_power, "1.0", "", "");
xbt_dynar_t links, keys;
unsigned int i,j;
-
+ unsigned int a,b,c;
int host_count = routing->generic_routing.host_count;
+ char * link_name = NULL;
+ void * link = NULL;
/* Create Cost, Predecessor and Link tables */
cost_table = xbt_new0(double, host_count * host_count); //link cost from host to host
src_id,dst_id,routing->generic_routing.host_count,xbt_dynar_length(links));
xbt_assert3(xbt_dynar_length(links) == 1, "%ld links in route between host %d and %d, should be 1", xbt_dynar_length(links), src_id, dst_id);
- char * link_name = xbt_dynar_getfirst_as(links, char*);
- void * link = xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
+ link_name = xbt_dynar_getfirst_as(links, char*);
+ link = xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
+
if (link)
link_list = link;
else
//Calculate path costs
- unsigned int a,b,c;
+
for(c=0;c<host_count;c++) {
for(a=0;a<host_count;a++) {
for(b=0;b<host_count;b++) {
* Utility functions
*/
static xbt_node_t route_graph_new_node(int id, int graph_id) {
+ xbt_node_t node = NULL;
+ graph_node_data_t data = NULL;
+ graph_node_map_element_t elm = NULL;
routing_dijkstra_t routing = (routing_dijkstra_t) used_routing;
- graph_node_data_t data = xbt_new0(struct graph_node_data, sizeof(struct graph_node_data));
+ data = xbt_new0(struct graph_node_data, sizeof(struct graph_node_data));
data->id = id;
data->graph_id = graph_id;
- xbt_node_t node = xbt_graph_new_node(routing->route_graph, data);
+ node = xbt_graph_new_node(routing->route_graph, data);
- graph_node_map_element_t elm = xbt_new0(struct graph_node_map_element, sizeof(struct graph_node_map_element));
+ elm = xbt_new0(struct graph_node_map_element, sizeof(struct graph_node_map_element));
elm->node = node;
xbt_dict_set_ext(routing->graph_node_map, (char*)(&id), sizeof(int), (xbt_set_elm_t)elm, &graph_node_map_elem_free);
char *key, *data, *end;
const char *sep = "#";
xbt_dynar_t links, keys;
-
+ char* link_name = NULL;
+ void* link = NULL;
+ xbt_node_t node = NULL;
+ unsigned int cursor2;
+ xbt_dynar_t nodes = NULL;
/* Create the topology graph */
routing->route_graph = xbt_graph_new_graph(1, NULL);
routing->graph_node_map = xbt_dict_new();
xbt_assert3(xbt_dynar_length(links) == 1, "%ld links in route between host %d and %d, should be 1", xbt_dynar_length(links), src_id, dst_id);
- char* link_name = xbt_dynar_getfirst_as(links, char*);
- void* link = xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
+ link_name = xbt_dynar_getfirst_as(links, char*);
+ link = xbt_dict_get_or_null(surf_network_model->resource_set, link_name);
if (link)
route_new_dijkstra(src_id,dst_id,link);
else
add_loopback_dijkstra();
/* initialize graph indexes in nodes after graph has been built */
- xbt_dynar_t nodes = xbt_graph_get_nodes(routing->route_graph);
+ nodes = xbt_graph_get_nodes(routing->route_graph);
- xbt_node_t node = NULL;
- unsigned int cursor2;
xbt_dynar_foreach(nodes, cursor2, node) {
graph_node_data_t data = xbt_graph_node_get_data(node);
data->graph_id = cursor2;
routing_dijkstra_t routing = (routing_dijkstra_t) used_routing;
int * pred_arr = NULL;
-
+ int src_node_id = 0;
+ int dst_node_id = 0;
+ int * nodeid = NULL;
+ int v;
+ int size = 0;
+ void * link = NULL;
+ route_cache_element_t elm = NULL;
xbt_dynar_t nodes = xbt_graph_get_nodes(routing->route_graph);
/*Use the graph_node id mapping set to quickly find the nodes */
graph_node_map_element_t src_elm = graph_node_map_search(src_id);
graph_node_map_element_t dst_elm = graph_node_map_search(dst_id);
xbt_assert2(src_elm != NULL && dst_elm != NULL, "src %d or dst %d does not exist", src_id, dst_id);
- int src_node_id = ((graph_node_data_t)xbt_graph_node_get_data(src_elm->node))->graph_id;
- int dst_node_id = ((graph_node_data_t)xbt_graph_node_get_data(dst_elm->node))->graph_id;
+ src_node_id = ((graph_node_data_t)xbt_graph_node_get_data(src_elm->node))->graph_id;
+ dst_node_id = ((graph_node_data_t)xbt_graph_node_get_data(dst_elm->node))->graph_id;
- route_cache_element_t elm = NULL;
if(routing->cached) {
/*check if there is a cached predecessor list avail */
elm = (route_cache_element_t)xbt_dict_get_or_null_ext(routing->route_cache, (char*)(&src_id), sizeof(int));
pred_arr[i] = 0;
//initialize priority queue
- int * nodeid = xbt_new0(int, 1);
+ nodeid = xbt_new0(int, 1);
*nodeid = i;
xbt_heap_push(pqueue, nodeid, cost_arr[i]);
if(cost_v_u + cost_arr[*v_id] < cost_arr[u_id]) {
pred_arr[u_id] = *v_id;
cost_arr[u_id] = cost_v_u + cost_arr[*v_id];
- int * nodeid = xbt_new0(int, 1);
+ nodeid = xbt_new0(int, 1);
*nodeid = u_id;
xbt_heap_push(pqueue, nodeid, cost_arr[u_id]);
}
//compose route path with links
xbt_dynar_reset(routing->last_route);
- int v;
- int size = 0;
for(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);
xbt_node_t node_v = xbt_dynar_get_as(nodes, v, xbt_node_t);
xbt_assert2(edge != NULL, "no route between host %d and %d", src_id, dst_id);
- void * link = xbt_graph_edge_get_data(edge);
+ link = xbt_graph_edge_get_data(edge);
xbt_dynar_unshift(routing->last_route, &link);
size++;
}
tmgr_trace_t tmgr_trace_new(const char *filename)
{
+ char *tstr = NULL;
FILE *f = NULL;
tmgr_trace_t trace = NULL;
xbt_assert2(f!=NULL, "Cannot open file '%s' (path=%s)", filename,
xbt_str_join(surf_path,":"));
- char *tstr = xbt_str_from_file(f);
+ tstr = xbt_str_from_file(f);
fclose(f);
trace = tmgr_trace_new_from_string(filename, tstr, 0.);
xbt_free(tstr);
void xbt_setset_elm_add(xbt_setset_t setset, void *obj)
{
xbt_setset_elm_entry_t new_entry = NULL;
+ xbt_setset_elm_entry_t first_elm = NULL;
xbt_setset_elm_t e = (xbt_setset_elm_t)obj;
xbt_assert0(e->ID == 0, "Adding element with non NULL ID");
- xbt_setset_elm_entry_t first_elm =
- (xbt_setset_elm_entry_t)xbt_dynar_get_ptr(setset->elm_array, 0);
+ first_elm = (xbt_setset_elm_entry_t)xbt_dynar_get_ptr(setset->elm_array, 0);
/* Before create a new elm entry check if there is one in the free elm list. */
/* If there is not free elm entries, then create a new one */
v = v - ((v >> 1) & 0x55555555); // reuse input as temporary
v = (v & 0x33333333) + ((v >> 2) & 0x33333333); // temp
return (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24; // count
-}
\ No newline at end of file
+}
xbt_log_appender_t app)
{
char *p;
-
+ const char *procname=NULL;
xbt_assert0(ev->priority >= 0,
"Negative logging priority naturally forbidden");
xbt_assert1(ev->priority < sizeof(xbt_log_priority_names),
check_overflow;
/* Display the proc info if available */
- const char *procname=xbt_procname();
+ procname=xbt_procname();
if (strlen(procname)) {
p += snprintf(p, XBT_LOG_BUFF_SIZE - (p - ev->buffer), "%s:%s:(%d) ",
gras_os_myname(), procname, (*xbt_getpid) ());