Skip to content

Commit b835f0c

Browse files
[clr-interp] Enhance InterpMode and CI testing (#120955)
- Enhance InterpMode flag to autoimply various other flags like ReadyToRun=0 EnableHWIntrinsic=0 consistently, so that InterpMode can be used on its own to control interpretation behavior - The comments around InterpMode are now accurate as to what they imply - Enhance CI to allow testing of various interpreter scenarios (The existing model + InterModes 1, 2, and 3) --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e9be069 commit b835f0c

File tree

10 files changed

+115
-16
lines changed

10 files changed

+115
-16
lines changed

eng/pipelines/common/templates/runtimes/run-test-job.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,23 @@ jobs:
332332
msbuildParallelism: '/maxcpucount:55'
333333

334334
${{ if in(parameters.testGroup, 'innerloop', 'outerloop') }}:
335-
${{ if eq(parameters.runtimeFlavor, 'mono') }}:
335+
${{ if and(eq(parameters.runInterpreter, 'true'),eq(variables['Build.Reason'], 'PullRequest')) }}:
336+
scenarios:
337+
- interpmode3_no_tiered_compilation
338+
- interpmode2_no_tiered_compilation
339+
- interpmode1_no_tiered_compilation
340+
- no_tiered_compilation
341+
${{ elseif eq(parameters.runInterpreter, 'true') }}:
342+
scenarios:
343+
- interpmode3_no_tiered_compilation
344+
- interpmode3
345+
- interpmode2_no_tiered_compilation
346+
- interpmode2
347+
- normal
348+
- no_tiered_compilation
349+
- interpmode1_no_tiered_compilation
350+
- interpmode1
351+
${{ elseif eq(parameters.runtimeFlavor, 'mono') }}:
336352
# tiered compilation isn't done on mono yet
337353
scenarios:
338354
- normal

src/coreclr/interpreter/eeinterp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ CorJitResult CILInterp::compileMethod(ICorJitInfo* compHnd,
7070
break;
7171
}
7272

73-
// 2: use interpreter for everything except intrinsics. All intrinsics fallback to JIT. Implies DOTNET_ReadyToRun=0.
73+
// 2: use interpreter for everything except intrinsics. All intrinsics fallback to JIT. Implies DOTNET_ReadyToRun=0
7474
case 2:
7575
doInterpret = !(compHnd->getMethodAttribs(methodInfo->ftn) & CORINFO_FLG_INTRINSIC);
7676
break;
7777

78-
// 3: use interpreter for everything, the full interpreter-only mode, no fallbacks to R2R or JIT whatsoever. Implies DOTNET_ReadyToRun=0, DOTNET_EnableHWIntrinsic=0
78+
// 3: use interpreter for everything, the full interpreter-only mode, no fallbacks to R2R or JIT whatsoever. Implies DOTNET_ReadyToRun=0, DOTNET_EnableHWIntrinsic=0, DOTNET_MaxVectorTBitWidth=128, DOTNET_PreferredVectorBitWidth=128
7979
case 3:
8080
doInterpret = true;
8181
break;

src/coreclr/vm/codeman.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,14 @@ void EEJitManager::SetCpuInfo()
11961196
// Get the maximum bitwidth of Vector<T>, rounding down to the nearest multiple of 128-bits
11971197
uint32_t maxVectorTBitWidth = (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_MaxVectorTBitWidth) / 128) * 128;
11981198

1199+
#if defined(FEATURE_INTERPRETER)
1200+
if (maxVectorTBitWidth != 128 && CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_InterpMode) == 3)
1201+
{
1202+
// Disable larger Vector<T> sizes when interpreter is enabled
1203+
maxVectorTBitWidth = 128;
1204+
}
1205+
#endif
1206+
11991207
#if defined(TARGET_X86) || defined(TARGET_AMD64)
12001208
CPUCompileFlags.Set(InstructionSet_VectorT128);
12011209

@@ -1213,7 +1221,7 @@ void EEJitManager::SetCpuInfo()
12131221

12141222
// x86-64-v2
12151223

1216-
if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableHWIntrinsic))
1224+
if (g_pConfig->EnableHWIntrinsic())
12171225
{
12181226
CPUCompileFlags.Set(InstructionSet_X86Base);
12191227
}
@@ -1324,7 +1332,7 @@ void EEJitManager::SetCpuInfo()
13241332
#elif defined(TARGET_ARM64)
13251333
CPUCompileFlags.Set(InstructionSet_VectorT128);
13261334

