Re: [RFC PATCH] i386/tcg: add AVX/AVX2 support (severely incomplete, just for preliminary feedback)
On Wed, 16 Feb 2022 at 10:24, Richard Henderson wrote: > > There's an enormous amount of legacy SSE instructions to adjust > > for VEX-128 and VEX-256 flavours, so I would want to know that this > > way would be acceptable. > > > > Signed-off-by: Alexander Kanavin > > --- > > Have a look at updating some existing work: > > https://lore.kernel.org/qemu-devel/20190821172951.15333-1-jan.bo...@gmail.com/ Nice! I agree that gen_sse() is in a bad need of a structured, extensible rewrite and glad to see it's been done, as I've been merely tweaking existing code. Jan, do you have a later version of these patches, or is v4 the final revision as of now? Do you have them in a git branch somewhere? Alex
[RFC PATCH] i386/tcg: add AVX/AVX2 support (severely incomplete, just for preliminary feedback)
Lack of AVX/AVX2 support in the i386 TCG has been a significant gap for a long while; I've started work to close this gap. This is of course nowhere near complete, or even buildable, I'm just requesting initial feedback from the qemu gurus - am I on the right track with this? Does something need to be done differently? There's an enormous amount of legacy SSE instructions to adjust for VEX-128 and VEX-256 flavours, so I would want to know that this way would be acceptable. Signed-off-by: Alexander Kanavin --- target/i386/cpu.h| 6 ++ target/i386/ops_sse.h| 40 +--- target/i386/ops_sse_header.h | 6 +- target/i386/tcg/translate.c | 115 ++- 4 files changed, 140 insertions(+), 27 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 9911d7c871..ff83c7ef5b 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -82,6 +82,12 @@ typedef enum X86Seg { R_TR = 7, } X86Seg; +enum { +SIMD_SSE, +SIMD_VEX128, +SIMD_VEX256 +}; + /* segment descriptor fields */ #define DESC_G_SHIFT23 #define DESC_G_MASK (1 << DESC_G_SHIFT) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 6f1fc174b3..5a57abd383 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -1249,15 +1249,27 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) } \ \ void glue(helper_punpck ## base_name ## dq, SUFFIX)(CPUX86State *env,\ -Reg *d, Reg *s) \ +Reg *d, Reg *s2, Reg *s1, unsigned int simd_type) \ { \ Reg r; \ \ -r.L(0) = d->L((base << SHIFT) + 0); \ -r.L(1) = s->L((base << SHIFT) + 0); \ +if (simd_type == SIMD_SSE) \ +s1 = d;\ +r.L(0) = s1->L((base << SHIFT) + 0); \ +r.L(1) = s2->L((base << SHIFT) + 0); \ XMM_ONLY( \ - r.L(2) = d->L((base << SHIFT) + 1);\ - r.L(3) = s->L((base << SHIFT) + 1);\ + r.L(2) = s1->L((base << SHIFT) + 1);\ + r.L(3) = s2->L((base << SHIFT) + 1);\ + if (simd_type == SIMD_VEX256) {\ + r.L(4) = s1->L((base<<1) + 4); \ + r.L(5) = s2->L((base<<1) + 4); \ + r.L(6) = s1->L((base<<1) + 5); \ + r.L(7) = s2->L((base<<1) + 5); \ + } \ + if (simd_type == SIMD_VEX128) {\ + r.Q(2) = 0;\ + r.Q(3) = 0;\ + } \ ) \ *d = r; \ } \ @@ -1266,12 +1278,24 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) void glue(helper_punpck ## base_name ## qdq, SUFFIX)(CPUX86State \ *env, \ Reg *d, \ - Reg *s) \ + Reg *s2, \ + Reg *s1, \ + unsigned int simd_type) \ { \ Reg r; \ \ - r.Q(0) = d->Q(base); \ - r.Q(1) = s->Q(base);
[RFC PATCH] i386/tcg: add AVX/AVX2 support (severely incomplete, just for preliminary feedback)
Lack of AVX/AVX2 support in the i386 TCG has been a significant gap for a long while; I've started work to close this gap. This is of course nowhere near complete, or even buildable, I'm just requesting initial feedback from the qemu gurus - am I on the right track with this? Does something need to be done differently? There's an enormous amount of legacy SSE instructions to adjust for VEX-128 and VEX-256 flavours, so I would want to know that this way would be acceptable. Signed-off-by: Alexander Kanavin --- target/i386/cpu.h| 6 ++ target/i386/ops_sse.h| 40 +--- target/i386/ops_sse_header.h | 6 +- target/i386/tcg/translate.c | 115 ++- 4 files changed, 140 insertions(+), 27 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 9911d7c871..ff83c7ef5b 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -82,6 +82,12 @@ typedef enum X86Seg { R_TR = 7, } X86Seg; +enum { +SIMD_SSE, +SIMD_VEX128, +SIMD_VEX256 +}; + /* segment descriptor fields */ #define DESC_G_SHIFT23 #define DESC_G_MASK (1 << DESC_G_SHIFT) diff --git a/target/i386/ops_sse.h b/target/i386/ops_sse.h index 6f1fc174b3..5a57abd383 100644 --- a/target/i386/ops_sse.h +++ b/target/i386/ops_sse.h @@ -1249,15 +1249,27 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) } \ \ void glue(helper_punpck ## base_name ## dq, SUFFIX)(CPUX86State *env,\ -Reg *d, Reg *s) \ +Reg *d, Reg *s2, Reg *s1, unsigned int simd_type) \ { \ Reg r; \ \ -r.L(0) = d->L((base << SHIFT) + 0); \ -r.L(1) = s->L((base << SHIFT) + 0); \ +if (simd_type == SIMD_SSE) \ +s1 = d;\ +r.L(0) = s1->L((base << SHIFT) + 0); \ +r.L(1) = s2->L((base << SHIFT) + 0); \ XMM_ONLY( \ - r.L(2) = d->L((base << SHIFT) + 1);\ - r.L(3) = s->L((base << SHIFT) + 1);\ + r.L(2) = s1->L((base << SHIFT) + 1);\ + r.L(3) = s2->L((base << SHIFT) + 1);\ + if (simd_type == SIMD_VEX256) {\ + r.L(4) = s1->L((base<<1) + 4); \ + r.L(5) = s2->L((base<<1) + 4); \ + r.L(6) = s1->L((base<<1) + 5); \ + r.L(7) = s2->L((base<<1) + 5); \ + } \ + if (simd_type == SIMD_VEX128) {\ + r.Q(2) = 0;\ + r.Q(3) = 0;\ + } \ ) \ *d = r; \ } \ @@ -1266,12 +1278,24 @@ void glue(helper_packssdw, SUFFIX)(CPUX86State *env, Reg *d, Reg *s) void glue(helper_punpck ## base_name ## qdq, SUFFIX)(CPUX86State \ *env, \ Reg *d, \ - Reg *s) \ + Reg *s2, \ + Reg *s1, \ + unsigned int simd_type) \ { \ Reg r; \ \ - r.Q(0) = d->Q(base); \ - r.Q(1) = s->Q(base);
Re: [Qemu-devel] [PATCH] egl-helpers.h: add a missing X11 include
On Wed, 16 Jan 2019 at 12:10, Philippe Mathieu-Daudé wrote: > >> we build mesa explicitly using "--with-platforms='drm surfaceless'" > >> (x11 is not in the list), which means MESA_EGL_NO_X11_HEADERS is > >> indeed defined according to [1]. We also enable opengl and gtk in > >> qemu. > > > > Hmm, should we use EGLNativeWindowType instead of Window then? > > Yes, I prefer this too but was not sure you'd like that :) > > Alexander do you want to write the patch or should I? I just sent the patch; I am not subscribed to qemu-devel so might take a moment to get through moderation (I suppose?). Alex
[Qemu-devel] [PATCH] egl-helpers.h: do not depend on X11 Window type, use EGLNativeWindowType
It was assumed that mesa provides the necessary X11 includes, but it is not always the case, as it can be configured without x11 support. Signed-off-by: Alexander Kanavin --- include/ui/egl-helpers.h | 2 +- ui/egl-helpers.c | 4 ++-- ui/gtk-egl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 9db7293bdb..3fc656a7ba 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -43,7 +43,7 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf); #endif -EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); +EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win); int qemu_egl_init_dpy_x11(EGLNativeDisplayType dpy, DisplayGLMode mode); int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, DisplayGLMode mode); diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 4f475142fc..5e115b3fb4 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -273,14 +273,14 @@ void egl_dmabuf_release_texture(QemuDmaBuf *dmabuf) /* -- */ -EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win) +EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, EGLNativeWindowType win) { EGLSurface esurface; EGLBoolean b; esurface = eglCreateWindowSurface(qemu_egl_display, qemu_egl_config, - (EGLNativeWindowType)win, NULL); + win, NULL); if (esurface == EGL_NO_SURFACE) { error_report("egl: eglCreateWindowSurface failed"); return NULL; diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 5420c2362b..1f9411626a 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -54,7 +54,7 @@ void gd_egl_init(VirtualConsole *vc) } vc->gfx.ectx = qemu_egl_init_ctx(); -vc->gfx.esurface = qemu_egl_init_surface_x11(vc->gfx.ectx, x11_window); +vc->gfx.esurface = qemu_egl_init_surface_x11(vc->gfx.ectx, (EGLNativeWindowType)x11_window); assert(vc->gfx.esurface); } -- 2.17.1
Re: [Qemu-devel] [PATCH] egl-helpers.h: add a missing X11 include
On Tue, 15 Jan 2019 at 20:58, Philippe Mathieu-Daudé wrote: > Cc'ing Gerd (the maintainer) and Marc-André. > > On 1/15/19 12:50 PM, Alexander Kanavin wrote: > > Otherwise these errors occur, when qemu is built in the Yocto project: > > | In file included from > > /home/alexander/development/poky/build-virgl-gtk-64/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-qemu/3.1.0-r0/qemu-3.1.0/include/ui/egl-context.h:5, > > | from > > /home/alexander/development/poky/build-virgl-gtk-64/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-qemu/3.1.0-r0/qemu-3.1.0/ui/egl-context.c:3: > > | > > /home/alexander/development/poky/build-virgl-gtk-64/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-qemu/3.1.0-r0/qemu-3.1.0/include/ui/egl-helpers.h:46:55: > > error: unknown type name 'Window'; did you mean 'minor'? > > | EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); > > |^~ > > |minor > > Can you provide more information to reproduce this failure? > > It seems some dependency is missing in your build setup. Missing headers > would trigger the definition of MESA_EGL_NO_X11_HEADERS and this error. > > includes which contains: > > #if defined(MESA_EGL_NO_X11_HEADERS) > typedef void*EGLNativeDisplayType; > typedef khronos_uintptr_t EGLNativePixmapType; > typedef khronos_uintptr_t EGLNativeWindowType; > #else > /* X11 (tentative) */ > #include > > So Window should already be declared. Hello Philippe, we build mesa explicitly using "--with-platforms='drm surfaceless'" (x11 is not in the list), which means MESA_EGL_NO_X11_HEADERS is indeed defined according to [1]. We also enable opengl and gtk in qemu. I believe this is a valid configuration, and so should not lead to compile errors (we're fine if it will cause run-time errors for some combinations of qemu options). A header should not rely on a conditional include happening somewhere else. [1] https://cgit.freedesktop.org/mesa/mesa/tree/configure.ac#n2533 Thanks, Alex
[Qemu-devel] [PATCH] egl-helpers.h: add a missing X11 include
Otherwise these errors occur, when qemu is built in the Yocto project: | In file included from /home/alexander/development/poky/build-virgl-gtk-64/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-qemu/3.1.0-r0/qemu-3.1.0/include/ui/egl-context.h:5, | from /home/alexander/development/poky/build-virgl-gtk-64/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-qemu/3.1.0-r0/qemu-3.1.0/ui/egl-context.c:3: | /home/alexander/development/poky/build-virgl-gtk-64/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-qemu/3.1.0-r0/qemu-3.1.0/include/ui/egl-helpers.h:46:55: error: unknown type name 'Window'; did you mean 'minor'? | EGLSurface qemu_egl_init_surface_x11(EGLContext ectx, Window win); |^~ |minor Signed-off-by: Alexander Kanavin --- include/ui/egl-helpers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 9db7293bdb..2c32d77e7a 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -4,6 +4,7 @@ #include #include #include +#include extern EGLDisplay *qemu_egl_display; extern EGLConfig qemu_egl_config; -- 2.17.1