- // tracing system must be:
- // - enabled (with --cfg=tracing:1)
- // - already configured (TRACE_global_init already called)
- if (!(TRACE_is_enabled() && TRACE_is_configured())){
- return 0;
- }
-
- /* open the trace file */
- char *filename = TRACE_get_filename();
- if (!filename) {
- THROW0(tracing_error, TRACE_ERROR_START,
- "Trace filename is not initialized.");
- return 0;
- }
- FILE *file = fopen(filename, "w");
- if (!file) {
- THROW1(tracing_error, TRACE_ERROR_START,
- "Tracefile %s could not be opened for writing.", filename);
- } else {
- TRACE_paje_start(file);
- }
-
- /* activate trace */
- TRACE_activate ();
-
- /* output header */
- TRACE_paje_create_header();
-
- /* define paje hierarchy for tracing */
- pajeDefineContainerType("PLATFORM", "0", "platform");
- pajeDefineContainerType("HOST", "PLATFORM", "HOST");
- pajeDefineContainerType("LINK", "PLATFORM", "LINK");
- pajeDefineVariableType("power", "HOST", "power");
- pajeDefineVariableType("bandwidth", "LINK", "bandwidth");
- pajeDefineVariableType("latency", "LINK", "latency");
- pajeDefineEventType("source", "LINK", "source");
- pajeDefineEventType("destination", "LINK", "destination");
-
- if (IS_TRACING_PLATFORM) {
- if (TRACE_uncategorized()){
- pajeDefineVariableType("power_used", "HOST", "power_used");
- pajeDefineVariableType("bandwidth_used", "LINK", "bandwidth_used");
- }
- }
-
- if (IS_TRACING_PROCESSES || IS_TRACING_VOLUME) {
- //processes grouped by host
- pajeDefineContainerType("PROCESS", "HOST", "PROCESS");
- }
-
- if (IS_TRACING_PROCESSES) {
- pajeDefineStateType("category", "PROCESS", "category");
- pajeDefineStateType("presence", "PROCESS", "presence");
- }
-
- if (IS_TRACING_VOLUME) {
- pajeDefineLinkType("volume", "0", "PROCESS", "PROCESS", "volume");
- }
-
- if (IS_TRACING_TASKS) {
- //tasks grouped by host
- pajeDefineContainerType("TASK", "HOST", "TASK");
- pajeDefineStateType("category", "TASK", "category");
- pajeDefineStateType("presence", "TASK", "presence");
- }
-
- if (IS_TRACING_SMPI) {
- if (TRACE_smpi_is_grouped()){
- pajeDefineContainerType("MPI_PROCESS", "HOST", "MPI_PROCESS");
- }else{
- pajeDefineContainerType("MPI_PROCESS", "PLATFORM", "MPI_PROCESS");
- }
- pajeDefineStateType("MPI_STATE", "MPI_PROCESS", "MPI_STATE");
- pajeDefineLinkType("MPI_LINK", "0", "MPI_PROCESS", "MPI_PROCESS",
- "MPI_LINK");
- }
-
- /* creating the platform */
- pajeCreateContainer(MSG_get_clock(), "platform", "PLATFORM", "0",
- "simgrid-platform");
-
- /* other trace initialization */
- defined_types = xbt_dict_new();
- created_categories = xbt_dict_new();
- TRACE_msg_task_alloc();
- TRACE_category_alloc();
- TRACE_surf_alloc();
- TRACE_msg_process_alloc();
- TRACE_smpi_alloc();
- return 0;
-}
-
-int TRACE_end()
-{
- if (!TRACE_is_active())
- return 1;
- FILE *file = TRACE_paje_end();
- fclose(file);
-
- TRACE_desactivate ();
- return 0;
-}
-
-int TRACE_category(const char *category)
-{
- return TRACE_category_with_color (category, NULL);
-}
-
-int TRACE_category_with_color (const char *category, const char *color)
-{
- static int first_time = 1;
- if (!TRACE_is_active())
- return 1;
-
- if (first_time) {
- TRACE_define_type("user_type", "0", 1);
- first_time = 0;
- }
- return TRACE_create_category_with_color(category, "user_type", "0", color);