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