Commit 9935e7f3 authored by malenov's avatar malenov
Browse files

merge high-level wrapper functions into _wmc variants and rename the extension

parent 76ffe247
Loading
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -164,7 +164,6 @@ int main(

#ifdef WMOPS
    reset_wmops();
    reset_wmops_wmc();
    reset_mem( USE_BYTES );
#endif

@@ -1548,7 +1547,6 @@ static ivas_error decodeG192(
#ifdef WMOPS
    reset_stack();
    reset_wmops();
    reset_wmops_wmc();
#endif

    nSamplesAvailableNext = 0;
@@ -1809,7 +1807,6 @@ static ivas_error decodeG192(
        if ( vec_pos_update == 0 )
        {
            update_wmops();
            update_wmops_wmc();
            update_mem();
        }
#endif
@@ -1939,7 +1936,6 @@ static ivas_error decodeG192(

#ifdef WMOPS
        update_wmops();
        update_wmops_wmc();
        update_mem();
#ifdef MEM_COUNT_DETAILS
        export_mem( "mem_analysis.csv" );
@@ -2206,7 +2202,6 @@ static ivas_error decodeVoIP(
#ifdef WMOPS
    reset_stack();
    reset_wmops();
    reset_wmops_wmc();
#endif

    /*------------------------------------------------------------------------------------------*
@@ -2490,7 +2485,6 @@ static ivas_error decodeVoIP(
#ifdef WMOPS
        update_mem();
        update_wmops();
        update_wmops_wmc();
#endif
    }

+0 −3
Original line number Diff line number Diff line
@@ -171,7 +171,6 @@ int main(

#ifdef WMOPS
    reset_wmops();
    reset_wmops_wmc();
    reset_mem( USE_BYTES );
#endif

@@ -568,7 +567,6 @@ int main(
#ifdef WMOPS
    reset_stack();
    reset_wmops();
    reset_wmops_wmc();
#endif

    /*------------------------------------------------------------------------------------------*
@@ -712,7 +710,6 @@ int main(
#ifdef WMOPS
        update_mem();
        update_wmops();
        update_wmops_wmc();
#endif
    }

+0 −3
Original line number Diff line number Diff line
@@ -663,7 +663,6 @@ int main(

#ifdef WMOPS
    reset_wmops();
    reset_wmops_wmc();
    reset_mem( USE_BYTES );
#endif

@@ -1278,7 +1277,6 @@ int main(
#ifdef WMOPS
    reset_stack();
    reset_wmops();
    reset_wmops_wmc();
#endif

    if ( !args.quietModeEnabled )
@@ -1710,7 +1708,6 @@ int main(
#ifdef WMOPS
        update_mem();
        update_wmops();
        update_wmops_wmc();
#endif
    }

+0 −6
Original line number Diff line number Diff line
@@ -586,12 +586,6 @@ void BASOP_get_total_wmops( double *min, double *max, double *avg );
#define SUB_WMOPS_INIT( label ) BASOP_sub_start( label )
#define END_SUB_WMOPS           BASOP_sub_end()

#define reset_wmops()   { BASOP_init }
#define push_wmops( x ) { BASOP_push_wmops( x ); }
#define pop_wmops()     { BASOP_pop_wmops(); }
#define update_wmops()  { BASOP_frame_update(); }
#define print_wmops()   { WMOPS_output_all_std( 0 ); WMOPS_destroy(); }


#endif /* _COUNT_H */

+186 −171
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@
#include "options.h"
#include "wmc_auto.h"

#include "typedef.h"
#include "count.h"


#define WMC_TOOL_SKIP /* Skip the instrumentation of this file, if invoked by accident */

@@ -87,7 +90,7 @@ static int *wmops_caller_stack = NULL, wmops_caller_stack_index, max_wmops_calle
static int *heap_allocation_call_tree = NULL, heap_allocation_call_tree_size = 0, heap_allocation_call_tree_max_size = 0;


void reset_wmops_wmc( void )
void reset_wmops( void )
{
    int i, j;
    //unsigned int *ptr;
@@ -126,6 +129,8 @@ void reset_wmops_wmc( void )
    //    exit( -1 );
    //}

    BASOP_init

    /* initilize the list of WMOPS records */
    /* initilize the BASOP WMOPS counters */
    for ( i = 0; i < max_num_wmops_records; i++ )
@@ -311,11 +316,13 @@ void push_wmops_fct( const char *label, ... )
    /* set the ID of BASOP functions counters */
    //Set_BASOP_WMOPS_counter( index_record );

    BASOP_push_wmops( func_name );

    return;
}


void pop_wmops_wmc( void )
void pop_wmops( void )
{
    //long tot;

@@ -348,11 +355,13 @@ void pop_wmops_wmc( void )
        current_record = -1;
    }

    BASOP_pop_wmops();

    return;
}


void update_wmops_wmc( void )
void update_wmops( void )
{
    int i;
    double current_cnt;
@@ -472,181 +481,187 @@ void update_wmops_wmc( void )
    /* increment frame counter */
    update_cnt++;

    return;
}

void print_wmops_wmc( void )
{
    int i, label_len, max_label_len;

    char *sfmts = "%*s %8s %8s %7s %7s\n";
    char *dfmts = "%*s %8.2f %8.3f %7.3f %7.3f\n";
    char *sfmt = "%*s %8s %8s %7s %7s  %7s %7s %7s\n";
    char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f  %7.3f %7.3f %7.3f\n";

#ifdef WMOPS_WC_FRAME_ANALYSIS
    int j;
    char *sfmtt = "%20s %4s %15s\n";
    char *dfmtt = "%20s %4d  ";
#endif

    /* calculate maximum label length for compact prinout */
    max_label_len = 0;
    for ( i = 0; i < num_wmops_records; i++ )
    {
        label_len = strlen( wmops[i].label );
        if ( label_len > max_label_len )
        {
            max_label_len = label_len;
        }
    }
    max_label_len += 4;

    fprintf( stdout, "\n\n --- Complexity analysis [WMOPS] ---  \n\n" );

    fprintf( stdout, "%*s %33s  %23s\n", max_label_len, "", "|------  SELF  ------|", "|---  CUMULATIVE  ---|" );
    fprintf( stdout, sfmt, max_label_len, "        routine", " calls", "  min ", "  max ", "  avg ", "  min ", "  max ", "  avg " );
    fprintf( stdout, sfmt, max_label_len, "---------------", "------", "------", "------", "------", "------", "------", "------" );

    for ( i = 0; i < num_wmops_records; i++ )
    {
        fprintf( stdout, dfmt, max_label_len, wmops[i].label, update_cnt == 0 ? 0 : (float) wmops[i].call_number / update_cnt,
                 wmops[i].min_selfcnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_selfcnt,
                 FAC * wmops[i].max_selfcnt,
                 wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_selfcnt / wmops[i].update_cnt,
                 wmops[i].min_cnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_cnt,
                 FAC * wmops[i].max_cnt,
                 wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_cnt / wmops[i].update_cnt );
    }

    fprintf( stdout, sfmts, max_label_len, "---------------", "------", "------", "------", "------" );
    fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt_wmc / update_cnt );
    fprintf( stdout, "\n" );

#ifdef WMOPS_WC_FRAME_ANALYSIS
    fprintf( stdout, "\nComplexity analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
    fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, "        routine", " calls", " SELF", "  CUMULATIVE" );
    fprintf( stdout, "%*s %8s %10s   %10s\n", max_label_len, "---------------", "------", "------", "----------" );
    BASOP_frame_update();

    for ( i = 0; i < num_wmops_records; i++ )
    {
        if ( wmops[i].wc_call_number > 0 )
        {
            fprintf( stdout, "%*s %8d %10.3f %12.3f\n", max_label_len, wmops[i].label, wmops[i].wc_call_number, FAC * wmops[i].wc_selfcnt, FAC * wmops[i].wc_cnt );
        }
    return;
}

    fprintf( stdout, "\nCall tree for the worst-case frame %ld:\n\n", fnum_cnt_wc );
    fprintf( stdout, sfmtt, "       function", "num", "called by     " );
    fprintf( stdout, sfmtt, "---------------", "---", "--------------" );

    for ( i = 0; i < num_wmops_records; i++ )
    {
        if ( wmops[i].wc_call_number > 0 )
        {
            fprintf( stdout, dfmtt, wmops[i].label, i );
            for ( j = 0; wmops[i].call_tree[j] != -1 && j < MAX_CALL_TREE_DEPTH; j++ )
            {
                if ( j != 0 )
void print_wmops( void )
{
                    fprintf( stdout, ", " );
                }
                fprintf( stdout, "%d", wmops[i].call_tree[j] );
            }
            fprintf( stdout, "\n" );
        }
    }
    //int i, label_len, max_label_len;

    fprintf( stdout, "\n\n" );
    //char *sfmts = "%*s %8s %8s %7s %7s\n";
    //char *dfmts = "%*s %8.2f %8.3f %7.3f %7.3f\n";
    //char *sfmt = "%*s %8s %8s %7s %7s  %7s %7s %7s\n";
    //char *dfmt = "%*s %8.2f %8.3f %7.3f %7.3f  %7.3f %7.3f %7.3f\n";

    fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
    for ( i = 0; i < NUM_INST; i++ )
    {
        switch ( (enum instructions) i )
        {
            case _ADD:
                fprintf( stdout, "\tAdds:          %12.1f\n", inst_cnt_wc[i] );
                break;
            case _ABS:
                fprintf( stdout, "\tAbsolutes:     %12.1f\n", inst_cnt_wc[i] );
                break;
            case _MULT:
                fprintf( stdout, "\tMultiplies:    %12.1f\n", inst_cnt_wc[i] );
                break;
            case _MAC:
                fprintf( stdout, "\tMACs:          %12.1f\n", inst_cnt_wc[i] );
                break;
            case _MOVE:
                fprintf( stdout, "\tMoves:         %12.1f\n", inst_cnt_wc[i] );
                break;
            case _STORE:
                fprintf( stdout, "\tStores:        %12.1f\n", inst_cnt_wc[i] );
                break;
            case _LOGIC:
                fprintf( stdout, "\tLogicals:      %12.1f\n", inst_cnt_wc[i] );
                break;
            case _SHIFT:
                fprintf( stdout, "\tShifts:        %12.1f\n", inst_cnt_wc[i] );
                break;
            case _BRANCH:
                fprintf( stdout, "\tBranches:      %12.1f\n", inst_cnt_wc[i] );
                break;
            case _DIV:
                fprintf( stdout, "\tDivisions:     %12.1f\n", inst_cnt_wc[i] );
                break;
            case _SQRT:
                fprintf( stdout, "\tSquare Root:   %12.1f\n", inst_cnt_wc[i] );
                break;
            case _TRANS:
                fprintf( stdout, "\tTrans:         %12.1f\n", inst_cnt_wc[i] );
                break;
            case _FUNC:
                fprintf( stdout, "\tFunc Call:     %12.1f\n", inst_cnt_wc[i] );
                break;
            case _LOOP:
                fprintf( stdout, "\tLoop Init:     %12.1f\n", inst_cnt_wc[i] );
                break;
            case _INDIRECT:
                fprintf( stdout, "\tIndirect Addr: %12.1f\n", inst_cnt_wc[i] );
                break;
            case _PTR_INIT:
                fprintf( stdout, "\tPointer Init:  %12.1f\n", inst_cnt_wc[i] );
                break;
            case _TEST:
                fprintf( stdout, "\tExtra condit.: %12.1f\n", inst_cnt_wc[i] );
                break;
            case _POWER:
                fprintf( stdout, "\tExponential:   %12.1f\n", inst_cnt_wc[i] );
                break;
            case _LOG:
                fprintf( stdout, "\tLogarithm:     %12.1f\n", inst_cnt_wc[i] );
                break;
            case _MISC:
                fprintf( stdout, "\tAll other op.: %12.1f\n", inst_cnt_wc[i] );
                break;
            default:
                fprintf( stdout, "\tERROR: Invalid instruction type: %d\n\n", i );
        }
    }
#endif

    /* De-allocate the list of wmops record */
    if ( wmops != NULL )
    {
        free( wmops );
    }
    WMOPS_output_all_std( 0 );
    WMOPS_destroy();
    return;

    /* De-allocate the list of wmops caller functions */
    if ( wmops_caller_stack != NULL )
    {
        free( wmops_caller_stack );
    }
//#ifdef WMOPS_WC_FRAME_ANALYSIS
//    int j;
//    char *sfmtt = "%20s %4s %15s\n";
//    char *dfmtt = "%20s %4d  ";
//#endif

    /* De-allocate the BASOP WMOPS counter */
    //if ( multiCounter != NULL )
//    /* calculate maximum label length for compact prinout */
//    max_label_len = 0;
//    for ( i = 0; i < num_wmops_records; i++ )
//    {
//        label_len = strlen( wmops[i].label );
//        if ( label_len > max_label_len )
//        {
//            max_label_len = label_len;
//        }
//    }
//    max_label_len += 4;
//
//    fprintf( stdout, "\n\n --- Complexity analysis [WMOPS] ---  \n\n" );
//
//    fprintf( stdout, "%*s %33s  %23s\n", max_label_len, "", "|------  SELF  ------|", "|---  CUMULATIVE  ---|" );
//    fprintf( stdout, sfmt, max_label_len, "        routine", " calls", "  min ", "  max ", "  avg ", "  min ", "  max ", "  avg " );
//    fprintf( stdout, sfmt, max_label_len, "---------------", "------", "------", "------", "------", "------", "------", "------" );
//
//    for ( i = 0; i < num_wmops_records; i++ )
//    {
//        fprintf( stdout, dfmt, max_label_len, wmops[i].label, update_cnt == 0 ? 0 : (float) wmops[i].call_number / update_cnt,
//                 wmops[i].min_selfcnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_selfcnt,
//                 FAC * wmops[i].max_selfcnt,
//                 wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_selfcnt / wmops[i].update_cnt,
//                 wmops[i].min_cnt == DOUBLE_MAX ? 0 : FAC * wmops[i].min_cnt,
//                 FAC * wmops[i].max_cnt,
//                 wmops[i].update_cnt == 0 ? 0 : FAC * wmops[i].tot_cnt / wmops[i].update_cnt );
//    }
//
//    fprintf( stdout, sfmts, max_label_len, "---------------", "------", "------", "------", "------" );
//    fprintf( stdout, dfmts, max_label_len, "total", (float) update_cnt, update_cnt == 0 ? 0 : FAC * min_cnt, FAC * max_cnt, update_cnt == 0 ? 0 : FAC * ops_cnt_wmc / update_cnt );
//    fprintf( stdout, "\n" );
//
//#ifdef WMOPS_WC_FRAME_ANALYSIS
//    fprintf( stdout, "\nComplexity analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
//    fprintf( stdout, "%*s %8s %10s %12s\n", max_label_len, "        routine", " calls", " SELF", "  CUMULATIVE" );
//    fprintf( stdout, "%*s %8s %10s   %10s\n", max_label_len, "---------------", "------", "------", "----------" );
//
//    for ( i = 0; i < num_wmops_records; i++ )
//    {
//        if ( wmops[i].wc_call_number > 0 )
//        {
//            fprintf( stdout, "%*s %8d %10.3f %12.3f\n", max_label_len, wmops[i].label, wmops[i].wc_call_number, FAC * wmops[i].wc_selfcnt, FAC * wmops[i].wc_cnt );
//        }
//    }
//
//    fprintf( stdout, "\nCall tree for the worst-case frame %ld:\n\n", fnum_cnt_wc );
//    fprintf( stdout, sfmtt, "       function", "num", "called by     " );
//    fprintf( stdout, sfmtt, "---------------", "---", "--------------" );
//
//    for ( i = 0; i < num_wmops_records; i++ )
//    {
//        if ( wmops[i].wc_call_number > 0 )
//        {
//            fprintf( stdout, dfmtt, wmops[i].label, i );
//            for ( j = 0; wmops[i].call_tree[j] != -1 && j < MAX_CALL_TREE_DEPTH; j++ )
//            {
//                if ( j != 0 )
//                {
//                    fprintf( stdout, ", " );
//                }
//                fprintf( stdout, "%d", wmops[i].call_tree[j] );
//            }
//            fprintf( stdout, "\n" );
//        }
//    }
//
//    fprintf( stdout, "\n\n" );
//
//    fprintf( stdout, "\nInstruction type analysis for the worst-case frame %ld:\n\n", fnum_cnt_wc );
//    for ( i = 0; i < NUM_INST; i++ )
//    {
//        switch ( (enum instructions) i )
//        {
//            case _ADD:
//                fprintf( stdout, "\tAdds:          %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _ABS:
//                fprintf( stdout, "\tAbsolutes:     %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _MULT:
//                fprintf( stdout, "\tMultiplies:    %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _MAC:
//                fprintf( stdout, "\tMACs:          %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _MOVE:
//                fprintf( stdout, "\tMoves:         %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _STORE:
//                fprintf( stdout, "\tStores:        %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _LOGIC:
//                fprintf( stdout, "\tLogicals:      %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _SHIFT:
//                fprintf( stdout, "\tShifts:        %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _BRANCH:
//                fprintf( stdout, "\tBranches:      %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _DIV:
//                fprintf( stdout, "\tDivisions:     %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _SQRT:
//                fprintf( stdout, "\tSquare Root:   %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _TRANS:
//                fprintf( stdout, "\tTrans:         %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _FUNC:
//                fprintf( stdout, "\tFunc Call:     %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _LOOP:
//                fprintf( stdout, "\tLoop Init:     %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _INDIRECT:
//                fprintf( stdout, "\tIndirect Addr: %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _PTR_INIT:
//                fprintf( stdout, "\tPointer Init:  %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _TEST:
//                fprintf( stdout, "\tExtra condit.: %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _POWER:
//                fprintf( stdout, "\tExponential:   %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _LOG:
//                fprintf( stdout, "\tLogarithm:     %12.1f\n", inst_cnt_wc[i] );
//                break;
//            case _MISC:
//                fprintf( stdout, "\tAll other op.: %12.1f\n", inst_cnt_wc[i] );
//                break;
//            default:
//                fprintf( stdout, "\tERROR: Invalid instruction type: %d\n\n", i );
//        }
//    }
//#endif
//
//    /* De-allocate the list of wmops record */
//    if ( wmops != NULL )
//    {
//        free( wmops );
//    }
//
//    /* De-allocate the list of wmops caller functions */
//    if ( wmops_caller_stack != NULL )
//    {
    //    free( multiCounter );
//        free( wmops_caller_stack );
//    }
//
//    /* De-allocate the BASOP WMOPS counter */
//    //if ( multiCounter != NULL )
//    //{
//    //    free( multiCounter );
//    //}

    return;
}
Loading