diff options
author | Jan Leyonberg <jan_sjodin@yahoo.com> | 2024-09-04 11:29:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 11:29:10 -0400 |
commit | 3ebd79751f2d5e1c54047409865c051daba0a21b (patch) | |
tree | b420bea817b532cad487815ffae634d3b158ef5b /mlir/test/Conversion | |
parent | 3d9abfc9f841b13825e3d03cfba272f5eeab9a3b (diff) | |
download | llvm-3ebd79751f2d5e1c54047409865c051daba0a21b.zip llvm-3ebd79751f2d5e1c54047409865c051daba0a21b.tar.gz llvm-3ebd79751f2d5e1c54047409865c051daba0a21b.tar.bz2 |
[MLIR][ROCDL] Remove patterns for ops supported as intrinsics in the AMDGPU backend (#102971)
This patch removes patterns for a few operations which allows mathToLLVM
conversion to convert the operations into LLVM intrinsics instead since
they are supported directly by the AMDGPU backend.
Diffstat (limited to 'mlir/test/Conversion')
-rw-r--r-- | mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir | 86 | ||||
-rw-r--r-- | mlir/test/Conversion/MathToROCDL/math-to-rocdl.mlir | 44 |
2 files changed, 25 insertions, 105 deletions
diff --git a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir index bf49a42..b6fb085 100644 --- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir +++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir @@ -132,21 +132,6 @@ gpu.module @test_module { // ----- gpu.module @test_module { - // CHECK: llvm.func @__ocml_fabs_f32(f32) -> f32 - // CHECK: llvm.func @__ocml_fabs_f64(f64) -> f64 - // CHECK-LABEL: func @gpu_fabs - func.func @gpu_fabs(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %result32 = math.absf %arg_f32 : f32 - // CHECK: llvm.call @__ocml_fabs_f32(%{{.*}}) : (f32) -> f32 - %result64 = math.absf %arg_f64 : f64 - // CHECK: llvm.call @__ocml_fabs_f64(%{{.*}}) : (f64) -> f64 - func.return %result32, %result64 : f32, f64 - } -} - -// ----- - -gpu.module @test_module { // CHECK: llvm.func @__ocml_cbrt_f32(f32) -> f32 // CHECK: llvm.func @__ocml_cbrt_f64(f64) -> f64 // CHECK-LABEL: func @gpu_cbrt @@ -207,17 +192,12 @@ gpu.module @test_module { // ----- gpu.module @test_module { - // CHECK: llvm.func @__ocml_exp_f32(f32) -> f32 // CHECK: llvm.func @__ocml_exp_f64(f64) -> f64 // CHECK-LABEL: func @gpu_exp - func.func @gpu_exp(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %exp_f32 = math.exp %arg_f32 : f32 - // CHECK: llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 - %result32 = math.exp %exp_f32 : f32 - // CHECK: llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 + func.func @gpu_exp(%arg_f64 : f64) -> (f64) { %result64 = math.exp %arg_f64 : f64 // CHECK: llvm.call @__ocml_exp_f64(%{{.*}}) : (f64) -> f64 - func.return %result32, %result64 : f32, f64 + func.return %result64 : f64 } } @@ -239,21 +219,20 @@ gpu.module @test_module { } // ----- - // Test that we handled properly operation with SymbolTable other than module op gpu.module @test_module { "test.symbol_scope"() ({ // CHECK: test.symbol_scope - // CHECK: llvm.func @__ocml_exp_f32(f32) -> f32 - // CHECK: llvm.func @__ocml_exp_f64(f64) -> f64 - // CHECK-LABEL: func @gpu_exp - func.func @gpu_exp(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %exp_f32 = math.exp %arg_f32 : f32 - // CHECK: llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 - %result32 = math.exp %exp_f32 : f32 - // CHECK: llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 - %result64 = math.exp %arg_f64 : f64 - // CHECK: llvm.call @__ocml_exp_f64(%{{.*}}) : (f64) -> f64 + // CHECK: llvm.func @__ocml_sin_f32(f32) -> f32 + // CHECK: llvm.func @__ocml_sin_f64(f64) -> f64 + // CHECK-LABEL: func @gpu_sin + func.func @gpu_sin(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { + %sin_f32 = math.sin %arg_f32 : f32 + // CHECK: llvm.call @__ocml_sin_f32(%{{.*}}) : (f32) -> f32 + %result32 = math.sin %sin_f32 : f32 + // CHECK: llvm.call @__ocml_sin_f32(%{{.*}}) : (f32) -> f32 + %result64 = math.sin %arg_f64 : f64 + // CHECK: llvm.call @__ocml_sin_f64(%{{.*}}) : (f64) -> f64 func.return %result32, %result64 : f32, f64 } "test.finish" () : () -> () @@ -280,15 +259,12 @@ gpu.module @test_module { // ----- gpu.module @test_module { - // CHECK: llvm.func @__ocml_log_f32(f32) -> f32 // CHECK: llvm.func @__ocml_log_f64(f64) -> f64 // CHECK-LABEL: func @gpu_log - func.func @gpu_log(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %result32 = math.log %arg_f32 : f32 - // CHECK: llvm.call @__ocml_log_f32(%{{.*}}) : (f32) -> f32 + func.func @gpu_log(%arg_f64 : f64) -> (f64) { %result64 = math.log %arg_f64 : f64 // CHECK: llvm.call @__ocml_log_f64(%{{.*}}) : (f64) -> f64 - func.return %result32, %result64 : f32, f64 + func.return %result64 : f64 } } @@ -360,26 +336,6 @@ gpu.module @test_module { // ----- gpu.module @test_module { - // CHECK: llvm.func @__ocml_sqrt_f32(f32) -> f32 - // CHECK: llvm.func @__ocml_sqrt_f64(f64) -> f64 - // CHECK-LABEL: func @gpu_sqrt - func.func @gpu_sqrt(%arg_f16 : f16, %arg_f32 : f32, %arg_f64 : f64) - -> (f16, f32, f64) { - %result16 = math.sqrt %arg_f16 : f16 - // CHECK: llvm.fpext %{{.*}} : f16 to f32 - // CHECK-NEXT: llvm.call @__ocml_sqrt_f32(%{{.*}}) : (f32) -> f32 - // CHECK-NEXT: llvm.fptrunc %{{.*}} : f32 to f16 - %result32 = math.sqrt %arg_f32 : f32 - // CHECK: llvm.call @__ocml_sqrt_f32(%{{.*}}) : (f32) -> f32 - %result64 = math.sqrt %arg_f64 : f64 - // CHECK: llvm.call @__ocml_sqrt_f64(%{{.*}}) : (f64) -> f64 - func.return %result16, %result32, %result64 : f16, f32, f64 - } -} - -// ----- - -gpu.module @test_module { // CHECK: llvm.func @__ocml_tan_f32(f32) -> f32 // CHECK: llvm.func @__ocml_tan_f64(f64) -> f64 // CHECK-LABEL: func @gpu_tan @@ -472,15 +428,15 @@ gpu.module @test_module { gpu.module @test_module { // CHECK-LABEL: func @gpu_unroll func.func @gpu_unroll(%arg0 : vector<4xf32>) -> vector<4xf32> { - %result = math.exp %arg0 : vector<4xf32> + %result = math.sin %arg0 : vector<4xf32> // CHECK: %[[V0:.+]] = llvm.mlir.undef : vector<4xf32> - // CHECK: %[[CL:.+]] = llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 + // CHECK: %[[CL:.+]] = llvm.call @__ocml_sin_f32(%{{.*}}) : (f32) -> f32 // CHECK: %[[V1:.+]] = llvm.insertelement %[[CL]], %[[V0]] - // CHECK: %[[CL:.+]] = llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 + // CHECK: %[[CL:.+]] = llvm.call @__ocml_sin_f32(%{{.*}}) : (f32) -> f32 // CHECK: %[[V2:.+]] = llvm.insertelement %[[CL]], %[[V1]] - // CHECK: %[[CL:.+]] = llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 + // CHECK: %[[CL:.+]] = llvm.call @__ocml_sin_f32(%{{.*}}) : (f32) -> f32 // CHECK: %[[V3:.+]] = llvm.insertelement %[[CL]], %[[V2]] - // CHECK: %[[CL:.+]] = llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 + // CHECK: %[[CL:.+]] = llvm.call @__ocml_sin_f32(%{{.*}}) : (f32) -> f32 // CHECK: %[[V4:.+]] = llvm.insertelement %[[CL]], %[[V3]] // CHECK: return %[[V4]] func.return %result : vector<4xf32> @@ -526,9 +482,9 @@ gpu.module @test_module { gpu.module @module { // CHECK-LABEL: @spirv_exp -// CHECK: llvm.call @__ocml_exp_f32 +// CHECK: llvm.call @__ocml_sin_f32 spirv.func @spirv_exp(%arg0: vector<4xf32>) -> vector<4xf32> "None" { - %0 = math.exp %arg0 : vector<4xf32> + %0 = math.sin %arg0 : vector<4xf32> spirv.ReturnValue %0 : vector<4xf32> } } diff --git a/mlir/test/Conversion/MathToROCDL/math-to-rocdl.mlir b/mlir/test/Conversion/MathToROCDL/math-to-rocdl.mlir index a406ec4..19d89e0 100644 --- a/mlir/test/Conversion/MathToROCDL/math-to-rocdl.mlir +++ b/mlir/test/Conversion/MathToROCDL/math-to-rocdl.mlir @@ -16,21 +16,6 @@ module @test_module { // ----- module @test_module { - // CHECK: llvm.func @__ocml_fabs_f32(f32) -> f32 - // CHECK: llvm.func @__ocml_fabs_f64(f64) -> f64 - // CHECK-LABEL: func @math_absf - func.func @math_absf(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %result32 = math.absf %arg_f32 : f32 - // CHECK: llvm.call @__ocml_fabs_f32(%{{.*}}) : (f32) -> f32 - %result64 = math.absf %arg_f64 : f64 - // CHECK: llvm.call @__ocml_fabs_f64(%{{.*}}) : (f64) -> f64 - func.return %result32, %result64 : f32, f64 - } -} - -// ----- - -module @test_module { // CHECK: llvm.func @__ocml_acos_f32(f32) -> f32 // CHECK: llvm.func @__ocml_acos_f64(f64) -> f64 // CHECK-LABEL: func @math_acos @@ -211,15 +196,12 @@ module @test_module { // ----- module @test_module { - // CHECK: llvm.func @__ocml_exp_f32(f32) -> f32 // CHECK: llvm.func @__ocml_exp_f64(f64) -> f64 // CHECK-LABEL: func @math_exp - func.func @math_exp(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %result32 = math.exp %arg_f32 : f32 - // CHECK: llvm.call @__ocml_exp_f32(%{{.*}}) : (f32) -> f32 + func.func @math_exp(%arg_f64 : f64) -> (f64) { %result64 = math.exp %arg_f64 : f64 // CHECK: llvm.call @__ocml_exp_f64(%{{.*}}) : (f64) -> f64 - func.return %result32, %result64 : f32, f64 + func.return %result64 : f64 } } @@ -271,15 +253,12 @@ module @test_module { // ----- module @test_module { - // CHECK: llvm.func @__ocml_log_f32(f32) -> f32 // CHECK: llvm.func @__ocml_log_f64(f64) -> f64 // CHECK-LABEL: func @math_log - func.func @math_log(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %result32 = math.log %arg_f32 : f32 - // CHECK: llvm.call @__ocml_log_f32(%{{.*}}) : (f32) -> f32 + func.func @math_log(%arg_f64 : f64) -> (f64) { %result64 = math.log %arg_f64 : f64 // CHECK: llvm.call @__ocml_log_f64(%{{.*}}) : (f64) -> f64 - func.return %result32, %result64 : f32, f64 + func.return %result64 : f64 } } @@ -361,21 +340,6 @@ module @test_module { // ----- module @test_module { - // CHECK: llvm.func @__ocml_sqrt_f32(f32) -> f32 - // CHECK: llvm.func @__ocml_sqrt_f64(f64) -> f64 - // CHECK-LABEL: func @math_sqrt - func.func @math_sqrt(%arg_f32 : f32, %arg_f64 : f64) -> (f32, f64) { - %result32 = math.sqrt %arg_f32 : f32 - // CHECK: llvm.call @__ocml_sqrt_f32(%{{.*}}) : (f32) -> f32 - %result64 = math.sqrt %arg_f64 : f64 - // CHECK: llvm.call @__ocml_sqrt_f64(%{{.*}}) : (f64) -> f64 - func.return %result32, %result64 : f32, f64 - } -} - -// ----- - -module @test_module { // CHECK: llvm.func @__ocml_tanh_f32(f32) -> f32 // CHECK: llvm.func @__ocml_tanh_f64(f64) -> f64 // CHECK-LABEL: func @math_tanh |