9 #include "llvm/Support/MathExtras.h"
12 #include <string_view>
14 #if (defined(_WIN32) || defined(__CYGWIN__))
15 #define MLIR_ARMRUNNERUTILS_EXPORTED __declspec(dllexport)
17 #define MLIR_ARMRUNNERUTILS_EXPORTED __attribute__((visibility("default")))
21 #include <sys/prctl.h>
31 #define PR_SVE_SET_VL 50
35 #define PR_SME_SET_VL 63
39 #define PR_VL_LEN_MASK 0xffff
43 #if defined(__linux__) && defined(__aarch64__)
44 if (bits < 128 || bits > 2048 || !llvm::isPowerOf2_32(bits)) {
45 std::cerr <<
"[error] Attempted to set an invalid vector length (" << bits
46 <<
"-bit)" << std::endl;
49 uint32_t vl = bits / 8;
51 std::cerr <<
"[error] prctl failed (" << ret <<
")" << std::endl;
55 std::cerr <<
"[error] " << helper_name <<
" is unsupported" << std::endl;
#define MLIR_ARMRUNNERUTILS_EXPORTED
void MLIR_ARMRUNNERUTILS_EXPORTED setArmSVLBits(uint32_t bits)
Sets the SME streaming vector length (in bits) to bits.
void MLIR_ARMRUNNERUTILS_EXPORTED setArmVLBits(uint32_t bits)
Sets the SVE vector length (in bits) to bits.
static void setArmVectorLength(std::string_view helper_name, int option, uint32_t bits)