Repository navigation
Initial commit to add experimental ROCM backend - #5881
Conversation
| #ifndef IREE_COMPILER_CONVERSION_LINALGTOLLVMGPU_LLVMGPUCODEGENOPTIONS_H_ | ||
| #define IREE_COMPILER_CONVERSION_LINALGTOLLVMGPU_LLVMGPUCODEGENOPTIONS_H_ | ||
|
|
||
| #include "llvm/ADT/SmallVector.h" |
There was a problem hiding this comment.
Doesn't look like it should be needed here.
There was a problem hiding this comment.
Thanks will remove.
| LogicalResult matchAndRewrite( | ||
| Operation *op, ArrayRef<Value> operands, | ||
| ConversionPatternRewriter &rewriter) const override; | ||
| }; |
There was a problem hiding this comment.
Let's move those pattern in the cpp file and expose populate* functions only
| #ifndef IREE_COMPILER_CONVERSION_LINALGTOLLVMGPU_LLVMGPUCODEGENOPTIONS_H_ | ||
| #define IREE_COMPILER_CONVERSION_LINALGTOLLVMGPU_LLVMGPUCODEGENOPTIONS_H_ | ||
|
|
||
| #include "llvm/ADT/SmallVector.h" |
There was a problem hiding this comment.
thanks will remove
| /// A pattern to convert hal.interface.workgroup.id/count/size into | ||
| /// corresponding NVVM/ROCDL ops. | ||
| template <typename InterfaceOpTy, typename XOp, typename YOp, typename ZOp> | ||
| struct HALInterfaceWorkgroupOpsConverter final |
There was a problem hiding this comment.
We should lower to GPU dialect IDs, so that we don't need different behavior between NVVM and ROCDL. I think it is fine to do as one of the first step of ConvertToNVVM/ConvertToROCDL this way we don't have to keep this pattern in the header. Later we'll probably want to do it earlier.
There was a problem hiding this comment.
That's a good idea. Sure will keep this as is for now then. Should I create an issue for the lowering to GPU dialect IDs so that it is tracked as one of the next work items?
| @@ -0,0 +1,104 @@ | |||
| // Copyright 2021 Nod Labs | |||
| // Copyright 2021 Google LLC | |||
There was a problem hiding this comment.
Can we pick a more specific file name than Common.cpp? Maybe ConvertToLLVMCommon.cpp or just ConverToLLVM.cpp?
There was a problem hiding this comment.
Sure I will rename it ConvertToLLVM.cpp
| namespace IREE { | ||
| namespace HAL { | ||
|
|
||
| ROCMTargetOptions getROCMTargetOptionsFromFlags() { |
There was a problem hiding this comment.
We could probably have a common class between CUDA and ROCM and inherit from it. This could be done later if we don't know how much is going to be shared.
There was a problem hiding this comment.
I think that's a good idea but currently I do not know how much will be shared. Yes, let's keep that decision late-binding and we can revisit when we have more information.
| @@ -0,0 +1,104 @@ | |||
| // Copyright 2021 Nod Labs | |||
There was a problem hiding this comment.
I think these additional copyright notices might cause problems for us (at the least I will need to contact lawyers before proceeding 😕 ). IANAL, but my understanding from https://opensource.google/docs/releasing/contributions/#copyright is that the presence of them doesn't actually affect the contributors rights in any way, so if you're ok with just leaving this off, that would be my preference. Otherwise, I can contact our licensing team to discuss the options.
There was a problem hiding this comment.
Sure that's fine. I can remove the Nod Labs copyright headers from this patch.
There was a problem hiding this comment.
Removed my blocking review, but I'll let Thomas review for actual content
| namespace mlir { | ||
| namespace iree_compiler { | ||
|
|
||
| namespace { |
There was a problem hiding this comment.
Let's keep the patterns in an anonymous namespace.
|
|
||
| void buildTranslationPassPipeline(OpPassManager &passManager) override { | ||
| auto codeGenOptions = getLLVMGPUCodegenOptionsFromClOptions(); | ||
| buildLLVMGPUTransformPassPipeline(passManager, codeGenOptions); |
There was a problem hiding this comment.
So the only way to get the correct is to have the right command option? We should always target AMDGPU from here, why not pass the right option?
There was a problem hiding this comment.
Yes looks like we can probably do away with LLVMGPUCodegenOptions completely. I will rework the patch to address that.
|
|
||
| void buildTranslationPassPipeline(OpPassManager &passManager) override { | ||
| buildNVVMTransformPassPipeline(passManager); | ||
| auto codeGenOptions = getLLVMGPUCodegenOptionsFromClOptions(); |
There was a problem hiding this comment.
Same here we should pass the right option.
| OwningRewritePatternList &patterns, | ||
| LLVMTypeConverter &converter) { | ||
| patterns.insert<ConvertFunc, ConvertIREEBindingOp>(context, converter); | ||
| auto codeGenOptions = getLLVMGPUCodegenOptionsFromClOptions(); |
There was a problem hiding this comment.
we shouldn't get the option from command line here, it should be passed by the caller.
There was a problem hiding this comment.
makes sense, will modify the function signature appropriately
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
This patch adds the compiler passes to lower linalg to ROCDL and adds the ROCMTarget. The code follows the CUDA backend closely.
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
Initial pass to integrate ROCm in to IREE so that we can Codegen and run on AMDGPUs. Following steps similar to thomasraoux's CUDA backend. Since ROCm do not have graph or CommandBuffer by default, we implement ROCm's command buffer with Arrays. Tested out and pass most CTS tests except: semaphore_submission_test + semaphore_test-> some functionalities not implemented for rocm backend yet command_buffer_test -> some quirk with hipErrorNotInitialized during launch of kernel + CommandBufferTest.CopySubBuffer **-Does depend on harsh-nod's [PR](iree-org#5881 In the next patch: -Complete semaphore functionality -Squash CommandBuffer bugs
This patch adds the compiler passes to lower linalg to
ROCDL and adds the ROCMTarget. The code follows the CUDA
backend closely.