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

Add option to change SVE vector length for current and children processes #101295

Merged
merged 18 commits into from
Jun 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use ACLE to detect vector length on Linux and hardcode on Windows
  • Loading branch information
SwapnilGaikwad committed May 3, 2024
commit 43ece1e83930e6a982a19d58744eb4c5920458a3
10 changes: 4 additions & 6 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
@@ -1525,14 +1525,12 @@ void EEJitManager::SetCpuInfo()

if (((cpuFeatures & ARM64IntrinsicConstants_Sve) != 0) && CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableArm64Sve))
{
int maxVectorLength = (maxVectorTBitWidth >> 3);
uint64_t systemVectorTLength = GetSystemVectorLength();
uint32_t maxVectorTLength = (maxVectorTBitWidth / 8);
uint64_t sveLengthFromOS = GetSveLengthFromOS();

if (maxVectorLength >= systemVectorTLength)
// Do not enable SVE when the user specified vector length is smaller than the one offered by underlying OS.
if ((maxVectorTLength >= sveLengthFromOS) || (maxVectorTBitWidth == 0))
{
// Enable SVE only when user specified vector length larger than or equal to the system
// vector length. When eabled, SVE would use full vector length available to the process.
// For a 256-bit machine, if user provides DOTNET_MaxVectorTBitWidth=128, disable SVE.
CPUCompileFlags.Set(InstructionSet_Sve);
}
}
22 changes: 16 additions & 6 deletions src/coreclr/vm/codeman.h
Original file line number Diff line number Diff line change
@@ -69,6 +69,10 @@ Module Name:
#include "gcinfo.h"
#include "eexcp.h"

#if defined(TARGET_ARM64) || defined(TARGET_LINUX)
#include <arm_sve.h>
#endif

class MethodDesc;
class ICorJitCompiler;
class IJitManager;
@@ -1912,15 +1916,21 @@ protected :
return m_CPUCompileFlags;
}

#ifdef __GNUC__
#if defined(TARGET_ARM64)
#if defined(TARGET_LINUX)
__attribute__((target("sve")))
#endif
inline UINT64 GetSystemVectorLength()
inline UINT64 GetSveLengthFromOS()
{
return svcntb();
}
#elif defined(TARGET_WINDOWS)
inline UINT64 GetSveLengthFromOS()
{
UINT64 size;
__asm__ __volatile__("cntb %0" : "=r"(size));
return size;
//TODO-SVE: SVE vector length is hardcoded to 128-bits on Windows until a suitable method is available.
return 16;
}
#endif // TARGET_LINUX
#endif // TARGET_ARM64

private:
bool m_storeRichDebugInfo;
Loading