* hex-mm: fix artificial limit in the solver that restricted number of act-prep threads * hex-mm: fix warning * hex-prof: do not apply --top to the timeline report * hmx-mm: add suport for tiled act-processing to better distribute hvx work * hex-l2: add tracing for l2flush events * workqueue: redo the legacy workpool api to match hmx-queue and dma-queue * hmx-mm: fix f32 activation buffer alignmnet for nhvx=5,6,7 * hex-work: minor cleanup for work-queue apis * hex-work: further cleanup of the work-queue api * hex-l2: optimize l2flushes at the opbatch level * hex-work: remove unused mask * hex-work: no need to drop hvx ctx in the work-queue * hex-work: add explicit wakeup/suspend and make threads spin * hex-bufs: mark any non-weight tensor as compute * hex-dma: dma-queue support for alias queues and cached dma * hex-l2: track tensor aliases and delay or skip flushes as much as possible * hex-l2: simplify tensor alias handling * hex-l2: handle overlapping views as a circular list of aliases * hex-tens: add flags helper * hex-l2: add helper for marking tensors clearn/dirty * hex-l2: mark binary and rope outputs as l2-clean and keep the rest as is for now * hex-l2: proper support for handling all tensor overlap scenarios * hex-trace: instrument matmul init code and cleanup trace checks * hex-thread: introduce dedicated main thread with explicit stack and priority * hex-l2: track dirty state as bitmap and introduce threaded flush * hex-trace: remove redundant checks for ctx != null * hex-l2: allocate entire context as one buffer and l2fetch it after big flushes * hex-l2: disable tensor clearing in binary and rope for now seems to cause issues with fusion * hmx-mm: update act proc to use fastdivs and fix DMA overflow * hmx-mm: make MUL_MAT_ID kernels robust to multi-chunk cases (start_row>0) * hex-queue: remove obsolete queue interfaces and flush hmx-queue at the end of the op-batch * hex-queue: dont use early wakeup for small op-batches * hex-tensors: properly cap max_tensors in op-batches and dirty_map * hex-l2: make sure threaded l2flush does proper rounding * hex-l2: factor out htp_tensor_flush for reuse (if needed) * hex-l2: optimize tensor flushes by coalescing flush-all * hex-l2: optimize multi-threaded flush * hex-drv: futureproof version checks * hexagon: fix errors and warnings on windows * hex-main: update main thread to only use dspqueue_read, dspqueue_peek is not available on some platforms * hex-main: add fallback mode for dspqueue with callbacks * hex-main: introduce fallback mode for using dspqueue callbacks for full op processing * hex-main: remove early wakeup, not helping and seems to cause some errors with certain batch sizes * hex-l2: make sure to use invalidate version of flushall * hex-l2: dont try to trace early l2flush at the start of op-batch * hex-main: remove offset_ctx that must be zero anyway * hex-hmx: fix hmx_queue_depth to use idx_write - idx_read * hex-hmx: use atomic_load for idx_read/write * hex-main: add static assert to make sure n_threads are aligned
65 lines
2.0 KiB
C
65 lines
2.0 KiB
C
#ifndef HEX_PROFILE_H
|
|
#define HEX_PROFILE_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <qurt.h>
|
|
|
|
#include "hex-utils.h"
|
|
#include "htp-ops.h"
|
|
|
|
#define HTP_TRACE_EVT_START 0
|
|
#define HTP_TRACE_EVT_STOP 1
|
|
|
|
#ifndef HEX_NUM_PMU_COUNTERS
|
|
#define HEX_NUM_PMU_COUNTERS 8
|
|
#endif
|
|
|
|
static inline void hex_get_pmu(uint32_t counters[]) {
|
|
#if __HVX_ARCH__ >= 79
|
|
asm volatile("%0 = upmucnt0" : "=r"(counters[0]));
|
|
asm volatile("%0 = upmucnt1" : "=r"(counters[1]));
|
|
asm volatile("%0 = upmucnt2" : "=r"(counters[2]));
|
|
asm volatile("%0 = upmucnt3" : "=r"(counters[3]));
|
|
asm volatile("%0 = upmucnt4" : "=r"(counters[4]));
|
|
asm volatile("%0 = upmucnt5" : "=r"(counters[5]));
|
|
asm volatile("%0 = upmucnt6" : "=r"(counters[6]));
|
|
asm volatile("%0 = upmucnt7" : "=r"(counters[7]));
|
|
#else
|
|
counters[0] = qurt_pmu_get(QURT_PMUCNT0);
|
|
counters[1] = qurt_pmu_get(QURT_PMUCNT1);
|
|
counters[2] = qurt_pmu_get(QURT_PMUCNT2);
|
|
counters[3] = qurt_pmu_get(QURT_PMUCNT3);
|
|
counters[4] = qurt_pmu_get(QURT_PMUCNT4);
|
|
counters[5] = qurt_pmu_get(QURT_PMUCNT5);
|
|
counters[6] = qurt_pmu_get(QURT_PMUCNT6);
|
|
counters[7] = qurt_pmu_get(QURT_PMUCNT7);
|
|
#endif
|
|
}
|
|
|
|
struct htp_thread_trace {
|
|
uint32_t count;
|
|
uint32_t max_events;
|
|
struct htp_trace_desc * events;
|
|
};
|
|
|
|
static inline void htp_trace_event(struct htp_thread_trace * tr, uint16_t id, uint16_t info, uint32_t type) {
|
|
if (tr->count < tr->max_events) {
|
|
uint32_t i = tr->count;
|
|
tr->events[i].id = id;
|
|
tr->events[i].info = info | (type == HTP_TRACE_EVT_STOP ? 0x8000 : 0);
|
|
tr->events[i].cycles = (uint32_t) hex_get_cycles();
|
|
tr->count++;
|
|
}
|
|
}
|
|
|
|
static inline void htp_trace_event_start(struct htp_thread_trace * tr, uint16_t id, uint16_t info) {
|
|
htp_trace_event(tr, id, info, HTP_TRACE_EVT_START);
|
|
}
|
|
|
|
static inline void htp_trace_event_stop(struct htp_thread_trace * tr, uint16_t id, uint16_t info) {
|
|
htp_trace_event(tr, id, info, HTP_TRACE_EVT_STOP);
|
|
}
|
|
|
|
#endif /* HEX_PROFILE_H */
|