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
Show file tree
Hide file tree
Changes from 13 commits
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
7 changes: 7 additions & 0 deletions src/coreclr/vm/arm64/asmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ LEAF_ENTRY GetDataCacheZeroIDReg, _TEXT
ret lr
LEAF_END GetDataCacheZeroIDReg, _TEXT

// DWORD64 __stdcall GetSveLengthFromOS(void);
jkotas marked this conversation as resolved.
Show resolved Hide resolved
.arch_extension sve
LEAF_ENTRY GetSveLengthFromOS, _TEXT
rdvl x0, 1
ret lr
LEAF_END GetSveLengthFromOS, _TEXT

//-----------------------------------------------------------------------------
// This routine captures the machine state. It is used by helper method frame
//-----------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/vm/arm64/asmhelpers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
ret lr
LEAF_END

;; DWORD64 __stdcall GetSveLengthFromOS(void);
jkotas marked this conversation as resolved.
Show resolved Hide resolved
LEAF_ENTRY GetSveLengthFromOS
rdvl x0, 1
SwapnilGaikwad marked this conversation as resolved.
Show resolved Hide resolved
ret lr
LEAF_END

;;-----------------------------------------------------------------------------
;; This routine captures the machine state. It is used by helper method frame
;;-----------------------------------------------------------------------------
Expand Down
15 changes: 11 additions & 4 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,12 +1257,12 @@ void EEJitManager::SetCpuInfo()

int cpuFeatures = minipal_getcpufeatures();

#if defined(TARGET_X86) || defined(TARGET_AMD64)
CPUCompileFlags.Set(InstructionSet_VectorT128);

// Get the maximum bitwidth of Vector<T>, rounding down to the nearest multiple of 128-bits
uint32_t maxVectorTBitWidth = (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_MaxVectorTBitWidth) / 128) * 128;
SwapnilGaikwad marked this conversation as resolved.
Show resolved Hide resolved

#if defined(TARGET_X86) || defined(TARGET_AMD64)
CPUCompileFlags.Set(InstructionSet_VectorT128);

if (((cpuFeatures & XArchIntrinsicConstants_Avx2) != 0) && ((maxVectorTBitWidth == 0) || (maxVectorTBitWidth >= 256)))
{
// We allow 256-bit Vector<T> by default
Expand Down Expand Up @@ -1514,7 +1514,14 @@ void EEJitManager::SetCpuInfo()

if (((cpuFeatures & ARM64IntrinsicConstants_Sve) != 0) && CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableArm64Sve))
{
CPUCompileFlags.Set(InstructionSet_Sve);
uint32_t maxVectorTLength = (maxVectorTBitWidth / 8);
uint64_t sveLengthFromOS = GetSveLengthFromOS();

// Do not enable SVE when the user specified vector length is smaller than the one offered by underlying OS.
if ((maxVectorTLength >= sveLengthFromOS) || (maxVectorTBitWidth == 0))
{
CPUCompileFlags.Set(InstructionSet_Sve);
}
}

// DCZID_EL0<4> (DZP) indicates whether use of DC ZVA instructions is permitted (0) or prohibited (1).
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/vm/codeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Module Name:
#include "gcinfo.h"
#include "eexcp.h"

#if defined(TARGET_ARM64)
extern "C" DWORD64 __stdcall GetSveLengthFromOS();
jkotas marked this conversation as resolved.
Show resolved Hide resolved
#endif

class MethodDesc;
class ICorJitCompiler;
class IJitManager;
Expand Down
Loading