[llvm-dev] OpenCL toolset (for AMD GPU)

Tobias Grosser via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 29 08:32:39 PDT 2015


On 09/29/2015 05:23 PM, Tom Stellard wrote:
> On Tue, Sep 29, 2015 at 04:37:40PM +0200, Tobias Grosser wrote:
>> On 09/29/2015 04:19 PM, Tom Stellard via llvm-dev wrote:
>>> On Tue, Sep 29, 2015 at 01:20:57PM +0000, Paweł Bylica via llvm-dev wrote:
>>>> Hi LLVM,
>>>>
>>>> I would like to compile OpenCL kernel for a specific AMD GPU target. Is it
>>>> possible with the current clang/LLVM?
>>>>
>>>> I started by using `clang -x cl` but it looks like at least some OpenCL
>>>> specific headers are missing (e.g. uint2 is not recognized as a type).
>>>>
>>>> Any links to documentation / tutorials very welcome. Thanks.
>>>>
>>>
>>> Hi,
>>>
>>> You need to include OpenCL library headers from libclc
>>> (http://libclc.llvm.org/) to compile most OpenCL code.
>>>
>>> Here is an example command:
>>>
>>> clang -include /path/to/libclc/headers/clc.h -I /path/to/libclc/headers  -Dcl_clang_storage_class_specifiers -target amdgcn--amdhsa -mcpu=carrizo  $INPUT_FILE -o $OUTPUT_FILE
>>
>> Hi Tom,
>>
>> to piggy-pack on this question. To load this kernel in OpenCL, is it sufficient to just pass $OUTPUT_FILE
>> to clCreateProgramWithBinary?
>>
>
> Hi Tobias,
>
> The are currently no OpenCL runtimes that can load the AMDGPU binaries
> emitted by clang.  If you want to use OpenCL with the AMDGPU backend,
> you will need to install Mesa[0], enable OpenCL support[1], and use the
> OpenCL API to compile the OpenCL C code.
>
> You can however load AMDGPU binaries using the hsa-runtime.
> Take a look at the example code in my repo[2].  Note that this requires that
> you build lld along with llvm and clang.
>
>> Also, assuming this is enough. Is the code quality for recent AMD GPUs quality-wise on the level of what AMD's closed-source driver would generate.
>>
>
> I haven't done a lot of comparisons, so the best answer I can give is 'not as good'.
> The main feature that is missing is OpenCL images.  We support OpenGL images,
> but they just haven't been wired up yet to the OpenCL builtin library.
>
> There is experimental assembler / inline assembly support for AMDGPU in clang, so
> you could always write a kernel in assembly if you are concerned about performance.

OK, thank you Tom for this information!

Tobias


More information about the llvm-dev mailing list