Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][ArmSME][test] Make use of arm_sme.streaming_vl (NFC) #77322

Merged
merged 1 commit into from Jan 11, 2024

Conversation

MacDue
Copy link
Member

@MacDue MacDue commented Jan 8, 2024

No description provided.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 10, 2024

@llvm/pr-subscribers-mlir-linalg

@llvm/pr-subscribers-mlir-sme

Author: Benjamin Maxwell (MacDue)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/77322.diff

7 Files Affected:

  • (modified) mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir (+1-4)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir (+1-3)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir (+1-8)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir (+1-8)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir (+1-3)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir (+2-8)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir (+1-4)
diff --git a/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir b/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir
index 81546de6a3466b..6314e6f279952b 100644
--- a/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir
+++ b/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir
@@ -20,12 +20,9 @@ func.func @entry() {
 
   %c123_f32 = arith.constant 123.0 : f32
 
-  %min_elts_s = arith.constant 4 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_s" the number of
   // 32-bit elements in a vector of SVL bits.
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
 
   %tile_init = bufferization.alloc_tensor(%svl_s, %svl_s) : tensor<?x?xf32>
 
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir
index 936163d1cd30d9..064141c349241e 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir
@@ -17,9 +17,7 @@ func.func @entry() {
   %c1_i32 = arith.constant 1 : i32
 
   // Calculate the size of a 32-bit tile, e.g. ZA{n}.s.
-  %vscale = vector.vscale
-  %min_elts_s = arith.constant 4 : index
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
   %za_s_size = arith.muli %svl_s, %svl_s : index
 
   // Allocate memory.
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir
index 839aed2e840c90..6e028d5fb83614 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir
@@ -134,12 +134,6 @@ func.func @initialize_memory(%d0 : index, %d1 : index) -> memref<?x?xf32> {
   return %A : memref<?x?xf32>
 }
 
-// This will be made a streaming function by enable-arm-streaming so return SVL.
-func.func @get_svl() -> index {
-  %vscale = vector.vscale
-  return %vscale : index
-}
-
 func.func @entry() {
   %c0 = arith.constant 0 : index
   %c1 = arith.constant 1 : index
@@ -148,8 +142,7 @@ func.func @entry() {
 
   // Allocate enough memory to load a 32-bit tile plus a tiny bit more to test
   // non-zero offsets while remaining inbounds.
-  %svl = call @get_svl() : () -> index
-  %svl_s = arith.muli %c4, %svl : index
+  %svl_s = arm_sme.streaming_vl <word>
   %svl_s_plus_two = arith.addi %svl_s, %c2 : index
 
   %A = call @initialize_memory(%svl_s_plus_two, %svl_s_plus_two) : (index, index) -> memref<?x?xf32>
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir
index 84246606daa8af..cb30fee4e12d72 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir
@@ -96,12 +96,6 @@ func.func @initialize_memory(%d0 : index, %d1 : index) -> memref<?x?xf32> {
   return %A : memref<?x?xf32>
 }
 
-// This will be made a streaming function by enable-arm-streaming so return SVL.
-func.func @get_svl() -> index {
-  %vscale = vector.vscale
-  return %vscale : index
-}
-
 func.func @entry() {
   %c0 = arith.constant 0 : index
   %c2 = arith.constant 2 : index
@@ -111,8 +105,7 @@ func.func @entry() {
   //
   // Allocate enough memory to load a 32-bit tile plus a tiny bit more to test
   // non-zero offsets while remaining inbounds.
-  %svl = call @get_svl() : () -> index
-  %svl_s = arith.muli %c4, %svl : index
+  %svl_s = arm_sme.streaming_vl <word>
   %svl_s_plus_two = arith.addi %svl_s, %c2 : index
   %A = call @initialize_memory(%svl_s_plus_two, %svl_s_plus_two) : (index, index) -> memref<?x?xf32>
 
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir
index 2751c2d136485e..eee3c56351d81e 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir
@@ -17,9 +17,7 @@ func.func @entry() {
   %c1_i32 = arith.constant 1 : i32
 
   // Calculate the size of a 32-bit tile, e.g. ZA{n}.s.
-  %vscale = vector.vscale
-  %min_elts_s = arith.constant 4 : index
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
   %za_s_size = arith.muli %svl_s, %svl_s : index
 
   // Allocate memory.
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir
index 5d2d0a73992f1e..2f151e2ec72fb7 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir
@@ -24,12 +24,9 @@ func.func @za0_d_f64() -> i32 {
   %c1_f64 = arith.constant 1.0 : f64
   %c1_index = arith.constant 1 : index
 
-  %min_elts_d = arith.constant 2 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_d" the number of
   // 64-bit elements in a vector of SVL bits.
-  %svl_d = arith.muli %min_elts_d, %vscale : index
+  %svl_d = arm_sme.streaming_vl <double>
 
   // Allocate "mem1" and fill each "row" with row number.
   //
@@ -170,13 +167,10 @@ func.func @load_store_two_za_s_tiles() -> i32 {
   %c1_index = arith.constant 1 : index
   %c2_index = arith.constant 2 : index
 
-  %min_elts_s = arith.constant 4 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_s" can mean either:
   // * the number of 32-bit elements in a vector of SVL bits.
   // * the number of tile slices (1d vectors) in a 32-bit element tile.
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
 
   // Allocate memory for two 32-bit element tiles.
   %size_of_tile = arith.muli %svl_s, %svl_s : index
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir
index af5fe236e5bd57..073c08bff1c415 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir
@@ -14,12 +14,9 @@ func.func @entry() -> i32 {
   %c1_i8 = arith.constant 1 : i8
   %c1_index = arith.constant 1 : index
 
-  %c16 = arith.constant 16 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_b" the number of
   // 8-bit elements in a vector of SVL bits.
-  %svl_b = arith.muli %c16, %vscale : index
+  %svl_b = arm_sme.streaming_vl <byte>
 
   // Allocate memory and fill with ones.
   //

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 10, 2024

@llvm/pr-subscribers-mlir-vector

Author: Benjamin Maxwell (MacDue)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/77322.diff

7 Files Affected:

  • (modified) mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir (+1-4)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir (+1-3)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir (+1-8)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir (+1-8)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir (+1-3)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir (+2-8)
  • (modified) mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir (+1-4)
diff --git a/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir b/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir
index 81546de6a3466b..6314e6f279952b 100644
--- a/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir
+++ b/mlir/test/Integration/Dialect/Linalg/CPU/ArmSME/fill-2d.mlir
@@ -20,12 +20,9 @@ func.func @entry() {
 
   %c123_f32 = arith.constant 123.0 : f32
 
-  %min_elts_s = arith.constant 4 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_s" the number of
   // 32-bit elements in a vector of SVL bits.
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
 
   %tile_init = bufferization.alloc_tensor(%svl_s, %svl_s) : tensor<?x?xf32>
 
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir
index 936163d1cd30d9..064141c349241e 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-load-vertical.mlir
@@ -17,9 +17,7 @@ func.func @entry() {
   %c1_i32 = arith.constant 1 : i32
 
   // Calculate the size of a 32-bit tile, e.g. ZA{n}.s.
-  %vscale = vector.vscale
-  %min_elts_s = arith.constant 4 : index
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
   %za_s_size = arith.muli %svl_s, %svl_s : index
 
   // Allocate memory.
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir
index 839aed2e840c90..6e028d5fb83614 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-read-2d.mlir
@@ -134,12 +134,6 @@ func.func @initialize_memory(%d0 : index, %d1 : index) -> memref<?x?xf32> {
   return %A : memref<?x?xf32>
 }
 
-// This will be made a streaming function by enable-arm-streaming so return SVL.
-func.func @get_svl() -> index {
-  %vscale = vector.vscale
-  return %vscale : index
-}
-
 func.func @entry() {
   %c0 = arith.constant 0 : index
   %c1 = arith.constant 1 : index
@@ -148,8 +142,7 @@ func.func @entry() {
 
   // Allocate enough memory to load a 32-bit tile plus a tiny bit more to test
   // non-zero offsets while remaining inbounds.
-  %svl = call @get_svl() : () -> index
-  %svl_s = arith.muli %c4, %svl : index
+  %svl_s = arm_sme.streaming_vl <word>
   %svl_s_plus_two = arith.addi %svl_s, %c2 : index
 
   %A = call @initialize_memory(%svl_s_plus_two, %svl_s_plus_two) : (index, index) -> memref<?x?xf32>
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir
index 84246606daa8af..cb30fee4e12d72 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transfer-write-2d.mlir
@@ -96,12 +96,6 @@ func.func @initialize_memory(%d0 : index, %d1 : index) -> memref<?x?xf32> {
   return %A : memref<?x?xf32>
 }
 
-// This will be made a streaming function by enable-arm-streaming so return SVL.
-func.func @get_svl() -> index {
-  %vscale = vector.vscale
-  return %vscale : index
-}
-
 func.func @entry() {
   %c0 = arith.constant 0 : index
   %c2 = arith.constant 2 : index
@@ -111,8 +105,7 @@ func.func @entry() {
   //
   // Allocate enough memory to load a 32-bit tile plus a tiny bit more to test
   // non-zero offsets while remaining inbounds.
-  %svl = call @get_svl() : () -> index
-  %svl_s = arith.muli %c4, %svl : index
+  %svl_s = arm_sme.streaming_vl <word>
   %svl_s_plus_two = arith.addi %svl_s, %c2 : index
   %A = call @initialize_memory(%svl_s_plus_two, %svl_s_plus_two) : (index, index) -> memref<?x?xf32>
 
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir
index 2751c2d136485e..eee3c56351d81e 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/test-transpose.mlir
@@ -17,9 +17,7 @@ func.func @entry() {
   %c1_i32 = arith.constant 1 : i32
 
   // Calculate the size of a 32-bit tile, e.g. ZA{n}.s.
-  %vscale = vector.vscale
-  %min_elts_s = arith.constant 4 : index
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
   %za_s_size = arith.muli %svl_s, %svl_s : index
 
   // Allocate memory.
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir
index 5d2d0a73992f1e..2f151e2ec72fb7 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-load-store.mlir
@@ -24,12 +24,9 @@ func.func @za0_d_f64() -> i32 {
   %c1_f64 = arith.constant 1.0 : f64
   %c1_index = arith.constant 1 : index
 
-  %min_elts_d = arith.constant 2 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_d" the number of
   // 64-bit elements in a vector of SVL bits.
-  %svl_d = arith.muli %min_elts_d, %vscale : index
+  %svl_d = arm_sme.streaming_vl <double>
 
   // Allocate "mem1" and fill each "row" with row number.
   //
@@ -170,13 +167,10 @@ func.func @load_store_two_za_s_tiles() -> i32 {
   %c1_index = arith.constant 1 : index
   %c2_index = arith.constant 2 : index
 
-  %min_elts_s = arith.constant 4 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_s" can mean either:
   // * the number of 32-bit elements in a vector of SVL bits.
   // * the number of tile slices (1d vectors) in a 32-bit element tile.
-  %svl_s = arith.muli %min_elts_s, %vscale : index
+  %svl_s = arm_sme.streaming_vl <word>
 
   // Allocate memory for two 32-bit element tiles.
   %size_of_tile = arith.muli %svl_s, %svl_s : index
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir
index af5fe236e5bd57..073c08bff1c415 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSME/vector-ops.mlir
@@ -14,12 +14,9 @@ func.func @entry() -> i32 {
   %c1_i8 = arith.constant 1 : i8
   %c1_index = arith.constant 1 : index
 
-  %c16 = arith.constant 16 : index
-  %vscale = vector.vscale
-
   // "svl" refers to the Streaming Vector Length and "svl_b" the number of
   // 8-bit elements in a vector of SVL bits.
-  %svl_b = arith.muli %c16, %vscale : index
+  %svl_b = arm_sme.streaming_vl <byte>
 
   // Allocate memory and fill with ones.
   //

Copy link
Collaborator

@c-rhodes c-rhodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! LGTM cheers

Copy link
Contributor

@banach-space banach-space left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the clean-up!

This does make me think that we should introduce some tests comparing SVE and SSVE.

@MacDue MacDue merged commit dc97457 into llvm:main Jan 11, 2024
10 of 11 checks passed
@MacDue MacDue deleted the streaming_vl_nfc branch January 11, 2024 10:24
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants