Commit 3971b69f authored by malenov's avatar malenov
Browse files

synchronization of wmc_auto.h and wmc_auto.c with the float codebase

parent 56bb0e5e
Loading
Loading
Loading
Loading
Loading
+336 −145

File changed.

Preview size limit exceeded, changes collapsed.

+39 −49
Original line number Diff line number Diff line
@@ -23,23 +23,15 @@
#include <stdio.h> /* stdio is needed for fprintf() */
#endif

#include "options.h"


/* To Prevent "warning: '$' in identifier or number" message under GCC */
#ifdef __GNUC__
#pragma GCC system_header
#endif

/* Real-time relationships */
#define FRAMES_PER_SECOND 50.0
#define MILLION_CYCLES    1e6
#define WMOPS_BOOST_FAC   ( 1.0f ) /* scaling factor for equalizing the difference between automatic and manual instrumentation */
#define FAC               ( FRAMES_PER_SECOND / MILLION_CYCLES * WMOPS_BOOST_FAC )
#define NUM_INST          20 /* Total number of instruction types (in enum below) */

#define PROM_INST_SIZE    32 /* number of bits of each program instruction when stored in the PROM memory (applied only when the user selects reporting in bytes) */

#ifdef WMOPS_FLT
#ifdef WMOPS
enum instructions
{
    _ADD,
@@ -61,7 +53,8 @@ enum instructions
    _TEST,
    _POWER,
    _LOG,
    _MISC
    _MISC,
    NUM_INST
};

#define _ADD_C      1
@@ -560,29 +553,26 @@ enum instructions
        }                                             \
    }

#if 0 /* -> defined in count.h instead */
void reset_wmops_wmc( void );
void push_wmops( const char *label );
void pop_wmops( void );
void update_wmops( void );
void print_wmops( void );
#endif
extern double ops_cnt_wmc;
extern double prom_cnt_wmc;
extern double inst_cnt[NUM_INST];
extern int cntr_push_pop;

void push_wmops_wmc( const char *label );
void pop_wmops_wmc( void );
void reset_wmops_wmc( void );
void print_wmops_wmc( void );
void update_wmops_wmc();
void update_mem( void );

#else /* WMOPS_FLT counting disabled */
#if 0 /* -> defined in count.h instead */
#include <assert.h>
#define reset_wmops()
#define push_wmops( x ) ( cntr_push_pop++ )
#define pop_wmops()     ( cntr_push_pop-- )
#define update_wmops()  ( assert( cntr_push_pop == 0 ) )
#define print_wmops()
#endif
#else

#define push_wmops_wmc( x ) ( cntr_push_pop++ )
#define pop_wmops_wmc()     ( cntr_push_pop-- )
#define reset_wmops_wmc()
#define print_wmops_wmc()
#define update_wmops_wmc() ( assert( cntr_push_pop == 0 ) )
#define update_mem()
extern int cntr_push_pop;

#define ADD( x )
#define ABS( x )
@@ -626,7 +616,7 @@ extern int cntr_push_pop;
#define msu( a, b, c ) ( ( a ) - ( b ) * ( c ) )
#endif

#ifndef WMOPS_FLT
#ifndef WMOPS
/* DESACTIVATE the Counting Mechanism */
#define OP_COUNT_( op, n )

@@ -673,24 +663,24 @@ static int wmc_flag_ = 0;
#endif

