summaryrefslogtreecommitdiff
path: root/runtimes/libs/xdata
diff options
context:
space:
mode:
Diffstat (limited to 'runtimes/libs/xdata')
-rw-r--r--runtimes/libs/xdata/CMakeLists.txt7
-rw-r--r--runtimes/libs/xdata/README.md3
-rw-r--r--runtimes/libs/xdata/include/xdata.h22
-rw-r--r--runtimes/libs/xdata/include/xdata/trace.h95
-rw-r--r--runtimes/libs/xdata/src/trace.cpp42
5 files changed, 169 insertions, 0 deletions
diff --git a/runtimes/libs/xdata/CMakeLists.txt b/runtimes/libs/xdata/CMakeLists.txt
new file mode 100644
index 000000000..23a08303b
--- /dev/null
+++ b/runtimes/libs/xdata/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_library(nnfw_lib_xdata SHARED src/trace.cpp)
+target_include_directories(nnfw_lib_xdata PUBLIC include)
+target_link_libraries(nnfw_lib_xdata PUBLIC nnfw_lib_xray_event)
+target_link_libraries(nnfw_lib_xdata PRIVATE nnfw_common)
+target_link_libraries(nnfw_lib_xdata PRIVATE nnfw_coverage)
+
+install(TARGETS nnfw_lib_xdata LIBRARY DESTINATION lib)
diff --git a/runtimes/libs/xdata/README.md b/runtimes/libs/xdata/README.md
new file mode 100644
index 000000000..76b100936
--- /dev/null
+++ b/runtimes/libs/xdata/README.md
@@ -0,0 +1,3 @@
+# xdata
+
+_xdata_ is a collection of XRay data structures for performance analysis.
diff --git a/runtimes/libs/xdata/include/xdata.h b/runtimes/libs/xdata/include/xdata.h
new file mode 100644
index 000000000..4f291ef6b
--- /dev/null
+++ b/runtimes/libs/xdata/include/xdata.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NNFW_XDATA_H__
+#define __NNFW_XDATA_H__
+
+#include <xdata/trace.h>
+
+#endif // __NNFW_XDATA_H__
diff --git a/runtimes/libs/xdata/include/xdata/trace.h b/runtimes/libs/xdata/include/xdata/trace.h
new file mode 100644
index 000000000..700c39aaa
--- /dev/null
+++ b/runtimes/libs/xdata/include/xdata/trace.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NNFW_XDATA_TRACE_H__
+#define __NNFW_XDATA_TRACE_H__
+
+#include <xray/event_category.h>
+#include <xray/event_code.h>
+
+#include <memory>
+#include <string>
+
+namespace xdata
+{
+namespace trace
+{
+
+class region
+{
+public:
+ region(const char *s) : _name{s}
+ {
+ // DO NOTHING
+ }
+
+public:
+ const std::string &name(void) const { return _name; }
+
+private:
+ std::string _name;
+};
+
+enum action
+{
+ enter,
+ leave
+};
+
+class info final
+{
+public:
+ info(const trace::region *rgn, const trace::action &act) : _region{rgn}, _action{act}
+ {
+ // DO NOTHING
+ }
+
+public:
+ const trace::region *region(void) const { return _region; }
+ const trace::action &action(void) const { return _action; }
+
+private:
+ const trace::region *_region;
+ trace::action _action;
+};
+
+// WARN! This implementation is not thread-safe.
+// TODO Make this thread-safe
+class category final : public xray::event_category
+{
+private:
+ category() = default;
+
+public:
+ xray::event_code set(std::unique_ptr<trace::info> &&info);
+ void reset(void);
+
+public:
+ const trace::info *info(void) const { return _info.get(); }
+
+private:
+ std::unique_ptr<trace::info> _info;
+
+public:
+ static category *get(void);
+};
+
+static inline category *cat(void) { return category::get(); }
+
+} // namespace trace
+} // namespace xdata
+
+#endif // __NNFW_XDATA_TRACE_H__
diff --git a/runtimes/libs/xdata/src/trace.cpp b/runtimes/libs/xdata/src/trace.cpp
new file mode 100644
index 000000000..6f11847ae
--- /dev/null
+++ b/runtimes/libs/xdata/src/trace.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xdata/trace.h"
+
+#include <cassert>
+
+namespace xdata
+{
+namespace trace
+{
+
+xray::event_code category::set(std::unique_ptr<trace::info> &&info)
+{
+ assert(info != nullptr);
+ _info = std::move(info);
+ return xray::event_code{0};
+}
+
+void category::reset(void) { _info.release(); }
+
+category *category::get(void)
+{
+ static category cat;
+ return &cat;
+}
+
+} // namespace trace
+} // namespace xdata