Repository navigation
Open
Description
I named the example simple_matmul.cu and tried to compile like
nyck33@lenovo-gtx1650:/mnt/d/LLVM/NewPolygeistDir/nobu-polygeist-demos$ cgeist simple_matmul.cu -function=matmul -S
warning: CUDA version 12.1 is only partially supported
error: GPU arch sm_35 is supported by CUDA versions between 7.0 and 11.8 (inclusive), but installation at /usr/local/cuda-12.1 is 12.1; use '--cuda-path' to specify a different CUDA install, pass a different GPU arch with '--cuda-gpu-arch', or pass '--no-cuda-version-check'
<built-in>:1:10: fatal error: '__clang_cuda_runtime_wrapper.h' file not found
1 | #include "__clang_cuda_runtime_wrapper.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nyck33@lenovo-gtx1650:/mnt/d/LLVM/NewPolygeistDir/nobu-polygeist-demos$ cgeist simple_matmul.cu -function=matmul -S --cuda-gpu-a
rch sm_75
warning: CUDA version 12.1 is only partially supported
<built-in>:1:10: fatal error: '__clang_cuda_runtime_wrapper.h' file not found
1 | #include "__clang_cuda_runtime_wrapper.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nyck33@lenovo-gtx1650:/mnt/d/LLVM/NewPolygeistDir/nobu-polygeist-demos$
will Cuda 12.1 be supported soon? What are some workarounds?
My nvidia-smi and nvcc --version are:
nyck33@lenovo-gtx1650:/mnt/d/LLVM/NewPolygeistDir/build$ nvidia-smi
Wed Apr 3 23:18:44 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 530.54 Driver Version: 531.97 CUDA Version: 12.1 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA GeForce GTX 1650 On | 00000000:01:00.0 Off | N/A |
| N/A 46C P0 17W / N/A| 0MiB / 4096MiB | 0% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes:
|
| GPU GI CI PID Type Process name
GPU Memory |
| ID ID
Usage |
|=======================================================================================|
| No running processes found
|
+---------------------------------------------------------------------------------------+
nyck33@lenovo-gtx1650:/mnt/d/LLVM/NewPolygeistDir/build$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Feb__7_19:32:13_PST_2023
Cuda compilation tools, release 12.1, V12.1.66
Metadata
Metadata
Assignees
Labels
No labels
Activity
wsmoses commentedon Apr 3, 2024
cc @ivanradanov
So the support being partial comes from LLVM upstream.
It looks like here the issue is a header is missing, can you run find on your build dir to see if it was built anywhere?
ivanradanov commentedon Apr 3, 2024
The partial support works for my machine.
Your issue here is that you need to point Polygeist to the correct clang resource dir, which would be
$LLVM_BUILD_DIR/lib/clang/18using--resource-dir=$LLVM_BUILD_DIR/lib/clang/18. I agree that this is under documented and should probably be handled automatically.We need better support for installing polygeist and having it properly set up include paths link paths etc, need to look into how clang does it... But for the meantime better documentation would be nice...
ivanradanov commentedon Apr 4, 2024
You are getting an empty module, can you try removing
-function=matmulfrom the arguments? (that would limit polygeist to only compiling the functions calledmatmul.)nyck33 commentedon Apr 4, 2024
@ivanradanov I'm sorry I deleted that as I realized some errors but here is fuller output incorporating your advice:
ivanradanov commentedon Apr 4, 2024
If you would like to see MLIR (raised to affine) you need
-S -raise-scf-to-affinenyck33 commentedon Apr 4, 2024
I'll have to study more to understand why I need to output assembly in order to raise to affine. Thanks though.
Regarding that error "Failed to emit LLVM IR" is "LVM IR: missing 'LLVMTranslationDialectInterface' registration for dialect for op: gpu.block_id, suggests that the operation gpu.block_id cannot be translated into LLVM IR due to a missing interface registration. This typically occurs when the MLIR to LLVM IR conversion infrastructure doesn't have the necessary mappings or handlers to translate MLIR GPU dialect operations to their corresponding LLVM IR representations." the gist of it and I need to go back and check what happened during step 1 of the build which was "build LLVM, MLIR and Clang"?
ivanradanov commentedon Apr 4, 2024
So, this is Polygeist specific, but in order to emit GPU executables we require the programmer to explicitly specify the target on the command line as such:
-emit-cuda. This is because we can also do-emit-rocm, and the compiler needs to know whether to translategpu.block_idto the CUDA or AMD intrinsic. (we can also translate to CPU too)ivanradanov commentedon Apr 4, 2024
As for
-S, you only need that if you want to see the MLIR at the point after it was raised to affine. Otherwise, it will be raised to affine, some optimizations done on that level and then lowered down to llvm and so on.nyck33 commentedon Apr 4, 2024
Thanks @ivanradanov for all the tips. This is an amazing library bridging the gap for people like me with some Cuda background learning mlir.
For any other beginners like me, I just discovered this in the MLIR discord channel:
https://github.com/j2kun/mlir-tutorial so that's next for me.
pal-stdr commentedon Apr 8, 2024
Hello @ivanradanov
Sorry to interrupt! I have just two questions which I think related to this issue thread.
Clang 18.1.x? When I am writing this, i can see the latestllvmrelease is18.1.3.CUDA 12.1, that means it should also work forCUDA 12.2. Am I correct?Thanks in advance!
ivanradanov commentedon Apr 9, 2024
We do not support llvm release 18. The 18 in that string indicates that release 18 is in development (or released) on that specific commit.
We only support the specific llvm commit the git submodule points to.
I believe it may work for cuda 12, but that specific PR you linked is unrelated and on our ROCm end.