/* Define all Macros without '{' & '}' (None of these should be called externally!) */
#define ABS_( x )      OP_COUNT_( _ABS, ( x ) / WMOPS_BOOST_FAC )
#define ADD_( x )      OP_COUNT_( _ADD, ( x ) / WMOPS_BOOST_FAC )
#define MULT_( x )     OP_COUNT_( _MULT, ( x ) / WMOPS_BOOST_FAC )
#define MAC_( x )      OP_COUNT_( _MAC, ( x ) / WMOPS_BOOST_FAC )
#define MOVE_( x )     OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC )
#define STORE_( x )    OP_COUNT_( _STORE, ( x ) / WMOPS_BOOST_FAC )
#define LOGIC_( x )    OP_COUNT_( _LOGIC, ( x ) / WMOPS_BOOST_FAC )
#define SHIFT_( x )    OP_COUNT_( _SHIFT, ( x ) / WMOPS_BOOST_FAC )
#define BRANCH_( x )   OP_COUNT_( _BRANCH, ( x ) / WMOPS_BOOST_FAC )
#define DIV_( x )      OP_COUNT_( _DIV, ( x ) / WMOPS_BOOST_FAC )
#define SQRT_( x )     OP_COUNT_( _SQRT, ( x ) / WMOPS_BOOST_FAC )
#define TRANS_( x )    OP_COUNT_( _TRANS, ( x ) / WMOPS_BOOST_FAC )
#define ABS_( x )      OP_COUNT_( _ABS, ( x )  )
#define ADD_( x )      OP_COUNT_( _ADD, ( x )  )
#define MULT_( x )     OP_COUNT_( _MULT, ( x )  )
#define MAC_( x )      OP_COUNT_( _MAC, ( x )  )
#define MOVE_( x )     OP_COUNT_( _MOVE, ( x )  )
#define STORE_( x )    OP_COUNT_( _STORE, ( x )  )
#define LOGIC_( x )    OP_COUNT_( _LOGIC, ( x )  )
#define SHIFT_( x )    OP_COUNT_( _SHIFT, ( x )  )
#define BRANCH_( x )   OP_COUNT_( _BRANCH, ( x )  )
#define DIV_( x )      OP_COUNT_( _DIV, ( x )  )
#define SQRT_( x )     OP_COUNT_( _SQRT, ( x )  )
#define TRANS_( x )    OP_COUNT_( _TRANS, ( x )  )
#define POWER_( x )    TRANS_( x )
#define LOG_( x )      TRANS_( x )
#define LOOP_( x )     OP_COUNT_( _LOOP, ( x ) / WMOPS_BOOST_FAC )
#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x ) / WMOPS_BOOST_FAC )
#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x ) / WMOPS_BOOST_FAC )
#define FUNC_( x )     ( OP_COUNT_( _MOVE, ( x ) / WMOPS_BOOST_FAC ), OP_COUNT_( _FUNC, 1 ) )
#define LOOP_( x )     OP_COUNT_( _LOOP, ( x )  )
#define INDIRECT_( x ) OP_COUNT_( _INDIRECT, ( x )  )
#define PTR_INIT_( x ) OP_COUNT_( _PTR_INIT, ( x )  )
#define FUNC_( x )     ( OP_COUNT_( _MOVE, ( x )  ), OP_COUNT_( _FUNC, 1 ) )
#define MISC_( x )     ABS_( x )

/* Math Operations */
@@ -814,7 +804,7 @@ static int wmc_flag_ = 0;
    switch
#define cost_( n ) OP_COUNT_WRAPPER2_( wmc_flag_ ? ( ADD_( n ), BRANCH_( n ), wmc_flag_ = 0 ) : 0 );

#ifdef WMOPS_FLT
#ifdef WMOPS

#define ACC 2
#define MUL 1
@@ -1015,7 +1005,7 @@ typedef enum
#endif


#ifdef WMOPS_FLT
#ifdef WMOPS

void *mem_alloc( const char *func_name, int func_lineno, size_t size, char *alloc_str );
void mem_free( const char *func_name, int func_lineno, void *ptr );
@@ -1031,8 +1021,8 @@ int push_stack( const char *filename, const char *fctname );
int pop_stack( const char *filename, const char *fctname );

#ifdef WMOPS_DETAIL
#define STACK_DEPTH_FCT_CALL   ( push_wmops( __FUNCTION__ ), push_stack( __FILE__, __FUNCTION__ ) ) /* add push_wmops() in all function calls */
#define STACK_DEPTH_FCT_RETURN ( pop_wmops(), pop_stack( __FILE__, __FUNCTION__ ) )                 /* add pop_wmops() in all function returns */
#define STACK_DEPTH_FCT_CALL   ( push_wmops_wmc( __FUNCTION__ ), push_stack( __FILE__, __FUNCTION__ ) ) /* add push_wmops() in all function calls */
#define STACK_DEPTH_FCT_RETURN ( pop_wmops_wmc(), pop_stack( __FILE__, __FUNCTION__ ) )                 /* add pop_wmops() in all function returns */
#else
#define STACK_DEPTH_FCT_CALL   push_stack( __FILE__, __FUNCTION__ )
#define STACK_DEPTH_FCT_RETURN pop_stack( __FILE__, __FUNCTION__ )