1327-
if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableHWIntrinsic))
1335+
if (g_pConfig->EnableHWIntrinsic())
13281336
{
13291337
CPUCompileFlags.Set(InstructionSet_ArmBase);
13301338
CPUCompileFlags.Set(InstructionSet_AdvSimd);
@@ -1408,7 +1416,7 @@ void EEJitManager::SetCpuInfo()
14081416
g_arm64_atomics_present = true;
14091417
}
14101418
#elif defined(TARGET_RISCV64)
1411-
if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableHWIntrinsic))
1419+
if (g_pConfig->EnableHWIntrinsic())
14121420
{
14131421
CPUCompileFlags.Set(InstructionSet_RiscV64Base);
14141422
}
@@ -1509,6 +1517,14 @@ void EEJitManager::SetCpuInfo()
15091517

15101518
uint32_t preferredVectorBitWidth = (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_PreferredVectorBitWidth) / 128) * 128;
15111519

1520+
#ifdef FEATURE_INTERPRETER
1521+
if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_InterpMode) == 3)
1522+
{
1523+
// Disable larger Vector<T> sizes when interpreter is enabled, and not compiling S.P.Corelib
1524+
preferredVectorBitWidth = 128;
1525+
}
1526+
#endif
1527+
15121528
if ((preferredVectorBitWidth == 0) && throttleVector512)
15131529
{
15141530
preferredVectorBitWidth = 256;

src/coreclr/vm/eeconfig.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,45 @@ HRESULT EEConfig::sync()
454454

455455
pReadyToRunExcludeList = NULL;
456456

457+
#ifdef FEATURE_INTERPRETER
458+
#ifdef FEATURE_JIT
459+
LPWSTR interpreterConfig;
460+
IfFailThrow(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Interpreter, &interpreterConfig));
461+
if (interpreterConfig == NULL)
462+
{
463+
if ((CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_InterpMode) != 0))
464+
{
465+
enableInterpreter = true;
466+
}
467+
}
468+
else
469+
{
470+
enableInterpreter = true;
471+
}
472+
#else
473+
enableInterpreter = true;
474+
#endif // FEATURE_JIT
475+
#endif // FEATURE_INTERPRETER
476+
477+
enableHWIntrinsic = (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_EnableHWIntrinsic) != 0);
478+
#ifdef FEATURE_INTERPRETER
479+
if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_InterpMode) == 3)
480+
{
481+
// InterpMode 3 disables all hw intrinsics
482+
enableHWIntrinsic = false;
483+
}
484+
#endif // FEATURE_INTERPRETER
485+
457486
#if defined(FEATURE_READYTORUN)
458487
fReadyToRun = CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_ReadyToRun);
488+
#if defined(FEATURE_INTERPRETER)
489+
if (fReadyToRun && CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_InterpMode) >= 2)
490+
{
491+
// ReadyToRun and Interpreter modes 2 and 3 are mutually exclusive.
492+
// If both are set, Interpreter wins.
493+
fReadyToRun = false;
494+
}
495+
#endif // defined(FEATURE_INTERPRETER)
459496

