Remove getMaxIntrinsicSIMDVectorLength from the JIT/EE interface (#86479)
authorTanner Gooding <tagoo@outlook.com>
Fri, 19 May 2023 04:22:12 +0000 (21:22 -0700)
committerGitHub <noreply@github.com>
Fri, 19 May 2023 04:22:12 +0000 (21:22 -0700)
* Fixing a couple small typos

* Remove getMaxIntrinsicSIMDVectorLength from the JIT/EE interface

* Update src/coreclr/vm/methodtablebuilder.cpp

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
15 files changed:
docs/design/coreclr/jit/ryujit-overview.md
src/coreclr/inc/corjit.h
src/coreclr/inc/jiteeversionguid.h
src/coreclr/jit/compiler.cpp
src/coreclr/jit/ee_il_dll.cpp
src/coreclr/jit/ee_il_dll.hpp
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/tools/aot/jitinterface/jitwrapper.cpp
src/coreclr/tools/superpmi/superpmi-shared/icorjitcompilerimpl.h
src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitcompiler.cpp
src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitcompiler.cpp
src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitcompiler.cpp
src/coreclr/vm/cgensys.h
src/coreclr/vm/codeman.cpp
src/coreclr/vm/methodtablebuilder.cpp

index e38e487..5635815 100644 (file)
@@ -34,8 +34,7 @@ The following are the key methods on this interface:
   It returns a pointer to the code, its size, and additional GC, EH and (optionally) debug info.
   * `getVersionIdentifier` is the mechanism by which the JIT/EE interface is versioned.
   There is a single GUID (manually generated) which the JIT and EE must agree on.
-  * `getMaxIntrinsicSIMDVectorLength` communicates to the EE the largest SIMD vector length that the JIT can support.
-* `ICorJitInfo` – this is the interface that the EE implements. It has many methods defined on it that allow the JIT to
+  * `ICorJitInfo` – this is the interface that the EE implements. It has many methods defined on it that allow the JIT to
 look up metadata tokens, traverse type signatures, compute field and vtable offsets, find method entry points,
 construct string literals, etc. This bulk of this interface is inherited from `ICorDynamicInfo` which is defined in
 [src/inc/corinfo.h](https://github.com/dotnet/runtime/blob/main/src/coreclr/inc/corinfo.h). The implementation
index 0f29b27..c48bf93 100644 (file)
@@ -209,11 +209,6 @@ public:
             GUID*   versionIdentifier   /* OUT */
             ) = 0;
 
-    // When the EE loads the System.Numerics.Vectors assembly, it asks the JIT what length (in bytes) of
-    // SIMD vector it supports as an intrinsic type.  Zero means that the JIT does not support SIMD
-    // intrinsics, so the EE should use the default size (i.e. the size of the IL implementation).
-    virtual unsigned getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags) { return 0; }
-
     // Some JIT's may support multiple OSs. This api provides a means to specify to the JIT what OS it should
     // be trying to compile. This api does not produce any errors, any errors are to be generated by the
     // the compileMethod call, which will call back into the VM to ensure bits are correctly setup.
@@ -340,7 +335,7 @@ public:
     //
     // SAMPLE_INTERVAL must be >= SIZE. SAMPLE_INTERVAL / SIZE
     // gives the average number of calls between table updates.
