================
@@ -0,0 +1,501 @@
+//===- LowerGPUIntrinsic.cpp 
----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Lower the llvm.gpu intrinsics to target specific code sequences.
+// Can be called from clang if building for a specific GPU or from the backend
+// as part of a SPIRV lowering pipeline. Initial pass can lower to amdgcn or
----------------
Keenuts wrote:

Hello!

> First of all I agree, that having a common interface between various 
> frontends is a good idea. Yet as from what I see now - the intrinsics added 
> in the PR are not common, but tuned only for AMDGPU and NVPTX (also 
> intrinsics are not necessarily the only possible common interface).

Agree with this. I think having shared intrinsic at the IR level 
`llvm.gpu.num_threads()` would be a nice thing.
- Frontends would have to do some adjusting around it (maybe a language exposes 
a `num_threads` function which returns an array instead of a vector)
- backends would need to know how to lower this to the respective target.

> or they come out the other end in IR to be handled later in the pipeline.

That's the part I don't quite follow. I don't think those should be visible in 
the emitted SPIR-V. I believe those shared intrinsics should be lowered by the 
respective backends into the target specific output: for SPIR-V, that would be 
a builtin load/store or something like this. And if we don't support it yet, 
fail.

The benefit I'd see in shared intrinsics is not to have 1 frontend emits a 
`opencl.thread_id`, another `hlsl.thread_id`, and a last `random.thread_id`, 
and have each one implemented by a single backend.
 

https://github.com/llvm/llvm-project/pull/131190
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to