char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
b2dd28a3b
char/aliceai-t5-moe
1#ifndef HEX_PROFILE_H 2#define HEX_PROFILE_H 3 4#include <stdbool.h> 5#include <stdint.h> 6#include <qurt.h> 7 8#include "hex-utils.h" 9#include "htp-ops.h" 10 11#define HTP_TRACE_EVT_START 0 12#define HTP_TRACE_EVT_STOP 1 13 14#ifndef HEX_NUM_PMU_COUNTERS 15#define HEX_NUM_PMU_COUNTERS 8 16#endif 17 18static inline void hex_get_pmu (uint32_t counters []) { 19#if __HVX_ARCH__ >=79 20 asmvolatile ("%0 = upmucnt0" :"=r" (counters [0 ])); 21 asmvolatile ("%0 = upmucnt1" :"=r" (counters [1 ])); 22 asmvolatile ("%0 = upmucnt2" :"=r" (counters [2 ])); 23 asmvolatile ("%0 = upmucnt3" :"=r" (counters [3 ])); 24 asmvolatile ("%0 = upmucnt4" :"=r" (counters [4 ])); 25 asmvolatile ("%0 = upmucnt5" :"=r" (counters [5 ])); 26 asmvolatile ("%0 = upmucnt6" :"=r" (counters [6 ])); 27 asmvolatile ("%0 = upmucnt7" :"=r" (counters [7 ])); 28#else 29counters [0 ]= qurt_pmu_get (QURT_PMUCNT0 ); 30counters [1 ]= qurt_pmu_get (QURT_PMUCNT1 ); 31counters [2 ]= qurt_pmu_get (QURT_PMUCNT2 ); 32counters [3 ]= qurt_pmu_get (QURT_PMUCNT3 ); 33counters [4 ]= qurt_pmu_get (QURT_PMUCNT4 ); 34counters [5 ]= qurt_pmu_get (QURT_PMUCNT5 ); 35counters [6 ]= qurt_pmu_get (QURT_PMUCNT6 ); 36counters [7 ]= qurt_pmu_get (QURT_PMUCNT7 ); 37#endif 38} 39 40struct htp_thread_trace { 41uint32_t count ; 42uint32_t max_events ; 43struct htp_trace_desc * events ; 44}; 45 46static inline void htp_trace_event (struct htp_thread_trace * tr ,uint16_t id ,uint16_t info ,uint32_t type ) { 47if (tr -> count < tr -> max_events ) { 48uint32_t i = tr -> count ; 49tr -> events [i ].id = id ; 50tr -> events [i ].info = info | (type == HTP_TRACE_EVT_STOP ?0x8000 :0 ); 51tr -> events [i ].cycles = (uint32_t )hex_get_cycles (); 52tr -> count ++ ; 53 } 54} 55 56static inline void htp_trace_event_start (struct htp_thread_trace * tr ,uint16_t id ,uint16_t info ) { 57htp_trace_event (tr ,id ,info ,HTP_TRACE_EVT_START ); 58} 59 60static inline void htp_trace_event_stop (struct htp_thread_trace * tr ,uint16_t id ,uint16_t info ) { 61htp_trace_event (tr ,id ,info ,HTP_TRACE_EVT_STOP ); 62} 63 64#endif /* HEX_PROFILE_H */