summaryrefslogtreecommitdiff
path: root/source/profiler/Profiler.cc
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/Profiler.cc
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/Profiler.cc')
-rw-r--r--source/profiler/Profiler.cc52
1 files changed, 25 insertions, 27 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
};