MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / simd_width

Method simd_width

op_builder/builder.py:529–559  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

527 return hwcap is not None and hwcap & (1 << (ord('V') - ord('A'))) != 0 # COMPAT_HWCAP_ISA_V
528
529 def simd_width(self):
530 try:
531 from cpuinfo import get_cpu_info
532 except ImportError as e:
533 cpu_info = self._backup_cpuinfo()
534 if cpu_info is None:
535 return '-D__SCALAR__'
536
537 try:
538 cpu_info = get_cpu_info()
539 except Exception as e:
540 self.warning(f"{self.name} attempted to use py-cpuinfo but failed (exception type: {type(e)}, {e}), "
541 "falling back to lscpu to get this information.")
542 cpu_info = self._backup_cpuinfo()
543 if cpu_info is None:
544 return '-D__SCALAR__'
545
546 if cpu_info['arch'] == 'X86_64':
547 if 'avx512' in cpu_info['flags'] or 'avx512f' in cpu_info['flags']:
548 return '-D__AVX512__'
549 elif 'avx2' in cpu_info['flags']:
550 return '-D__AVX256__'
551 elif (cpu_info['arch'] or '').startswith('ARM') and 'sve' in cpu_info['flags']:
552 return '-D__SVE__'
553 elif cpu_info['arch'] == 'ARM_8':
554 # NEON is baseline on AArch64; vdivq/vsqrtq used by simd.h are A64-only,
555 # so do not advertise it for 32-bit ARM.
556 return '-D__NEON__'
557 elif (cpu_info['arch'] or '').lower().replace('_', '').startswith('riscv64') and self._riscv_has_vector():
558 return '-D__RVV__'
559 return '-D__SCALAR__'
560
561 def command_exists(self, cmd):
562 if '|' in cmd:

Callers 7

cxx_argsMethod · 0.80
cxx_argsMethod · 0.80
cxx_argsMethod · 0.80
cxx_argsMethod · 0.80
cxx_argsMethod · 0.80
cxx_argsMethod · 0.80
cxx_argsMethod · 0.80

Calls 3

_backup_cpuinfoMethod · 0.95
warningMethod · 0.95
_riscv_has_vectorMethod · 0.95

Tested by

no test coverage detected