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

Tom Stellard tom at stellard.net
Tue Oct 9 06:44:04 PDT 2012


On Fri, Oct 05, 2012 at 10:24:00PM +0800, Liu Xin wrote:
> Hi, Tom,
> 
> thanks for your kind guidance. within a daunting day, we have made clover
> work on our APU platform.  for your information, we are running on ubuntu
> 12-04, i386.
> 
> out of curiosity, r600 driver relies on the newest llvm API, see llvm 3.2.
> is it stable? we know LLVM is a fast moving project and their APIs are
> subject to change year by year.  I assume you are working tightly to llvm
> 3.2 because AMD backend will merge to trunk, right?  we ask this question
> because android-x86 can not support up-to-date llvm. it only has llvm 2.8
> now. we may port a certain version of llvm to satisfy with android and
> mesa.
>

The version of the backend included in the Mesa tree will work with LLVM 3.1, but
I don't expect much more development to happen on this version, so it
is recommended that you upgrade to LLVM 3.2

LLVM 3.2 is not stable yet, but it will be in a month or two.  I would
like to get the backend merged into the LLVM tree prior to the 3.2
release, but it's uncertain whether or not this will happen.

-Tom

> thanks,
> --lx
> 
> 
> On Thu, Oct 4, 2012 at 11:04 PM, Alex Deucher <alexdeucher at gmail.com> wrote:
> 
> > On Thu, Oct 4, 2012 at 10:53 AM, Tom Stellard <tom at stellard.net> wrote:
> > > On Thu, Oct 04, 2012 at 10:42:45PM +0800, Liu Xin wrote:
> > >> 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?
> > >>
> > >
> > > Build instructions for clover + r600g are here:
> > > http://dri.freedesktop.org/wiki/GalliumCompute#How_to_Install
> > > these should work on most any distro.
> > >
> > > We are in the process of transitioning from LLVM 3.2 to LLVM 3.1, so
> > > these instructions may change in the near future.
> >
> > 3.1 to 3.2 ;)
> >
> > >
> > > There are no plans to update the r600g tgsi compiler to handle TGSI
> > > compute instructions.  LLVM IR is the preferred IR for compute programs,
> > > and it is well supported.
> > >
> > > -Tom
> > >
> > >
> > >> 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
> > >> >
> > >> >
> > > _______________________________________________
> > > mesa-dev mailing list
> > > mesa-dev at lists.freedesktop.org
> > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >


More information about the mesa-dev mailing list