--- /dev/null
+/* Copyright (c) 2010-2012, 2014-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. */
+
+#ifndef JEDULE_HPP_
+#define JEDULE_HPP_
+#include <stdio.h>
+#include "simgrid_config.h"
+
+#include "jedule_events.hpp"
+#include "jedule_platform.hpp"
+
+#if HAVE_JEDULE
+
+XBT_ATTRIB_UNUSED static std::unordered_map <const char *, jed_container_t> host2_simgrid_parent_container;
+XBT_ATTRIB_UNUSED static std::unordered_map <std::string, jed_container_t> container_name2container;
+
+namespace simgrid {
+namespace jedule{
+
+
+XBT_PUBLIC_CLASS Jedule {
+public:
+ Jedule()=default;
+ ~Jedule();
+ std::vector<Event *> event_set;
+ Container* root_container = nullptr;
+ std::unordered_map<char*, char*> meta_info;
+ void addMetaInfo(char* key, char* value);
+ void cleanupOutput();
+ void writeOutput(FILE *file);
+};
+
+}
+}
+
+SG_BEGIN_DECL()
+
+typedef simgrid::jedule::Jedule *jedule_t;
+
+SG_END_DECL()
+#endif
+
+#endif /* JEDULE_HPP_ */
namespace jedule{
XBT_PUBLIC_CLASS Event{
- private:
- virtual ~Event()=default;
public:
Event(std::string name, double start_time, double end_time, std::string type)
: name(name), start_time(start_time), end_time(end_time), type(type){}
- void deleteEvent();
+ ~Event();
void addCharacteristic(char *characteristic);
void addResources(std::vector<sg_host_t> *host_selection);
void addInfo(char *key, char *value);
+++ /dev/null
-/* Copyright (c) 2010-2012, 2014-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. */
-
-#ifndef JEDULE_OUTPUT_H_
-#define JEDULE_OUTPUT_H_
-
-#include <stdio.h>
-#include "simgrid_config.h"
-
-#include "jedule_events.hpp"
-#include "jedule_platform.hpp"
-
-#if HAVE_JEDULE
-SG_BEGIN_DECL()
-extern xbt_dynar_t jedule_event_list;
-
-void jedule_init_output(void);
-void jedule_cleanup_output(void);
-void jedule_store_event(jed_event_t event);
-void write_jedule_output(FILE *file, jedule_t jedule, xbt_dynar_t event_list);
-
-SG_END_DECL()
-#endif
-
-#endif /* JEDULE_OUTPUT_H_ */
#include "simgrid_config.h"
#include "simgrid/forward.h"
#include "xbt/dynar.h"
-#include "xbt/dict.h"
#include <unordered_map>
#include <vector>
#include <string>
XBT_PUBLIC_CLASS Container {
public:
Container(std::string name);
- virtual ~Container()=default;
+ virtual ~Container();
private:
int last_id;
int is_lowest = 0;
typedef struct jed_res_subset s_jed_res_subset_t, *jed_res_subset_t;
-/* FIXME: jedule should be objectified too */
-
-typedef struct jedule_struct {
- jed_container_t root_container;
- std::unordered_map<char*, char*> jedule_meta_info;
-} s_jedule_t;
-
-typedef s_jedule_t *jedule_t;
-
-void jed_create_jedule(jedule_t *jedule);
-void jed_free_jedule(jedule_t jedule);
-void jedule_add_meta_info(jedule_t jedule, char *key, char *value);
-
/**
* it is assumed that the host_names in the entire system are unique that means that we don't need parent references
*
--- /dev/null
+/* Copyright (c) 2010-2014. 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/host.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "xbt/asserts.h"
+#include "simgrid/jedule/jedule.hpp"
+
+#if HAVE_JEDULE
+
+namespace simgrid{
+namespace jedule {
+
+Jedule::~Jedule() {
+ delete this->root_container;
+ for (auto evt: this->event_set)
+ delete evt;
+ this->event_set.clear();
+}
+
+void Jedule::addMetaInfo(char *key, char *value) {
+ xbt_assert(key != nullptr);
+ xbt_assert(value != nullptr);
+
+ this->meta_info.insert({key, value});
+}
+
+void Jedule::cleanupOutput() {
+ for (auto evt: this->event_set)
+ delete evt;
+ this->event_set.clear();
+}
+void Jedule::writeOutput(FILE *file) {
+ if (!this->event_set.empty()){
+
+ fprintf(file, "<jedule>\n");
+
+ if (!this->meta_info.empty()){
+ fprintf(file, " <jedule_meta>\n");
+ for (auto elm: this->meta_info)
+ fprintf(file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
+ fprintf(file, " </jedule_meta>\n");
+ }
+
+ fprintf(file, " <platform>\n");
+ this->root_container->print(file);
+ fprintf(file, " </platform>\n");
+
+ fprintf(file, " <events>\n");
+ for (auto event :this->event_set)
+ event->print(file);
+ fprintf(file, " </events>\n");
+
+ fprintf(file, "</jedule>\n");
+ }
+}
+
+}
+}
+#endif
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/jedule/jedule_events.hpp"
-#include "simgrid/jedule/jedule_output.hpp"
+#include "simgrid/jedule/jedule.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <string>
namespace simgrid{
namespace jedule{
- /* FIXME: this should could maybe be merged into the destructor? */
-void Event::deleteEvent(){
+Event::~Event(){
while (!this->resource_subsets.empty()){
xbt_free(this->resource_subsets.back());
this->resource_subsets.pop_back();
}
- delete this;
}
void Event::addResources(std::vector<sg_host_t> *host_selection) {
+++ /dev/null
-/* Copyright (c) 2010-2014. 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/jedule/jedule_output.hpp"
-#include "simgrid/host.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "xbt/dynar.h"
-#include "xbt/asserts.h"
-
-#if HAVE_JEDULE
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(jed_out, jedule, "Logging specific to Jedule output");
-
-xbt_dynar_t jedule_event_list;
-
-void write_jedule_output(FILE *file, jedule_t jedule, xbt_dynar_t event_list) {
- if (!xbt_dynar_is_empty(jedule_event_list)){
-
- fprintf(file, "<jedule>\n");
-
- if (!jedule->jedule_meta_info.empty()){
- fprintf(file, " <jedule_meta>\n");
- for (auto elm: jedule->jedule_meta_info)
- fprintf(file, " <prop key=\"%s\" value=\"%s\" />\n",elm.first,elm.second);
- fprintf(file, " </jedule_meta>\n");
- }
-
- fprintf(file, " <platform>\n");
- jedule->root_container->print(file);
- fprintf(file, " </platform>\n");
-
- fprintf(file, " <events>\n");
- unsigned int i;
- jed_event_t event;
- xbt_dynar_foreach(event_list, i, event) {
- event->print(file);
- }
- fprintf(file, " </events>\n");
-
- fprintf(file, "</jedule>\n");
- }
-}
-
-void jedule_init_output() {
- jedule_event_list = xbt_dynar_new(sizeof(jed_event_t), nullptr);
-}
-
-void jedule_cleanup_output() {
- while (!xbt_dynar_is_empty(jedule_event_list)) {
- jed_event_t evt = xbt_dynar_pop_as(jedule_event_list, jed_event_t) ;
- evt->deleteEvent();
- }
-
- xbt_dynar_free_container(&jedule_event_list);
-}
-
-void jedule_store_event(jed_event_t event) {
- xbt_assert(event != nullptr);
- xbt_dynar_push(jedule_event_list, &event);
-}
-#endif
/* 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/jedule/jedule.hpp"
#include "simgrid/jedule/jedule_platform.hpp"
-#include "simgrid/jedule/jedule_output.hpp"
#include "simgrid/s4u/As.hpp"
#include "simgrid/host.h"
#if HAVE_JEDULE
-static xbt_dict_t host2_simgrid_parent_container;
-static xbt_dict_t container_name2container;
-
namespace simgrid {
namespace jedule {
Container::Container(std::string name)
: name(name) {
+ container_name2container.insert({this->name, this});
+}
- xbt_dict_set(container_name2container, this->name.c_str(), this, nullptr);
+Container::~Container(){
+ if(!this->children.empty()) {
+ for (auto child: this->children){
+ delete child;
+ }
+ }
}
void Container::addChild(jed_container_t child){
const char *host_name = sg_host_get_name(host);
this->name2id.insert({host_name, this->last_id});
(this->last_id)++;
- xbt_dict_set(host2_simgrid_parent_container, host_name, this, nullptr);
+ host2_simgrid_parent_container.insert({host_name, this});
this->resource_list.push_back(host);
}
}
return *((int*) num1) - *((int*) num2);
}
-/* FIXME: That should be the destructor, shouldnt it? */
-static void jed_free_container(jed_container_t container) {
- if(!container->children.empty()) {
- for (auto child: container->children){
- jed_free_container(child);
- }
- }
- delete container;
-}
-
static void add_subset_to(xbt_dynar_t subset_list, int start, int end, jed_container_t parent) {
jed_res_subset_t subset;
// compact ids
// create subset for each id group
- xbt_assert( host2_simgrid_parent_container != nullptr );
xbt_assert( subset_list != nullptr );
xbt_assert( hostgroup != nullptr );
xbt_assert( parent != nullptr );
xbt_dynar_foreach(hostgroup, iter, host_name) {
jed_container_t parent;
xbt_assert( host_name != nullptr );
- parent = (jed_container_t)xbt_dict_get(host2_simgrid_parent_container, host_name);
+ parent = (jed_container_t)host2_simgrid_parent_container.at(host_name);
id = parent->name2id.at(host_name);
xbt_dynar_push(id_list, &id);
}
for (auto host: *host_list) {
const char *host_name = sg_host_get_name(host);
- jed_container_t parent = (jed_container_t)xbt_dict_get(host2_simgrid_parent_container, host_name);
+ jed_container_t parent = (jed_container_t)host2_simgrid_parent_container.at(host_name);
xbt_assert( parent != nullptr );
auto host_group = parent2hostgroup.find(parent->name.c_str());
}
for (auto elm: parent2hostgroup) {
- jed_container_t parent = (jed_container_t)xbt_dict_get(container_name2container, elm.first);
+ jed_container_t parent = (jed_container_t)container_name2container.at(elm.first);
add_subsets_to(subset_list, elm.second, parent);
xbt_dynar_free_container(&elm.second);
}
}
-void jedule_add_meta_info(jedule_t jedule, char *key, char *value) {
- xbt_assert(key != nullptr);
- xbt_assert(value != nullptr);
- jedule->jedule_meta_info.insert({key, value});
-}
-
-void jed_create_jedule(jedule_t *jedule) {
- *jedule = xbt_new0(s_jedule_t,1);
- host2_simgrid_parent_container = xbt_dict_new_homogeneous(nullptr);
- container_name2container = xbt_dict_new_homogeneous(nullptr);
-}
-
-void jed_free_jedule(jedule_t jedule) {
- jed_free_container(jedule->root_container);
-
- xbt_free(jedule);
-
- xbt_dict_free(&host2_simgrid_parent_container);
- xbt_dict_free(&container_name2container);
-}
#endif
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "xbt/asserts.h"
-#include "xbt/dynar.h"
#include "src/surf/surf_private.h"
#include "surf/surf.h"
#include <stdio.h>
#include "simgrid/forward.h"
+#include "simgrid/jedule/jedule.hpp"
#include "simgrid/jedule/jedule_events.hpp"
-#include "simgrid/jedule/jedule_output.hpp"
#include "simgrid/jedule/jedule_platform.hpp"
#include "../../simdag/simdag_private.hpp"
jed_event_t event =
new simgrid::jedule::Event(std::string(SD_task_get_name(task)), task->start_time, task->finish_time,"SD");
event->addResources(task->allocation);
- jedule_store_event(event);
+ my_jedule->event_set.push_back(event);
}
void jedule_setup_platform()
{
- jed_create_jedule(&my_jedule);
-
AS_t root_comp = simgrid::s4u::Engine::instance()->rootAs();
XBT_DEBUG("root name %s\n", root_comp->name());
- jed_container_t root_container = new simgrid::jedule::Container(std::string(root_comp->name()));
- my_jedule->root_container = root_container;
+ my_jedule = new simgrid::jedule::Jedule();
+ jed_container_t root_container = new simgrid::jedule::Container(std::string(root_comp->name()));
root_container->createHierarchy(root_comp);
+ my_jedule->root_container = root_container;
}
void jedule_sd_cleanup()
{
- jedule_cleanup_output();
+ my_jedule->cleanupOutput();
}
void jedule_sd_init()
{
- jedule_init_output();
}
void jedule_sd_exit(void)
{
- if (my_jedule) {
- jed_free_jedule(my_jedule);
- my_jedule = nullptr;
- }
+ delete my_jedule;
}
void jedule_sd_dump(const char * filename)
FILE *fh = fopen(fname, "w");
- write_jedule_output(fh, my_jedule, jedule_event_list);
+ my_jedule->writeOutput(fh);
fclose(fh);
xbt_free(fname);
/* jedule */
#if HAVE_JEDULE
XBT_LOG_CONNECT(jedule);
- XBT_LOG_CONNECT(jed_out);
XBT_LOG_CONNECT(jed_sd);
#endif
set(JEDULE_SRC
include/simgrid/jedule/jedule_events.hpp
- include/simgrid/jedule/jedule_output.hpp
+ include/simgrid/jedule/jedule.hpp
include/simgrid/jedule/jedule_platform.hpp
include/simgrid/jedule/jedule_sd_binding.h
src/instr/jedule/jedule_events.cpp
- src/instr/jedule/jedule_output.cpp
+ src/instr/jedule/jedule.cpp
src/instr/jedule/jedule_platform.cpp
src/instr/jedule/jedule_sd_binding.cpp
)