[llvm-dev] [Non-DoD Source] Re: llvm OpenMP support for Apple Silicon

Johannes Doerfert via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 19 14:03:30 PDT 2021


On 10/19/21 15:24, GRISMER, MATTHEW J CIV USAF AFMC AFRL/RQVC wrote:
> Johannes,
>
> According to the Apple documentation, you access the GPU via their Metal API.  Metal supports computation as well as graphics acceleration.  Digging a little deeper, kernels that run on the GPU are written in Metal Shading Language, which is a variant of C++ designed for GPUs.  The preparatory stuff to get the kernel running on the GPU is all done through a Metal Objective-C/C++ object which is tied to the particular device you want to use.  With that object you get a reference to your kernel function(s), setup a pipeline (converts function to executable code), create a queue, create data buffers and load data, create a command buffer and encode commands, specify thread count and group size, and commit the queue to execute it.  Somewhat similar to how SYCL works, at least from what I’ve read.  Since Apple uses LLVM/Clang for their system compiler, I assume it is also used to compile for the GPU.  Anyway, the short answer to the question appears to be OpenMP offload would need to be implemented using Apple’s Metal API.

Yes. Given that description one would need two things:
1) A Metal API plugin for libomptarget (next to the CUDA and AMDGCN 
plugin). That is actually pretty easy if
    their API is somewhat sane.
2) A backend that can produce device code. I don't think they upstreamed 
their Metal backend *but* one can
    probably use their clang as "backend" given that it can consume LLVM-IR.

If you are interested in developing a protoype, feel free to reach out. 
We have some projects in the pipeline
that will make 2) much easier, plus experience with the plugin system.

~ Johannes


>
> Matt
>
> From: Johannes Doerfert <johannesdoerfert at gmail.com>
> Date: Saturday, October 16, 2021 at 12:30 PM
> To: GRISMER, MATTHEW J CIV USAF AFMC AFRL/RQVC <matthew.grismer at us.af.mil>, llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org>
> Cc: openmp-dev <openmp-dev at lists.llvm.org>
> Subject: [Non-DoD Source] Re: [llvm-dev] llvm OpenMP support for Apple Silicon
> Hi Matt,
>
> not that I'm aware of any ongoing effort.
>
> Though, I'm not an expert on Apple hardware (or software for that matter).
> How would you program them right now?
> Does LLVM have code generation capabilities for those GPUs?
>
> Depending on the answers it might be reasonable to add OpenMP offloading
> support (or not).
>
> ~ Johannes
>
>
> On 10/15/21 12:42, GRISMER, MATTHEW J CIV USAF AFMC AFRL/RQVC via
> llvm-dev wrote:
>> Hi,
>>
>> I'm interested in exploring Apple Silicon performance with computational fluid dynamic codes, in particular codes that take advantage of OpenMP offload to accelerate performance.  Are there any plans to support OpenMP offload to the integrated GPU in Apple Silicon processors?
>>
>> Thanks.
>>
>> Matt
>>
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list