Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
[Arm64] Enable SIMD (#14633)
Browse files Browse the repository at this point in the history
* [Arm64] EXTERNAL_FeatureSIMD_Default = 1

* [Arm64] Enable SIMD compilation

* [Arm64] Enable SIMD in crossgen

* [Arm64] Allow SIMD in altjit

Add flag SIMD16ByteOnly
Set COMPlus_SIMD16ByteOnly=1 in x64_arm64_altjit.cmd
If SIMD16ByteOnly, limit clear FLAG_USE_AVX2 to disable SIMD32 vector size
Enable SIMD in protonjit

* Fix #if per feedback
  • Loading branch information
sdmaclea authored and BruceForstall committed Dec 5, 2017
1 parent cced4d7 commit 2b9e70f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/inc/clrconfigvalues.h
Expand Up @@ -529,14 +529,18 @@ CONFIG_DWORD_INFO_EX(INTERNAL_JitLoopHoistStats, W("JitLoopHoistStats"), 0, "Dis
CONFIG_DWORD_INFO_EX(INTERNAL_JitDebugLogLoopCloning, W("JitDebugLogLoopCloning"), 0, "In debug builds log places where loop cloning optimizations are performed on the fast path.", CLRConfig::REGUTIL_default);
CONFIG_DWORD_INFO_EX(INTERNAL_JitVNMapSelLimit, W("JitVNMapSelLimit"), 0, "If non-zero, assert if # of VNF_MapSelect applications considered reaches this", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO(INTERNAL_JitVNMapSelBudget, W("JitVNMapSelBudget"), 100, "Max # of MapSelect's considered for a particular top-level invocation.")
#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_) || defined(_TARGET_ARM64_)
#define EXTERNAL_FeatureSIMD_Default 1
#define EXTERNAL_JitEnableAVX_Default 1
#else // !defined(_TARGET_AMD64_) && !defined(_TARGET_X86_)
#else // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_) || defined(_TARGET_ARM64_))
#define EXTERNAL_FeatureSIMD_Default 0
#endif // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_) || defined(_TARGET_ARM64_))
#if defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
#define EXTERNAL_JitEnableAVX_Default 1
#else // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
#define EXTERNAL_JitEnableAVX_Default 0
#endif // !defined(_TARGET_AMD64_) && !defined(_TARGET_X86_)
#endif // !(defined(_TARGET_AMD64_) || defined(_TARGET_X86_)
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_FeatureSIMD, W("FeatureSIMD"), EXTERNAL_FeatureSIMD_Default, "Enable SIMD support with companion SIMDVector.dll", CLRConfig::REGUTIL_default)
RETAIL_CONFIG_DWORD_INFO(INTERNAL_SIMD16ByteOnly, W("SIMD16ByteOnly"), 0, "Limit maximum SIMD vector length to 16 bytes (used by x64_arm64_altjit)")
RETAIL_CONFIG_DWORD_INFO_EX(EXTERNAL_EnableAVX, W("EnableAVX"), EXTERNAL_JitEnableAVX_Default, "Enable AVX instruction set for wide operations as default", CLRConfig::REGUTIL_default)

#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_)
Expand Down
5 changes: 5 additions & 0 deletions src/jit/CMakeLists.txt
Expand Up @@ -9,6 +9,10 @@ if (CLR_CMAKE_TARGET_ARCH_AMD64 OR (CLR_CMAKE_TARGET_ARCH_I386 AND NOT CLR_CMAKE
add_definitions(-DFEATURE_HW_INTRINSICS)
endif ()

if (CLR_CMAKE_TARGET_ARCH_ARM64)
add_definitions(-DFEATURE_SIMD)
endif ()

# JIT_BUILD disables certain PAL_TRY debugging features
add_definitions(-DJIT_BUILD=1)

Expand Down Expand Up @@ -141,6 +145,7 @@ set( JIT_ARM64_SOURCES
lowerarm64.cpp
lsraarmarch.cpp
lsraarm64.cpp
simd.cpp
targetarm64.cpp
unwindarm.cpp
unwindarm64.cpp
Expand Down
3 changes: 1 addition & 2 deletions src/jit/protononjit/CMakeLists.txt
Expand Up @@ -5,8 +5,6 @@ add_definitions(-DFEATURE_NO_HOST)
add_definitions(-DSELF_NO_HOST)
remove_definitions(-DFEATURE_MERGE_JIT_AND_ENGINE)

remove_definitions(-DFEATURE_SIMD)

remove_definitions(-DFEATURE_HW_INTRINSICS)

if(FEATURE_READYTORUN)
Expand All @@ -15,6 +13,7 @@ endif(FEATURE_READYTORUN)

if (CLR_CMAKE_PLATFORM_ARCH_I386)
remove_definitions(-D_TARGET_X86_=1)
remove_definitions(-DFEATURE_SIMD)
add_definitions(-D_TARGET_ARM_)
set(JIT_ARCH_ALTJIT_SOURCES ${JIT_ARM_SOURCES})
set(JIT_ARCH_LINK_LIBRARIES gcinfo_arm)
Expand Down
13 changes: 13 additions & 0 deletions src/vm/codeman.cpp
Expand Up @@ -1432,10 +1432,23 @@ void EEJitManager::SetCpuInfo()
{
CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_FEATURE_SIMD);
}

if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_SIMD16ByteOnly) != 0)
{
CPUCompileFlags.Clear(CORJIT_FLAGS::CORJIT_FLAG_USE_AVX2);
}
}
}
#endif // defined(_TARGET_X86_) || defined(_TARGET_AMD64_)

#if defined(_TARGET_ARM64_)
static ConfigDWORD fFeatureSIMD;
if (fFeatureSIMD.val(CLRConfig::EXTERNAL_FeatureSIMD) != 0)
{
CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_FEATURE_SIMD);
}
#endif

m_CPUCompileFlags = CPUCompileFlags;
}

Expand Down
8 changes: 8 additions & 0 deletions src/zap/zapper.cpp
Expand Up @@ -1394,6 +1394,14 @@ void Zapper::InitializeCompilerFlags(CORCOMPILE_VERSION_INFO * pVersionInfo)

#endif // _TARGET_X86_

#if defined(_TARGET_ARM64_)
static ConfigDWORD fFeatureSIMD;
if (fFeatureSIMD.val(CLRConfig::EXTERNAL_FeatureSIMD) != 0)
{
m_pOpt->m_compilerFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_FEATURE_SIMD);
}
#endif

if ( m_pOpt->m_compilerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_INFO)
&& m_pOpt->m_compilerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)
&& m_pOpt->m_compilerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_PROF_ENTERLEAVE))
Expand Down
1 change: 1 addition & 0 deletions tests/x64_arm64_altjit.cmd
Expand Up @@ -4,3 +4,4 @@ set COMPlus_AltJitName=protononjit.dll
set COMPlus_NoGuiOnAssert=1
set COMPlus_ContinueOnAssert=0
set COMPlus_AltJitAssertOnNYI=1
set COMPlus_SIMD16ByteOnly=1

0 comments on commit 2b9e70f

Please sign in to comment.