On 2024/6/6 上午11:42, Richard Henderson wrote:
On 6/5/24 20:36, maobibo wrote:
static biz_accel_fn const accel_table[] = {
     buffer_is_zero_int_ge256,
#ifdef __loongarch_sx
     buffer_is_zero_lsx,
#endif
#ifdef __loongarch_asx
     buffer_is_zero_lasx,
#endif
};

static unsigned best_accel(void)
{
#ifdef __loongarch_asx
     /* lasx may be index 1 or 2, but always last */
     return ARRAY_SIZE(accel_table) - 1;
#else
     /* lsx is always index 1 */
     return 1;
#endif
}
size of accel_table is decided at compile-time, will it be better if runtime checking is added also?  something like this:

  unsigned info = cpuinfo_init();

  #ifdef __loongarch_asx
  if (info & CPUINFO_LASX) {
       /* lasx may be index 1 or 2, but always last */
       return ARRAY_SIZE(accel_table) - 1;
  }
  #endif

No, because the ifdef checks that the *compiler* is prepared to use LASX/LSX instructions itself without further checks.  There's no point in qemu checking further.
By my understanding, currently compiler option is the same with all files, there is no separate compiler option with single file or file function.

So if compiler is prepared to use LASX/LSX instructions itself, host hardware must support LASX/LSX instructions, else there will be problem.

My main concern is that there is one hw machine which supports LSX, but no LASX, no KVM neither. QEMU binary maybe fails to run on such hw machine if it is compiled with LASX option.

Regards
Bibo Mao


r~


Reply via email to