/* Diagnostic-only exclusive buckets; included only by the copied worker. */ #ifndef LOCAL_PROBE_PROFILE_H #define LOCAL_PROBE_PROFILE_H #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #endif #include #include #include #include "local_probe.h" enum { PF_OTHER, PF_INCREMENT, PF_PERTURB, PF_ZERO, PF_ASSEMBLY, PF_BASELINE, PF_INIT, PF_GAS_PREP, PF_RETAINED, PF_FALLBACK, PF_CONTEXT, PF_SNAPSHOT, PF_RESTORE, PF_NODE, PF_PORT, PF_MECHANICAL, PF_GAS_EQUATIONS, PF_OUTPUTS, PF_PIPE, PF_FINITE, PF_DISPATCH, PF_FULL_FALLBACK, PF_CATEGORIES }; /* row 0 = outer callback, row 1 = baseline, row 2+g = probe group g. */ typedef struct { uint64_t ticks,intervals; } PfBucket; extern PfBucket pf_buckets[LP_NC+2][PF_CATEGORIES],*pf_current; extern uint64_t pf_previous_tick; extern unsigned pf_row; extern int pf_coarse; extern const unsigned char pf_affected[LP_NC][LP_NO]; extern uint64_t pf_operations[LP_NC][2]; static inline uint64_t pf_clock(void){ unsigned lo,hi; __asm__ __volatile__("lfence\n\trdtsc\n\tlfence" : "=a"(lo),"=d"(hi) :: "memory"); return ((uint64_t)hi<<32)|lo; } static inline void pf_mark(unsigned category) { uint64_t t=pf_clock(); pf_current->ticks+=t-pf_previous_tick; pf_current->intervals++; pf_previous_tick=t;pf_current=&pf_buckets[pf_row][category]; } #define PF_MARK(category) pf_mark(category) #define PF_SCOPE(row,category) do {pf_row=(row);pf_mark(category);} while(0) #define PF_PROBE(category) do {if(lp_color>=0)pf_mark(category);} while(0) void pf_initialize(void);void pf_finish(void); int pf_select(void);void pf_flush(uint64_t,uint64_t); void pf_eval_count(void); static inline void pf_operation(int position){ int retained=pf_affected[lp_color][position]; pf_operations[lp_color][retained?0:1]++; PF_MARK(retained?PF_RETAINED:PF_FALLBACK); } void pf_open(void);void pf_close(void); void pf_snapshot(int,NativePropertyCache*,NativePipeCache*); void pf_save(double*,double*,double*,double*,double*); int pf_reuse(int,NativePropertyCache*,NativePipeCache*,double*,double*,double*,double*,double*); int pf_lp_eval(double,const double*,double*,double*,ModelJacobianWorkspace*); void lp_jac_time_end(uint64_t,uint64_t); void pf_validate_matrix(double,const double*,const double*); #endif