@@ -154,6 +154,7 @@ struct ggml_backend_hexagon_context;
154154
155155#if !defined (_WINDOWS)
156156#pragma weak remote_system_request
157+ #pragma weak remote_session_control
157158#endif
158159
159160#define CHECK_QNN_API (error, result ) \
@@ -5186,6 +5187,41 @@ static void ggmlhexagon_set_rpc_latency(remote_handle64 handle, int qos, int lat
51865187 return ;
51875188}
51885189
5190+ /* *
5191+ * set FastRPC thread priority (default unchanged at 192)
5192+ * priority values range from 1 to 255, with smaller values representing higher priorities
5193+ * Unprivileged clients: 64 through 254 (cDSP only)
5194+ * Privileged clients: 1 through 254
5195+ *
5196+ * ref:file:///opt/qcom/Hexagon_SDK/6.2.0.1/docs/software/system_integration.html#priority-levels
5197+ */
5198+ static int ggmlhexagon_set_priority (int domain, int priority) {
5199+ int err = 0 ;
5200+
5201+ if (priority < 1 ) {
5202+ priority = 1 ;
5203+ }
5204+ if (priority > 255 ) {
5205+ priority = 255 ;
5206+ }
5207+
5208+ if (remote_session_control) {
5209+ struct remote_rpc_thread_params data;
5210+ data.domain = domain;
5211+ data.prio = priority;
5212+ data.stack_size = -1 ;
5213+ err = remote_session_control (FASTRPC_THREAD_PARAMS, (void *)&data, sizeof (data));
5214+ if (err != AEE_SUCCESS) {
5215+ GGMLHEXAGON_LOG_WARN (" remote_session_control failed with 0x%x when setting thread priority\n " , err);
5216+ } else {
5217+ GGMLHEXAGON_LOG_VERBOSE (" thread priority set to %d\n " , priority);
5218+ }
5219+ } else {
5220+ GGMLHEXAGON_LOG_WARN (" cannot set thread priority\n " );
5221+ }
5222+ return err;
5223+ }
5224+
51895225static bool ggmlhexagon_is_status_notification_supported (int domain) {
51905226 int hexagon_error = AEE_SUCCESS;
51915227
@@ -5640,7 +5676,7 @@ static int ggmlhexagon_init_dsp(ggml_backend_hexagon_context * ctx) {
56405676 hexagon_error = remote_session_control (DSPRPC_CONTROL_UNSIGNED_MODULE, (void *)&data, sizeof (data));
56415677 GGMLHEXAGON_LOG_DEBUG (" remote_session_control returned %d for configuring unsigned PD success" , hexagon_error);
56425678 if (AEE_SUCCESS != hexagon_error) {
5643- GGMLHEXAGON_LOG_DEBUG (" error 0x%x: remote_session_control failed" , hexagon_error);
5679+ GGMLHEXAGON_LOG_WARN (" error 0x%x: remote_session_control failed" , hexagon_error);
56445680 }
56455681 } else {
56465682 GGMLHEXAGON_LOG_DEBUG (" unsigned PD not supported on this device" );
@@ -5657,6 +5693,7 @@ static int ggmlhexagon_init_dsp(ggml_backend_hexagon_context * ctx) {
56575693 GGMLHEXAGON_LOG_WARN (" error 0x%x: failed to compute on domain %d" , hexagon_error, domain_id);
56585694 goto bail;
56595695 }
5696+ ggmlhexagon_set_priority (domain_id, 160 );
56605697
56615698 ggmlop_domain_uri_len = strlen (ggmlop_URI) + MAX_DOMAIN_NAMELEN;
56625699 ggmlop_domain_uri = (char *)malloc (ggmlop_domain_uri_len);
0 commit comments