Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 15b07521 authored by François Trahay's avatar François Trahay
Browse files

OTF2: show the thread begin/end events

parent 5bd79b4e
No related branches found
No related tags found
2 merge requests!109Improve the OTF2 parser,!106fix Otf2
...@@ -5,7 +5,7 @@ project(VITE CXX C) ...@@ -5,7 +5,7 @@ project(VITE CXX C)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
# Set c++11 support # Set c++11 support
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
......
...@@ -232,9 +232,12 @@ OTF2_CallbackCode ParserDefinitionOTF2::handler_DefLocation(void *userData, ...@@ -232,9 +232,12 @@ OTF2_CallbackCode ParserDefinitionOTF2::handler_DefLocation(void *userData,
uint64_t numberOfEvents, uint64_t numberOfEvents,
OTF2_LocationGroupRef locationGroup) { OTF2_LocationGroupRef locationGroup) {
OTF2_Reader *reader = (OTF2_Reader *)userData; OTF2_Reader *reader = (OTF2_Reader *)userData;
OTF2_Reader_SelectLocation(reader, locationIdentifier);
OTF2_EvtReader *evt_reader = OTF2_Reader_GetEvtReader(reader, locationIdentifier); OTF2_EvtReader *evt_reader = OTF2_Reader_GetEvtReader(reader, locationIdentifier);
OTF2_DefReader *def_reader = OTF2_Reader_GetDefReader(reader, locationIdentifier); OTF2_DefReader *def_reader = OTF2_Reader_GetDefReader(reader, locationIdentifier);
uint64_t definitions_read = 0; uint64_t definitions_read = 0;
OTF2_Reader_ReadAllLocalDefinitions(reader, def_reader, &definitions_read); OTF2_Reader_ReadAllLocalDefinitions(reader, def_reader, &definitions_read);
OTF2_Location *temp = new OTF2_Location(); OTF2_Location *temp = new OTF2_Location();
...@@ -537,6 +540,11 @@ Color *ParserDefinitionOTF2::get_color(uint32_t func_id) { ...@@ -537,6 +540,11 @@ Color *ParserDefinitionOTF2::get_color(uint32_t func_id) {
return new Color(*_default_colors[func_id % NB_COLORS]); return new Color(*_default_colors[func_id % NB_COLORS]);
} }
Color *ParserDefinitionOTF2::get_color(String function_name) {
uint32_t func_id = std::hash<std::string>{}(function_name.to_string());
return get_color(func_id);
}
// //
// Other public functions // Other public functions
// //
......
...@@ -454,6 +454,7 @@ public: ...@@ -454,6 +454,7 @@ public:
static double get_timestamp(OTF2_TimeStamp ts); static double get_timestamp(OTF2_TimeStamp ts);
static Color *get_color(uint32_t func_id); static Color *get_color(uint32_t func_id);
static Color *get_color(String function_name);
static const char *get_string_by_id(uint32_t id); static const char *get_string_by_id(uint32_t id);
}; };
......
...@@ -178,6 +178,84 @@ OTF2_CallbackCode ParserEventOTF2::callback_ProgramEnd(OTF2_LocationRef location ...@@ -178,6 +178,84 @@ OTF2_CallbackCode ParserEventOTF2::callback_ProgramEnd(OTF2_LocationRef location
return OTF2_CALLBACK_SUCCESS; return OTF2_CALLBACK_SUCCESS;
} }
static OTF2_CallbackCode pushState(OTF2_LocationRef locationID,
OTF2_TimeStamp time,
Trace *t,
String function_name) {
Date d = ParserDefinitionOTF2::get_timestamp(time);
map<string, Value *> extra_fields;
// get the container
OTF2_Location *temp_location = ParserDefinitionOTF2::get_location_by_id(locationID);
const String proc_name = String(ParserDefinitionOTF2::get_string_id(temp_location));
Container *temp_container = temp_location->container;
#if defined(OTF2_DEBUG)
cout << d.to_string() << " Enter_print(location=" << proc_name.to_string() << ", fname=" << function_name.to_string() << ")\n";
#endif // defined(OTF2_DEBUG)
// get the state type
String state_type_string("Function");
StateType *temp_state_type = t->search_state_type(state_type_string);
if (temp_state_type == 0) {
Name name_temp(state_type_string);
ContainerType cont_type = *temp_container->get_type();
t->define_state_type(name_temp, &cont_type, extra_fields);
temp_state_type = t->search_state_type(state_type_string);
assert(temp_state_type != 0);
}
// get the entity value
EntityValue *temp_value = NULL;
temp_value = t->search_entity_value(function_name, temp_state_type);
if (temp_value == NULL) {
map<string, Value *> opt;
Name entity_name(function_name);
opt["Color"] = ParserDefinitionOTF2::get_color(function_name);
t->define_entity_value(entity_name, temp_state_type, opt);
temp_value = t->search_entity_value(function_name, temp_state_type);
}
assert(temp_value);
t->push_state(d, temp_state_type, temp_container, temp_value, extra_fields);
return OTF2_CALLBACK_SUCCESS;
}
static OTF2_CallbackCode popState(OTF2_LocationRef locationID,
OTF2_TimeStamp time,
Trace *t,
String function_name) {
Date d = ParserDefinitionOTF2::get_timestamp(time);
map<string, Value *> extra_fields;
// get the container
OTF2_Location *temp_location = ParserDefinitionOTF2::get_location_by_id(locationID);
const String proc_name = String(ParserDefinitionOTF2::get_string_id(temp_location));
Container *temp_container = temp_location->container;
#if defined(OTF2_DEBUG)
cout << d.to_string() << " Leave_print(location=" << proc_name.to_string() << ", fname=" << function_name.to_string() << ")\n";
#endif // defined(OTF2_DEBUG)
// get the state type
String state_type_string("Function");
StateType *temp_state_type = t->search_state_type(state_type_string);
if (temp_state_type == 0) {
Name name_temp(state_type_string);
ContainerType cont_type = *temp_container->get_type();
t->define_state_type(name_temp, &cont_type, extra_fields);
temp_state_type = t->search_state_type(state_type_string);
assert(temp_state_type != 0);
}
t->pop_state(d, temp_state_type, temp_container, extra_fields);
return OTF2_CALLBACK_SUCCESS;
}
// //
// Start definition of handlers for OTF2 event records // Start definition of handlers for OTF2 event records
// //
...@@ -188,6 +266,11 @@ OTF2_CallbackCode ParserEventOTF2::callback_Enter(OTF2_LocationRef locationID, ...@@ -188,6 +266,11 @@ OTF2_CallbackCode ParserEventOTF2::callback_Enter(OTF2_LocationRef locationID,
OTF2_RegionRef regionID) { OTF2_RegionRef regionID) {
ENTER_CALLBACK(time, locationID); ENTER_CALLBACK(time, locationID);
Trace *t = (Trace *)userData; Trace *t = (Trace *)userData;
OTF2_Function temp_function = ParserDefinitionOTF2::get_function_by_id(regionID);
const String function_name = String(ParserDefinitionOTF2::get_string_by_id(temp_function._name_id));
return pushState(locationID, time, t, function_name);
#if 0
Date d = ParserDefinitionOTF2::get_timestamp(time); Date d = ParserDefinitionOTF2::get_timestamp(time);
OTF2_Function temp_function = ParserDefinitionOTF2::get_function_by_id(regionID); OTF2_Function temp_function = ParserDefinitionOTF2::get_function_by_id(regionID);
const String function_name = String(ParserDefinitionOTF2::get_string_by_id(temp_function._name_id)); const String function_name = String(ParserDefinitionOTF2::get_string_by_id(temp_function._name_id));
...@@ -226,7 +309,7 @@ OTF2_CallbackCode ParserEventOTF2::callback_Enter(OTF2_LocationRef locationID, ...@@ -226,7 +309,7 @@ OTF2_CallbackCode ParserEventOTF2::callback_Enter(OTF2_LocationRef locationID,
assert(temp_value); assert(temp_value);
t->push_state(d, temp_state_type, temp_container, temp_value, extra_fields); t->push_state(d, temp_state_type, temp_container, temp_value, extra_fields);
#endif
return OTF2_CALLBACK_SUCCESS; return OTF2_CALLBACK_SUCCESS;
} }
...@@ -1025,14 +1108,15 @@ OTF2_CallbackCode ParserEventOTF2::callback_ThreadCreate(OTF2_LocationRef locati ...@@ -1025,14 +1108,15 @@ OTF2_CallbackCode ParserEventOTF2::callback_ThreadCreate(OTF2_LocationRef locati
OTF2_CallbackCode ParserEventOTF2::callback_ThreadBegin(OTF2_LocationRef locationID, OTF2_CallbackCode ParserEventOTF2::callback_ThreadBegin(OTF2_LocationRef locationID,
OTF2_TimeStamp time, OTF2_TimeStamp time,
void * /*userData*/, void * userData,
OTF2_AttributeList * /*attributeList*/, OTF2_AttributeList * /*attributeList*/,
OTF2_CommRef /*threadContingent*/, OTF2_CommRef /*threadContingent*/,
uint64_t /*sequenceCount*/) { uint64_t /*sequenceCount*/) {
ENTER_CALLBACK(time, locationID); ENTER_CALLBACK(time, locationID);
// Nothing to do here Trace *t = (Trace *)userData;
return OTF2_CALLBACK_SUCCESS; const String function_name("");
return pushState(locationID, time, t, function_name);
} }
OTF2_CallbackCode ParserEventOTF2::callback_ThreadWait(OTF2_LocationRef locationID, OTF2_CallbackCode ParserEventOTF2::callback_ThreadWait(OTF2_LocationRef locationID,
...@@ -1048,12 +1132,16 @@ OTF2_CallbackCode ParserEventOTF2::callback_ThreadWait(OTF2_LocationRef location ...@@ -1048,12 +1132,16 @@ OTF2_CallbackCode ParserEventOTF2::callback_ThreadWait(OTF2_LocationRef location
OTF2_CallbackCode ParserEventOTF2::callback_ThreadEnd(OTF2_LocationRef locationID, OTF2_CallbackCode ParserEventOTF2::callback_ThreadEnd(OTF2_LocationRef locationID,
OTF2_TimeStamp time, OTF2_TimeStamp time,
void * /*userData*/, void * userData,
OTF2_AttributeList * /*attributeList*/, OTF2_AttributeList * /*attributeList*/,
OTF2_CommRef /*threadContingent*/, OTF2_CommRef /*threadContingent*/,
uint64_t /*sequenceCount*/) { uint64_t /*sequenceCount*/) {
ENTER_CALLBACK(time, locationID); ENTER_CALLBACK(time, locationID);
// Nothing to do here // Nothing to do here
Trace *t = (Trace *)userData;
const String function_name("");
return popState(locationID, time, t, function_name);
return OTF2_CALLBACK_SUCCESS; return OTF2_CALLBACK_SUCCESS;
} }
......
...@@ -78,7 +78,7 @@ bool ParserFactory::create(Parser **parser, ...@@ -78,7 +78,7 @@ bool ParserFactory::create(Parser **parser,
else if (ext == ".ept") { else if (ext == ".ept") {
*parser = new ParserVite(filename); *parser = new ParserVite(filename);
} }
else if (ext == ".otf2") { else if (ext == ".pallas") {
#ifdef WITH_OTF2 #ifdef WITH_OTF2
*parser = new ParserOTF2(filename); *parser = new ParserOTF2(filename);
#else #else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment