[Mesa-dev] how to run gallium/tests/trivial/compute.c on r600

Liu Xin navy.xliu at gmail.com
Thu Oct 4 07:42:45 PDT 2012


Hi, Tom,

thank you for your instant response.  we decide to try clover for r600. it
should work on ubuntu(11.10), right?
have you refined tgsi compiler for r600?

thanks,
--lx





On Thu, Oct 4, 2012 at 9:42 PM, Tom Stellard <tom at stellard.net> wrote:

> On Wed, Oct 03, 2012 at 08:15:07PM +0800, Liu Xin wrote:
> > Hi, Gallium Hackers,
> >
> > We are working on Gallium3D on android-x86, APU. We want to run general
> > compute programs on r600 GPU, specifically, "Radeon HD6310(Evergreen
> > family)".
> >
> > The first thing drawn our eyes are gallium/tests/trivial/compute.c
> because
> > it calls general compute APIs and attempts to execute tgsi programs on a
> > back-end. unfortunately, we failed to execute it even we have
> pipe_r600.so
> > on android-x86. now we have a healthy android-x86 and it supports opengl
> > well. further, we can run tri.c under tests/trivial/ directory as well.
> >
>
> The gallium/tests/trivial/compute.c program won't work on r600g, because
> the driver only supports compute programs written in LLVM IR and not
> TGSI.
>
> There are some example OpenCL programs here:
> http://cgit.freedesktop.org/~tstellar/opencl-example/
> that work with r600g.  Make sure you build Mesa with the --enable-opencl
> configure flag.
>
> If you don't want to use OpenCL and just want to play with the Gallium
> compute interface, you can replace the TGSI program with LLVM IR.
> You can use the LLVM C API builder interface to create a program (see:
> http://llvm.org/docs/doxygen/html/Core_8h.html) or you can write the
> LLVM IR by hand and then parse it into LLVM bitcode (I think there are C
> API functions that will do this too).
>
>
> Hope this helps.
>
> -Tom
> > let's take a simple example. can a kind person give us pointers?
> > static void test_resource_access(struct context *ctx)
> > {
> >         const char *src = "COMP\n"
> >                 "DCL RES[0], BUFFER, RAW, WR\n"
> >                 "DCL RES[1], 2D, RAW, WR\n"
> >                 "DCL SV[0], BLOCK_ID[0]\n"
> >                 "DCL TEMP[0], LOCAL\n"
> >                 "DCL TEMP[1], LOCAL\n"
> >                 "IMM UINT32 { 15, 0, 0, 0 }\n"
> >                 "IMM UINT32 { 16, 1, 0, 0 }\n"
> >                 "\n"
> >                 "    BGNSUB\n"
> >                 "       UADD TEMP[0].x, SV[0].xxxx, SV[0].yyyy\n"
> >                 "       AND TEMP[0].x, TEMP[0], IMM[0]\n"
> >                 "       UMUL TEMP[0].x, TEMP[0], IMM[1]\n"
> >                 "       LOAD TEMP[0].xyzw, RES[0], TEMP[0]\n"
> >                 "       UMUL TEMP[1], SV[0], IMM[1]\n"
> >                 "       STORE RES[1].xyzw, TEMP[1], TEMP[0]\n"
> >                 "       RET\n"
> >                 "    ENDSUB\n";
> >         void init0(void *p, int s, int x, int y) {
> >                 *(float *)p = 8.0 - (float)x;
> >         }
> >         void init1(void *p, int s, int x, int y) {
> >                 *(uint32_t *)p = 0xdeadbeef;
> >         }
> >         void expect(void *p, int s, int x, int y) {
> >                 *(float *)p = 8.0 - (float)((x + 4*y) & 0x3f);
> >         }
> >
> >         printf("- %s\n", __func__);
> >
> >         init_prog(ctx, 0, 0, 0, src, NULL);
> >         init_tex(ctx, 0, PIPE_BUFFER, true, PIPE_FORMAT_R32_FLOAT,
> >                  256, 0, init0);
> >         init_tex(ctx, 1, PIPE_TEXTURE_2D, true, PIPE_FORMAT_R32_FLOAT,
> >                  60, 12, init1);
> >         init_compute_resources(ctx, (int []) { 0, 1, -1 });
> >         launch_grid(ctx, (uint []){1, 1, 1}, (uint []){15, 12, 1}, 0,
> NULL);
> >         check_tex(ctx, 1, expect, NULL);
> >         destroy_compute_resources(ctx);
> >         destroy_tex(ctx);
> >         destroy_prog(ctx);
> > }
> >
> > for init_prog, here is the key functions:
> >         *tgsi_text_translate(psrc, prog, Elements(prog));
> > what's the meaning for this API?  the input is tgsi program, what's the
> > output?
> > in a nutshell, how can gallium translate tgsi to evergreen's ISA.
> >
> >         *ctx->hwcs = pipe->create_compute_state(pipe, &cs);
> >         *pipe->bind_compute_state(pipe, ctx->hwcs);
> > in evergreen_compute.c, it doesn't calloc kernels array and process
> > cso->prog if HAVE_OPENCL is not set.  should we set HAVE_OPENCL for
> general
> > compute?
> >
> > thanks,
> > --lx
>
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121004/b073eb1f/attachment-0001.html>


More information about the mesa-dev mailing list