diff --git a/CMakeLists.txt b/CMakeLists.txt index 10ef645d43f89af389fe760e91cd74006c939ccf..dc33dcb7d20e89917e80f4571d25b0391346fe2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,8 @@ cmake_dependent_option(VITE_DBG_MEMORY_TRACE ### Trace format options option(VITE_ENABLE_OTF "Enable the support of OTF file format." OFF) +option(VITE_ENABLE_OTF2 + "Enable the support of OTF2 file format." OFF) option(VITE_ENABLE_TAU "Enable the support of TAU file format." OFF) @@ -190,6 +192,10 @@ if(VITE_ENABLE_OTF) find_package(OTF) endif(VITE_ENABLE_OTF) +if(VITE_ENABLE_OTF2) + find_package(OTF2) +endif(VITE_ENABLE_OTF2) + if(VITE_ENABLE_TAU) find_package(TAU) endif(VITE_ENABLE_TAU) diff --git a/cmake/FindOTF2.cmake b/cmake/FindOTF2.cmake new file mode 100644 index 0000000000000000000000000000000000000000..15f075ad4d5a2353d08dcabf732231d02eaf5a6d --- /dev/null +++ b/cmake/FindOTF2.cmake @@ -0,0 +1,56 @@ +# +# Find the OTF2 libraries and include dir +# + +# OTF2_INCLUDE_DIR - Directories to include to use OTF2 +# OTF2_LIBRARY - Files to link against to use OTF2 +# OTF2_FOUND - When false, don't try to use OTF2 +# +# OTF2_DIR can be used to make it simpler to find the various include +# directories and compiled libraries when OTF2 was not installed in the +# usual/well-known directories (e.g. because you made an in tree-source +# compilation or because you installed it in an "unusual" directory). +# Just set OTF2_DIR it to your specific installation directory +# +FIND_LIBRARY(OTF2_LIBRARY otf2 + PATHS + /usr/lib + /usr/local/lib + ${OTF2_DIR}/lib +) + +IF(OTF2_LIBRARY) + GET_FILENAME_COMPONENT(OTF2_GUESSED_INCLUDE_DIR_tmp "${OTF2_LIBRARY}" PATH) + STRING(REGEX REPLACE "lib$" "include" OTF2_GUESSED_INCLUDE_DIR "${OTF2_GUESSED_INCLUDE_DIR_tmp}") +ENDIF(OTF2_LIBRARY) + +FIND_PATH( OTF2_INCLUDE_DIR otf2/otf2.h + PATHS + ${OTF2_GUESSED_INCLUDE_DIR} + ${OTF2_DIR}/include + /usr/include + /usr/local/include + ${CMAKE_SOURCE_DIR}/externals/otf2/include/ +) + +IF( OTF2_INCLUDE_DIR ) + IF( OTF2_LIBRARY ) + SET( OTF2_FOUND "YES" ) + MARK_AS_ADVANCED( OTF2_DIR ) + MARK_AS_ADVANCED( OTF2_INCLUDE_DIR ) + MARK_AS_ADVANCED( OTF2_LIBRARY ) + ENDIF( OTF2_LIBRARY ) +ENDIF( OTF2_INCLUDE_DIR ) + +IF( NOT OTF2_FOUND ) + MESSAGE("OTF2 installation was not found. Please provide OTF2_DIR:") + MESSAGE(" - through the GUI when working with ccmake, ") + MESSAGE(" - as a command line argument when working with cmake e.g. ") + MESSAGE(" cmake .. -DOTF2_DIR:PATH=/usr/local/otf ") + MESSAGE("Note: the following message is triggered by cmake on the first ") + MESSAGE(" undefined necessary PATH variable (e.g. OTF2_INCLUDE_DIR).") + MESSAGE(" Providing OTF2_DIR (as above described) is probably the") + MESSAGE(" simplest solution unless you have a really customized/odd") + MESSAGE(" OTF2 installation...") + SET(OTF2_DIR "" CACHE PATH "Root of OTF2 install tree." ) +ENDIF( NOT OTF2_FOUND ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d2ef7216bf73f20fd85d4d17cd07ad6db0e5afc2..ecce85f104798052847d548db565cca410941a52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -296,6 +296,30 @@ IF(VITE_ENABLE_OTF) ENDIF(VITE_ENABLE_OTF) +############################################# +# OTF2 Parser +############################################# +IF(VITE_ENABLE_OTF2) + ADD_DEFINITIONS(-DWITH_OTF2) + + SET(VITE_HDRS + ${VITE_HDRS} + parser/OTF2Parser/ParserDefinitionOTF2.hpp + parser/OTF2Parser/ParserEventOTF2.hpp + parser/OTF2Parser/ParserOTF2.hpp + ) + + SET(VITE_SRCS + ${VITE_SRCS} + parser/OTF2Parser/ParserDefinitionOTF2.cpp + parser/OTF2Parser/ParserEventOTF2.cpp + parser/OTF2Parser/ParserOTF2.cpp + ) + + INCLUDE_DIRECTORIES(${OTF2_INCLUDE_DIR}) + +ENDIF(VITE_ENABLE_OTF2) + ############################################# # TAU Parser ############################################# @@ -411,6 +435,10 @@ IF( VITE_ENABLE_OTF ) LINK_DIRECTORIES( ${OTF_LIBRARY_DIR} ) ENDIF( VITE_ENABLE_OTF ) +IF(VITE_ENABLE_OTF2) + LINK_DIRECTORIES(${OTF2_LIBRARY_DIR} ) +ENDIF(VITE_ENABLE_OTF2) + #resource IF(WIN32) set(VITE_RES @@ -476,6 +504,18 @@ IF(VITE_ENABLE_OTF) ENDIF(WIN32) ENDIF(VITE_ENABLE_OTF) +IF(VITE_ENABLE_OTF2) + TARGET_LINK_LIBRARIES(vite + ${OTF2_LIBRARY} + ) + # if OTF2 is compiled with zlib support we need to add it + IF(WIN32) + TARGET_LINK_LIBRARIES(vite + ${ZLIB_LIBRARY} + ) + ENDIF(WIN32) +ENDIF(VITE_ENABLE_OTF2) + IF(VITE_ENABLE_TAU) TARGET_LINK_LIBRARIES(vite ${TAU_LIBRARY} diff --git a/src/parser/OTF2Parser/ParserDefinitionOTF2.cpp b/src/parser/OTF2Parser/ParserDefinitionOTF2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8101f5c37dff73a6e58635c0e3f3661bc58ee5bf --- /dev/null +++ b/src/parser/OTF2Parser/ParserDefinitionOTF2.cpp @@ -0,0 +1,670 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +/** + * @file ParserDefinitionOTF2.cpp + * + * @author François Trahay + * @author Lagrasse Olivier + * @author Johnny Jazeix + * @author Mathieu Faverge + * + */ +#include <iostream> +#include <fstream> +#include <string> +#include <map> +#include <set> +#include <list> +#include <cmath> +#include <queue> +#include <cassert> +/* -- */ +#include <otf2/otf2.h> +/* -- */ +#include "common/common.hpp" +#include "common/Errors.hpp" +/* -- */ +#include "trace/values/Values.hpp" +#include "trace/EntityTypes.hpp" +#include "trace/Entitys.hpp" +#include "trace/Trace.hpp" +/* -- */ +#include "parser/OTF2Parser/ParserDefinitionOTF2.hpp" +/* -- */ +using namespace std; + +map<OTF2_SystemTreeNodeRef, OTF2_SystemTreeNode* > ParserDefinitionOTF2::_system_tree_node; +map<OTF2_LocationGroupRef, OTF2_LocationGroup* > ParserDefinitionOTF2::_location_group; +map<OTF2_LocationRef, OTF2_Location* > ParserDefinitionOTF2::_location; + +map<OTF2_MetricMemberRef, OTF2_MetricMember > ParserDefinitionOTF2::_metric_member; +map<OTF2_MetricRef, OTF2_MetricClass > ParserDefinitionOTF2::_metric_class; + +map<uint32_t, OTF2_Function > ParserDefinitionOTF2::_functions; + +map<uint32_t, const char * > ParserDefinitionOTF2::_strings; + +vector<Color *> ParserDefinitionOTF2::_default_colors; + +uint64_t ParserDefinitionOTF2::_ticks_per_second = 1; +double ParserDefinitionOTF2::_first_timestamp = -1; + +ParserDefinitionOTF2::ParserDefinitionOTF2(OTF2_Reader *reader) { + + _global_def_reader = OTF2_Reader_GetGlobalDefReader(reader); + _global_def_callbacks = OTF2_GlobalDefReaderCallbacks_New(); + + // Create the colors + _default_colors.push_back(new Color(1, 0, 0)); // Red + _default_colors.push_back(new Color(0, 1, 0)); // Green + _default_colors.push_back(new Color(0, 0, 1)); // Blue + _default_colors.push_back(new Color(1, 1, 0)); // Yellow + _default_colors.push_back(new Color(0, 1, 1)); // Cyan + _default_colors.push_back(new Color(1, 0, 1)); // Magenta + _default_colors.push_back(new Color(1, 0.5, 0)); // Orange + _default_colors.push_back(new Color(0.5, 0, 0.5)); // Purple + _default_colors.push_back(new Color(1, 0, 0.5)); // Orange + _default_colors.push_back(new Color(0, 0.5, 1)); // Clear blue + +} + +ParserDefinitionOTF2::~ParserDefinitionOTF2() { + + OTF2_GlobalDefReaderCallbacks_Delete(_global_def_callbacks); + + // Free the memory used by the colors + for(int i = 0 ; i < NB_COLORS ; ++ i) { + delete _default_colors[i]; + _default_colors[i] = NULL; + } + _default_colors.clear(); + + _strings.clear(); + + ParserDefinitionOTF2::_location.erase(ParserDefinitionOTF2::_location.begin(), + ParserDefinitionOTF2::_location.end()); + ParserDefinitionOTF2::_location_group.erase(ParserDefinitionOTF2::_location_group.begin(), + ParserDefinitionOTF2::_location_group.end()); + ParserDefinitionOTF2::_system_tree_node.erase(ParserDefinitionOTF2::_system_tree_node.begin(), + ParserDefinitionOTF2::_system_tree_node.end()); +} + +void ParserDefinitionOTF2::set_handlers(Trace *t) { + + OTF2_GlobalDefReaderCallbacks_SetSystemTreeNodeCallback(_global_def_callbacks, &handler_DefSystemTreeNode); + OTF2_GlobalDefReaderCallbacks_SetLocationCallback(_global_def_callbacks, &handler_DefLocation); + OTF2_GlobalDefReaderCallbacks_SetLocationGroupCallback(_global_def_callbacks, handler_DefLocationGroup); + OTF2_GlobalDefReaderCallbacks_SetStringCallback(_global_def_callbacks, &handler_DefString); + OTF2_GlobalDefReaderCallbacks_SetClockPropertiesCallback(_global_def_callbacks, &handler_DefTimerResolution); + OTF2_GlobalDefReaderCallbacks_SetRegionCallback(_global_def_callbacks, &handler_DefState); + // SetGroupCallback to get containerType, stateType... ? + OTF2_GlobalDefReaderCallbacks_SetGroupCallback(_global_def_callbacks, &handler_DefGroup); + + OTF2_GlobalDefReaderCallbacks_SetMetricMemberCallback(_global_def_callbacks, &handler_DefMetricMember ); + OTF2_GlobalDefReaderCallbacks_SetMetricClassCallback(_global_def_callbacks, &handler_DefMetricClass ); + OTF2_GlobalDefReaderCallbacks_SetMetricInstanceCallback(_global_def_callbacks, &handler_DefMetricInstance ); + OTF2_GlobalDefReaderCallbacks_SetMetricClassRecorderCallback(_global_def_callbacks, &handler_DefMetricClassRecorder); + +} + +/* + * All the definition handlers + */ + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefTimerResolution(void *, uint64_t timer_resolution, uint64_t /*global_offset*/, uint64_t /*trace_length*/) +{ + ParserDefinitionOTF2::_ticks_per_second = timer_resolution; + return OTF2_CALLBACK_SUCCESS; +} + +double ParserDefinitionOTF2::get_timestamp(OTF2_TimeStamp ts) { + if(_first_timestamp<0) { + _first_timestamp=(double)ts/(double)ParserDefinitionOTF2::get_ticks_per_second(); + } + return (double)ts/(double)ParserDefinitionOTF2::get_ticks_per_second()-_first_timestamp; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefString(void */*userData */, + OTF2_StringRef id, + const char *value) +{ + _strings[id] = value; + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefSystemTreeNode(void */*userData */, + OTF2_SystemTreeNodeRef tree_node_id, + OTF2_StringRef name_id, + OTF2_StringRef class_id, + OTF2_SystemTreeNodeRef parent_node_id) { + OTF2_SystemTreeNode* temp = new OTF2_SystemTreeNode(); + temp->_node_id=tree_node_id; + temp->_name_id=name_id; + temp->_parent=parent_node_id; + generate_string_id(temp); + + struct OTF2_SystemTreeNode *tree_node = ParserDefinitionOTF2::get_system_tree_node_by_id(parent_node_id); + if(tree_node != NULL) { + tree_node->_child_nodes[tree_node_id] = temp; + } + _system_tree_node[tree_node_id] = temp; + +#if DEBUG + cout<<"DefSystemTreeNode(node_id="<<tree_node_id<<", name="<<temp->_id_string<<", parent="; + if(tree_node) + cout<<tree_node->_id_string; + else + cout<<"(none)"; + cout<<"\n"; +#endif // DEBUG + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefLocationGroup(void */*userdata*/, + OTF2_LocationGroupRef location_group_identifier, + OTF2_StringRef name, + OTF2_LocationGroupType type, + OTF2_SystemTreeNodeRef system_tree_parent) { + OTF2_LocationGroup *temp = new OTF2_LocationGroup(); + temp->_group_id = location_group_identifier; + temp->_name_id = name; + temp->_node_id=system_tree_parent; + generate_string_id(temp); + + struct OTF2_SystemTreeNode *tree_node = ParserDefinitionOTF2::get_system_tree_node_by_id(system_tree_parent); + if(tree_node != NULL) { + tree_node->_location_group[location_group_identifier] = temp; + } + _location_group[location_group_identifier] = temp; + +#if DEBUG + cout<<"DefLocationGroup(group_id="<<location_group_identifier<<", name="<<temp->_id_string<<", parent="; + if(tree_node) + cout<<tree_node->_id_string; + else + cout<<"(none)"; + cout<<"\n"; +#endif // DEBUG + return OTF2_CALLBACK_SUCCESS; +} + + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefLocation(void *userData, + OTF2_LocationRef locationIdentifier, + OTF2_StringRef name_id, + OTF2_LocationType location_type, + uint64_t numberOfEvents, + OTF2_LocationGroupRef locationGroup) { + OTF2_Reader* reader = (OTF2_Reader *) userData; + OTF2_EvtReader* evt_reader = OTF2_Reader_GetEvtReader(reader, locationIdentifier); + OTF2_DefReader* def_reader = OTF2_Reader_GetDefReader(reader, locationIdentifier); + uint64_t definitions_read = 0; + OTF2_Reader_ReadAllLocalDefinitions(reader, def_reader, &definitions_read); + + OTF2_Location* temp= new OTF2_Location(); + temp->_location_id=locationIdentifier; + temp->_name_id = name_id; + temp->_group_id=locationGroup; + temp->_number_of_events=numberOfEvents; + generate_string_id(temp); + + struct OTF2_LocationGroup *location_group = ParserDefinitionOTF2::get_location_group_by_id(locationGroup); + if(location_group != NULL) { + location_group->_location[locationIdentifier] = temp; + } + _location[locationIdentifier] = temp; + +#if DEBUG + cout<<"DefLocation(id="<<locationIdentifier<<", name="<<temp->_id_string<<", parent="; + if(location_group) + cout<<location_group->_id_string; + else + cout<<"(none)"; + cout<<"\n"; +#endif // DEBUG + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefState(void *userData, + OTF2_RegionRef self, + OTF2_StringRef name, + OTF2_StringRef canonicalName, + OTF2_StringRef description, + OTF2_RegionRole regionRole, + OTF2_Paradigm paradigm, + OTF2_RegionFlag regionFlags, + OTF2_StringRef sourceFile, + uint32_t beginLineNumber, + uint32_t endLineNumber) { + + OTF2_Function temp = {name, canonicalName, description, regionRole, paradigm, regionFlags, sourceFile, beginLineNumber, endLineNumber}; + ParserDefinitionOTF2::_functions[self] = temp; + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefGroup(void *userData, + OTF2_GroupRef group_id, + OTF2_StringRef name_id, + OTF2_GroupType type, + OTF2_Paradigm paradigm, + OTF2_GroupFlag flags, + uint32_t numberOfMembers, + const uint64_t *members) { + switch(type) { + case OTF2_GROUP_TYPE_UNKNOWN: + break; + case OTF2_GROUP_TYPE_LOCATIONS: + cout << "New location group: group_id " << group_id << ", name_id" << name_id << endl; + break; + case OTF2_GROUP_TYPE_REGIONS: + cout << "New region group: group_id " << group_id << ", name_id" << name_id << endl; + break; + case OTF2_GROUP_TYPE_METRIC: + cout << "New metric group: group_id " << group_id << ", name_id" << name_id << endl; + break; + case OTF2_GROUP_TYPE_COMM_LOCATIONS: + cout << "New comm location group: group_id " << group_id << ", name_id" << name_id << endl; + break; + case OTF2_GROUP_TYPE_COMM_GROUP: + cout << "New comm group: group_id " << group_id << ", name_id" << name_id << endl; + break; + case OTF2_GROUP_TYPE_COMM_SELF: + cout << "New comm self: group_id " << group_id << ", name_id" << name_id << endl; + break; + default : + cout << "type " << type << " not yet handled" << endl; + } + cout<<"\tNot yet implemented\n"; + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefMetricMember( void* userData, + OTF2_MetricMemberRef self, + OTF2_StringRef name, + OTF2_StringRef description, + OTF2_MetricType metricType, + OTF2_MetricMode metricMode, + OTF2_Type valueType, + OTF2_Base base, + int64_t exponent, + OTF2_StringRef unit ) { + OTF2_MetricMember temp = { + ._id =self, + ._name =name, + ._description=description, + ._metricType =metricType, + ._metricMode =metricMode, + ._valueType =valueType, + ._base =base, + ._exponent =exponent, + ._unit =unit + }; + + ParserDefinitionOTF2::_metric_member[self] = temp; + + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefMetricClass( void* userData, + OTF2_MetricRef self, + uint8_t numberOfMetrics, + const OTF2_MetricMemberRef* metricMembers, + OTF2_MetricOccurrence metricOccurrence, + OTF2_RecorderKind recorderKind ) { + + OTF2_MetricClass temp = { + ._id = self, + ._metricOccurrence = metricOccurrence, + ._recorderKind = recorderKind, + }; + + for(int i=0; i<numberOfMetrics; i++) { + temp._metricMembers.push_back(metricMembers[i]); + } + + ParserDefinitionOTF2::_metric_class[self] = temp; + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefMetricInstance( void* userData, + OTF2_MetricRef self, + OTF2_MetricRef metricClass, + OTF2_LocationRef recorder, + OTF2_MetricScope metricScope, + uint64_t scope ) { + + cout<<__FUNCTION__<<" not implemented\n"; + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserDefinitionOTF2::handler_DefMetricClassRecorder( void* userData, + OTF2_MetricRef metric, + OTF2_LocationRef recorder ) { + + cout<<__FUNCTION__<<" not implemented\n"; + return OTF2_CALLBACK_SUCCESS; +} + +// +// Accessors to the data structures +// + +OTF2_MetricClass ParserDefinitionOTF2::get_metric_class(const OTF2_MetricRef id) { + return ParserDefinitionOTF2::_metric_class[id]; +} + +OTF2_MetricMember ParserDefinitionOTF2::get_metric_member(const OTF2_MetricClass metric_class, int index) { + OTF2_MetricMemberRef ref = metric_class._metricMembers[index]; + return ParserDefinitionOTF2::_metric_member[ref]; +} + +OTF2_SystemTreeNode* ParserDefinitionOTF2::get_system_tree_node_by_id(const OTF2_SystemTreeNodeRef id) +{ + return ParserDefinitionOTF2::_system_tree_node[id]; +} + +OTF2_LocationGroup* ParserDefinitionOTF2::get_location_group_by_id(const OTF2_LocationGroupRef id) +{ + return ParserDefinitionOTF2::_location_group[id]; +} + +OTF2_Location* ParserDefinitionOTF2::get_location_by_id(const OTF2_LocationRef id) +{ + return ParserDefinitionOTF2::_location[id]; +} + +OTF2_Function ParserDefinitionOTF2::get_function_by_id(const uint32_t id) { + return ParserDefinitionOTF2::_functions[id]; +} + +const char *ParserDefinitionOTF2::get_string_by_id(uint32_t id) { + return ParserDefinitionOTF2::_strings[id]; +} + +uint64_t ParserDefinitionOTF2::get_ticks_per_second() { + return ParserDefinitionOTF2::_ticks_per_second; +} + +Color *ParserDefinitionOTF2::get_color(uint32_t func_id) { + return new Color(*_default_colors[func_id % NB_COLORS]); +} + +// +// Other public functions +// +void ParserDefinitionOTF2::read_definitions(OTF2_Reader *reader) { + OTF2_Reader_RegisterGlobalDefCallbacks(reader, _global_def_reader, _global_def_callbacks, reader); + uint64_t definitions_read = 0; + OTF2_Reader_ReadAllGlobalDefinitions(reader, _global_def_reader, &definitions_read); +} + +void ParserDefinitionOTF2::generate_string_id(OTF2_Location* l) { + const char*s = get_string_by_id(l->_name_id); + l->_id_string=string(s?s:"") +"_"+std::to_string(l->_location_id); +} + +void ParserDefinitionOTF2::generate_string_id(OTF2_LocationGroup* lg) { + const char* s = get_string_by_id(lg->_name_id); + lg->_id_string= string(s?s:"")+"_"+std::to_string(lg->_group_id); +} + +void ParserDefinitionOTF2::generate_string_id(OTF2_SystemTreeNode* n) { + const char* s = get_string_by_id(n->_name_id); + n->_id_string=string(s?s:"")+"_"+std::to_string(n->_node_id); +} + +string ParserDefinitionOTF2::get_string_id(OTF2_Location* l) { + return l->_id_string; +} + +string ParserDefinitionOTF2::get_string_id(OTF2_LocationGroup* lg) { + return lg->_id_string; +} + +string ParserDefinitionOTF2::get_string_id(OTF2_SystemTreeNode* n) { + return n->_id_string; +} + +ContainerType* define_container_type(Trace*t, const char* name, const char* parent_name) { + ContainerType *container_type = t->search_container_type(String(name)); + if(container_type == NULL) { + // first type we create this kind of container. Let's define a container_type + Name name_temp(name); + map<std::string, Value *> extra_fields; + ContainerType *parent_container_type = NULL; + if(parent_name) { + parent_container_type = t->search_container_type(String(parent_name)); + } + t->define_container_type(name_temp, parent_container_type, extra_fields); + container_type = t->search_container_type(String(name)); + assert(container_type != NULL); + } + return container_type; +} + +void ParserDefinitionOTF2::create_location(Trace *t, OTF2_Location *l) { + Name name_temp(get_string_id(l)); + OTF2_LocationGroup* parent=get_location_group_by_id(l->_group_id); + Container *parent_container=NULL; + map<string, Value *> extra_fields; + if(parent != NULL) { + parent_container = t->search_container(get_string_id(parent)); + } + const char* parent_name=NULL; + if(parent) { + parent_name = get_string_by_id(parent->_name_id); + } + ContainerType *container_type = define_container_type(t, get_string_by_id(l->_name_id), parent_name); + + Date d = 0; + Container* c = t->search_container(name_temp.get_name()); + if(c) { + cerr<<"Error: container "<<name_temp.get_name()<<" already exists!\n"; + abort(); + } + t->create_container(d, name_temp, container_type, parent_container, extra_fields); + l->container = t->search_container(name_temp.get_name()); +} + + +void ParserDefinitionOTF2::create_location_group(Trace *t, OTF2_LocationGroup *lg) { + Name name_temp(get_string_id(lg)); + OTF2_SystemTreeNode* parent=get_system_tree_node_by_id(lg->_node_id); + Container *parent_container=NULL; + map<string, Value *> extra_fields; + if(parent != NULL) { + parent_container = t->search_container(get_string_id(parent)); + } + + const char* parent_name=NULL; + if(parent) { + parent_name = get_string_by_id(parent->_name_id); + } + ContainerType *container_type = define_container_type(t, get_string_by_id(lg->_name_id), parent_name); + + Date d = 0; + t->create_container(d, name_temp, container_type, parent_container, extra_fields); +} + +void ParserDefinitionOTF2::create_system_tree_node(Trace *t, OTF2_SystemTreeNode *node) { + + Name name_temp(get_string_id(node)); + OTF2_SystemTreeNode* parent=get_system_tree_node_by_id(node->_parent); + Container *parent_container=NULL; + + const char* parent_name=NULL; + if(parent) { + parent_name = get_string_by_id(parent->_name_id); + } + ContainerType *container_type = define_container_type(t, get_string_by_id(node->_name_id), parent_name); + + map<string, Value *> extra_fields; + if(parent != NULL) { + parent_container = t->search_container(get_string_id(parent)); + } + Date d = 0; + t->create_container(d, name_temp, container_type, parent_container, extra_fields); +} + +void ParserDefinitionOTF2::create_container_types(Trace *t) { + unsigned int i; + + std::map<OTF2_SystemTreeNodeRef, OTF2_SystemTreeNode* >::const_iterator it_tree, end_tree; + end_tree = _system_tree_node.end(); + for (it_tree = _system_tree_node.begin() ; it_tree != end_tree ; ++ it_tree) { + OTF2_SystemTreeNode* n = (*it_tree).second; + if(n) { + // Create the containers + create_system_tree_node(t, n); + } + } + + std::map<OTF2_LocationGroupRef, OTF2_LocationGroup* >::const_iterator it_lg, end_lg; + end_lg = _location_group.end(); + for (it_lg = _location_group.begin() ; it_lg != end_lg ; ++ it_lg) { + OTF2_LocationGroup* n = (*it_lg).second; + if(n) { + // Create the containers + create_location_group(t, n); + } + } + + std::map<OTF2_LocationRef, OTF2_Location* >::const_iterator it_l, end_l; + end_l = _location.end(); + for (it_l = _location.begin() ; it_l != end_l ; ++ it_l) { + OTF2_Location* n = (*it_l).second; + if(n) { + // Create the containers + create_location(t, n); + } + } +} + +void ParserDefinitionOTF2::create_metric_member(Trace *t, OTF2_MetricMember m) { + ContainerType *temp_container_type = NULL; + std::map<OTF2_LocationRef, OTF2_Location* >::const_iterator it_l; + it_l = _location.begin(); + if(it_l != _location.end()) { + OTF2_Location* n = (*it_l).second; + if(n) { + temp_container_type = t->search_container_type(String(get_string_by_id(n->_name_id))); + } + } + if(!temp_container_type) + temp_container_type = t->search_container_type(String("0")); + + if(temp_container_type == NULL){ + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE, Error::VITE_ERRCODE_ERROR); + } + else{ + map<string, Value *> extra_fields; + Name alias_name(get_string_by_id(m._name)); + t->define_variable_type(alias_name, temp_container_type, extra_fields); + } +} + +void ParserDefinitionOTF2::create_metric_class(Trace *t, OTF2_MetricClass m) { + // Nothing to do ? +} + +void ParserDefinitionOTF2::initialize_types(Trace *t) { + + std::map<uint32_t, OTF2_MetricMember >::const_iterator it_member, end_member; + end_member = _metric_member.end(); + for (it_member = _metric_member.begin() ; it_member != end_member ; ++ it_member) { + OTF2_MetricMember n = (*it_member).second; + // Create the metricMember + create_metric_member(t, n); + } + + std::map<uint32_t, OTF2_MetricClass >::const_iterator it_class, end_class; + end_class = _metric_class.end(); + for (it_class = _metric_class.begin() ; it_class != end_class ; ++ it_class) { + OTF2_MetricClass n = (*it_class).second; + // Create the metricClass + create_metric_class(t, n); + } + +} + +// Debug purposes +void ParserDefinitionOTF2::print_definitions() { + cout << "Strings:" << endl; + for (map<uint32_t, const char *>::const_iterator it = _strings.begin() ; it != _strings.end() ; ++ it) { + cout << "str#" << (*it).first << " " << (*it).second << endl; + } + + cout << "SystemTreeNode:" << endl; + for (map<OTF2_SystemTreeNodeRef, OTF2_SystemTreeNode*>::const_iterator it = _system_tree_node.begin() ; it != _system_tree_node.end() ; ++ it) { + cout << "#" << (*it).first; + OTF2_SystemTreeNode *temp = (*it).second; + if(temp) { + cout << " string_id: '" << temp->_id_string << "' parent:'" << temp->_parent << "'" << endl; + } + } + + cout << "LocationGroup:" << endl; + for (map<OTF2_LocationGroupRef, OTF2_LocationGroup*>::const_iterator it = _location_group.begin() ; it != _location_group.end() ; ++ it) { + cout << "#" << (*it).first; + OTF2_LocationGroup *temp = (*it).second; + if(temp) { + cout << " name: '" << temp->_id_string << " ' node_id: '" << temp->_node_id << "'" << endl; + } + } + + cout << "Location:" << endl; + for (map<OTF2_LocationRef, OTF2_Location*>::const_iterator it = _location.begin() ; it != _location.end() ; ++ it) { + cout << "#" << (*it).first; + OTF2_Location* temp = (*it).second; + if(temp) { + cout << " name: '" << temp->_id_string << " ' locationGroup: '" << temp->_group_id << "'" << endl; + } + } + + cout << "Function:" << endl; + for (map<uint32_t, OTF2_Function>::const_iterator it = _functions.begin() ; it != _functions.end() ; ++ it) { + cout << "#" << (*it).first; + OTF2_Function temp = (*it).second; + cout << " name id: '" << temp._name_id << "' name:'" << _strings[temp._name_id] << "' region_description: '" << _strings[temp._region_description] << "' region_type: '" << temp._regionRole << "'" << endl; + } +} diff --git a/src/parser/OTF2Parser/ParserDefinitionOTF2.hpp b/src/parser/OTF2Parser/ParserDefinitionOTF2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..daa0d6f6123dce675f1be90f2f53fa1630b0aea1 --- /dev/null +++ b/src/parser/OTF2Parser/ParserDefinitionOTF2.hpp @@ -0,0 +1,388 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +/** + * @file ParserDefinitionOTF2.hpp + * + * @author François Trahay + * @author Lagrasse Olivier + * @author Johnny Jazeix + * @author Mathieu Faverge + * + */ + +#ifndef PARSERDEFINITIONOTF2_HPP +#define PARSERDEFINITIONOTF2_HPP + +#include <otf2/otf2.h> + +class Trace; + +/*! + * \def NB_COLORS + * The number of default colors. + * They are created in the constructor, deleted in destructor. + */ +#define NB_COLORS 10 + +struct OTF2_Location; +struct OTF2_LocationGroup; +/*! + * \struct OTF2_SystemTreeNode + * \brief Contains the definition of a machine (equivalent in Paje : Container) + */ +struct OTF2_SystemTreeNode { + /*! \brief Id of the node */ + OTF2_SystemTreeNodeRef _node_id; + /*! \brief String that identifies the node */ + std::string _id_string; + /*! \brief Name of the node */ + uint32_t _name_id; + /*! \brief id of the parent node */ + OTF2_SystemTreeNodeRef _parent; + /*! \brief child system tree nodes */ + std::map<OTF2_SystemTreeNodeRef, OTF2_SystemTreeNode* > _child_nodes; + /*! \brief child location groups */ + std::map<OTF2_LocationGroupRef, OTF2_LocationGroup* > _location_group; +}; + +/*! + * \struct OTF2_LocationGroup + * \brief Contains the definition of a processGroup (equivalent in Paje : Container) + */ +struct OTF2_LocationGroup { + /*! \brief Id of the LocationGroup */ + OTF2_LocationGroupRef _group_id; + /*! \brief String that identifies the group */ + std::string _id_string; + /*! \brief Name of the LocationGroup */ + uint32_t _name_id; + /*! \brief Child locations */ + std::map<OTF2_LocationRef, OTF2_Location* > _location; + /*! \brief Id of the parent node */ + OTF2_SystemTreeNodeRef _node_id; +}; + +/*! + * \struct OTF2_Location + * \brief Contains the definition of a process (equivalent in Paje : Container) + */ +struct OTF2_Location { + /*! \brief Id of the Location */ + OTF2_LocationRef _location_id; + /*! \brief String that identifies the location */ + std::string _id_string; + /*! \brief Name of the Location */ + uint32_t _name_id; + /*! \brief Id of the parent group */ + OTF2_LocationGroupRef _group_id; + /*! \brief Number of events in this Location */ + uint64_t _number_of_events; + /*! \brief Container corresponding to this Location */ + Container* container; +}; + +/*! + * \struct OTF2_Function + * \brief Contains the definition of a function (equivalent in Paje : State) + */ +struct OTF2_Function { + /*! \brief Name of the state */ + OTF2_StringRef _name_id; + /*! \brief Alternative name of the region (e.g. mangled name */ + OTF2_StringRef _canonicalName; + /*! \brief A more detailed description of this region */ + OTF2_StringRef _region_description; + /*! \brief Region role. */ + OTF2_RegionRole _regionRole; + /*! \brief Paradigm. */ + OTF2_Paradigm _paradigm; + /*! \brief Region flags. */ + OTF2_RegionFlag _regionFlags; + /*! \brief The source file where this region was declared */ + OTF2_StringRef _sourceFile; + /*! \brieg Starting line number of this region in the source file. */ + uint32_t _begin_line_number; + /*! \brieg Ending line number of this region in the source file. */ + uint32_t _end_line_number; +}; + +struct OTF2_MetricMember { + OTF2_MetricMemberRef _id; + OTF2_StringRef _name; + OTF2_StringRef _description; + OTF2_MetricType _metricType; + OTF2_MetricMode _metricMode; + OTF2_Type _valueType; + OTF2_Base _base; + int64_t _exponent; + OTF2_StringRef _unit; +}; + +struct OTF2_MetricClass { + OTF2_MetricRef _id; + std::vector<OTF2_MetricMemberRef> _metricMembers; + OTF2_MetricOccurrence _metricOccurrence; + OTF2_RecorderKind _recorderKind; +}; + +/*! + * + * \class ParserDefinitionOTF2 + * \brief Parse the definitions of the trace and store them. + * + */ +class ParserDefinitionOTF2 { +private: + + /*! + * Reader for the file + */ + OTF2_GlobalDefReader* _global_def_reader; + + OTF2_GlobalDefReaderCallbacks* _global_def_callbacks; + + /*! + * Maps in order to easily retrieve the events. + */ + static std::map<OTF2_SystemTreeNodeRef, OTF2_SystemTreeNode* > _system_tree_node; + static std::map<OTF2_LocationGroupRef, OTF2_LocationGroup* > _location_group; + static std::map<OTF2_LocationRef, OTF2_Location* > _location; + + static std::map<OTF2_MetricMemberRef, OTF2_MetricMember > _metric_member; + static std::map<OTF2_MetricRef, OTF2_MetricClass > _metric_class; + + static std::map<uint32_t, OTF2_Function > _functions; + static std::map<uint32_t, const char *> _strings; + + static uint64_t _ticks_per_second; + static double _first_timestamp; + + /*! + * Table containing default colors. + * We take the state id modulo the max number to get the color. + */ + static std::vector<Color *> _default_colors; + + static OTF2_CallbackCode handler_DefTimerResolution(void *, uint64_t, uint64_t, uint64_t); + static OTF2_CallbackCode handler_DefString(void *, OTF2_StringRef, const char *); + + // System tree callback + static OTF2_CallbackCode handler_DefSystemTreeNode(void */*userData */, + OTF2_SystemTreeNodeRef tree_node_id, + OTF2_StringRef name_id, + OTF2_StringRef class_id, + OTF2_SystemTreeNodeRef parent_node_id); + + static OTF2_CallbackCode handler_DefLocationGroup(void */*userdata*/, + OTF2_LocationGroupRef location_group_identifier, + OTF2_StringRef name, + OTF2_LocationGroupType type, + OTF2_SystemTreeNodeRef system_tree_parent); + static OTF2_CallbackCode handler_DefLocation(void *userData, + OTF2_LocationRef locationIdentifier, + OTF2_StringRef name_id, + OTF2_LocationType location_type, + uint64_t numberOfEvents, + OTF2_LocationGroupRef locationGroup); + + //Region callback + static OTF2_CallbackCode handler_DefState(void *, OTF2_RegionRef, OTF2_StringRef, OTF2_StringRef, OTF2_StringRef description, OTF2_RegionRole, OTF2_Paradigm, OTF2_RegionFlag, OTF2_StringRef, uint32_t, uint32_t); + + + static OTF2_CallbackCode handler_DefGroup(void *userData, + OTF2_GroupRef group_id, + OTF2_StringRef name_id, + OTF2_GroupType type, + OTF2_Paradigm paradigm, + OTF2_GroupFlag flags, + uint32_t numberOfMembers, + const uint64_t *members); + + + static OTF2_CallbackCode handler_DefMetricMember( void* userData, + OTF2_MetricMemberRef self, + OTF2_StringRef name, + OTF2_StringRef description, + OTF2_MetricType metricType, + OTF2_MetricMode metricMode, + OTF2_Type valueType, + OTF2_Base base, + int64_t exponent, + OTF2_StringRef unit ); + + static OTF2_CallbackCode handler_DefMetricClass( void* userData, + OTF2_MetricRef self, + uint8_t numberOfMetrics, + const OTF2_MetricMemberRef* metricMembers, + OTF2_MetricOccurrence metricOccurrence, + OTF2_RecorderKind recorderKind ); + + static OTF2_CallbackCode handler_DefMetricInstance( void* userData, + OTF2_MetricRef self, + OTF2_MetricRef metricClass, + OTF2_LocationRef recorder, + OTF2_MetricScope metricScope, + uint64_t scope ); + static OTF2_CallbackCode handler_DefMetricClassRecorder( void* userData, + OTF2_MetricRef metric, + OTF2_LocationRef recorder ); + + ParserDefinitionOTF2(const ParserDefinitionOTF2&); + +public: + + /*! + * \fn ParserDefinitionOTF2(OTF2_Reader *reader) + * \brief constructor + */ + ParserDefinitionOTF2(OTF2_Reader *reader); + + /*! + * \fn ~ParserDefinitionOTF2() + * \brief destructor + */ + ~ParserDefinitionOTF2(); + + /*! + * \fn set_handlers(Trace *t) + * \brief Create and set the handlers for the definition parsing. + * \param t The trace we want to store in. + */ + void set_handlers(Trace *t); + + /*! + * \fn read_definitions(OTF2_Reader *reader) + * \brief Begin the reading of the definitions + * \param reader The main otf2 file we want to read in. + */ + void read_definitions(OTF2_Reader *reader); + + /*! + * \fn create_container_types(Trace *t) + * \brief Create all the container types needed for the trace + * It is run at the end of the definitions parsing. + * \param t The trace where we store data + */ + void create_container_types(Trace *t); + + void create_metric_member(Trace *t, OTF2_MetricMember m); + void create_metric_class(Trace *t, OTF2_MetricClass m); + + /*! + * \fn initialize_types(Trace *t) + * \brief Create all the types needed for the trace + * It is run at the end of the definitions parsing. + * \param t The trace where we store data + */ + void initialize_types(Trace *t); + + void create_location(Trace *t, OTF2_Location *l); + void create_location_group(Trace *t, OTF2_LocationGroup *lg); + void create_system_tree_node(Trace *t, OTF2_SystemTreeNode *node); + + static void generate_string_id(OTF2_Location* l); + static void generate_string_id(OTF2_LocationGroup* lg); + static void generate_string_id(OTF2_SystemTreeNode* n); + + static std::string get_string_id(OTF2_Location* l); + static std::string get_string_id(OTF2_LocationGroup* lg); + static std::string get_string_id(OTF2_SystemTreeNode* n); + + /*! + * \fn print_definitions() + * \brief Print all the definitions stored. Useful for debug + */ + void print_definitions(); + + static OTF2_MetricClass get_metric_class(const OTF2_MetricRef id); + + static OTF2_MetricMember get_metric_member(const OTF2_MetricClass metric_class, int index); + + /*! + * \fn get_system_tree_node_by_id(const uint32_t id) + * \brief Accessor for the system_tree_node map + * \param id the id we want the corresponding system tree node + * \return The system tree node associated to id + */ + static OTF2_SystemTreeNode* get_system_tree_node_by_id(const OTF2_SystemTreeNodeRef id); + + /*! + * \fn get_location_group_by_id(const uint32_t id) + * \brief Accessor for the location_group map + * \param id the id we want the corresponding location group + * \return The location group associated to id + */ + static OTF2_LocationGroup *get_location_group_by_id(const OTF2_LocationGroupRef id); + + /*! + * \fn get_location_by_id(const uint32_t id) + * \brief Accessor for the location map + * \param id the id we want the corresponding location + * \return The location associated to id + */ + static OTF2_Location *get_location_by_id(const OTF2_LocationRef id); + + + /*! + * \fn get_function_by_id(const uint32_t id) + * \brief Accessor for the function map + * \param id the id we want the corresponding function + * \return The OTF2_Function associated to id + */ + static OTF2_Function get_function_by_id(const uint32_t id); + + /*! + * \fn get_ticks_per_second() + * \brief Accessor for the tick_per_second (equivalent to a time unit) + * \return The number of ticks per second + */ + static uint64_t get_ticks_per_second(); + + static double get_timestamp(OTF2_TimeStamp ts); + + static Color *get_color(uint32_t func_id); + + static const char *get_string_by_id(uint32_t id); +}; + +#endif // PARSERDEFINITIONOTF2_HPP diff --git a/src/parser/OTF2Parser/ParserEventOTF2.cpp b/src/parser/OTF2Parser/ParserEventOTF2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7f89811b14c9187e65c83c5464ab26115387914f --- /dev/null +++ b/src/parser/OTF2Parser/ParserEventOTF2.cpp @@ -0,0 +1,1341 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +/** + * @file ParserEventOTF2.cpp + * + * @author François Trahay + * @author Lagrasse Olivier + * @author Johnny Jazeix + * @author Mathieu Faverge + * + */ +#include <sstream> +#include <string> +#include <map> +#include <queue> +#include <list> +#include <iostream> +/* -- */ +#include <otf2/otf2.h> +/* -- */ +#include "common/Errors.hpp" +/* -- */ +#include "trace/values/Values.hpp" +#include "trace/EntityValue.hpp" +#include "trace/EntityTypes.hpp" +#include "trace/Entitys.hpp" +#include "trace/Trace.hpp" +/* -- */ +#include "parser/OTF2Parser/ParserDefinitionOTF2.hpp" +#include "parser/OTF2Parser/ParserEventOTF2.hpp" +/* -- */ +using namespace std; + +map <const String, Container *, String::less_than> ParserEventOTF2::_containers; + +ParserEventOTF2::ParserEventOTF2(OTF2_Reader *reader) { + _global_evt_reader = OTF2_Reader_GetGlobalEvtReader(reader); + _global_evt_callbacks = OTF2_GlobalEvtReaderCallbacks_New(); +} + +ParserEventOTF2::~ParserEventOTF2() { + OTF2_GlobalEvtReaderCallbacks_Delete(_global_evt_callbacks); + _containers.clear(); +} + +void ParserEventOTF2::set_handlers(OTF2_Reader *reader, Trace *trace) { + OTF2_GlobalEvtReaderCallbacks_SetUnknownCallback(_global_evt_callbacks, &callback_Unknown); + OTF2_GlobalEvtReaderCallbacks_SetBufferFlushCallback(_global_evt_callbacks, &callback_BufferFlush); + OTF2_GlobalEvtReaderCallbacks_SetMeasurementOnOffCallback(_global_evt_callbacks, &callback_MeasurementOnOff); + OTF2_GlobalEvtReaderCallbacks_SetEnterCallback(_global_evt_callbacks, &callback_Enter); + OTF2_GlobalEvtReaderCallbacks_SetLeaveCallback(_global_evt_callbacks, &callback_Leave); + OTF2_GlobalEvtReaderCallbacks_SetMpiSendCallback(_global_evt_callbacks, &callback_MpiSend); + OTF2_GlobalEvtReaderCallbacks_SetMpiIsendCallback(_global_evt_callbacks, &callback_MpiIsend); + OTF2_GlobalEvtReaderCallbacks_SetMpiIsendCompleteCallback(_global_evt_callbacks, &callback_MpiIsendComplete); + OTF2_GlobalEvtReaderCallbacks_SetMpiIrecvRequestCallback(_global_evt_callbacks, &callback_MpiIrecvRequest); + OTF2_GlobalEvtReaderCallbacks_SetMpiRecvCallback(_global_evt_callbacks, &callback_MpiRecv); + OTF2_GlobalEvtReaderCallbacks_SetMpiIrecvCallback(_global_evt_callbacks, &callback_MpiIrecv); + OTF2_GlobalEvtReaderCallbacks_SetMpiRequestTestCallback(_global_evt_callbacks, &callback_MpiRequestTest); + OTF2_GlobalEvtReaderCallbacks_SetMpiRequestCancelledCallback(_global_evt_callbacks, &callback_MpiRequestCancelled); + OTF2_GlobalEvtReaderCallbacks_SetMpiCollectiveBeginCallback(_global_evt_callbacks, &callback_MpiCollectiveBegin); + OTF2_GlobalEvtReaderCallbacks_SetMpiCollectiveEndCallback(_global_evt_callbacks, &callback_MpiCollectiveEnd); + OTF2_GlobalEvtReaderCallbacks_SetOmpForkCallback(_global_evt_callbacks, &callback_OmpFork); + OTF2_GlobalEvtReaderCallbacks_SetOmpJoinCallback(_global_evt_callbacks, &callback_OmpJoin); + OTF2_GlobalEvtReaderCallbacks_SetOmpAcquireLockCallback(_global_evt_callbacks, &callback_OmpAcquireLock); + OTF2_GlobalEvtReaderCallbacks_SetOmpReleaseLockCallback(_global_evt_callbacks, &callback_OmpReleaseLock); + OTF2_GlobalEvtReaderCallbacks_SetOmpTaskCreateCallback(_global_evt_callbacks, &callback_OmpTaskCreate); + OTF2_GlobalEvtReaderCallbacks_SetOmpTaskSwitchCallback(_global_evt_callbacks, &callback_OmpTaskSwitch); + OTF2_GlobalEvtReaderCallbacks_SetOmpTaskCompleteCallback(_global_evt_callbacks, &callback_OmpTaskComplete); + OTF2_GlobalEvtReaderCallbacks_SetMetricCallback(_global_evt_callbacks, &callback_Metric); + OTF2_GlobalEvtReaderCallbacks_SetParameterStringCallback(_global_evt_callbacks, &callback_ParameterString); + OTF2_GlobalEvtReaderCallbacks_SetParameterIntCallback(_global_evt_callbacks, &callback_ParameterInt); + OTF2_GlobalEvtReaderCallbacks_SetParameterUnsignedIntCallback(_global_evt_callbacks, &callback_ParameterUnsignedInt); + OTF2_GlobalEvtReaderCallbacks_SetRmaWinCreateCallback(_global_evt_callbacks, &callback_RmaWinCreate); + OTF2_GlobalEvtReaderCallbacks_SetRmaWinDestroyCallback(_global_evt_callbacks, &callback_RmaWinDestroy); + OTF2_GlobalEvtReaderCallbacks_SetRmaCollectiveBeginCallback(_global_evt_callbacks, &callback_RmaCollectiveBegin); + OTF2_GlobalEvtReaderCallbacks_SetRmaCollectiveEndCallback(_global_evt_callbacks, &callback_RmaCollectiveEnd); + OTF2_GlobalEvtReaderCallbacks_SetRmaGroupSyncCallback(_global_evt_callbacks, &callback_RmaGroupSync); + OTF2_GlobalEvtReaderCallbacks_SetRmaRequestLockCallback(_global_evt_callbacks, &callback_RmaRequestLock); + OTF2_GlobalEvtReaderCallbacks_SetRmaAcquireLockCallback(_global_evt_callbacks, &callback_RmaAcquireLock); + OTF2_GlobalEvtReaderCallbacks_SetRmaTryLockCallback(_global_evt_callbacks, &callback_RmaTryLock); + OTF2_GlobalEvtReaderCallbacks_SetRmaReleaseLockCallback(_global_evt_callbacks, &callback_RmaReleaseLock); + OTF2_GlobalEvtReaderCallbacks_SetRmaSyncCallback(_global_evt_callbacks, &callback_RmaSync); + OTF2_GlobalEvtReaderCallbacks_SetRmaWaitChangeCallback(_global_evt_callbacks, &callback_RmaWaitChange); + OTF2_GlobalEvtReaderCallbacks_SetRmaPutCallback(_global_evt_callbacks, &callback_RmaPut); + OTF2_GlobalEvtReaderCallbacks_SetRmaGetCallback(_global_evt_callbacks, &callback_RmaGet); + OTF2_GlobalEvtReaderCallbacks_SetRmaAtomicCallback(_global_evt_callbacks, &callback_RmaAtomic); + OTF2_GlobalEvtReaderCallbacks_SetRmaOpCompleteBlockingCallback(_global_evt_callbacks, &callback_RmaOpCompleteBlocking); + OTF2_GlobalEvtReaderCallbacks_SetRmaOpCompleteNonBlockingCallback(_global_evt_callbacks, &callback_RmaOpCompleteNonBlocking); + OTF2_GlobalEvtReaderCallbacks_SetRmaOpTestCallback(_global_evt_callbacks, &callback_RmaOpTest); + OTF2_GlobalEvtReaderCallbacks_SetRmaOpCompleteRemoteCallback(_global_evt_callbacks, &callback_RmaOpCompleteRemote); + OTF2_GlobalEvtReaderCallbacks_SetThreadForkCallback(_global_evt_callbacks, &callback_ThreadFork); + OTF2_GlobalEvtReaderCallbacks_SetThreadJoinCallback(_global_evt_callbacks, &callback_ThreadJoin); + OTF2_GlobalEvtReaderCallbacks_SetThreadTeamBeginCallback(_global_evt_callbacks, &callback_ThreadTeamBegin); + OTF2_GlobalEvtReaderCallbacks_SetThreadTeamEndCallback(_global_evt_callbacks, &callback_ThreadTeamEnd); + OTF2_GlobalEvtReaderCallbacks_SetThreadAcquireLockCallback(_global_evt_callbacks, &callback_ThreadAcquireLock); + OTF2_GlobalEvtReaderCallbacks_SetThreadReleaseLockCallback(_global_evt_callbacks, &callback_ThreadReleaseLock); + OTF2_GlobalEvtReaderCallbacks_SetThreadTaskCreateCallback(_global_evt_callbacks, &callback_ThreadTaskCreate); + OTF2_GlobalEvtReaderCallbacks_SetThreadTaskSwitchCallback(_global_evt_callbacks, &callback_ThreadTaskSwitch); + OTF2_GlobalEvtReaderCallbacks_SetThreadTaskCompleteCallback(_global_evt_callbacks, &callback_ThreadTaskComplete); + OTF2_GlobalEvtReaderCallbacks_SetThreadCreateCallback(_global_evt_callbacks, &callback_ThreadCreate); + OTF2_GlobalEvtReaderCallbacks_SetThreadBeginCallback(_global_evt_callbacks, &callback_ThreadBegin); + OTF2_GlobalEvtReaderCallbacks_SetThreadWaitCallback(_global_evt_callbacks, &callback_ThreadWait); + OTF2_GlobalEvtReaderCallbacks_SetThreadEndCallback(_global_evt_callbacks, &callback_ThreadEnd); + OTF2_GlobalEvtReaderCallbacks_SetCallingContextEnterCallback(_global_evt_callbacks, &callback_CallingContextEnter); + OTF2_GlobalEvtReaderCallbacks_SetCallingContextLeaveCallback(_global_evt_callbacks, &callback_CallingContextLeave); + OTF2_GlobalEvtReaderCallbacks_SetCallingContextSampleCallback(_global_evt_callbacks, &callback_CallingContextSample); + OTF2_GlobalEvtReaderCallbacks_SetIoCreateHandleCallback(_global_evt_callbacks, &callback_IoCreateHandle); + OTF2_GlobalEvtReaderCallbacks_SetIoDestroyHandleCallback(_global_evt_callbacks, &callback_IoDestroyHandle); + OTF2_GlobalEvtReaderCallbacks_SetIoDuplicateHandleCallback(_global_evt_callbacks, &callback_IoDuplicateHandle); + OTF2_GlobalEvtReaderCallbacks_SetIoSeekCallback(_global_evt_callbacks, &callback_IoSeek); + OTF2_GlobalEvtReaderCallbacks_SetIoChangeStatusFlagsCallback(_global_evt_callbacks, &callback_IoChangeStatusFlags); + OTF2_GlobalEvtReaderCallbacks_SetIoDeleteFileCallback(_global_evt_callbacks, &callback_IoDeleteFile); + OTF2_GlobalEvtReaderCallbacks_SetIoOperationBeginCallback(_global_evt_callbacks, &callback_IoOperationBegin); + OTF2_GlobalEvtReaderCallbacks_SetIoOperationTestCallback(_global_evt_callbacks, &callback_IoOperationTest); + OTF2_GlobalEvtReaderCallbacks_SetIoOperationIssuedCallback(_global_evt_callbacks, &callback_IoOperationIssued); + OTF2_GlobalEvtReaderCallbacks_SetIoOperationCompleteCallback(_global_evt_callbacks, &callback_IoOperationComplete); + OTF2_GlobalEvtReaderCallbacks_SetIoOperationCancelledCallback(_global_evt_callbacks, &callback_IoOperationCancelled); + OTF2_GlobalEvtReaderCallbacks_SetIoAcquireLockCallback(_global_evt_callbacks, &callback_IoAcquireLock); + OTF2_GlobalEvtReaderCallbacks_SetIoReleaseLockCallback(_global_evt_callbacks, &callback_IoReleaseLock); + OTF2_GlobalEvtReaderCallbacks_SetIoTryLockCallback(_global_evt_callbacks, &callback_IoTryLock); + OTF2_GlobalEvtReaderCallbacks_SetProgramBeginCallback(_global_evt_callbacks, &callback_ProgramBegin); + OTF2_GlobalEvtReaderCallbacks_SetProgramEndCallback(_global_evt_callbacks, &callback_ProgramEnd); + + OTF2_Reader_RegisterGlobalEvtCallbacks(reader, _global_evt_reader, _global_evt_callbacks, trace); +} + + +#ifdef DEBUG +#define ENTER_CALLBACK(timestamp, locationID) do { \ + Date d = ParserDefinitionOTF2::get_timestamp(time); \ + OTF2_Location *temp_location = ParserDefinitionOTF2::get_location_by_id(locationID); \ + const String proc_name = String(ParserDefinitionOTF2::get_string_id(temp_location)); \ + cout<<d.to_string()<<" - "<<proc_name.to_string()<<" - "<<__FUNCTION__<<"\n"; \ + } while(0) +#else +#define ENTER_CALLBACK(timestamp, locationID) do { \ + } while(0) +#endif + +#define NOT_IMPLEMENTED_YET(timestamp) do { \ + Date d = ParserDefinitionOTF2::get_timestamp(timestamp); \ + cout<<"Warning OTF2 parser: "<< d.to_string()<<" "<<__FUNCTION__<<" not implemented\n"; \ + return OTF2_CALLBACK_SUCCESS; \ + } while(0) + +OTF2_CallbackCode ParserEventOTF2::callback_ProgramBegin(OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributeList, + OTF2_StringRef programName, + uint32_t numberOfArguments, + const OTF2_StringRef *programArguments) +{ + ENTER_CALLBACK(time, locationID); + // make sure get_timestamp is called anyway since it initialize the first timestamp + Date d = ParserDefinitionOTF2::get_timestamp(time); + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ProgramEnd(OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributeList, + int64_t exitStatus) +{ + ENTER_CALLBACK(time, locationID); + return OTF2_CALLBACK_SUCCESS; +} + +// +// Start definition of handlers for OTF2 event records +// +OTF2_CallbackCode ParserEventOTF2::callback_Enter(OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributes, + OTF2_RegionRef regionID) +{ + ENTER_CALLBACK(time, locationID); + Trace *t = (Trace *)userData; + Date d = ParserDefinitionOTF2::get_timestamp(time); + OTF2_Function temp_function = ParserDefinitionOTF2::get_function_by_id(regionID); + const String function_name = String(ParserDefinitionOTF2::get_string_by_id(temp_function._name_id)); + 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 DEBUG + cout<<d.to_string()<<" Enter_print(location="<<proc_name.to_string()<<", region="<<regionID<<", fname="<<function_name.to_string()<<")\n"; +#endif // 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(regionID); + 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; +} + +OTF2_CallbackCode ParserEventOTF2::callback_Leave(OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributes, + OTF2_RegionRef regionID) +{ + ENTER_CALLBACK(time, locationID); + Trace *t = (Trace *)userData; + Date d = ParserDefinitionOTF2::get_timestamp(time); + map<string, Value *> extra_fields; + + OTF2_Function temp_function = ParserDefinitionOTF2::get_function_by_id(regionID); + const String function_name = String(ParserDefinitionOTF2::get_string_by_id(temp_function._name_id)); + + // 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 DEBUG + cout<<d.to_string()<<" Leave_print(location="<<proc_name.to_string()<<", region="<<regionID<<", fname="<<function_name.to_string()<<")\n"; +#endif // 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; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiSend(OTF2_LocationRef sender, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributes, + uint32_t receiver, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t length) +{ + ENTER_CALLBACK(time, sender); + // We define the LinkType if not exist and we store the time and other fields + Trace *t = (Trace *)userData; + Date d = ParserDefinitionOTF2::get_timestamp(time); + + OTF2_Location *temp_sender = ParserDefinitionOTF2::get_location_by_id(sender); + OTF2_Location *temp_receiver = ParserDefinitionOTF2::get_location_by_id(receiver); + + // The sender process may have no ancestor, so let's say that his ancestor is himself + OTF2_Location *temp_ancestor = temp_sender; + + String sender_string = String(ParserDefinitionOTF2::get_string_id(temp_sender)); + String ancestor_string = String(ParserDefinitionOTF2::get_string_id(temp_ancestor)); + String receiver_string = String(ParserDefinitionOTF2::get_string_id(temp_receiver)); + +#if DEBUG + cout<<d.to_string()<<" start_link(src="<<sender_string.to_string()<<", dest="<<receiver_string.to_string()<<")\n"; +#endif + String sender_type_string = String(ParserDefinitionOTF2::get_string_by_id(temp_sender->_name_id)); + String ancestor_type_string = String(ParserDefinitionOTF2::get_string_by_id(temp_ancestor->_name_id)); + String receiver_type_string = String(ParserDefinitionOTF2::get_string_by_id(temp_receiver->_name_id)); + + /* Value */ + string name = string(ParserDefinitionOTF2::get_string_id(temp_sender)) + " to " + ParserDefinitionOTF2::get_string_id(temp_receiver)+ " tag "+to_string(msgTag); + String name_string = String(name); + + ostringstream link_type_oss; + link_type_oss << communicator; + String link_type_string = String(link_type_oss.str()); + + Name name_temp = Name(name, ""); + LinkType *link_type = t->search_link_type(link_type_string); + + Container *source_container = NULL; + Container *ancestor_container = NULL; + + ContainerType *source_type = t->search_container_type(sender_type_string); + ContainerType *destination_type = t->search_container_type(receiver_type_string); + ContainerType *ancestor_type = t->search_container_type(ancestor_type_string); + + EntityValue *value; + + map<string, Value *> opt; + + if(_containers.find(sender_string) != _containers.end()) { + source_container = _containers[sender_string]; + } + else { + source_container = t->search_container(sender_string); + _containers[sender_string] = source_container; + } + + if(source_container==0) { + // ignore this event + // TODO: fix this ! + cout<<"MPI_Send: cannot find source container !"<<sender_string.to_string()<<"\n"; + return OTF2_CALLBACK_SUCCESS; + } + if(_containers.find(ancestor_string) != _containers.end() && !_containers.empty()) { + // found + ancestor_container = _containers[ancestor_string]; + } + else { + // receiver not found + ancestor_container = t->search_container(ancestor_string); + if(ancestor_container) { + _containers[ancestor_string] = ancestor_container; + } + } + + if(ancestor_type == 0) { + // No ancestor + ancestor_type = source_type; + } + + if(ancestor_container == 0) { + // No ancestor + ancestor_container = source_container; + } + + if(link_type == 0) { + Name link_name = Name(link_type_oss.str()); + t->define_link_type(link_name, ancestor_type, destination_type, destination_type, opt); + link_type = t->search_link_type(link_type_string); + assert(link_type != NULL); + } + + value = t->search_entity_value(name_string, link_type); + + /* Creation of the optional fields */ + if(length != 0) { + Integer *length_int = new Integer(length); + opt["Length"] = length_int; + } + opt["Tag"] = new Integer(msgTag); + + t->start_link(d, link_type, ancestor_container, source_container, name_string, opt); + + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiIsend(OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributeList, + uint32_t receiver, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t msgLength, + uint64_t requestID) +{ + ENTER_CALLBACK(time, locationID); + return callback_MpiSend(locationID, time, userData, attributeList, receiver, communicator, msgTag, msgLength); +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiRecv(OTF2_LocationRef receiver, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributes, + uint32_t sender, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t length) + { + ENTER_CALLBACK(time, receiver); + Trace *t = (Trace *)userData; + Date d = ParserDefinitionOTF2::get_timestamp(time); + + OTF2_Location *temp_sender = ParserDefinitionOTF2::get_location_by_id(sender); + OTF2_Location *temp_receiver = ParserDefinitionOTF2::get_location_by_id(receiver); + // The sender process may have no ancestor, so let's say that his ancestor is himself + OTF2_Location *temp_ancestor = temp_sender; + + String sender_string = String(ParserDefinitionOTF2::get_string_id(temp_sender)); + String ancestor_string = String(ParserDefinitionOTF2::get_string_id(temp_ancestor)); + String receiver_string = String(ParserDefinitionOTF2::get_string_id(temp_receiver)); + + /* Value */ + string name = string(ParserDefinitionOTF2::get_string_id(temp_sender)) + " to " + ParserDefinitionOTF2::get_string_id(temp_receiver)+ " tag "+to_string(msgTag); + + String name_string = String(name); + + ostringstream link_type_oss; + link_type_oss << communicator; + String link_type_string = String(link_type_oss.str()); + + Name name_temp = Name(name, ""); + LinkType *link_type = t->search_link_type(link_type_string); + + Container *destination_cont = NULL; + Container *ancestor_cont = NULL; + Container *sender_cont = NULL; + + ContainerType *destination_type = t->search_container_type(receiver_string); + ContainerType *ancestor_type = t->search_container_type(ancestor_string); + ContainerType *sender_type = t->search_container_type(sender_string); + + EntityValue *value; + + map<string, Value *> opt; + + if(_containers.find(receiver_string) != _containers.end()) { + destination_cont = _containers[receiver_string]; + } + else { + destination_cont = t->search_container(receiver_string); + _containers[receiver_string] = destination_cont; + } + + if(destination_cont == 0) { + return OTF2_CALLBACK_SUCCESS; + + } + if(_containers.find(ancestor_string) != _containers.end() && !_containers.empty()) { + ancestor_cont = _containers[ancestor_string]; + } + else { + ancestor_cont = t->search_container(ancestor_string); + if(ancestor_cont) + _containers[ancestor_string] = ancestor_cont; + } + + if(ancestor_type == 0) { + // No ancestor + ancestor_type = sender_type; + } + + if(ancestor_cont == 0) { + // No ancestor + ancestor_cont = sender_cont; + } + + if(link_type == 0) { + Name link_name = Name(link_type_oss.str()); + t->define_link_type(link_name, ancestor_type, destination_type, destination_type, opt); + link_type = t->search_link_type(link_type_string); + assert(link_type != NULL); + } + + value = t->search_entity_value(name_string, link_type); + + /* Creation of the optional fields */ + if(length != 0) { + Integer *length_int = new Integer(length); + opt["Length"] = length_int; + } + opt["Tag"] = new Integer(msgTag); + + t->end_link(d, link_type, ancestor_cont, destination_cont, name_string, opt); + + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiIrecv(OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void *userData, + OTF2_AttributeList *attributeList, + uint32_t sender, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t msgLength, + uint64_t requestID) { + ENTER_CALLBACK(time, locationID); + // A MpiIrecv record indicates that a MPI message was received (MPI_IRECV). + return callback_MpiRecv(locationID, time, userData, attributeList, sender, communicator, msgTag, msgLength); +} + +OTF2_CallbackCode ParserEventOTF2::callback_Unknown( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_BufferFlush( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_TimeStamp stopTime ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_MeasurementOnOff( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_MeasurementMode measurementMode ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiIsendComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiIrecvRequest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiRequestTest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiRequestCancelled( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiCollectiveBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; + // NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_MpiCollectiveEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CollectiveOp collectiveOp, + OTF2_CommRef communicator, + uint32_t root, + uint64_t sizeSent, + uint64_t sizeReceived ) { + ENTER_CALLBACK(time, locationID); + // NOT_IMPLEMENTED_YET(time); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; + +} + +OTF2_CallbackCode ParserEventOTF2::callback_OmpFork( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t numberOfRequestedThreads ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_OmpJoin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_OmpAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t lockID, + uint32_t acquisitionOrder ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_OmpReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t lockID, + uint32_t acquisitionOrder ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_OmpTaskCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t taskID ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_OmpTaskSwitch( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t taskID ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_OmpTaskComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t taskID ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_Metric( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_MetricRef metric, + uint8_t numberOfMetrics, + const OTF2_Type* typeIDs, + const OTF2_MetricValue* metricValues ) { + ENTER_CALLBACK(time, locationID); + Trace *t = (Trace *)userData; + Date d = ParserDefinitionOTF2::get_timestamp(time); + + OTF2_Location *temp_location = ParserDefinitionOTF2::get_location_by_id(locationID); + const String proc_name = ParserDefinitionOTF2::get_string_id(temp_location); + Container* temp_container = t->search_container(proc_name); + if(!temp_container) { + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER, Error::VITE_ERRCODE_ERROR); + return OTF2_CALLBACK_SUCCESS; + } + + const ContainerType* temp_container_type = temp_container->get_type(); + if(!temp_container_type) { + Error::set(Error::VITE_ERR_UNKNOWN_CONTAINER_TYPE, Error::VITE_ERRCODE_ERROR); + return OTF2_CALLBACK_SUCCESS; + } + + OTF2_MetricClass m = ParserDefinitionOTF2::get_metric_class(metric); + + for(int i=0; i<numberOfMetrics; i++) { + map<string, Value *> extra_fields; + OTF2_MetricMember member = ParserDefinitionOTF2::get_metric_member(m, i); + VariableType *temp_variable_type = t->search_variable_type(String(ParserDefinitionOTF2::get_string_by_id(member._name))); + OTF2_MetricValue value = metricValues[i]; + double value_double=-1; + switch(typeIDs[i]) { + case OTF2_TYPE_UINT8 : value_double = (double)((uint8_t) value.unsigned_int); break; + case OTF2_TYPE_UINT16: value_double = (double)((uint16_t) value.unsigned_int); break; + case OTF2_TYPE_UINT32: value_double = (double)((uint32_t) value.unsigned_int); break; + case OTF2_TYPE_UINT64: value_double = (double)((uint64_t) value.unsigned_int); break; + + case OTF2_TYPE_INT8 : value_double = (double)((int8_t) value.signed_int); break; + case OTF2_TYPE_INT16 : value_double = (double)((int16_t) value.signed_int); break; + case OTF2_TYPE_INT32 : value_double = (double)((int32_t) value.signed_int); break; + case OTF2_TYPE_INT64 : value_double = (double)((int64_t) value.signed_int); break; + + case OTF2_TYPE_FLOAT : value_double = (double)((float) value.floating_point); break; + case OTF2_TYPE_DOUBLE: value_double = (double)(value.floating_point); break; + } + + t->set_variable(d, temp_variable_type, temp_container, value_double, extra_fields); + } + return OTF2_CALLBACK_SUCCESS; + +} + +OTF2_CallbackCode ParserEventOTF2::callback_ParameterString( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_ParameterRef parameter, + OTF2_StringRef string ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_ParameterInt( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_ParameterRef parameter, + int64_t value ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_ParameterUnsignedInt( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_ParameterRef parameter, + uint64_t value ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaWinCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaWinDestroy( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaCollectiveBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaCollectiveEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CollectiveOp collectiveOp, + OTF2_RmaSyncLevel syncLevel, + OTF2_RmaWinRef win, + uint32_t root, + uint64_t bytesSent, + uint64_t bytesReceived ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaGroupSync( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaSyncLevel syncLevel, + OTF2_RmaWinRef win, + OTF2_GroupRef group ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaRequestLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId, + OTF2_LockType lockType ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId, + OTF2_LockType lockType ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaTryLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId, + OTF2_LockType lockType ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaSync( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + OTF2_RmaSyncType syncType ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaWaitChange( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaPut( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t bytes, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaGet( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t bytes, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaAtomic( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + OTF2_RmaAtomicType type, + uint64_t bytesSent, + uint64_t bytesReceived, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaOpCompleteBlocking( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaOpCompleteNonBlocking( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaOpTest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_RmaOpCompleteRemote( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadFork( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model, + uint32_t numberOfRequestedThreads ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadJoin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadTeamBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadTeamEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model, + uint32_t lockID, + uint32_t acquisitionOrder ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model, + uint32_t lockID, + uint32_t acquisitionOrder ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadTaskCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam, + uint32_t creatingThread, + uint32_t generationNumber ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadTaskSwitch( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam, + uint32_t creatingThread, + uint32_t generationNumber ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadTaskComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam, + uint32_t creatingThread, + uint32_t generationNumber ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ) { + + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadWait( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_ThreadEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_CallingContextEnter( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CallingContextRef callingContext, + uint32_t unwindDistance ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_CallingContextLeave( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CallingContextRef callingContext ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_CallingContextSample( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CallingContextRef callingContext, + uint32_t unwindDistance, + OTF2_InterruptGeneratorRef interruptGenerator ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoCreateHandle( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_IoAccessMode mode, + OTF2_IoCreationFlag creationFlags, + OTF2_IoStatusFlag statusFlags ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoDestroyHandle( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoDuplicateHandle( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef oldHandle, + OTF2_IoHandleRef newHandle, + OTF2_IoStatusFlag statusFlags ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoSeek( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + int64_t offsetRequest, + OTF2_IoSeekOption whence, + uint64_t offsetResult ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoChangeStatusFlags( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_IoStatusFlag statusFlags ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoDeleteFile( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoParadigmRef ioParadigm, + OTF2_IoFileRef file ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoOperationBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_IoOperationMode mode, + OTF2_IoOperationFlag operationFlags, + uint64_t bytesRequest, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoOperationTest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoOperationIssued( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + NOT_IMPLEMENTED_YET(time); +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoOperationComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t bytesResult, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoOperationCancelled( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t matchingId ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_LockType lockType ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_LockType lockType ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +OTF2_CallbackCode ParserEventOTF2::callback_IoTryLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_LockType lockType ) { + ENTER_CALLBACK(time, locationID); + // Nothing to do here + return OTF2_CALLBACK_SUCCESS; +} + +// +// End of all handlers +// + +int ParserEventOTF2::read_events(OTF2_Reader *reader) { + + uint64_t events_read = 0; + OTF2_Reader_ReadAllGlobalEvents(reader, _global_evt_reader, &events_read); + return events_read; +} + +float ParserEventOTF2::get_percent_loaded() { + // TODO: there's no easy way of computing this. + return 0.5f; +} diff --git a/src/parser/OTF2Parser/ParserEventOTF2.hpp b/src/parser/OTF2Parser/ParserEventOTF2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b8e0890dd4ed76c332abd6a9ba4a8fc87dd13734 --- /dev/null +++ b/src/parser/OTF2Parser/ParserEventOTF2.hpp @@ -0,0 +1,670 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +/** + * @file ParserEventOTF2.hpp + * + * @brief This file contains the event parser used by the ParserOTF2. + * + * @author Lagrasse Olivier + * @author Johnny Jazeix + * @author Mathieu Faverge + * + */ +#ifndef PARSEREVENTOTF2_HPP +#define PARSEREVENTOTF2_HPP + +class Trace; +class ParserDefinitionOTF2; + + +/** + * \class ParserEventOTF2 + * \brief Reads Use handlers in order to fill the data structure + */ + +class ParserEventOTF2 { +private: + /*! + * Reader for the file + */ + OTF2_GlobalEvtReader* _global_evt_reader; + + OTF2_GlobalEvtReaderCallbacks* _global_evt_callbacks; + + static std::map <const String, Container *, String::less_than> _containers; + + ParserEventOTF2(const ParserEventOTF2 &); + + static OTF2_CallbackCode callback_Unknown( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ); + + static OTF2_CallbackCode callback_BufferFlush( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_TimeStamp stopTime ); + + static OTF2_CallbackCode callback_MeasurementOnOff( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_MeasurementMode measurementMode ); + + static OTF2_CallbackCode callback_Enter( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RegionRef region ); + + static OTF2_CallbackCode callback_Leave( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RegionRef region ); + + static OTF2_CallbackCode callback_MpiSend( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t receiver, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t msgLength ); + + static OTF2_CallbackCode callback_MpiIsend( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t receiver, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t msgLength, + uint64_t requestID ); + + static OTF2_CallbackCode callback_MpiIsendComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ); + + static OTF2_CallbackCode callback_MpiIrecvRequest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ); + + static OTF2_CallbackCode callback_MpiRecv( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t sender, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t msgLength ); + + static OTF2_CallbackCode callback_MpiIrecv( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t sender, + OTF2_CommRef communicator, + uint32_t msgTag, + uint64_t msgLength, + uint64_t requestID ); + + static OTF2_CallbackCode callback_MpiRequestTest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ); + + static OTF2_CallbackCode callback_MpiRequestCancelled( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t requestID ); + + static OTF2_CallbackCode callback_MpiCollectiveBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ); + + static OTF2_CallbackCode callback_MpiCollectiveEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CollectiveOp collectiveOp, + OTF2_CommRef communicator, + uint32_t root, + uint64_t sizeSent, + uint64_t sizeReceived ); + + static OTF2_CallbackCode callback_OmpFork( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t numberOfRequestedThreads ); + + static OTF2_CallbackCode callback_OmpJoin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ); + + static OTF2_CallbackCode callback_OmpAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t lockID, + uint32_t acquisitionOrder ); + + static OTF2_CallbackCode callback_OmpReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint32_t lockID, + uint32_t acquisitionOrder ); + + static OTF2_CallbackCode callback_OmpTaskCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t taskID ); + + static OTF2_CallbackCode callback_OmpTaskSwitch( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t taskID ); + + static OTF2_CallbackCode callback_OmpTaskComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + uint64_t taskID ); + + static OTF2_CallbackCode callback_Metric( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_MetricRef metric, + uint8_t numberOfMetrics, + const OTF2_Type* typeIDs, + const OTF2_MetricValue* metricValues ); + + static OTF2_CallbackCode callback_ParameterString( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_ParameterRef parameter, + OTF2_StringRef string ); + + static OTF2_CallbackCode callback_ParameterInt( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_ParameterRef parameter, + int64_t value ); + + static OTF2_CallbackCode callback_ParameterUnsignedInt( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_ParameterRef parameter, + uint64_t value ); + + static OTF2_CallbackCode callback_RmaWinCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win ); + + static OTF2_CallbackCode callback_RmaWinDestroy( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win ); + + static OTF2_CallbackCode callback_RmaCollectiveBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList ); + + static OTF2_CallbackCode callback_RmaCollectiveEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CollectiveOp collectiveOp, + OTF2_RmaSyncLevel syncLevel, + OTF2_RmaWinRef win, + uint32_t root, + uint64_t bytesSent, + uint64_t bytesReceived ); + + static OTF2_CallbackCode callback_RmaGroupSync( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaSyncLevel syncLevel, + OTF2_RmaWinRef win, + OTF2_GroupRef group ); + + static OTF2_CallbackCode callback_RmaRequestLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId, + OTF2_LockType lockType ); + + static OTF2_CallbackCode callback_RmaAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId, + OTF2_LockType lockType ); + + static OTF2_CallbackCode callback_RmaTryLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId, + OTF2_LockType lockType ); + + static OTF2_CallbackCode callback_RmaReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t lockId ); + + static OTF2_CallbackCode callback_RmaSync( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + OTF2_RmaSyncType syncType ); + + static OTF2_CallbackCode callback_RmaWaitChange( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win ); + + static OTF2_CallbackCode callback_RmaPut( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t bytes, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_RmaGet( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + uint64_t bytes, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_RmaAtomic( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint32_t remote, + OTF2_RmaAtomicType type, + uint64_t bytesSent, + uint64_t bytesReceived, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_RmaOpCompleteBlocking( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_RmaOpCompleteNonBlocking( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_RmaOpTest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_RmaOpCompleteRemote( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_RmaWinRef win, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_ThreadFork( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model, + uint32_t numberOfRequestedThreads ); + + static OTF2_CallbackCode callback_ThreadJoin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model ); + + static OTF2_CallbackCode callback_ThreadTeamBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam ); + + static OTF2_CallbackCode callback_ThreadTeamEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam ); + + static OTF2_CallbackCode callback_ThreadAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model, + uint32_t lockID, + uint32_t acquisitionOrder ); + + static OTF2_CallbackCode callback_ThreadReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_Paradigm model, + uint32_t lockID, + uint32_t acquisitionOrder ); + + static OTF2_CallbackCode callback_ThreadTaskCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam, + uint32_t creatingThread, + uint32_t generationNumber ); + + static OTF2_CallbackCode callback_ThreadTaskSwitch( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam, + uint32_t creatingThread, + uint32_t generationNumber ); + + static OTF2_CallbackCode callback_ThreadTaskComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadTeam, + uint32_t creatingThread, + uint32_t generationNumber ); + + static OTF2_CallbackCode callback_ThreadCreate( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ); + + static OTF2_CallbackCode callback_ThreadBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ); + + static OTF2_CallbackCode callback_ThreadWait( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ); + + static OTF2_CallbackCode callback_ThreadEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CommRef threadContingent, + uint64_t sequenceCount ); + + static OTF2_CallbackCode callback_CallingContextEnter( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CallingContextRef callingContext, + uint32_t unwindDistance ); + + static OTF2_CallbackCode callback_CallingContextLeave( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CallingContextRef callingContext ); + + static OTF2_CallbackCode callback_CallingContextSample( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_CallingContextRef callingContext, + uint32_t unwindDistance, + OTF2_InterruptGeneratorRef interruptGenerator ); + + static OTF2_CallbackCode callback_IoCreateHandle( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_IoAccessMode mode, + OTF2_IoCreationFlag creationFlags, + OTF2_IoStatusFlag statusFlags ); + + static OTF2_CallbackCode callback_IoDestroyHandle( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle ); + + static OTF2_CallbackCode callback_IoDuplicateHandle( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef oldHandle, + OTF2_IoHandleRef newHandle, + OTF2_IoStatusFlag statusFlags ); + + static OTF2_CallbackCode callback_IoSeek( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + int64_t offsetRequest, + OTF2_IoSeekOption whence, + uint64_t offsetResult ); + + static OTF2_CallbackCode callback_IoChangeStatusFlags( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_IoStatusFlag statusFlags ); + + static OTF2_CallbackCode callback_IoDeleteFile( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoParadigmRef ioParadigm, + OTF2_IoFileRef file ); + + static OTF2_CallbackCode callback_IoOperationBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_IoOperationMode mode, + OTF2_IoOperationFlag operationFlags, + uint64_t bytesRequest, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_IoOperationTest( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_IoOperationIssued( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_IoOperationComplete( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t bytesResult, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_IoOperationCancelled( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + uint64_t matchingId ); + + static OTF2_CallbackCode callback_IoAcquireLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_LockType lockType ); + + static OTF2_CallbackCode callback_IoReleaseLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_LockType lockType ); + + static OTF2_CallbackCode callback_IoTryLock( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_IoHandleRef handle, + OTF2_LockType lockType ); + + static OTF2_CallbackCode callback_ProgramBegin( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + OTF2_StringRef programName, + uint32_t numberOfArguments, + const OTF2_StringRef* programArguments ); + + static OTF2_CallbackCode callback_ProgramEnd( OTF2_LocationRef locationID, + OTF2_TimeStamp time, + void* userData, + OTF2_AttributeList* attributeList, + int64_t exitStatus ); + + +public: + /*! + * \fn ParserEventOTF2() + * \brief constructor + */ + ParserEventOTF2(OTF2_Reader *reader); + + /*! + * \fn ~ParserEventOTF2() + * \brief constructor + */ + ~ParserEventOTF2(); + + /*! + * \fn set_handlers(OTF2_Reader *reader, Trace *t) + * \brief Create and set the handlers for the event parsing. + * \param t The trace we want to store in. + */ + void set_handlers(OTF2_Reader *reader, Trace *t); + + /*! + * \fn read_events(OTF_Reader2 *reader) + * \brief Begin the reading of the events + * \param reader The main otf file we want to read in. + */ + int read_events(OTF2_Reader *reader); + + /*! + * \fn get_percent_loaded() + * \brief get the size already parsed. + * It is an approximation, we consider that parsing the definitions is done in a constant time. + * \return the scale of the size already parsed. (between 0 and 1) + */ + static float get_percent_loaded(); + +}; +#endif // PARSEREVENTOTF2_HPP diff --git a/src/parser/OTF2Parser/ParserOTF2.cpp b/src/parser/OTF2Parser/ParserOTF2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..997044f2424f131a634749bbf4fffef93a8ed6e8 --- /dev/null +++ b/src/parser/OTF2Parser/ParserOTF2.cpp @@ -0,0 +1,134 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +/** + * @file ParserOTF2.cpp + * + * @author Lagrasse Olivier + * @author Johnny Jazeix + * @author Mathieu Faverge + * + */ + +#include <iostream> +#include <fstream> +#include <string> +#include <map> +#include <list> +/* -- */ +#include <otf2/otf2.h> +/* -- */ +#include "trace/values/Values.hpp" +#include "trace/EntityTypes.hpp" +#include "trace/Entitys.hpp" +#include "trace/Trace.hpp" +/* -- */ +#include "parser/Parser.hpp" +#include "parser/OTF2Parser/ParserOTF2.hpp" +#include "parser/OTF2Parser/ParserDefinitionOTF2.hpp" +#include "parser/OTF2Parser/ParserEventOTF2.hpp" +/* -- */ + +using namespace std; + +#define VITE_OTF_2_MAXFILES_OPEN 100 + +#define VITE_ERR_OTF_2_OPENREADER "Failed to create the OTF2 Reader\n" + + +ParserOTF2::ParserOTF2() {} +ParserOTF2::ParserOTF2(const string &filename) : Parser(filename) {} +ParserOTF2::~ParserOTF2() {} + +void ParserOTF2::parse(Trace &trace, + bool finish_trace_after_parse) { + + ParserDefinitionOTF2 *parserdefinition; + ParserEventOTF2 *parserevent; + OTF2_Reader *reader; + string filename = get_next_file_to_parse(); + + reader = OTF2_Reader_Open(filename.c_str()); + if(reader == NULL) { + cerr << QObject::tr(VITE_ERR_OTF_2_OPENREADER).toStdString() << endl; + finish(); + + if(finish_trace_after_parse) { // true by default + trace.finish(); + } + return; + } + + parserdefinition = new ParserDefinitionOTF2(reader); + parserdefinition->set_handlers(&trace); + parserdefinition->read_definitions(reader); + parserdefinition->create_container_types(&trace); + parserdefinition->initialize_types(&trace); + +#if DEBUG + parserdefinition->print_definitions(); +#endif // DEBUG + + parserevent = new ParserEventOTF2(reader); + parserevent->set_handlers(reader, &trace); + + parserevent->read_events(reader); + + // parserevent->read_markers(reader); + + finish(); + + if(finish_trace_after_parse) { // true by default + trace.finish(); + } + + delete parserevent; + delete parserdefinition; + + OTF2_Reader_Close(reader); +} + + +float ParserOTF2::get_percent_loaded() const { + // return ParserEventOTF::get_percent_loaded(); + return 1; +} diff --git a/src/parser/OTF2Parser/ParserOTF2.hpp b/src/parser/OTF2Parser/ParserOTF2.hpp new file mode 100644 index 0000000000000000000000000000000000000000..74293c3b6f3af308fbcdffc0fb5aa9dcc288e812 --- /dev/null +++ b/src/parser/OTF2Parser/ParserOTF2.hpp @@ -0,0 +1,93 @@ +/* +** This file is part of the ViTE project. +** +** This software is governed by the CeCILL-A license under French law +** and abiding by the rules of distribution of free software. You can +** use, modify and/or redistribute the software under the terms of the +** CeCILL-A license as circulated by CEA, CNRS and INRIA at the following +** URL: "http://www.cecill.info". +** +** As a counterpart to the access to the source code and rights to copy, +** modify and redistribute granted by the license, users are provided +** only with a limited warranty and the software's author, the holder of +** the economic rights, and the successive licensors have only limited +** liability. +** +** In this respect, the user's attention is drawn to the risks associated +** with loading, using, modifying and/or developing or reproducing the +** software by the user in light of its specific status of free software, +** that may mean that it is complicated to manipulate, and that also +** therefore means that it is reserved for developers and experienced +** professionals having in-depth computer knowledge. Users are therefore +** encouraged to load and test the software's suitability as regards +** their requirements in conditions enabling the security of their +** systems and/or data to be ensured and, more generally, to use and +** operate it in the same conditions as regards security. +** +** The fact that you are presently reading this means that you have had +** knowledge of the CeCILL-A license and that you accept its terms. +** +** +** ViTE developers are (for version 0.* to 1.0): +** +** - COULOMB Kevin +** - FAVERGE Mathieu +** - JAZEIX Johnny +** - LAGRASSE Olivier +** - MARCOUEILLE Jule +** - NOISETTE Pascal +** - REDONDY Arthur +** - VUCHENER Clément +** +*/ +/** + * @file ParserOTF2.hpp + * + * @brief the implementation of Parser for OTF2 traces. + * + * @author Lagrasse Olivier + * @author Johnny Jazeix + * @author Mathieu Faverge + * + */ +#ifndef PARSEROTF2_HPP +#define PARSEROTF2_HPP + +/*! + * + * \class ParserOTF2 + * \brief parse the input data format of OTF2. + * + */ +class ParserOTF2 : public Parser { +private: + ParserOTF2(const ParserOTF2 &); + +public: + + /*! + * \fn ParserOTF2() + */ + ParserOTF2(); + ParserOTF2(const std::string &filename); + ~ParserOTF2(); + + /*! + * \fn parse(Trace &trace, bool finish_trace_after_parse = true) + * \param trace : the structure of data to fill + * \param finish_trace_after_parse boolean set if we do not have to finish the trace after parsing + */ + void parse(Trace &trace, + bool finish_trace_after_parse = true); + + /*! + * \fn get_percent_loaded() const + * \brief return the size of the file already read. + * \return the scale of the size already loaded of the file by the parser. (between 0 and 1) + */ + float get_percent_loaded() const; + +}; + +#endif // PARSEROTF2_HPP + diff --git a/src/parser/ParserFactory.cpp b/src/parser/ParserFactory.cpp index 4ba4e6be8b0cba454183badba56a8a1ce7ba659a..be1ca0be1e31599b4487a70d42a22f773078ebff 100644 --- a/src/parser/ParserFactory.cpp +++ b/src/parser/ParserFactory.cpp @@ -74,6 +74,11 @@ #endif #endif //VITE_ENABLE_OTF +#ifdef WITH_OTF2 +#include <otf2/otf2.h> +#include "parser/OTF2Parser/ParserOTF2.hpp" +#endif //WITH_OTF2 + #ifdef VITE_ENABLE_TAU #include <TAU_tf.h> #include "parser/TauParser/ParserTau.hpp" @@ -118,6 +123,14 @@ bool ParserFactory::create(Parser **parser, *Message::get_instance() << "OTF parser was not compiled. Use parser Paje by default" << Message::endw; return false; #endif //VITE_ENABLE_OTF + } + else if( ext == ".otf2" ) { +#ifdef WITH_OTF2 + *parser = new ParserOTF2(filename); +#else + *Message::get_instance() << "OTF2 parser was not compiled. Use parser Paje by default" << Message::endw; + return false; +#endif //WITH_OTF2 } else if( (ext == ".trc") || (ext == ".edf") ) { #ifdef VITE_ENABLE_TAU diff --git a/src/render/Render_alternate.hpp b/src/render/Render_alternate.hpp index 4030940bae15ab082c354251bd1c1fea6392d929..4a8064d5b429e370579299431e6c42750e045cb4 100644 --- a/src/render/Render_alternate.hpp +++ b/src/render/Render_alternate.hpp @@ -57,6 +57,7 @@ #include <QPainter> #define GLM_FORCE_RADIANS #include <glm/glm.hpp> +#define GLM_ENABLE_EXPERIMENTAL #include <glm/gtx/transform.hpp> #include <glm/gtc/type_ptr.hpp> //#include <ft2build.h> diff --git a/src/trace/Trace.cpp b/src/trace/Trace.cpp index ea31e0808395d4c9879741b2f938999722d165dd..94cdf5aed41475e233c06b6a7611363561b1b34b 100644 --- a/src/trace/Trace.cpp +++ b/src/trace/Trace.cpp @@ -269,7 +269,6 @@ void Trace::define_link_type(Name &name, if (source && destination) { LinkType *lt = new LinkType(name, ancestor, source, destination, opt); _link_types.insert( pair<std::string, LinkType*>(name.get_alias(), lt) ); - #if defined(USE_ITC) && defined(BOOST_SERIALIZE) Serializer<EntityType>::Instance().setUid(lt); #endif