[Libclc-dev] Using clang + libclc to compile OpenCL kernels to ptx23

Alex Breslow via Libclc-dev libclc-dev at lists.llvm.org
Tue Aug 25 09:43:37 PDT 2015


Hi Jeroen,
Correct me if I am mistaken (there is a good chance of that :) ), but I
think the issue here is that ptx32 and ptx23 appear to refer to completely
different things.  ptx32 is the 32-bit version of the PTX assembly, and
ptx23 appears to refer to the version of the PTX assembly from a feature
point of view (see http://llvm.org/devmtg/2011-11/Holewinski_PTXBackend.pdf
slide 9/37).

I'm a bit perplexed by all of this given that it appears that clang used to
be able to compile OpenCL to ptx23.  For instance, I found some old slides
by Justin Holewinski showing how one used to be able to compile to ptx23
circa 2011 (http://llvm.org/devmtg/2011-11/Holewinski_PTXBackend.pdf).
Below is an example from slide 10/37:
 *clang -ccc-host-triple ptx32 -Xclang -target-feature -Xclang +ptx23
-Xclang -target-feature -Xclang +sm20 -I$LIBCLC/include/generic
-I$LIBCLC/include/ptx  -include clc/clc.h
-Dcl_clang_storage_class_specifiers -O3 SOURCE.cl -S*

I tried generating the code this way, but it doesn't work for me.  Is this
syntax out of date?  Are the slides referring to something else?  If not,
what would be the equivalent for llvm 3.4?

-Alex



On Mon, Aug 24, 2015 at 3:39 PM, Jeroen Ketema <j.ketema at imperial.ac.uk>
wrote:

>
> Hi Alex,
>
> I think this question might be more appropriate for the cfe-dev list, but
> to answer your question: looking at lib/Target/NVPTX/NVPTX.td and its
> history, it seems that the llvm NVPTX backend at present (llvm trunk) only
> supports ptx32 and up, and never supported anything below ptx30.
>
> Jeroen
>
> On 24 Aug 2015, at 23:24, Alex Breslow via Libclc-dev <
> libclc-dev at lists.llvm.org> wrote:
>
> Hi there,
>
> I'm using clang to compile OpenCL kernels to PTX so that they can be run
> on an architectural simulator.  The simulator is only compatible with ptx23
> not ptx30 or ptx31.
>
> I'm compiling the kernels as follows:
> *SRC=VectorAdd.cl*
> *DEST=VectorAdd.ptx*
>
>
> *clang -Dcl_clang_storage_class_specifiers -isystem libclc/generic/include
> -include clc/clc.h -target nvptx-unknown-nvcl -xcl $SRC -emit-llvm -S -o
> $DEST.ll*
>
> *opt -S -O3 -loop-unroll $DEST.ll -o $DEST.opt.ll*
>
> *llc -mcpu=sm_20 -mattr=+ptx30 $DEST.opt.ll -o $DEST"*
>
> The following code works to compile the kernel to ptx30, but when I
> attempt to change -mattr=+ptx30 to -mattr=+ptx23, I get the following
> warning:
>
> *'+ptx23' is not a recognized feature for this target (ignoring feature)*
> *'+ptx23' is not a recognized feature for this target (ignoring feature)*
>
> Is there a way to around this warning so that ptx23 code is generated?
>
> I am using the Ubuntu 14.04 aptitude packages for libclc-dev, libclc-ptx,
> clang, and llvm.
> Ubuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM
> 3.4)
>
>
> Thanks again for your time and let me know if you need further information.
>
> Regards,
> Alex
>
> --
> Alex Breslow
>
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/libclc-dev
>
>
>


-- 
Alex Breslow
PhD student in computer science at UC San Diego
Email: abreslow at cs.ucsd.edu
Website: cseweb.ucsd.edu/~abreslow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libclc-dev/attachments/20150825/41e97426/attachment.html>


More information about the Libclc-dev mailing list