@@ -342,6 +342,7 @@ struct hexagon_appcfg_t {
342342 int profiler_duration; // threshold of duration in profiler, per seconds
343343 int profiler_counts; // threshold of counts in profiler
344344 int thread_counts; // thread_counts on cDSP side
345+ int mulmat_algotype; // algorithm type of mulmat on cDSP side
345346 const char * cfgfilename;
346347 const char * runtime_libpath;
347348 char ggml_hexagon_version[GGMLHEXAGON_TMPBUF_LEN];
@@ -367,6 +368,7 @@ static struct hexagon_appcfg_t g_hexagon_appcfg = {
367368 .profiler_duration = 5 , // seconds
368369 .profiler_counts = 100 ,
369370 .thread_counts = 4 ,
371+ .mulmat_algotype = 0 ,
370372 .cfgfilename = " ggml-hexagon.cfg" ,
371373#if defined(__ANDROID__)
372374 #if defined(STANDARD_ANDROID_APP)
@@ -379,7 +381,7 @@ static struct hexagon_appcfg_t g_hexagon_appcfg = {
379381#elif defined(_WIN32)
380382 .qnn_runtimelib_path = " C:\\ " ,
381383#endif
382- .ggml_hexagon_version = {" 1.11 " },
384+ .ggml_hexagon_version = {" 1.12 " },
383385 .ggml_dsp_version = {" 0.63" },
384386};
385387
@@ -643,6 +645,7 @@ static constexpr const qnn_op_caps ggmlqnn_k_op_caps[] = {
643645 {false , GGML_OP_UPSCALE, 0 , nullptr },
644646 {false , GGML_OP_PAD, 0 , nullptr },
645647 {false , GGML_OP_PAD_REFLECT_1D, 0 , nullptr },
648+ {false , GGML_OP_ROLL, 0 , nullptr },
646649 {false , GGML_OP_ARANGE, 0 , nullptr },
647650 {false , GGML_OP_TIMESTEP_EMBEDDING, 0 , nullptr },
648651 {false , GGML_OP_ARGSORT, 0 , nullptr },
@@ -751,6 +754,7 @@ static constexpr const hexagon_op_caps ggmlhexagon_k_op_caps[] = {
751754 {false , GGML_OP_UPSCALE, 0 , nullptr , nullptr },
752755 {false , GGML_OP_PAD, 0 , nullptr , nullptr },
753756 {false , GGML_OP_PAD_REFLECT_1D, 0 , nullptr , nullptr },
757+ {false , GGML_OP_ROLL, 0 , nullptr , nullptr },
754758 {false , GGML_OP_ARANGE, 0 , nullptr , nullptr },
755759 {false , GGML_OP_TIMESTEP_EMBEDDING, 0 , nullptr , nullptr },
756760 {false , GGML_OP_ARGSORT, 0 , nullptr , nullptr },
@@ -1322,11 +1326,9 @@ class hexagon_perf {
13221326 // had to expose two public function in hexagon_profiler class
13231327 if (g_hexagon_profiler.profiler_get_frame_index () <= g_hexagon_profiler.profiler_get_threshold_count ()) {
13241328 const char * devname = ggml_backend_hexagon_get_devname (g_hexagon_appcfg.hexagon_backend );
1329+ // the logic here is make sense because already checked in ggml_backend_hexagon_device_init_backend
13251330 if (g_hexagon_appcfg.hexagon_backend != HEXAGON_BACKEND_GGML) {
1326- // add this check for a special scenario: an invalid value passed from user's program
1327- if (0 != memcmp (devname, " unknown" , strlen (" unknown" ))) {
1328- devname += 16 ;
1329- }
1331+ devname += 16 ;
13301332 }
13311333 GGMLHEXAGON_LOG_VERBOSE (" inference duration of %s through %s: %lld microseconds" ,
13321334 _perf_name.c_str (), devname, _duration);
@@ -2006,6 +2008,7 @@ static void ggmlhexagon_load_cfg() {
20062008 hexagoncfg_instance.get_intvalue (" cdsp" , " enable_rpc_ion_mempool" , g_hexagon_appcfg.enable_rpc_ion_mempool , 0 );
20072009 hexagoncfg_instance.get_intvalue (" cdsp" , " enable_all_q_mulmat" , g_hexagon_appcfg.enable_all_q_mulmat , 0 );
20082010 hexagoncfg_instance.get_intvalue (" cdsp" , " thread_counts" , g_hexagon_appcfg.thread_counts , 4 );
2011+ hexagoncfg_instance.get_intvalue (" cdsp" , " mulmat_algotype" , g_hexagon_appcfg.mulmat_algotype , 0 );
20092012
20102013 memcpy (g_hexagon_appcfg.ggml_dsp_version , ggmldsp_version.c_str (), strlen (ggmldsp_version.c_str ()));
20112014
@@ -2053,7 +2056,7 @@ static void ggmlhexagon_load_cfg() {
20532056 initialized = true ;
20542057}
20552058
2056- void ggml_backend_set_hexagon_cfg (int new_hexagon_backend, int new_hwaccel_approach) {
2059+ void ggml_backend_hexagon_set_cfg (int new_hexagon_backend, int new_hwaccel_approach) {
20572060 std::string cfg_filename = std::string (g_hexagon_appcfg.runtime_libpath ) + std::string (g_hexagon_appcfg.cfgfilename );
20582061 GGMLHEXAGON_LOG_VERBOSE (" load hexagon appcfg from %s" , cfg_filename.c_str ());
20592062 hexagon_appcfg hexagoncfg_instance;
@@ -2063,14 +2066,25 @@ void ggml_backend_set_hexagon_cfg(int new_hexagon_backend, int new_hwaccel_appro
20632066 hexagoncfg_instance.dump ([](const std::string & section, const std::string & key, const std::string value) {
20642067 std::ostringstream tmposs;
20652068 tmposs << " section[" << std::setw (10 ) << std::left << section << " ],[" << std::setw (25 ) << std::left << key << " ] = [" << value << " ]" ;
2069+ #if 0
20662070 if (ggmlhexagon_is_llamabench_running()) {
20672071 GGMLHEXAGON_LOG_VERBOSE("%s", tmposs.str().c_str());
20682072 } else {
20692073 GGMLHEXAGON_LOG_INFO("%s", tmposs.str().c_str());
20702074 }
2075+ #endif
2076+ GGMLHEXAGON_LOG_VERBOSE (" %s" , tmposs.str ().c_str ());
20712077 });
20722078}
20732079
2080+ int ggml_backend_hexagon_get_mulmat_algotype () {
2081+ std::string cfg_filename = std::string (g_hexagon_appcfg.runtime_libpath ) + std::string (g_hexagon_appcfg.cfgfilename );
2082+ hexagon_appcfg hexagoncfg_instance;
2083+ hexagoncfg_instance.load (cfg_filename);
2084+ hexagoncfg_instance.get_intvalue (" cdsp" , " mulmat_algotype" , g_hexagon_appcfg.mulmat_algotype , 0 );
2085+ return g_hexagon_appcfg.mulmat_algotype ;
2086+ }
2087+
20742088static bool ggmlhexagon_check_valid_appcfg () {
20752089 bool is_valid_appcfg = true ;
20762090
@@ -5641,7 +5655,9 @@ static int ggmlhexagon_init_dsp(ggml_backend_hexagon_context * ctx) {
56415655 }
56425656 ggmlhexagon_probe_dspinfo (ctx);
56435657 // FIXME: re-use this function to pass thread_counts info to code on cDSP side before fully understand qidl mechanism
5644- ggmlop_dsp_setclocks (ctx->ggmlop_handle , HAP_DCVS_VCORNER_TURBO_PLUS, 40 , 1 , g_hexagon_appcfg.thread_counts );
5658+ // ggmlop_dsp_setclocks(ctx->ggmlop_handle, HAP_DCVS_VCORNER_TURBO_PLUS, 40, 1, g_hexagon_appcfg.thread_counts);
5659+ // backward compatible with previous codes on cDSP side
5660+ ggmlop_dsp_setclocks (ctx->ggmlop_handle , HAP_DCVS_VCORNER_TURBO_PLUS, 40 , g_hexagon_appcfg.mulmat_algotype , g_hexagon_appcfg.thread_counts );
56455661 ggmlhexagon_set_rpc_latency (ctx->ggmlop_handle , RPC_POLL_QOS, 100 );
56465662 int result = ggmlhexagon_init_rpcmempool (ctx);
56475663 if (0 != result) {
@@ -6427,7 +6443,10 @@ static ggml_backend_t ggml_backend_hexagon_device_init_backend(ggml_backend_dev_
64276443 if (dev_index < 0 ) {
64286444 GGMLHEXAGON_LOG_VERBOSE (" it shouldn't happend\n " );
64296445 // test-thread-safety might-be running at the moment or an invalid value passed from user's program
6430- dev_index = 0 ;
6446+ dev_index = HEXAGON_BACKEND_QNNCPU; // 0
6447+ }
6448+ if (dev_index > GGML_HEXAGON_MAX_DEVICES) {
6449+ dev_index = HEXAGON_BACKEND_GGML; // 4
64316450 }
64326451 g_hexagon_appcfg.hexagon_backend = dev_index;
64336452 GGMLHEXAGON_LOG_VERBOSE (" program specified dev_index %d\n " , dev_index);
0 commit comments