summaryrefslogtreecommitdiff
path: root/source/profiler
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-08 09:54:53 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-08 12:30:28 +0100
commit4cc4021d356c174f780be2b7ef96910e36c8dd7b (patch)
treec2a790b914577873a368982a07a9491f6743443e /source/profiler
parent11b75cc7dc140119dee490f425e25a004122703b (diff)
downloadml-embedded-evaluation-kit-4cc4021d356c174f780be2b7ef96910e36c8dd7b.tar.gz
MLECO-3070: Further HAL cleanup.
Cleaning up HAL sources by removing unnecessary redirections with function pointers. The "platform packages" under HAL are now streamlined enough to not need any major HAL wrapping (as was the case before). This allows us to have a very thin HAL layer that sits on top of the platform and compnent packs. Also helps in getting rid of "hal platform" pointer being passed around in the code to use any HAL functionality. Change-Id: I04b2057f972aad7a5cfb4a396bcdf147c9f9ef1c Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'source/profiler')
-rw-r--r--source/profiler/Profiler.cc52
-rw-r--r--source/profiler/include/Profiler.hpp10
2 files changed, 28 insertions, 34 deletions
diff --git a/source/profiler/Profiler.cc b/source/profiler/Profiler.cc
index 7e10097..64edcf2 100644
--- a/source/profiler/Profiler.cc
+++ b/source/profiler/Profiler.cc
@@ -21,28 +21,27 @@
namespace arm {
namespace app {
- Profiler::Profiler(hal_platform* platform, const char* name = "Unknown")
- : m_name(name)
- {
- if (platform && platform->inited) {
- this->m_pPlatform = platform;
- this->Reset();
- } else {
- printf_err("Profiler %s initialised with invalid platform\n",
- this->m_name.c_str());
- }
- }
+ Profiler::Profiler()
+ : Profiler("Unknown")
+ {}
+
+ Profiler::Profiler(const char* name)
+ : m_name(name)
+ {}
bool Profiler::StartProfiling(const char* name)
{
if (name) {
this->SetName(name);
}
- if (this->m_pPlatform && !this->m_started) {
- this->m_pPlatform->timer->reset();
- this->m_tstampSt = this->m_pPlatform->timer->get_counters();
- this->m_started = true;
- return true;
+ if (!this->m_started) {
+ hal_pmu_reset();
+ this->m_tstampSt.initialised = false;
+ hal_pmu_get_counters(&this->m_tstampSt);
+ if (this->m_tstampSt.initialised) {
+ this->m_started = true;
+ return true;
+ }
}
printf_err("Failed to start profiler %s\n", this->m_name.c_str());
return false;
@@ -50,13 +49,17 @@ namespace app {
bool Profiler::StopProfiling()
{
- if (this->m_pPlatform && this->m_started) {
- this->m_tstampEnd = this->m_pPlatform->timer->get_counters();
+ if (this->m_started) {
+ this->m_tstampEnd.initialised = false;
+ hal_pmu_get_counters(&this->m_tstampEnd);
this->m_started = false;
-
- this->AddProfilingUnit(this->m_tstampSt, this->m_tstampEnd, this->m_name);
-
- return true;
+ if (this->m_tstampEnd.initialised) {
+ this->AddProfilingUnit(
+ this->m_tstampSt,
+ this->m_tstampEnd,
+ this->m_name);
+ return true;
+ }
}
printf_err("Failed to stop profiler %s\n", this->m_name.c_str());
return false;
@@ -160,11 +163,6 @@ namespace app {
void Profiler::AddProfilingUnit(pmu_counters start, pmu_counters end,
const std::string& name)
{
- if (!this->m_pPlatform) {
- printf_err("Invalid platform\n");
- return;
- }
-
struct ProfilingUnit unit = {
.counters = end
};
diff --git a/source/profiler/include/Profiler.hpp b/source/profiler/include/Profiler.hpp
index b8f9089..581e1e5 100644
--- a/source/profiler/include/Profiler.hpp
+++ b/source/profiler/include/Profiler.hpp
@@ -62,13 +62,12 @@ namespace app {
public:
/**
* @brief Constructor for profiler.
- * @param[in] platform Pointer to a valid, initialised hal platform.
* @param[in] name A friendly name for this profiler.
**/
- Profiler(hal_platform* platform, const char* name);
+ Profiler(const char* name);
- /** Block the default constructor. */
- Profiler() = delete;
+ /** Default constructor. */
+ Profiler();
/** Default destructor. */
~Profiler() = default;
@@ -103,10 +102,7 @@ namespace app {
ProfilingMap m_series; /* Profiling series map. */
pmu_counters m_tstampSt{}; /* Container for a current starting timestamp. */
pmu_counters m_tstampEnd{}; /* Container for a current ending timestamp. */
- hal_platform * m_pPlatform = nullptr; /* Platform pointer - to get the timer. */
-
bool m_started = false; /* Indicates profiler has been started. */
-
std::string m_name; /* Name given to this profiler. */
/**