-    // 
+    //
     struct HandleHistogram32
     {
         enum
index 53e3edd..eee46d6 100644 (file)
@@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
 #define GUID_DEFINED
 #endif // !GUID_DEFINED
 
-constexpr GUID JITEEVersionIdentifier = { /* c540b287-0d17-4fc0-bac8-abd055acccb8 */
-    0xc540b287,
-    0x0d17,
-    0x4fc0,
-    {0xba, 0xc8, 0xab, 0xd0, 0x55, 0xac, 0xcc, 0xb8}
+constexpr GUID JITEEVersionIdentifier = { /* dfc41bc9-f134-4c50-897e-fc9304a82059 */
+    0xdfc41bc9,
+    0xf134,
+    0x4c50,
+    {0x89, 0x7e, 0xfc, 0x93, 0x04, 0xa8, 0x20, 0x59}
   };
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////
index dab3b58..1d7fbbf 100644 (file)
@@ -2304,7 +2304,7 @@ void Compiler::compSetProcessor()
             // Some architectures can experience frequency throttling when
             // executing 512-bit width instructions. To account for this we set the
             // default preferred vector width to 256-bits in some scenarios. Power
-            // users can override this with `DOTNET_PreferredVectorBitWith=512` to
+            // users can override this with `DOTNET_PreferredVectorBitWidth=512` to
             // allow using such instructions where hardware support is available.
 
             preferredVectorByteLength = 256;
index cc5ff29..5d7c5b9 100644 (file)
@@ -314,41 +314,6 @@ void CILJit::setTargetOS(CORINFO_OS os)
 #endif
 }
 
-/*****************************************************************************
- * Determine the maximum length of SIMD vector supported by this JIT.
- */
-
-unsigned CILJit::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags)
-{
-    JitFlags jitFlags;
-    jitFlags.SetFromFlags(cpuCompileFlags);
-
-#ifdef FEATURE_SIMD
-#if defined(TARGET_XARCH)
-    if (!jitFlags.IsSet(JitFlags::JIT_FLAG_PREJIT) &&
-        jitFlags.GetInstructionSetFlags().HasInstructionSet(InstructionSet_AVX2))
-    {
-        if (GetJitTls() != nullptr && JitTls::GetCompiler() != nullptr)
-        {
-            JITDUMP("getMaxIntrinsicSIMDVectorLength: returning 32\n");
-        }
-        return 32;
-    }
-#endif // defined(TARGET_XARCH)
-    if (GetJitTls() != nullptr && JitTls::GetCompiler() != nullptr)
-    {
-        JITDUMP("getMaxIntrinsicSIMDVectorLength: returning 16\n");
-    }
-    return 16;
-#else  // !FEATURE_SIMD
-    if (GetJitTls() != nullptr && JitTls::GetCompiler() != nullptr)
-    {
-        JITDUMP("getMaxIntrinsicSIMDVectorLength: returning 0\n");
-    }
-    return 0;
-#endif // !FEATURE_SIMD
-}
-
 //------------------------------------------------------------------------
 // eeGetArgSize: Returns the number of bytes required for the given type argument
 //   including padding after the actual value.
index cfdc1f8..0f81910 100644 (file)
@@ -17,8 +17,6 @@ class CILJit : public ICorJitCompiler
     void getVersionIdentifier(GUID* versionIdentifier /* OUT */
                               );
 
-    unsigned getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags);
-
     void setTargetOS(CORINFO_OS os);
 };
 
index 2a16f11..30f0b14 100644 (file)
@@ -149,9 +149,6 @@ namespace Internal.JitInterface
             ref CORINFO_METHOD_INFO info, uint flags, out IntPtr nativeEntry, out uint codeSize);
 
         [DllImport(JitSupportLibrary)]
-        private static extern uint GetMaxIntrinsicSIMDVectorLength(IntPtr jit, CORJIT_FLAGS* flags);
-
-        [DllImport(JitSupportLibrary)]
         private static extern IntPtr AllocException([MarshalAs(UnmanagedType.LPWStr)]string message, int messageLength);
 
         [DllImport(JitSupportLibrary)]
index 4b763ae..1a091b2 100644 (file)
@@ -50,10 +50,3 @@ DLL_EXPORT void JitProcessShutdownWork(ICorJitCompiler * pJit)
 {
     return pJit->ProcessShutdownWork(nullptr);
 }
-
-DLL_EXPORT unsigned GetMaxIntrinsicSIMDVectorLength(
-    ICorJitCompiler * pJit,
-    CORJIT_FLAGS * flags)
-{
-    return pJit->getMaxIntrinsicSIMDVectorLength(*flags);
-}
index 49cfb3b..66f7e09 100644 (file)
@@ -42,11 +42,6 @@ void ProcessShutdownWork(ICorStaticInfo* info); /* {}; */
 void getVersionIdentifier(GUID* versionIdentifier /* OUT */
                           );
 
-// When the EE loads the System.Numerics.Vectors assembly, it asks the JIT what length (in bytes) of
-// SIMD vector it supports as an intrinsic type.  Zero means that the JIT does not support SIMD
-// intrinsics, so the EE should use the default size (i.e. the size of the IL implementation).
-unsigned getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags); /* { return 0; } */
-
 // Some JIT's may support multiple OSs. This api provides a means to specify to the JIT what OS it should
 // be trying to compile. This api does not produce any errors, any errors are to be generated by the
 // the compileMethod call, which will call back into the VM to ensure bits are correctly setup.
index 0ef956b..331361a 100644 (file)
@@ -158,8 +158,3 @@ void interceptor_ICJC::getVersionIdentifier(GUID* versionIdentifier /* OUT */)
 {
     original_ICorJitCompiler->getVersionIdentifier(versionIdentifier);
 }
-
-unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags)
-{
-    return original_ICorJitCompiler->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags);
-}
index 1f1f1d2..f67c5cb 100644 (file)
@@ -40,9 +40,3 @@ void interceptor_ICJC::getVersionIdentifier(GUID* versionIdentifier /* OUT */)
     mcs->AddCall("getVersionIdentifier");
     original_ICorJitCompiler->getVersionIdentifier(versionIdentifier);
 }
