* 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
122 lines
3.0 KiB
C
122 lines
3.0 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
# pragma clang diagnostic ignored "-Wignored-attributes"
|
|
#endif
|
|
|
|
#include <AEEStdErr.h>
|
|
#include <rpcmem.h>
|
|
#include <remote.h>
|
|
#include <dspqueue.h>
|
|
|
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
|
# ifdef GGML_BACKEND_BUILD
|
|
# define HTPDRV_API __declspec(dllexport) extern
|
|
# else
|
|
# define HTPDRV_API __declspec(dllimport) extern
|
|
# endif
|
|
#else
|
|
# define HTPDRV_API __attribute__ ((visibility ("default"))) extern
|
|
#endif
|
|
|
|
/* Offset to differentiate HLOS and Hexagon error codes.
|
|
Stores the value of AEE_EOFFSET for Hexagon. */
|
|
#ifndef DSP_OFFSET
|
|
# define DSP_OFFSET 0x80000400
|
|
#endif
|
|
|
|
/* Errno for connection reset by peer. */
|
|
#ifndef ECONNRESET
|
|
# ifdef __hexagon__
|
|
# define ECONNRESET 104
|
|
# endif
|
|
#endif
|
|
|
|
/* Abstraction of different OS specific sleep APIs.
|
|
SLEEP accepts input in seconds. */
|
|
#ifndef SLEEP
|
|
# ifdef __hexagon__
|
|
# define SLEEP(x) \
|
|
{ /* Do nothing for simulator. */ \
|
|
}
|
|
# else
|
|
# ifdef _WIN32
|
|
# define SLEEP(x) Sleep(1000 * x) /* Sleep accepts input in milliseconds. */
|
|
# else
|
|
# define SLEEP(x) sleep(x) /* sleep accepts input in seconds. */
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
/* Include windows specific header files. */
|
|
#ifdef _WIN32
|
|
# include <windows.h>
|
|
# include <sysinfoapi.h>
|
|
# define _CRT_SECURE_NO_WARNINGS 1
|
|
# define _WINSOCK_DEPRECATED_NO_WARNINGS 1
|
|
#endif
|
|
|
|
/* Includes and defines for all HLOS except windows */
|
|
#if !defined(__hexagon__) && !defined(_WIN32)
|
|
# include "unistd.h"
|
|
|
|
# include <sys/time.h>
|
|
#endif
|
|
|
|
/* Includes and defines for Hexagon and all HLOS except Windows. */
|
|
#if !defined(_WIN32)
|
|
/* Weak reference to remote symbol for compilation. */
|
|
# pragma weak remote_session_control
|
|
# pragma weak remote_handle_control
|
|
# pragma weak remote_handle64_control
|
|
# pragma weak fastrpc_mmap
|
|
# pragma weak fastrpc_munmap
|
|
# pragma weak rpcmem_alloc2
|
|
#endif
|
|
|
|
#if !defined(_WIN32)
|
|
# pragma weak remote_system_request
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
# define DSPQUEUE_TIMEOUT DSPQUEUE_TIMEOUT_NONE
|
|
#else
|
|
# define DSPQUEUE_TIMEOUT 1000000
|
|
#endif
|
|
|
|
/**
|
|
* htpdrv_init API: driver interface entry point
|
|
*
|
|
* @return Return AEE error codes as defined in Hexagon SDK.
|
|
*/
|
|
HTPDRV_API int htpdrv_init(void);
|
|
|
|
/**
|
|
* htpdrv_get_domain API: get domain struct from domain value.
|
|
*
|
|
* @param[in] domain value of a domain
|
|
* @return Returns domain struct of the domain if it is supported or else
|
|
* returns NULL.
|
|
*
|
|
*/
|
|
HTPDRV_API domain * htpdrv_get_domain(int domain_id);
|
|
|
|
/**
|
|
* htpdrv_get_arch API: query the Hexagon processor architecture version information
|
|
*
|
|
* @param[in] domain_id value of a domain
|
|
* @param[out] Arch version (73, 75, ...)
|
|
* @return 0 if query is successful.
|
|
* non-zero if error, return value points to the error.
|
|
*
|
|
*/
|
|
HTPDRV_API int htpdrv_get_arch(int domain, int * arch);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|