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

Tom Stellard tom at stellard.net
Mon Nov 12 08:21:15 PST 2012


On Mon, Nov 12, 2012 at 03:37:40PM +0000, Tom Stellard wrote:
> On Sun, Nov 11, 2012 at 11:12:48AM +0800, Liu Xin wrote:
> > Hi, Tom,
> > 
> > now i want to try out the new features of gallium/clover. I notice you have
> > updated your wiki page for installation.  with your new instruction, i can
> > not build clang any more :(
> > 
> > xliu at xliu-desktop:~/Development/llvm-tstellar/tools/clang$ make
> > make[1]: Entering directory
> > `/home/xliu/Development/llvm-tstellar/tools/clang/utils/TableGen'
> > llvm[1]: Compiling ClangDiagnosticsEmitter.cpp for Debug+Asserts build
> > ClangDiagnosticsEmitter.cpp:398:9: error: use of undeclared identifier
> > 'PrintFatalError'; did you mean 'PrintError'?
> >         PrintFatalError(R.getLoc(), "Error " + R.getName() +
> >         ^~~~~~~~~~~~~~~
> >         PrintError
> > /home/xliu/Development/llvm-tstellar/include/llvm/TableGen/Error.h:38:6:
> > note: 'PrintError' declared here
> > void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg);
> >      ^
> > ClangDiagnosticsEmitter.cpp:398:37: error: no viable conversion from
> > 'basic_string<char, std::char_traits<char>, std::allocator<char> >' to
> > 'const llvm::Twine'
> >         PrintFatalError(R.getLoc(), "Error " + R.getName() +
> >                                     ^~~~~~~~~~~~~~~~~~~~~~~~
> > /home/xliu/Development/llvm-tstellar/include/llvm/TableGen/Error.h:38:56:
> > note: passing argument to parameter 'Msg' here
> > void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg);
> >                                                        ^
> > ClangDiagnosticsEmitter.cpp:560:7: error: use of undeclared identifier
> > 'PrintFatalError'; did you mean 'PrintError'?
> >       PrintFatalError("Invalid character in diagnostic group '" +
> >       ^~~~~~~~~~~~~~~
> >       PrintError
> > /home/xliu/Development/llvm-tstellar/include/llvm/TableGen/Error.h:38:6:
> > note: 'PrintError' declared here
> > void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg);
> >      ^
> > ClangDiagnosticsEmitter.cpp:561:37: error: too few arguments to function
> > call, expected 2, have 1
> >                       I->first + "'");
> >                                     ^
> > /home/xliu/Development/llvm-tstellar/include/llvm/TableGen/Error.h:38:1:
> > note: 'PrintError' declared here
> > void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg);
> > ^
> > 4 errors generated.
> > make[1]: ***
> > [/home/xliu/Development/llvm-tstellar/tools/clang/utils/TableGen/Debug+Asserts/ClangDiagnosticsEmitter.o]
> > Error 1
> > make[1]: Leaving directory
> > `/home/xliu/Development/llvm-tstellar/tools/clang/utils/TableGen'
> > make: *** [all] Error 1
> > 
> > 
> > 
> > here is my clang version. i think that it is the latest version. is there
> > anything mismatching or clang 's new checkin is broken?
> > 
> > xliu at xliu-desktop:~/Development/llvm-tstellar/tools/clang$ git log
> > commit a6600a339fee660cac2bd9b04cf578fa47ed491d
> > Author: Nico Weber <nicolasweber at gmx.de>
> > Date:   Sun Nov 11 01:35:05 2012 +0000
> > 
> >     FileCheckize test
> > 
> >     git-svn-id:
> > https://llvm.org/svn/llvm-project/cfe/trunk@16768091177308-0d34-0410-b5e6-96231b3b80d8
> >
> 
> Your checkout of clang is too new.  You should checkout out clang
> commit: 160f835dab76bb64249f2785ccc4a53efec1cc50
>

It looks like all the commit ids in the git mirror were changed
recently.  Maybe as a result of the 3.2 branch?  The new commit id is:
03e6fda61f48a6f11fb3c9459d5ac3d5b1db2809

In the future, you're probably better off searching by svn id, which is
appended to the commit message in the git-svn-id.

-Tom

> I've added this commit to the build instruction on the wiki:
> http://dri.freedesktop.org/wiki/GalliumCompute
> 
> -Tom
> 
> > 
> > thanks,
> > --lx
> > 
> > 
> > 
> > On Tue, Oct 9, 2012 at 9:44 PM, Tom Stellard <tom at stellard.net> wrote:
> > 
> > > 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
> > > > >
> > >
> _______________________________________________
> 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