-
-unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags)
-{
-    mcs->AddCall("getMaxIntrinsicSIMDVectorLength");
-    return original_ICorJitCompiler->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags);
-}
index 53442ce..5f266c0 100644 (file)
@@ -35,8 +35,3 @@ void interceptor_ICJC::getVersionIdentifier(GUID* versionIdentifier /* OUT */)
 {
     original_ICorJitCompiler->getVersionIdentifier(versionIdentifier);
 }
-
-unsigned interceptor_ICJC::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags)
-{
-    return original_ICorJitCompiler->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags);
-}
index 12f3a31..40f3f2b 100644 (file)
@@ -80,17 +80,6 @@ extern "C" DWORD xmmYmmStateSupport();
 extern "C" DWORD avx512StateSupport();
 #endif
 
-inline bool TargetHasAVXSupport()
-{
-#if (defined(TARGET_X86) || defined(TARGET_AMD64))
-    int cpuInfo[4];
-    __cpuid(cpuInfo, 0x00000001);           // All x86/AMD64 targets support cpuid.
-    const int CPUID_ECX = 2;
-    return ((cpuInfo[CPUID_ECX] & (1 << 28)) != 0); // The AVX feature is ECX bit 28.
-#endif // (defined(TARGET_X86) || defined(TARGET_AMD64))
-    return false;
-}
-
 #ifdef DACCESS_COMPILE
 
 // Used by dac/strike to make sense of non-jit/non-jit-helper call targets
index d2c7c4c..eba0c2c 100644 (file)
@@ -1256,6 +1256,8 @@ EEJitManager::EEJitManager()
 
     m_storeRichDebugInfo = false;
     m_cleanupList = NULL;
+
+    SetCpuInfo();
 }
 
 #if defined(TARGET_X86) || defined(TARGET_AMD64)
@@ -1940,7 +1942,7 @@ void EEJitManager::SetCpuInfo()
         // Some architectures can experience frequency throttling when executing
         // executing 512-bit width instructions. To account for this we set the
         // default preferred vector width to 256-bits in some scenarios. Power
-        // users can override this with `DOTNET_PreferredVectorBitWith=512` to
+        // users can override this with `DOTNET_PreferredVectorBitWidth=512` to
         // allow using such instructions where hardware support is available.
 
         if (xarchCpuInfo.FamilyId == 0x06)
@@ -2236,8 +2238,6 @@ BOOL EEJitManager::LoadJIT()
     if (IsJitLoaded())
         return TRUE;
 
-    SetCpuInfo();
-
     m_storeRichDebugInfo = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_RichDebugInfo) != 0;
 
     ICorJitCompiler* newJitCompiler = NULL;
index 147b222..0349ca2 100644 (file)
@@ -1141,25 +1141,27 @@ BOOL MethodTableBuilder::CheckIfSIMDAndUpdateSize()
     if (strcmp(className, "Vector`1") != 0 || strcmp(nameSpace, "System.Numerics") != 0)
         return false;
 
-    if (!TargetHasAVXSupport())
-        return false;
+    CORJIT_FLAGS CPUCompileFlags       = ExecutionManager::GetEEJitManager()->GetCPUCompileFlags();
+    uint32_t     numInstanceFieldBytes = 16;
+
+    if (CPUCompileFlags.IsSet(InstructionSet_AVX2))
+    {
+        numInstanceFieldBytes = 32;
+    }
 
-    EEJitManager *jitMgr = ExecutionManager::GetEEJitManager();
-    if (jitMgr->LoadJIT())
+    if (numInstanceFieldBytes != 16)
     {
-        CORJIT_FLAGS cpuCompileFlags = jitMgr->GetCPUCompileFlags();
-        unsigned intrinsicSIMDVectorLength = jitMgr->m_jit->getMaxIntrinsicSIMDVectorLength(cpuCompileFlags);
-        if (intrinsicSIMDVectorLength != 0)
+        bmtFP->NumInstanceFieldBytes = numInstanceFieldBytes;
+
+        if (HasLayout())
         {
-            bmtFP->NumInstanceFieldBytes     = intrinsicSIMDVectorLength;
-            if (HasLayout())
-            {
-                GetLayoutInfo()->m_cbManagedSize = intrinsicSIMDVectorLength;
-            }
-            return true;
+            GetLayoutInfo()->m_cbManagedSize = numInstanceFieldBytes;
         }
+
+        return true;
     }
-#endif // defined(TARGET_X86) || defined(TARGET_AMD64)
+#endif // TARGET_X86 || TARGET_AMD64
+
     return false;
 }