460497
if (fReadyToRun)
461498
{

src/coreclr/vm/eeconfig.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ class EEConfig
441441

442442
bool RuntimeAsync() const { LIMITED_METHOD_CONTRACT; return runtimeAsync; }
443443

444+
#ifdef FEATURE_INTERPRETER
445+
bool EnableInterpreter() const { LIMITED_METHOD_CONTRACT; return enableInterpreter; }
446+
#endif
447+
bool EnableHWIntrinsic() const { LIMITED_METHOD_CONTRACT; return enableHWIntrinsic; }
448+
444449
private: //----------------------------------------------------------------
445450

446451
bool fInited; // have we synced to the registry at least once?
@@ -612,6 +617,12 @@ class EEConfig
612617
bool fReadyToRun;
613618
#endif
614619

620+
bool enableHWIntrinsic;
621+
622+
#ifdef FEATURE_INTERPRETER
623+
bool enableInterpreter;
624+
#endif
625+
615626
#if defined(FEATURE_ON_STACK_REPLACEMENT)
616627
DWORD dwOSR_HitLimit;
617628
DWORD dwOSR_CounterBump;

src/coreclr/vm/jithost.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ int JitHost::getIntConfigValue(const char* name, int defaultValue)
2626
{
2727
WRAPPER_NO_CONTRACT;
2828

29+
if (!strcmp(name, "EnableHWIntrinsic"))
30+
{
31+
return g_pConfig->EnableHWIntrinsic() ? 1 : 0;
32+
}
33+
2934
StackSString str;
3035
SString(SString::Utf8Literal, name).ConvertToUnicode(str);
3136

src/coreclr/vm/jitinterface.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13423,15 +13423,9 @@ PCODE UnsafeJitFunction(PrepareCodeConfig* config,
1342313423

1342413424
#ifdef FEATURE_INTERPRETER
1342513425
InterpreterJitManager* interpreterMgr = ExecutionManager::GetInterpreterJitManager();
13426-
if (!interpreterMgr->IsInterpreterLoaded())
13426+
if (!interpreterMgr->IsInterpreterLoaded() && g_pConfig->EnableInterpreter())
1342713427
{
13428-
LPWSTR interpreterConfig;
13429-
IfFailThrow(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Interpreter, &interpreterConfig));
1343013428
if (
13431-
#ifdef FEATURE_JIT
13432-
// If both JIT and interpret are available, load the interpreter for testing purposes only if the config switch is set
13433-
(interpreterConfig != NULL) &&
13434-
#endif
1343513429
!interpreterMgr->LoadInterpreter())
1343613430
{
1343713431
EEPOLICY_HANDLE_FATAL_ERROR_WITH_MESSAGE(COR_E_EXECUTIONENGINE, W("Failed to load interpreter"));

src/tests/Common/CLRTest.Execute.Bash.targets

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ fi
8484
<BashCLRTestEnvironmentCompatibilityCheck Condition="'$(InterpreterIncompatible)' == 'true'"><![CDATA[
8585
$(BashCLRTestEnvironmentCompatibilityCheck)
8686
if [ ! -z "$RunInterpreter" ]
87+
then
88+
echo SKIPPING EXECUTION BECAUSE the test is incompatible with the interpreter
89+
exit $(IncompatibleTestBashScriptExitCode)
90+
fi
91+
if [ ! -z "$DOTNET_InterpMode" ]
8792
then
8893
echo SKIPPING EXECUTION BECAUSE the test is incompatible with the interpreter
8994
exit $(IncompatibleTestBashScriptExitCode)
@@ -407,8 +412,9 @@ if [ ! -z ${RunCrossGen2+x} ]%3B then
407412
fi
408413
409414
if [ ! -z "$RunInterpreter" ]; then
410-
# $(InputAssemblyName)
411-
export DOTNET_Interpreter='$(AssemblyName)!*'
415+
if [ -z "$DOTNET_InterpMode" ]; then
416+
export DOTNET_Interpreter='$(AssemblyName)!*'
417+
fi
412418
fi
413419
414420
echo $LAUNCHER $ExePath %24(printf "'%s' " "${CLRTestExecutionArguments[@]}")

src/tests/Common/CLRTest.Execute.Batch.targets

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ IF NOT "%RunInterpreter%"=="" (
8080
ECHO SKIPPING EXECUTION BECAUSE the test is incompatible with the interpreter
8181
popd
8282
Exit /b 0
83+
)
84+
IF NOT "%DOTNET_InterpMode%"=="" (
85+
ECHO SKIPPING EXECUTION BECAUSE the test is incompatible with the interpreter
86+
popd
87+
Exit /b 0
8388
)
8489
]]></BatchCLRTestEnvironmentCompatibilityCheck>
8590
<BatchCLRTestEnvironmentCompatibilityCheck Condition="'$(TieringTestIncompatible)' == 'true'"><![CDATA[
@@ -345,7 +350,9 @@ if defined RunCrossGen2 (
345350
)
346351
347352
if defined RunInterpreter (
348-
SET "DOTNET_Interpreter=$(AssemblyName)^!*"
353+
if "%DOTNET_InterpMode%"=="" (
354+
SET "DOTNET_Interpreter=$(AssemblyName)^!*"
355+
)
349356
)
350357
351358
ECHO %LAUNCHER% %ExePath% %CLRTestExecutionArguments%

src/tests/Common/testenvironment.proj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
-->
1414
<PropertyGroup>
1515
<DOTNETVariables>
16+
DOTNET_InterpMode;
1617
DOTNET_TieredCompilation;
1718
DOTNET_DbgEnableMiniDump;
1819
DOTNET_EnableCrashReport;
@@ -95,6 +96,12 @@
9596
while other scenarios use the default values of DOTNET_* variables defined in ItemDefinitionGroup above -->
9697
<TestEnvironment Include="normal" TieredCompilation="" />
9798
<TestEnvironment Include="jitminopts" JITMinOpts="1" />
99+
<TestEnvironment Include="interpmode1" TieredCompilation="" InterpMode="1" />
100+
<TestEnvironment Include="interpmode2" TieredCompilation="" InterpMode="2" />
101+
<TestEnvironment Include="interpmode3" TieredCompilation="" InterpMode="3" />
102+
<TestEnvironment Include="interpmode1_no_tiered_compilation" InterpMode="1" TieredCompilation="0"/>
103+
<TestEnvironment Include="interpmode2_no_tiered_compilation" InterpMode="2" TieredCompilation="0"/>
104+
<TestEnvironment Include="interpmode3_no_tiered_compilation" InterpMode="3" TieredCompilation="0"/>
98105
<TestEnvironment Include="no_tiered_compilation" TieredCompilation="0" />
99106
<TestEnvironment Include="forcerelocs" ForceRelocs="1" />
100107
<TestEnvironment Include="jitstress1" JitStress="1" />

0 commit comments

Comments
 (0)