]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - pasdk/common/paf_alg_print.c
PASDK114: updated PAF and MAT-THD submodule.
[processor-sdk/performance-audio-sr.git] / pasdk / common / paf_alg_print.c
2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without 
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 //
37 // Algorithm RAM_REPORT definitions
38 //
40 #include <stdlib.h> // malloc
41 #include <stdio.h>  // printf
42 #include <paf_alg_print.h>
44 #include <xdc/runtime/Memory.h>
45 #include <xdc/runtime/IHeap.h>
46 #include <ti/sysbios/heaps/HeapMem.h>
48 Int
49 PAF_ALG_allocPrint (const PAF_ALG_AllocInit *pInit, Int sizeofInit, PAF_IALG_Config *p)
50 {
51     IALG_MemRec *memTab;
52     Int commonSize[PAF_IALG_COMMON_MEMN+1];
53     Int commonCount[PAF_IALG_COMMON_MEMN+1];
54     Int commonSpace[PAF_IALG_COMMON_MEMN+1];
55     Int i,n;
57     for ( ; pInit && pInit->ialg_fxns; 
58         pInit=(const PAF_ALG_AllocInit *)((char *)pInit+sizeofInit)) {
59 #ifdef _TMS320C6X
60 #pragma UNROLL(1)
61 #endif
62         for (i=PAF_IALG_COMMON_MEM0;i<=PAF_IALG_COMMON_MEMN;++i) {
63             commonSize[i]=0;
64             commonCount[i]=0;
65             commonSpace[i]=-1;
66         }
67         n = pInit->ialg_fxns->algNumAlloc != NULL ? pInit->ialg_fxns->algNumAlloc() 
68                                                   : IALG_DEFMEMRECS;
69         if((memTab = (IALG_MemRec *)malloc(n * sizeof(IALG_MemRec)))){
70             n=pInit->ialg_fxns->algAlloc(pInit->ialg_prms,(IALG_Fxns ** )&(pInit->ialg_fxns),memTab);
71             if(n<=0)
72                 return PAF_ALGERR_MEMTAB_COUNT;
74             for(i=0;i<n;++i){
75                 if((((Int)memTab[i].attrs >= PAF_IALG_COMMON_MEM0) && ((Int)memTab[i].attrs <= PAF_IALG_COMMON_MEMN))) {
76                     commonSize[memTab[i].attrs] += memTab[i].size + 
77                 (commonCount[memTab[i].attrs] ? memTab[i].alignment : 0);
78                     commonCount[memTab[i].attrs]++;
79                 }
80                 // (***) FL: this is broken for printout of persistent memory
81                 // The code was broken before addition of persist memory in MSMC SHM.
82                 // commonSize[] and commonCount[] are correct, but here persist is treated like common memory, i.e.
83                 //     persistent memory is treated as through it's combined into a single memory space.
84                 //     For example, printout can only show persist memory as belonging to one space.
85                 //     This isn't true for persistent memory since it can be in multiple spaces.
86                 if (commonSpace[memTab[i].attrs] < (Int)memTab[i].space) {
87                     commonSpace[memTab[i].attrs] = (Int)memTab[i].space;
88                 }
89             }
90             free(memTab);
92             printf("\n0x%-3x\t",((PAF_ASP_LinkInit*)pInit)->thisCode.part.beta);
93             for(i=PAF_IALG_COMMON_MEM0;i<=PAF_IALG_COMMON_MEMN;++i){
94                 if (commonSize[i] == 0)
95                     printf("%9d\t",0);
96                 else 
97                     printf("%6d(%1d)\t", 
98                         commonSize[i], PAF_ALG_memSpaceToHeapId(p, (IALG_MemSpace)commonSpace[i]));
99             }
100             commonSize[IALG_SCRATCH] = commonSize[IALG_PERSIST] = commonSize[IALG_WRITEONCE] = 0;
101         }
102         else
103             return 1;
104     }
105     return 0;
108 Void
109 PAF_ALG_commonPrint (IALG_MemRec common[], PAF_IALG_Config *p)
112     Int i;
114     printf("\n\n");
115     for(i=0;i<130;i++)
116         printf ("--");
118     printf ("\nCOMMON                         \t\t\t\t");
119     for (i=PAF_IALG_COMMON_MEM0; i <= PAF_IALG_COMMON_MEMN; i++) {
120         if (i <= IALG_WRITEONCE)
121             ; //printf(""); // print empty string??
122         else if (common[i].size == 0)
123             printf("%9d\t",0);
124         else 
125             printf("%6d(%1d)\t",
126                 common[i].size, PAF_ALG_memSpaceToHeapId(p, common[i].space));
127     }
131 //PAF_ALG_memStatusPrint(Int internal, Int external, Int internal1)
132 Void
133 PAF_ALG_memStatusPrint(
134     HeapMem_Handle hInternalHeap, 
135     HeapMem_Handle hInternal1Heap,
136     HeapMem_Handle hExternalHeap, 
137     HeapMem_Handle hInternal1HeapShm
140     //MEM_Stat statbuf;
141     Memory_Stats stats;
143     printf("\n\nSegment\tSize\tUsed\tAvailable");
144     
145     //MEM_stat(internal,&statbuf);
146     //printf("\nIRAM\t%d\t%d\t%d",statbuf.size,statbuf.used,statbuf.length);
147     //MEM_stat(external,&statbuf);
148     //printf("\nSDRAM\t%d\t%d\t%d",statbuf.size,statbuf.used,statbuf.length);
149     //MEM_stat(internal1,&statbuf);
150     //printf("\nL3RAM\t%d\t%d\t%d\n",statbuf.size,statbuf.used,statbuf.length);
152     if (hInternalHeap != NULL)
153     {
154         Memory_getStats((IHeap_Handle)hInternalHeap, &stats);
155         printf("\nL2\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
156     }
157     if (hInternal1Heap != NULL)
158     {
159         Memory_getStats((IHeap_Handle)hInternal1Heap, &stats);
160         printf("\nMSMC\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);    
161     }
162     if (hExternalHeap != NULL)
163     {
164         Memory_getStats((IHeap_Handle)hExternalHeap, &stats);
165         printf("\nDDR3\t%d\t%d\t%d", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
166     }
167     if (hInternal1HeapShm != NULL)
168     {
169         Memory_getStats((IHeap_Handle)hInternal1HeapShm, &stats);
170         printf("\nMSMC SHM\t%d\t%d\t%d\n", stats.totalSize, stats.totalSize-stats.totalFreeSize, stats.largestFreeSize);
171     }
174 //PAF_ALG_bufMemPrint(Int z,Int size, Int heap,Int bufType)
175 Void
176 PAF_ALG_bufMemPrint(
177     Int z,
178     Int size, 
179     Int heapId,
180     Int bufType
183       printf("\n\n%s Device Buffer (Zone %d) = %d (%d)", 
184               (bufType==0 ? "Input" : bufType==1 ? "Output" : "Audio Frame"), 
185               z, size, heapId);
186       printf("\n");
189 Void
190 PAF_ALG_headerPrint()
192     Int i;
194     printf("\n\nAlgorithm Memory requirement:\n");
195     printf("  Key:  \n");
196     printf("    Beta ID can be decoded from stdbeta.h, oembeta.h or cusbeta.h in pa\\sio\\acp1.\n");
197     printf("    The number in parentheses is the heap.  (0) is L2.  (1) is MSMC.  (2) is DDR3.  (3) is MSMC SHM.  (4) is DDR SHM.\n");
198     printf("%8s\t","BetaId");
199     for(i=PAF_IALG_COMMON_MEM0;i<=PAF_IALG_COMMON_MEMN;++i){
200         if(i==0) printf("%8s\t","SCRATCH");
201         else if(i==1) printf("%8s\t","PERSIST");
202         else if(i==2) printf("%8s \t","WRITEONCE");
203         else if(i<10)
204             printf("%-7s%d  \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
205         else
206             printf("%6s%2d \t","COMMON",(i==0 ? i : i-IALG_WRITEONCE));
207     }