Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-hexagon/htp/hex-profile.h # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-hexagon / htp / hex-profile.h` 66 lines ยท 2040 bytes Raw Blame History 1 #ifndef HEX_PROFILE_H 2 #define HEX_PROFILE_H 3 4 #include 5 #include 6 #include 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 18 static inline void hex_get_pmu(uint32_t counters[]) { 19 #if __HVX_ARCH__ >= 79 20 asm volatile("%0 = upmucnt0" : "=r"(counters[0])); 21 asm volatile("%0 = upmucnt1" : "=r"(counters[1])); 22 asm volatile("%0 = upmucnt2" : "=r"(counters[2])); 23 asm volatile("%0 = upmucnt3" : "=r"(counters[3])); 24 asm volatile("%0 = upmucnt4" : "=r"(counters[4])); 25 asm volatile("%0 = upmucnt5" : "=r"(counters[5])); 26 asm volatile("%0 = upmucnt6" : "=r"(counters[6])); 27 asm volatile("%0 = upmucnt7" : "=r"(counters[7])); 28 #else 29 counters[0] = qurt_pmu_get(QURT_PMUCNT0); 30 counters[1] = qurt_pmu_get(QURT_PMUCNT1); 31 counters[2] = qurt_pmu_get(QURT_PMUCNT2); 32 counters[3] = qurt_pmu_get(QURT_PMUCNT3); 33 counters[4] = qurt_pmu_get(QURT_PMUCNT4); 34 counters[5] = qurt_pmu_get(QURT_PMUCNT5); 35 counters[6] = qurt_pmu_get(QURT_PMUCNT6); 36 counters[7] = qurt_pmu_get(QURT_PMUCNT7); 37 #endif 38 } 39 40 struct htp_thread_trace { 41 uint32_t count; 42 uint32_t max_events; 43 struct htp_trace_desc * events; 44 }; 45 46 static inline void htp_trace_event(struct htp_thread_trace * tr, uint16_t id, uint16_t info, uint32_t type) { 47 if (!tr->max_events) { 48 return; 49 } 50 uint32_t i = tr->count++; 51 if (i < tr->max_events) { 52 tr->events[i].id = id; 53 tr->events[i].info = info | (type == HTP_TRACE_EVT_STOP ? 0x8000 : 0); 54 tr->events[i].cycles = (uint32_t) hex_get_cycles(); 55 } 56 } 57 58 static inline void htp_trace_event_start(struct htp_thread_trace * tr, uint16_t id, uint16_t info) { 59 htp_trace_event(tr, id, info, HTP_TRACE_EVT_START); 60 } 61 62 static inline void htp_trace_event_stop(struct htp_thread_trace * tr, uint16_t id, uint16_t info) { 63 htp_trace_event(tr, id, info, HTP_TRACE_EVT_STOP); 64 } 65 66 #endif /* HEX_PROFILE_H */