Build PTX samples with LLVM/Clang/libclc

Hi Justin,

  I download llvm-ptx-samples [1] and try to build them. I found it seems lack
of a complete document on how to build them with LLVM/Clang/libclc. Do you think
it's a good idea to put a complete document/tutorial in _one_ place? Currently,
there are your website [2], LLVM [3], Clang and libclc websites [5] over there.
I feel people might get lost among those websites. :wink:

  Here are my flows, hope it's useful to you. (At least [1] should be updated to
include libclc)

1. Build LLVM/Clang with PTX support.

2. Download your PTX samples and libclc, then build them. I guess you want to
   pull libclc under llvm-ptx-samples/libclc/, right?

Hi Justin,

I download llvm-ptx-samples [1] and try to build them. I found it seems lack
of a complete document on how to build them with LLVM/Clang/libclc. Do you think
it’s a good idea to put a complete document/tutorial in one place? Currently,
there are your website [2], LLVM [3], Clang and libclc websites [5] over there.
I feel people might get lost among those websites. :wink:

I agree. I’m just not sure how these projects fit in with LLVM as a whole. LLVM does not really have a “samples” project, and these are very specific in their use-case.

Here are my flows, hope it’s useful to you. (At least [1] should be updated to
include libclc)

  1. Build LLVM/Clang with PTX support.

  2. Download your PTX samples and libclc, then build them. I guess you want to
    pull libclc under llvm-ptx-samples/libclc/, right?


$ git clone git://github.com/jholewinski/llvm-ptx-samples.git
$ cd llvm-ptx-samples; rm -rf libclc/
$ git clone git://git.pcc.me.uk/~peter/libclc.git

Build libclc first

$ cd libclc/
$ ./configure.py --with-llvm-config=/path/to/llvm-config && make

Then build your PTX samples

$ cd …/; make build; cd build
$ cmake …/
$ make

libclc is a submodule of the llvm-ptx-samples repo. Therefore, the flow is simple:

$ git clone git://github.com/jholewinski/llvm-ptx-samples
$ cd llvm-ptx-samples
$ git submodule init
$ git submodule update

I’ll update the documentation to reflect this.

Also, the libclc configuration is not necessary. Only some header files are pulled in by the samples.

O.K., I have a problem here.

[ 12%] Compiling blur2d_kernel.cl → blur2d_kernel.ll
clang: error: no such file or directory: ‘ptx32’
make[2]: *** [bin/blur2d_kernel.ll] Error 1
make[1]: *** [opencl/blur2d/CMakeFiles/blur2d_kernel.ptx.dir/all] Error 2

Do you know how to fix it? Thanks.

That’s a new one. I just tried a fresh clone and build, and did not experience this issue.

Can you run “make VERBOSE=1” and post the compiler command-line?

I agree. I'm just not sure how these projects fit in with LLVM as a whole.
LLVM does not really have a "samples" project, and these are very specific
in their use-case.

  I mean maintaining a document about PTX and its samples in one place so that
people won't get lost among those website.

libclc is a submodule of the llvm-ptx-samples repo. Therefore, the flow is
simple:

$ git clone git://github.com/jholewinski/llvm-ptx-samples
$ cd llvm-ptx-samples
$ git submodule init
$ git submodule update

  That's simple. I'm still learning how to git. :slight_smile:

> O.K., I have a problem here.
>
> [ 12%] Compiling blur2d_kernel.cl -> blur2d_kernel.ll
> clang: error: no such file or directory: 'ptx32'
> make[2]: *** [bin/blur2d_kernel.ll] Error 1
> make[1]: *** [opencl/blur2d/CMakeFiles/blur2d_kernel.ptx.dir/all] Error 2
>
> Do you know how to fix it? Thanks.
>

That's a new one. I just tried a fresh clone and build, and did not
experience this issue.

Can you run "make VERBOSE=1" and post the compiler command-line?

  Sorry, I delete the problematic source directory and cannot reproduce it. :confused:
`git submodule` works fine. Thanks! :slight_smile:

Regards,
chenwj