PASDK209: Added post processing and CPU load profiler.
authorChitresh Gupta <chitresh.g@pathpartnertech.com>
Thu, 23 Feb 2017 18:24:20 +0000 (23:54 +0530)
committerChitresh Gupta <chitresh.g@pathpartnertech.com>
Thu, 23 Feb 2017 18:24:20 +0000 (23:54 +0530)
pasdk/common/asp0.c
pasdk/test_dsp/application/app.cfg
pasdk/test_dsp/framework/audioStreamInpProc.c

index c21b74b9c11917797ab77a3dc647346569fdac9f..b25a449a12bcd475bd4f162dc7ab27b0df71acd3 100644 (file)
@@ -51,6 +51,24 @@ All rights reserved.
 #include <xdc/runtime/IHeap.h>
 #include <ti/sysbios/heaps/HeapMem.h>
 
+
+#define PROFILER
+
+#ifdef PROFILER
+#include <ti/sysbios/knl/Task.h>
+#include "ti/sysbios/knl/Clock.h"
+#include "xdc/runtime/Timestamp.h"
+#include "ti/sysbios/utils/Load.h"
+
+#ifndef MAX_NUM
+#define MAX_NUM 28515
+#endif
+UInt32 profile_array_dsp_cycles[MAX_NUM];
+UInt32 profile_array_dsp_cpuload[MAX_NUM];
+UInt32 profile_index = 0;
+UInt32 start_profiling = 0;
+#endif
+
 //
 #include "asp0.h"
 //#include <paf_alg.h>
@@ -287,9 +305,43 @@ PAF_ASP_chainApply_ (PAF_ASP_Chain *this, PAF_AudioFrame *pAudioFrame)
         }
         Log_info3("PAF_ASP_chainApply_: AS_%d. link %d.  alg: 0x%x.", this->stream, i, (IArg)alg);
 
-        if (alg->fxns->apply && (errno = alg->fxns->apply(alg, pAudioFrame)))
+        if (alg->fxns->apply /*&& (errno = alg->fxns->apply(alg, pAudioFrame))*/)
         {
-            if (this->log)
+
+#ifdef PROFILER
+        {
+            volatile UInt32 time32_1, time32_2;
+
+            time32_1 = Timestamp_get32();
+#endif
+            errno = alg->fxns->apply(alg, pAudioFrame);
+
+#ifdef PROFILER
+            time32_2 = Timestamp_get32();
+            //Load_Stat stat;
+            //Load_getTaskLoad (Task_getIdleTask(), &stat);
+            //UInt32 intLoad = Load_calculateLoad (&stat);
+            if (start_profiling == 1)
+            {
+                if (profile_index < MAX_NUM)
+                {
+                    profile_array_dsp_cycles[profile_index] = (time32_2 - time32_1);
+                    //profile_array_dsp_cpuload[profile_index] = (100   - intLoad);
+                    profile_array_dsp_cpuload[profile_index] =  Load_getCPULoad();
+                    profile_index++;
+                }
+                else
+                {
+                    //SW_BREAKPOINT;
+                }
+            }
+
+            //TRACE_TERSE1("profiler: Timestamp_get32() cycles: %u", (time32_2 - time32_1) * factor);
+            //TRACE_TERSE2("profiler: CPU load: idle: %d other: %d", intLoad, (100 - intLoad));
+        }
+#endif
+
+            if (errno && this->log)
             {
                 LOG_printf(this->log, "AS%d: ASP code 0x%08x apply error 0x%x.",
                     this->stream, pLink->code.full, errno);
index 006649177e60d95ac0cbf55f128e077762ac711d..8adf177ab53fb7b0df81863be08f34594b37a345 100644 (file)
@@ -187,10 +187,16 @@ LoggingSetup.mainLoggingRuntimeControl = false;
 LoggingSetup.mainLoggerSize = 327680; //81960;
 //LoggingSetup.memorySectionName = "CORE0_DDR3"; //"CORE0_MSMC";
 
-/* Configure Load Logging */ // FL: doesn't work
-//Load.taskEnabled = true;
-//Load.hwiEnabled = true;
-//Load.common$.diags_USER4 = Diags.ALWAYS_ON;
+// FL: CPU load logging via UIA doesn't work.
+//     Below settings work for target-side load computation (no UIA) when LoggingSetup.loadLogging set to false, but not true.
+//     Load.common$.diags_USER4 set to default or Diags.ALWAYS_ON makes no difference.
+/* Configure Load Logging */
+Load.updateInIdle = true;   // default=true
+Load.windowInMs = 5.33;    // 48KHz 256 @ 5.33ms  // in msec., default=500
+Load.taskEnabled = true;    // default=true
+Load.swiEnabled = false;    // default=true
+Load.hwiEnabled = false;    // default=true
+//Load.common$.diags_USER4 = Diags.ALWAYS_ON; // default=Diags.RUNTIME_ON
 
 //Task.common$.diags_USER1 = Diags.ALWAYS_ON;
 Task.common$.diags_INFO = Diags.ALWAYS_ON;
index 4c5227dd2363f154230b74708113fc204dd00d6a..5a4b569a510af475b49fd1572f5f9223f3adabcc 100644 (file)
@@ -243,6 +243,13 @@ All rights reserved.
 #include "audioStreamProc_config.h"
 #include "audioStreamInpProc.h"
 
+
+#define PROFILER
+
+#ifdef PROFILER
+extern UInt32 start_profiling;
+#endif
+
 //
 // Audio Stream Definitions
 //
@@ -3460,7 +3467,21 @@ PAF_ASIT_decodeDecode(
             {
                 frameLength = 256;
             }
-#endif                    
+#endif
+
+
+#ifdef PROFILER
+            // modify for different decoders
+            if (sourceSelect == PAF_SOURCE_THD)
+            {
+               start_profiling = 1;
+            }
+            else
+            {
+                start_profiling = 0;
+            }
+#endif
+
 
 // ............................................................................