[Mlir-commits] [mlir] [mlir] Add `mlir_arm_runner_utils` library for use in integration tests (PR #78583)

Benjamin Maxwell llvmlistbot at llvm.org
Fri Jan 19 02:51:26 PST 2024


================
@@ -0,0 +1,60 @@
+//===- ArmRunnerUtils.cpp - Utilities for configuring architecture properties //
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include <iostream>
+#include <stdint.h>
+#include <string_view>
+
+#if (defined(_WIN32) || defined(__CYGWIN__))
+#define MLIR_ARMRUNNERUTILS_EXPORTED __declspec(dllexport)
+#else
+#define MLIR_ARMRUNNERUTILS_EXPORTED __attribute__((visibility("default")))
+#endif
+
+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
+extern "C" {
+
+#define PR_VL_LEN_MASK 0xffff
+
+#ifndef PR_SVE_SET_VL
+#define PR_SVE_SET_VL 50
+#endif
+
+#ifndef PR_SME_SET_VL
+#define PR_SME_SET_VL 63
+#endif
+
+static void setArmVectorLength(std::string_view helper_name, int option,
+                               int bits) {
+#if defined(__linux__) && defined(__aarch64__)
+  if (bits < 128 || bits % 128 != 0 || bits > 2048) {
----------------
MacDue wrote:

The `prctl()` is more relaxed and will pick the nearest available vector size. 
Though... QEMU just lets you have `vscale = 3` :sweat_smile: 
```
%c384 = arith.constant 384 : i32
func.call @setArmVLBits(%c384) : (i32) -> ()
func.call @checkVScale() : () -> ()
%vec = llvm.intr.experimental.stepvector : vector<[4]xi32>
vector.print %vec : vector<[4]xi32>
```
->

```
vscale
3
( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 )
```
 

https://github.com/llvm/llvm-project/pull/78583


More information about the Mlir-commits mailing list