Skip to content

Commit 2937557

Browse files
SwapnilGaikwada74nh
authored andcommitted
Add option to change SVE vector length for current and children processes.
TEST_LABEL: ent-arch-aarch64 TEST_IMG: ubuntu/dotnet-build TEST_CMD: safe ./projects/dotnet/test-runtime.sh --scope coreclr,libs Jira: ENTLLT-7328 Change-Id: I727edf8652a5c8648e7008d4ca47e7a4f36d5a1e
1 parent 901c200 commit 2937557

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/coreclr/inc/clrconfigvalues.h

+4
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,10 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Sha256, W("EnableArm64Sh
790790
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Rcpc, W("EnableArm64Rcpc"), 1, "Allows Arm64 Rcpc+ hardware intrinsics to be disabled")
791791
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Rcpc2, W("EnableArm64Rcpc2"), 1, "Allows Arm64 Rcpc2+ hardware intrinsics to be disabled")
792792
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableArm64Sve, W("EnableArm64Sve"), 1, "Allows Arm64 SVE hardware intrinsics to be disabled")
793+
#if defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG))
794+
// TODO-SVE: Once coreclr supports vector lengths >16bytes, the default should be -1.
795+
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_MaxVectorLength, W("MaxVectorLength"), 16, "Specifies maximum size of the vector length in bytes while using SVE on Arm64", CLRConfig::LookupOptions::ParseIntegerAsBase10)
796+
#endif //defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG))
793797
#endif
794798

795799
///

src/coreclr/vm/codeman.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
//
55
// codeman.cpp - a managment class for handling multiple code managers
66
//
7-
7+
#if defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG))
8+
#include <sys/prctl.h>
9+
#include <sys/syscall.h>
10+
#endif // defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG))
811
#include "common.h"
912
#include "jitinterface.h"
1013
#include "corjit.h"
@@ -1525,6 +1528,18 @@ void EEJitManager::SetCpuInfo()
15251528

15261529
if (((cpuFeatures & ARM64IntrinsicConstants_Sve) != 0) && CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableArm64Sve))
15271530
{
1531+
#if defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG))
1532+
int maxVectorLength = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_MaxVectorLength);
1533+
1534+
// Limit the SVE vector length to 'maxVectorLength' if the underlying hardware offers longer vectors.
1535+
if ((prctl(PR_SVE_GET_VL, 0,0,0,0) & PR_SVE_VL_LEN_MASK) > maxVectorLength)
1536+
{
1537+
if (prctl(PR_SVE_SET_VL, (maxVectorLength | PR_SVE_VL_INHERIT), 0, 0, 0) == -1)
1538+
{
1539+
LogErrorToHost("LoadAndInitializeJIT: prctl() FAILED - unable to set maxVectorLength to %d", maxVectorLength);
1540+
}
1541+
}
1542+
#endif // defined(TARGET_LINUX) && (defined(DEBUG) || defined(_DEBUG))
15281543
CPUCompileFlags.Set(InstructionSet_Sve);
15291544
}
15301545

0 commit comments

Comments
 (0)