Skip to content

development strategy for support beyond host platform #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BurntSushi opened this issue Oct 3, 2017 · 5 comments
Closed

development strategy for support beyond host platform #92

BurntSushi opened this issue Oct 3, 2017 · 5 comments

Comments

@BurntSushi
Copy link
Member

I would like it to be possible for programmers to run tests using intrinsics that their development platform doesn't have access to. For example, as someone developing on an Intel SandyBridge machine, I'd like to be able to run tests that use AVX512 intrinsics or even ARM tests.

Is this possible? Can some kind of VM make this happen?

@mattico noted some thoughts on the topic.

@AdamNiederer
Copy link
Contributor

AdamNiederer commented Oct 4, 2017

AFAIK QEMU can't emulate AVX-512 in software, but Intel has a proprietary (I know, eww) solution to do it: https://software.intel.com/en-us/articles/intel-software-development-emulator/

I'll report on whether it can handle NEON as soon as my aarch64 toolchain builds.

EDIT: Looks like QEMU emulates NEON, although I didn't write anything exhaustive.

#include "stdio.h"

#ifdef __x86_64__
#include "x86intrin.h"
#endif

#ifdef __aarch64__
#include "arm_neon.h"
#endif

int main(void) {
#ifdef __x86_64__
  __m512d arr = _mm512_set_pd(0.0, 0.1, 0.0, 0.1, 0.0, 0.1, 0.0, 0.1);
  __m512d arr2 = _mm512_set_pd(0.0, 0.1, 0.0, 0.1, 0.0, 0.1, 0.0, 0.1);
  __m512d ans = _mm512_add_pd(arr, arr2);
  printf("%f\n", ans[0]);
#endif

#ifdef __aarch64__
  float64x2_t arr = {0.0, 1.0};
  float64x2_t arr2 = {0.0, 1.0};
  float64x2_t ans = vaddq_f64(arr, arr2);
  printf("%f, %f\n", ans[0], ans[1]);
#endif
}
$ clang -march=skylake-avx512 simd.c
$ qemu-x86_64 -cpu Skylake-Server ./a.out 
warning: TCG doesn't support requested feature: CPUID.01H:ECX.fma [bit 12]
warning: TCG doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
warning: TCG doesn't support requested feature: CPUID.01H:ECX.x2apic [bit 21]
warning: TCG doesn't support requested feature: CPUID.01H:ECX.tsc-deadline [bit 24]
warning: TCG doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
warning: TCG doesn't support requested feature: CPUID.01H:ECX.f16c [bit 29]
warning: TCG doesn't support requested feature: CPUID.01H:ECX.rdrand [bit 30]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx2 [bit 5]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512f [bit 16]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512dq [bit 17]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.rdseed [bit 18]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512cd [bit 28]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512bw [bit 30]
warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512vl [bit 31]
warning: TCG doesn't support requested feature: CPUID.80000001H:ECX.3dnowprefetch [bit 8]
warning: TCG doesn't support requested feature: CPUID.0DH:EAX.xsavec [bit 1]
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction (core dumped)
$ aarch64-linux-gnu-gcc simd.c
$ qemu-aarch64 -L /usr/aarch64-linux-gnu/ ./a.out 
0.000000, 2.000000
$ aarch64-linux-gnu-objdump -S ./a.out | grep fadd
  4005a4:	4e60d420 	fadd	v0.2d, v1.2d, v0.2d```

This was all done on an Ivy Bridge box (AVX and below natively supported)

@alexcrichton
Copy link
Member

Bah I would have hoped we could just use QEMU for this, but apparently not :(

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 11, 2017

@AdamNiederer

AFAIK QEMU can't emulate AVX-512 in software,

Does anybody know if this is going to stay this way, or if it is something being worked on?

EDIT: This QEMU change log from 2016 says that it has some support for AVX-512: https://wiki.qemu.org/ChangeLog/2.8

alexcrichton added a commit to alexcrichton/stdarch that referenced this issue Oct 12, 2017
This commit adds a new builder on CI for running tests in Intel's own emulator
and also adds an assertion that on this emulator no tests are skipped due to
missing CPU features by accident.

Closes rust-lang#92
alexcrichton added a commit that referenced this issue Oct 18, 2017
This commit adds a new builder on CI for running tests in Intel's own emulator
and also adds an assertion that on this emulator no tests are skipped due to
missing CPU features by accident.

Closes #92
pythoneer pushed a commit to pythoneer/stdsimd that referenced this issue Oct 19, 2017
This commit adds a new builder on CI for running tests in Intel's own emulator
and also adds an assertion that on this emulator no tests are skipped due to
missing CPU features by accident.

Closes rust-lang#92
@Rtoax
Copy link

Rtoax commented Aug 20, 2024

Thanks, qemu tcg 8.2.2 still not support avx512 yet:

$ qemu-x86_64 -cpu Skylake-Server ./vfmadd231ps
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512f [bit 16]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512dq [bit 17]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512cd [bit 28]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512bw [bit 30]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512vl [bit 31]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.0DH:EAX.xsavec [bit 1]
Illegal instruction (core dumped)

@dElogics
Copy link

dElogics commented Mar 23, 2025

Confirmed with 9.1.2
qemu-x86_64 -cpu Icelake-Server-v7 bash
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512f [bit 16]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512dq [bit 17]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512ifma [bit 21]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512cd [bit 28]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512bw [bit 30]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:EBX.avx512vl [bit 31]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:ECX.avx512vbmi [bit 1]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:ECX.avx512vbmi2 [bit 6]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:ECX.gfni [bit 8]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:ECX.vpclmulqdq [bit 10]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:ECX.avx512vnni [bit 11]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:ECX.avx512bitalg [bit 12]
qemu-x86_64: warning: TCG doesn't support requested feature: CPUID.07H:ECX.avx512-vpopcntdq [bit 14]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants