diff options
author | Russ Keldorph <Russ.Keldorph@microsoft.com> | 2018-04-16 10:24:20 -0700 |
---|---|---|
committer | Russ Keldorph <Russ.Keldorph@microsoft.com> | 2018-04-16 10:24:20 -0700 |
commit | aec93559245d3e4498397e214c8214ebe789088c (patch) | |
tree | 94a404d56d5b33a2775db0b442278a9fc89d39d7 /tests | |
parent | b3dff4d441013cbfa39ce209f45ba96d605d8e77 (diff) | |
parent | 91ce6edff7b897f1356ba43af7b26565639fb6fc (diff) | |
download | coreclr-aec93559245d3e4498397e214c8214ebe789088c.tar.gz coreclr-aec93559245d3e4498397e214c8214ebe789088c.tar.bz2 coreclr-aec93559245d3e4498397e214c8214ebe789088c.zip |
Merge commit 'master' into release/2.1
Diffstat (limited to 'tests')
35 files changed, 1470 insertions, 34 deletions
diff --git a/tests/arm/Tests.lst b/tests/arm/Tests.lst index 689a792eba..30f55e4750 100644 --- a/tests/arm/Tests.lst +++ b/tests/arm/Tests.lst @@ -6393,7 +6393,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_dbglcs2\_dbglcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_dbglcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [_il_dbgrefloc_r8.cmd_804] @@ -13121,7 +13121,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_speed_dbglcs2\_speed_dbglcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_speed_dbglcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [TimeSpanCtor4.cmd_1651] @@ -13377,7 +13377,7 @@ RelativePath=baseservices\compilerservices\dynamicobjectproperties\Dev10_535767\ WorkingDir=baseservices\compilerservices\dynamicobjectproperties\Dev10_535767 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [b12022.cmd_1683] @@ -16881,7 +16881,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_rellcs2\_rellcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_rellcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [conv_ovf_u8_u4.cmd_2122] @@ -19225,7 +19225,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_speed_rellcs2\_speed_rellcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_speed_rellcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [ConvertToSByte11.cmd_2416] @@ -22825,7 +22825,7 @@ RelativePath=CoreMangLib\cti\system\array\ArraySort3\ArraySort3.cmd WorkingDir=CoreMangLib\cti\system\array\ArraySort3 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [cpblkInt32.cmd_2867] @@ -24009,7 +24009,7 @@ RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeT WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeTClass Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [TimeSpanFromTicks.cmd_3015] @@ -27905,7 +27905,7 @@ RelativePath=JIT\Methodical\refany\_relvirtcall\_relvirtcall.cmd WorkingDir=JIT\Methodical\refany\_relvirtcall Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [Generated1106.cmd_3505] @@ -32561,7 +32561,7 @@ RelativePath=JIT\Methodical\refany\_speed_relvirtcall\_speed_relvirtcall.cmd WorkingDir=JIT\Methodical\refany\_speed_relvirtcall Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [box-unbox044.cmd_4089] @@ -35105,7 +35105,7 @@ RelativePath=baseservices\exceptions\regressions\V1\SEH\VJ\ExternalException\Ext WorkingDir=baseservices\exceptions\regressions\V1\SEH\VJ\ExternalException Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;LEGACYJIT_GCSTRESS_FAIL;13203;Pri1 +Categories=EXPECTED_PASS;LEGACYJIT_GCSTRESS_FAIL;13203;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [ConvertToString6.cmd_4407] @@ -37641,7 +37641,7 @@ RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeT WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeTClass_1 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [_speed_relldc_mul.cmd_4724] diff --git a/tests/arm/corefx_test_exclusions.txt b/tests/arm/corefx_test_exclusions.txt index ba2126eb8e..237f07fb54 100644 --- a/tests/arm/corefx_test_exclusions.txt +++ b/tests/arm/corefx_test_exclusions.txt @@ -1,3 +1,4 @@ +Microsoft.Win32.Registry.Tests System.Console.Tests System.Data.SqlClient.Tests System.Diagnostics.Process.Tests diff --git a/tests/arm64/Tests.lst b/tests/arm64/Tests.lst index f06e58a899..5af8bd5d24 100644 --- a/tests/arm64/Tests.lst +++ b/tests/arm64/Tests.lst @@ -9,7 +9,7 @@ RelativePath=baseservices\compilerservices\dynamicobjectproperties\Dev10_535767\ WorkingDir=baseservices\compilerservices\dynamicobjectproperties\Dev10_535767 Expected=0 MaxAllowedDurationSeconds=600 -Categories=Pri1;RT;EXPECTED_PASS;UNWIND;10070;GCSTRESS_FAIL +Categories=Pri1;RT;EXPECTED_PASS;UNWIND;10070;GCSTRESS_EXCLUDE HostStyle=0 [test448035.cmd_1] @@ -785,7 +785,7 @@ RelativePath=baseservices\exceptions\regressions\V1\SEH\VJ\ExternalException\Ext WorkingDir=baseservices\exceptions\regressions\V1\SEH\VJ\ExternalException Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [HandlerException.cmd_98] @@ -2761,7 +2761,7 @@ RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeT WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeTClass Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [CompareExchangeTClass_1.cmd_345] @@ -2769,7 +2769,7 @@ RelativePath=baseservices\threading\interlocked\compareexchange\CompareExchangeT WorkingDir=baseservices\threading\interlocked\compareexchange\CompareExchangeTClass_1 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [CompareExchangeTString.cmd_346] @@ -5297,7 +5297,7 @@ RelativePath=CoreMangLib\cti\system\array\ArraySort3\ArraySort3.cmd WorkingDir=CoreMangLib\cti\system\array\ArraySort3 Expected=0 MaxAllowedDurationSeconds=600 -Categories=Pri1;RT;LONG_RUNNING;EXPECTED_PASS +Categories=Pri1;RT;LONG_RUNNING;EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [ArraySort3b.cmd_662] @@ -44065,7 +44065,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_dbglcs2\_dbglcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_dbglcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=JIT;EXPECTED_PASS +Categories=JIT;EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [_dbglcsbas.cmd_5810] @@ -44145,7 +44145,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_rellcs2\_rellcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_rellcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=JIT;EXPECTED_PASS +Categories=JIT;EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [_rellcsbas.cmd_5820] @@ -44209,7 +44209,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_speed_dbglcs2\_speed_dbglcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_speed_dbglcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=JIT;EXPECTED_PASS +Categories=JIT;EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [_speed_dbglcsbas.cmd_5828] @@ -44273,7 +44273,7 @@ RelativePath=JIT\Methodical\Arrays\lcs\_speed_rellcs2\_speed_rellcs2.cmd WorkingDir=JIT\Methodical\Arrays\lcs\_speed_rellcs2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=JIT;EXPECTED_PASS +Categories=JIT;EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [_speed_rellcsbas.cmd_5836] @@ -57953,7 +57953,7 @@ RelativePath=JIT\Methodical\refany\_relvirtcall\_relvirtcall.cmd WorkingDir=JIT\Methodical\refany\_relvirtcall Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [_speed_dbggcreport.cmd_7560] @@ -58033,7 +58033,7 @@ RelativePath=JIT\Methodical\refany\_speed_relvirtcall\_speed_relvirtcall.cmd WorkingDir=JIT\Methodical\refany\_speed_relvirtcall Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;GCSTRESS_EXCLUDE HostStyle=0 [test1-xassem.cmd_7570] diff --git a/tests/scripts/run-xunit-perf.py b/tests/scripts/run-xunit-perf.py index 3c1cb89dca..18a0b8e446 100755 --- a/tests/scripts/run-xunit-perf.py +++ b/tests/scripts/run-xunit-perf.py @@ -182,9 +182,9 @@ def run_benchmark(benchname, benchdir, env, sandboxDir, benchmarkOutputDir, test myEnv = dict(env) benchnameWithExt = benchname + '.' + testFileExt fullPath = os.path.join(benchdir, benchnameWithExt) - shutil.copy2(fullPath, sandboxDir) - files = glob.iglob(os.path.join(benchdir, "*.txt")) + # Copy all files in the benchmark directory to the sandbox + files = glob.iglob(os.path.join(benchdir, "*.*")) for filename in files: if os.path.isfile(filename): shutil.copy2(filename, sandboxDir) diff --git a/tests/src/CLRTest.Execute.Bash.targets b/tests/src/CLRTest.Execute.Bash.targets index 53b632b12e..a3fecb22a4 100644 --- a/tests/src/CLRTest.Execute.Bash.targets +++ b/tests/src/CLRTest.Execute.Bash.targets @@ -252,7 +252,6 @@ fi <BashCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun'"> <![CDATA[ -ExePath=$(InputAssemblyName) $(BashLinkerTestLaunchCmds) $(BashCLRTestLaunchCmds) if [ ! -z ${RunCrossGen+x} ]%3B then @@ -373,6 +372,8 @@ $(BashCLRTestArgPrep) $(BashCLRTestExitCodePrep) $(JitDisasmBashScript) $(IlasmRoundTripBashScript) +# Allow precommands to override the ExePath +ExePath=$(InputAssemblyName) # PreCommands $(BashCLRTestPreCommands) # Launch diff --git a/tests/src/CLRTest.Execute.Batch.targets b/tests/src/CLRTest.Execute.Batch.targets index b02c396cd4..0a6fd439a3 100644 --- a/tests/src/CLRTest.Execute.Batch.targets +++ b/tests/src/CLRTest.Execute.Batch.targets @@ -257,7 +257,6 @@ $(BatchIlrtTestLaunchCmds) ]]></BatchCLRTestLaunchCmds> <BatchCLRTestLaunchCmds Condition="'$(CLRTestKind)' == 'BuildAndRun'"> <![CDATA[ -set ExePath=$(InputAssemblyName) $(BatchLinkerTestLaunchCmds) $(BatchCLRTestLaunchCmds) @@ -375,6 +374,9 @@ $(JitDisasmBatchScript) $(IlasmRoundTripBatchScript) +REM Allow precommands to override the ExePath +set ExePath=$(InputAssemblyName) + REM Precommands $(CLRTestBatchPreCommands) REM Launch diff --git a/tests/src/CoreMangLib/cti/system/array/ArraySort3.csproj b/tests/src/CoreMangLib/cti/system/array/ArraySort3.csproj index 136e86679a..172831fff7 100644 --- a/tests/src/CoreMangLib/cti/system/array/ArraySort3.csproj +++ b/tests/src/CoreMangLib/cti/system/array/ArraySort3.csproj @@ -12,6 +12,7 @@ <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestKind>BuildAndRun</CLRTestKind> <CLRTestPriority>1</CLRTestPriority> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> diff --git a/tests/src/CoreMangLib/cti/system/gc/GCCollect.csproj b/tests/src/CoreMangLib/cti/system/gc/GCCollect.csproj index c3c3e545db..cd47825957 100644 --- a/tests/src/CoreMangLib/cti/system/gc/GCCollect.csproj +++ b/tests/src/CoreMangLib/cti/system/gc/GCCollect.csproj @@ -12,6 +12,7 @@ <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestKind>BuildAndRun</CLRTestKind> <CLRTestPriority>1</CLRTestPriority> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs new file mode 100644 index 0000000000..bed639c202 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs @@ -0,0 +1,62 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace GitHub_17435 +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + + if (Sse2.IsSupported) + { + (uint a, uint b) = Program.Repro(); + if ((a !=3) || (b != 6)) + { + Console.WriteLine($"FAILED {a}, {b}"); + return Fail; + } + else + { + Console.WriteLine("Passed"); + return Pass; + } + } + else + { + Console.WriteLine("SSE2 not supported"); + return Pass; + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public unsafe static (uint, uint) Repro() + { + uint* a = stackalloc uint[4]; + a[0] = 1; + a[1] = 1; + a[2] = 1; + a[3] = 1; + + // Here we force populate the registers + var b = a[0]; + var h = a[3]; + var c = a[1]; + + // We operate the values in xmm0 + Vector128<uint> v = Sse2.LoadVector128(a); + v = Sse2.Add(v, v); + // We send to the memory the modified values + Sse2.Store(a, v); + + // We return both sums (from registers and from memory) + return (b + h + c, a[0]+a[1]+a[3]); + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.csproj new file mode 100644 index 0000000000..70fdafb626 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.csproj @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + <DebugType>None</DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <Compile Include="GitHub_17435.cs" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup> +</Project> diff --git a/tests/src/JIT/Methodical/Arrays/lcs/_dbglcs2.csproj b/tests/src/JIT/Methodical/Arrays/lcs/_dbglcs2.csproj index e49867da8c..ce14744089 100644 --- a/tests/src/JIT/Methodical/Arrays/lcs/_dbglcs2.csproj +++ b/tests/src/JIT/Methodical/Arrays/lcs/_dbglcs2.csproj @@ -24,6 +24,7 @@ <PropertyGroup> <DebugType>Full</DebugType> <Optimize>False</Optimize> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="lcs2.cs" /> diff --git a/tests/src/JIT/Methodical/Arrays/lcs/_rellcs2.csproj b/tests/src/JIT/Methodical/Arrays/lcs/_rellcs2.csproj index 8df4a9a3f7..7839dae6a3 100644 --- a/tests/src/JIT/Methodical/Arrays/lcs/_rellcs2.csproj +++ b/tests/src/JIT/Methodical/Arrays/lcs/_rellcs2.csproj @@ -24,6 +24,7 @@ <PropertyGroup> <DebugType>None</DebugType> <Optimize>False</Optimize> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="lcs2.cs" /> diff --git a/tests/src/JIT/Methodical/Arrays/lcs/_speed_dbglcs2.csproj b/tests/src/JIT/Methodical/Arrays/lcs/_speed_dbglcs2.csproj index 9e084b709f..195bf47cc2 100644 --- a/tests/src/JIT/Methodical/Arrays/lcs/_speed_dbglcs2.csproj +++ b/tests/src/JIT/Methodical/Arrays/lcs/_speed_dbglcs2.csproj @@ -24,6 +24,7 @@ <PropertyGroup> <DebugType>Full</DebugType> <Optimize>True</Optimize> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="lcs2.cs" /> diff --git a/tests/src/JIT/Methodical/Arrays/lcs/_speed_rellcs2.csproj b/tests/src/JIT/Methodical/Arrays/lcs/_speed_rellcs2.csproj index 0b01e846fa..66dcabd9c1 100644 --- a/tests/src/JIT/Methodical/Arrays/lcs/_speed_rellcs2.csproj +++ b/tests/src/JIT/Methodical/Arrays/lcs/_speed_rellcs2.csproj @@ -24,6 +24,7 @@ <PropertyGroup> <DebugType>None</DebugType> <Optimize>True</Optimize> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="lcs2.cs" /> diff --git a/tests/src/JIT/Methodical/refany/_relvirtcall.csproj b/tests/src/JIT/Methodical/refany/_relvirtcall.csproj index d1e9e6767c..30c3cbf26a 100644 --- a/tests/src/JIT/Methodical/refany/_relvirtcall.csproj +++ b/tests/src/JIT/Methodical/refany/_relvirtcall.csproj @@ -25,6 +25,7 @@ <PropertyGroup> <DebugType>None</DebugType> <Optimize>False</Optimize> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="virtcall.cs" /> diff --git a/tests/src/JIT/Methodical/refany/_speed_relvirtcall.csproj b/tests/src/JIT/Methodical/refany/_speed_relvirtcall.csproj index ab78d753e8..52d1b8f676 100644 --- a/tests/src/JIT/Methodical/refany/_speed_relvirtcall.csproj +++ b/tests/src/JIT/Methodical/refany/_speed_relvirtcall.csproj @@ -24,6 +24,7 @@ <PropertyGroup> <DebugType>None</DebugType> <Optimize>True</Optimize> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <ItemGroup> <Compile Include="virtcall.cs" /> diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.cs b/tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.cs new file mode 100644 index 0000000000..dd690d1d52 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.cs @@ -0,0 +1,57 @@ +using System; +using System.Numerics; + +// In this test case, we have a struct S that contains a single Vector2 field (Vector), +// with an implicit conversion from an array of float to S. +// We inline a call to this op_Implicit, and then the constructor that it invokes. +// The op_Implicit RET_EXPR is TYP_LONG, since that's how the value is returned from the method. +// It is then stored to the Vector field which is TYP_SIMD8. +// +// Bug: The JIT had code to deal with this kind of retyping (which must be made explicit by +// Lowering, as the two types require different register types), when it involves locals +// (GT_LCL_VAR) but not fields of locals (GT_LCL_FLD). +// +// Perf Issue: What we wind up with is this: (V05 & V07 are both TYP_SIMD8, V01 is the struct type S +// V05 = *(TYP_SIMD8)numbers +// V07 = V05 +// LCL_FLD(V01) = LCL_FLD(V07) // Both re-typed as TYP_LONG +// This generates: +// vmovsd xmm0, qword ptr [rax+16] +// vmovsd qword ptr[rsp + 28H], xmm0 +// vmovsd xmm0, qword ptr[rsp + 28H] +// vmovsd qword ptr[rsp + 20H], xmm0 +// vmovsd xmm0, qword ptr[rsp + 20H] +// vmovsd qword ptr[rsp + 30H], xmm0 +// +// We should be able to elide these excessive copies and unnecessary retyping, producing close to this: +// vmovsd xmm0, qword ptr [rax+16] +// vmovsd qword ptr[rsp + 30H], xmm0 + +namespace Repro +{ + class Program + { + struct S + { + public Vector2 Vector; + public S(float[] numbers) + { + Vector = new Vector2(numbers[0], numbers[1]); + } + public static implicit operator S(float[] numbers) => new S(numbers); + } + static int Main(string[] args) + { + S s = new float[] { 1.0f, 2.0f }; + Console.WriteLine(s.Vector); + if ((s.Vector.X != 1.0f) || (s.Vector.Y != 2.0f)) + { + return -1; + } + else + { + return 100; + } + } + } +} diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.csproj b/tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.csproj new file mode 100644 index 0000000000..6d58ab0227 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.csproj @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + <DebugType></DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Compile Include="$(MSBuildProjectName).cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project> diff --git a/tests/src/Regressions/coreclr/GitHub_17398/test17398.cs b/tests/src/Regressions/coreclr/GitHub_17398/test17398.cs new file mode 100644 index 0000000000..a9cc4b9980 --- /dev/null +++ b/tests/src/Regressions/coreclr/GitHub_17398/test17398.cs @@ -0,0 +1,84 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; + +// Repro case for CoreCLR 17398 + +class X +{ + static int v; + + string s; + + public override string ToString() => s; + + [MethodImpl(MethodImplOptions.NoInlining)] + X(int x) + { + s = "String" + x; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static void F() { } + + public static void T0(object o, int x) + { + GC.Collect(2); + throw new Exception(o.ToString()); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static void Test() + { + object x1 = new X(1); + object x2 = new X(2); + + if (v == 1) + { + // Generate enough pressure here to + // kill ESI so in linear flow it is dead + // at the call to T0 + int w = v; + int x = v; + int y = v; + int z = v; + + // Unbounded loop here forces fully interruptible GC + for (int i = 0; i < v; i++) + { + w++; + } + + T0(x2, w + x + y + z); + } + + // Encourage x1 to be in callee save (ESI) + F(); + + if (v == 2) + { + T0(x1, 0); + } + } + + public static int Main() + { + v = 1; + int r = 0; + + try + { + Test(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + r = 100; + } + + return r; + } +} diff --git a/tests/src/Regressions/coreclr/GitHub_17398/test17398.csproj b/tests/src/Regressions/coreclr/GitHub_17398/test17398.csproj new file mode 100644 index 0000000000..53d0e2ed21 --- /dev/null +++ b/tests/src/Regressions/coreclr/GitHub_17398/test17398.csproj @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{E55A6F8B-B9E3-45CE-88F4-22AE70F606CB}</ProjectGuid> + <OutputType>Exe</OutputType> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <CLRTestKind>BuildAndRun</CLRTestKind> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + <DebugType></DebugType> + <Optimize>True</Optimize> + </PropertyGroup> + <ItemGroup> + <Compile Include="test17398.cs" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/compilerservices/dynamicobjectproperties/Dev10_535767.csproj b/tests/src/baseservices/compilerservices/dynamicobjectproperties/Dev10_535767.csproj index 08f9711d42..cc221a00dd 100644 --- a/tests/src/baseservices/compilerservices/dynamicobjectproperties/Dev10_535767.csproj +++ b/tests/src/baseservices/compilerservices/dynamicobjectproperties/Dev10_535767.csproj @@ -12,6 +12,7 @@ <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestKind>BuildAndRun</CLRTestKind> <CLRTestPriority>1</CLRTestPriority> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj index b3c3245e96..5dce623cf9 100644 --- a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj @@ -12,6 +12,7 @@ <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestKind>BuildAndRun</CLRTestKind> <CLRTestPriority>1</CLRTestPriority> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass.csproj index 4b45e944ab..798bf6fb59 100644 --- a/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass.csproj +++ b/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass.csproj @@ -12,6 +12,7 @@ <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <CLRTestExecutionArguments>null</CLRTestExecutionArguments> <CLRTestPriority>1</CLRTestPriority> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass_1.csproj b/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass_1.csproj index daff397fd5..50cdc0b517 100644 --- a/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass_1.csproj +++ b/tests/src/baseservices/threading/interlocked/compareexchange/CompareExchangeTClass_1.csproj @@ -13,6 +13,7 @@ <CLRTestPriority>1</CLRTestPriority> <CLRTestProjectToRun>CompareExchangeTClass.csproj</CLRTestProjectToRun> <CLRTestExecutionArguments>"hello world"</CLRTestExecutionArguments> + <GCStressIncompatible>true</GCStressIncompatible> </PropertyGroup> <!-- Default configurations to help VS understand the configurations --> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> diff --git a/tests/src/performance/Scenario/JitBench/Benchmarks/MLBenchmark.cs b/tests/src/performance/Scenario/JitBench/Benchmarks/MLBenchmark.cs new file mode 100644 index 0000000000..f9c5dfd81b --- /dev/null +++ b/tests/src/performance/Scenario/JitBench/Benchmarks/MLBenchmark.cs @@ -0,0 +1,256 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Reflection; +using Microsoft.Xunit.Performance.Api; + +namespace JitBench +{ + class Word2VecBenchmark : MLBenchmark + { + public Word2VecBenchmark() : base("Word2Vec") { } + + protected override string ExecutableName => "Word2VecScenario.dll"; + + protected override string GetWord2VecNetSrcDirectory(string outputDir) + { + return Path.Combine(GetWord2VecNetRepoRootDir(outputDir), "Word2VecScenario"); + } + } + + abstract class MLBenchmark : Benchmark + { + private static readonly HashSet<int> DefaultExitCodes = new HashSet<int>(new[] { 0 }); + + public MLBenchmark(string name) : base(name) + { + ExePath = ExecutableName; + } + + protected abstract string ExecutableName { get; } + + public override async Task Setup(DotNetInstallation dotNetInstall, string outputDir, bool useExistingSetup, ITestOutputHelper output) + { + if(!useExistingSetup) + { + using (var setupSection = new IndentedTestOutputHelper("Setup " + Name, output)) + { + await CloneWord2VecNetRepo(outputDir, setupSection); + await Publish(dotNetInstall, outputDir, setupSection); + await DownloadAndExtractTextCorpus(dotNetInstall, outputDir, setupSection); + } + } + string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); + WorkingDirPath = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); + } + + async Task CloneWord2VecNetRepo(string outputDir, ITestOutputHelper output) + { + // If the repo already exists, we delete it and extract it again. + string word2VecNetRepoRootDir = GetWord2VecNetRepoRootDir(outputDir); + FileTasks.DeleteDirectory(word2VecNetRepoRootDir, output); + + string word2VecPatchFullPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), Word2VecNetPatch); + + await ExecuteGitCommand($"clone {Word2VecNetRepoUrl} {word2VecNetRepoRootDir}", output); + await ExecuteGitCommand($"checkout {Word2VecNetCommitSha1Id}", output, workingDirectory: word2VecNetRepoRootDir); + await ExecuteGitCommand($"apply {word2VecPatchFullPath}", output, workingDirectory: word2VecNetRepoRootDir); + } + + async Task ExecuteGitCommand(string arguments, ITestOutputHelper output, string workingDirectory = null) + { + int exitCode = await new ProcessRunner("git", arguments).WithLog(output).WithWorkingDirectory(workingDirectory).Run(); + + if (!DefaultExitCodes.Contains(exitCode)) + throw new Exception($"git {arguments} has failed, the exit code was {exitCode}"); + } + + async Task DownloadAndExtractTextCorpus(DotNetInstallation dotNetInstall, string outputDir, ITestOutputHelper output) + { + // If the file already exists, exit + string word2VecNetRepoRootDir = GetWord2VecNetRepoRootDir(outputDir); + string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); + string word2VecNetPublishDir = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); + + // Download the corpus of text. This is a zip file that contains a text file of 100M of text from Wikipedia + var url = "https://perfbenchmarkstorage.blob.core.windows.net/corpus/Corpus10.zip"; + await FileTasks.DownloadAndUnzip(url, word2VecNetRepoRootDir + "_temp", output); + + FileTasks.MoveFile(Path.Combine(word2VecNetRepoRootDir + "_temp", "Corpus.txt"), + Path.Combine(word2VecNetPublishDir, "Corpus.txt"), output); + } + + private async Task<string> Publish(DotNetInstallation dotNetInstall, string outputDir, ITestOutputHelper output) + { + string tfm = DotNetSetup.GetTargetFrameworkMonikerForFrameworkVersion(dotNetInstall.FrameworkVersion); + string publishDir = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); + if (publishDir != null) + { + FileTasks.DeleteDirectory(publishDir, output); + } + string dotNetExePath = dotNetInstall.DotNetExe; + await new ProcessRunner(dotNetExePath, $"publish -c Release -f {tfm}") + .WithWorkingDirectory(GetWord2VecNetSrcDirectory(outputDir)) + .WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0") + .WithEnvironmentVariable("WORD2VEC_FRAMEWORK_VERSION", dotNetInstall.FrameworkVersion) + .WithEnvironmentVariable("UseSharedCompilation", "false") + .WithLog(output) + .Run(); + + publishDir = GetWord2VecNetPublishDirectory(dotNetInstall, outputDir, tfm); + if (publishDir == null) + { + throw new DirectoryNotFoundException("Could not find 'publish' directory"); + } + return publishDir; + } + + public override Metric[] GetDefaultDisplayMetrics() + { + return new Metric[] + { + TrainingMetric, + FirstSearchMetric, + MedianSearchMetric + }; + } + + protected override IterationResult RecordIterationMetrics(ScenarioExecutionResult scenarioIteration, string stdout, string stderr, ITestOutputHelper output) + { + IterationResult result = base.RecordIterationMetrics(scenarioIteration, stdout, stderr, output); + AddConsoleMetrics(result, stdout, output); + return result; + } + + void AddConsoleMetrics(IterationResult result, string stdout, ITestOutputHelper output) + { + output.WriteLine("Processing iteration results."); + + double? trainingTime = null; + double? firstSearchTime = null; + double? steadyStateMedianTime = null; + + using (var reader = new StringReader(stdout)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + Match match = Regex.Match(line, @"^Training took \s*(\d+)ms$"); + if (match.Success && match.Groups.Count == 2) + { + trainingTime = Convert.ToDouble(match.Groups[1].Value); + continue; + } + + match = Regex.Match(line, @"^Search took \s*(\d+)ms$"); + if (match.Success && match.Groups.Count == 2) + { + firstSearchTime = Convert.ToDouble(match.Groups[1].Value); + continue; + } + + match = Regex.Match(line, @"^Steadystate median search time: \s*(\d+\.\d+)ms$"); + if (match.Success && match.Groups.Count == 2) + { + //many lines will match, but the final values of these variables will be from the last batch which is presumably the + //best measurement of steady state performance + steadyStateMedianTime = Convert.ToDouble(match.Groups[1].Value); + continue; + } + } + } + + if (!trainingTime.HasValue) + throw new FormatException("Training time was not found."); + if (!firstSearchTime.HasValue) + throw new FormatException("First Search time was not found."); + if (!steadyStateMedianTime.HasValue) + throw new FormatException("Steady state median response time not found."); + + + result.Measurements.Add(TrainingMetric, trainingTime.Value); + result.Measurements.Add(FirstSearchMetric, firstSearchTime.Value); + result.Measurements.Add(MedianSearchMetric, steadyStateMedianTime.Value); + + output.WriteLine($"Training took {trainingTime}ms"); + output.WriteLine($"Search took {firstSearchTime}ms"); + output.WriteLine($"Median steady state search {steadyStateMedianTime.Value}ms"); + } + + /// <summary> + /// When serializing the result data to benchview this is called to determine if any of the metrics should be reported differently + /// than they were collected. Both web apps use this to collect several measurements in each iteration, then present those measurements + /// to benchview as if each was the Duration metric of a distinct scenario test with its own set of iterations. + /// </summary> + public override bool TryGetBenchviewCustomMetricReporting(Metric originalMetric, out Metric newMetric, out string newScenarioModelName) + { + if(originalMetric.Equals(TrainingMetric)) + { + newScenarioModelName = "Training"; + } + else if (originalMetric.Equals(FirstSearchMetric)) + { + newScenarioModelName = "First Search"; + } + else if (originalMetric.Equals(MedianSearchMetric)) + { + newScenarioModelName = "Median Search"; + } + else + { + return base.TryGetBenchviewCustomMetricReporting(originalMetric, out newMetric, out newScenarioModelName); + } + newMetric = Metric.ElapsedTimeMilliseconds; + return true; + } + + protected static string GetWord2VecNetRepoRootDir(string outputDir) + { + return Path.Combine(outputDir, "W"); + } + + protected abstract string GetWord2VecNetSrcDirectory(string outputDir); + + string GetWord2VecNetPublishDirectory(DotNetInstallation dotNetInstall, string outputDir, string tfm) + { + string dir = Path.Combine(GetWord2VecNetSrcDirectory(outputDir), "bin", dotNetInstall.Architecture, "Release", tfm, "publish"); + if (Directory.Exists(dir)) + { + return dir; + } + + dir = Path.Combine(GetWord2VecNetSrcDirectory(outputDir), "bin", "Release", tfm, "publish"); + if (Directory.Exists(dir)) + { + return dir; + } + + return null; + } + + string GetCoreClrRoot() + { + string currentDirectory = Directory.GetCurrentDirectory(); + string workspace = Environment.GetEnvironmentVariable("CORECLR_REPO"); + if (workspace == null) + { + workspace = currentDirectory; + } + + return workspace; + } + + private const string Word2VecNetRepoUrl = "https://github.com/eabdullin/Word2Vec.Net"; + private const string Word2VecNetCommitSha1Id = "6012a2b5b886926918d51b1b56387d785115f448"; + private const string Word2VecNetPatch = "word2vecnet.patch"; + private const string EnvironmentFileName = "Word2VecNetEnvironment.txt"; + private const string StoreDirName = ".store"; + private readonly Metric TrainingMetric = new Metric("Training", "ms"); + private readonly Metric FirstSearchMetric = new Metric("First Search", "ms"); + private readonly Metric MedianSearchMetric = new Metric("Median Search", "ms"); + private readonly Metric MeanSearchMetric = new Metric("Mean Search", "ms"); + } +} + diff --git a/tests/src/performance/Scenario/JitBench/JitBench.csproj b/tests/src/performance/Scenario/JitBench/JitBench.csproj index 2e384d183e..0d1f4fb0df 100644 --- a/tests/src/performance/Scenario/JitBench/JitBench.csproj +++ b/tests/src/performance/Scenario/JitBench/JitBench.csproj @@ -54,5 +54,8 @@ Overwrite="true" Encoding="Unicode"/> </Target> + <Target Name="AfterBuild"> + <Copy SourceFiles="Resources\word2vecnet.patch" DestinationFolder="$(OutDir)" /> + </Target> </Project> diff --git a/tests/src/performance/Scenario/JitBench/Resources/word2vecnet.patch b/tests/src/performance/Scenario/JitBench/Resources/word2vecnet.patch new file mode 100644 index 0000000000..dbad57ba5f --- /dev/null +++ b/tests/src/performance/Scenario/JitBench/Resources/word2vecnet.patch @@ -0,0 +1,605 @@ +diff --git a/.gitignore b/.gitignore +index 8098fe2..7c82f99 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -17,7 +17,6 @@ + [Rr]eleases/ + x64/ + x86/ +-build/ + bld/ + [Bb]in/ + [Oo]bj/ +diff --git a/NuGet.config b/NuGet.config +new file mode 100644 +index 0000000..bd3a6f8 +--- /dev/null ++++ b/NuGet.config +@@ -0,0 +1,8 @@ ++<?xml version="1.0" encoding="utf-8"?> ++<configuration> ++ <packageSources> ++ <clear /> ++ <add key="dotnet core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> ++ <add key="NuGet" value="https://api.nuget.org/v3/index.json" /> ++ </packageSources> ++</configuration> +\ No newline at end of file +diff --git a/Word2LibConsole/Word2LibConsole.vcxproj b/Word2LibConsole/Word2LibConsole.vcxproj +index 2caa5a0..03b8ada 100644 +--- a/Word2LibConsole/Word2LibConsole.vcxproj ++++ b/Word2LibConsole/Word2LibConsole.vcxproj +@@ -1,5 +1,5 @@ + <?xml version="1.0" encoding="utf-8"?> +-<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ++<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> +@@ -14,19 +14,19 @@ + <ProjectGuid>{9C719670-3571-4B68-A3DA-053B18C654A0}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>Word2LibConsole</RootNamespace> +- <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> ++ <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> +- <PlatformToolset>v140</PlatformToolset> ++ <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> +- <PlatformToolset>v140</PlatformToolset> ++ <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> +diff --git a/Word2Vec.Net/Distance.cs b/Word2Vec.Net/Distance.cs +index f2c3cdc..32929cd 100644 +--- a/Word2Vec.Net/Distance.cs ++++ b/Word2Vec.Net/Distance.cs +@@ -46,7 +46,7 @@ namespace Word2Vec.Net + } + if (b == Words) b = -1; + bi[a] = b; +- Console.Write("\nWord: {0} Position in vocabulary: {1}\n", st[a], bi[a]); ++ //Console.Write("\nWord: {0} Position in vocabulary: {1}\n", st[a], bi[a]); + if (b == -1) + { + Console.Write("Out of dictionary word!\n"); +@@ -99,4 +99,4 @@ namespace Word2Vec.Net + public string Word { get; set; } + public float Distance { get; set; } + } +-} +\ No newline at end of file ++} +diff --git a/Word2Vec.Net/Properties/AssemblyInfo.cs b/Word2Vec.Net/Properties/AssemblyInfo.cs +deleted file mode 100644 +index 89452bf..0000000 +--- a/Word2Vec.Net/Properties/AssemblyInfo.cs ++++ /dev/null +@@ -1,36 +0,0 @@ +-using System.Reflection; +-using System.Runtime.CompilerServices; +-using System.Runtime.InteropServices; +- +-// General Information about an assembly is controlled through the following +-// set of attributes. Change these attribute values to modify the information +-// associated with an assembly. +-[assembly: AssemblyTitle("Word2Vec.Net")] +-[assembly: AssemblyDescription("")] +-[assembly: AssemblyConfiguration("")] +-[assembly: AssemblyCompany("")] +-[assembly: AssemblyProduct("Word2Vec.Net")] +-[assembly: AssemblyCopyright("Copyright © 2015")] +-[assembly: AssemblyTrademark("")] +-[assembly: AssemblyCulture("")] +- +-// Setting ComVisible to false makes the types in this assembly not visible +-// to COM components. If you need to access a type in this assembly from +-// COM, set the ComVisible attribute to true on that type. +-[assembly: ComVisible(false)] +- +-// The following GUID is for the ID of the typelib if this project is exposed to COM +-[assembly: Guid("b2bcc46d-a28b-40a4-a873-f0b1ffe65181")] +- +-// Version information for an assembly consists of the following four values: +-// +-// Major Version +-// Minor Version +-// Build Number +-// Revision +-// +-// You can specify all the values or you can default the Build and Revision Numbers +-// by using the '*' as shown below: +-// [assembly: AssemblyVersion("1.0.*")] +-[assembly: AssemblyVersion("1.0.0.0")] +-[assembly: AssemblyFileVersion("1.0.0.0")] +diff --git a/Word2Vec.Net/Word2Vec.Net.csproj b/Word2Vec.Net/Word2Vec.Net.csproj +index ee3ddb9..52cc678 100644 +--- a/Word2Vec.Net/Word2Vec.Net.csproj ++++ b/Word2Vec.Net/Word2Vec.Net.csproj +@@ -1,62 +1,26 @@ +-<?xml version="1.0" encoding="utf-8"?> +-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> ++<Project Sdk="Microsoft.NET.Sdk.Web"> ++ <Import Project="..\build\common.props" /> + <PropertyGroup> +- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> +- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> +- <ProjectGuid>{FEFCA2DC-137B-4EEE-A779-0194BDFEBE1F}</ProjectGuid> +- <OutputType>Library</OutputType> +- <AppDesignerFolder>Properties</AppDesignerFolder> +- <RootNamespace>Word2Vec.Net</RootNamespace> ++ <Description>Word2Vec.Net</Description> ++ <TargetFramework>netcoreapp2.1</TargetFramework> ++ <DefineConstants>$(DefineConstants);DEMO</DefineConstants> ++ <WarningsAsErrors>true</WarningsAsErrors> ++ <PreserveCompilationContext>true</PreserveCompilationContext> + <AssemblyName>Word2Vec.Net</AssemblyName> +- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> +- <FileAlignment>512</FileAlignment> ++ <OutputType>library</OutputType> ++ ++ <!-- This will prevent our build system from trying to package this project. --> ++ <IsPackable>false</IsPackable> ++ ++ <!-- This will be set as an environment variable to pin the version. --> ++ <RuntimeFrameworkVersion>$(WORD2VEC_FRAMEWORK_VERSION)</RuntimeFrameworkVersion> + </PropertyGroup> +- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> +- <DebugSymbols>true</DebugSymbols> +- <DebugType>full</DebugType> +- <Optimize>false</Optimize> +- <OutputPath>bin\Debug\</OutputPath> +- <DefineConstants>DEBUG;TRACE</DefineConstants> +- <ErrorReport>prompt</ErrorReport> +- <WarningLevel>4</WarningLevel> +- <DocumentationFile>bin\Debug\Word2Vec.Net.XML</DocumentationFile> +- <PlatformTarget>AnyCPU</PlatformTarget> ++ ++ <PropertyGroup Condition=" '$(RuntimeFrameworkVersion)' == '' "> ++ <RuntimeFrameworkVersion>2.1.0-*</RuntimeFrameworkVersion> + </PropertyGroup> +- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> +- <DebugType>pdbonly</DebugType> +- <Optimize>true</Optimize> +- <OutputPath>bin\Release\</OutputPath> +- <DefineConstants>TRACE</DefineConstants> +- <ErrorReport>prompt</ErrorReport> +- <WarningLevel>4</WarningLevel> ++ ++ <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> ++ <DefineConstants>$(DefineConstants);RELEASE</DefineConstants> + </PropertyGroup> +- <ItemGroup> +- <Reference Include="System" /> +- <Reference Include="System.Core" /> +- <Reference Include="System.Xml.Linq" /> +- <Reference Include="System.Data.DataSetExtensions" /> +- <Reference Include="Microsoft.CSharp" /> +- <Reference Include="System.Data" /> +- <Reference Include="System.Xml" /> +- </ItemGroup> +- <ItemGroup> +- <Compile Include="Distance.cs" /> +- <Compile Include="StringExtension.cs" /> +- <Compile Include="Utils\FileStreamExtensions.cs" /> +- <Compile Include="VocubWord.cs" /> +- <Compile Include="Word2Vec.cs" /> +- <Compile Include="Properties\AssemblyInfo.cs" /> +- <Compile Include="Word2VecAnalysisBase.cs" /> +- <Compile Include="Word2VecBuilder.cs" /> +- <Compile Include="WordAnalogy.cs" /> +- </ItemGroup> +- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +- <!-- To modify your build process, add your task inside one of the targets below and uncomment it. +- Other similar extension points exist, see Microsoft.Common.targets. +- <Target Name="BeforeBuild"> +- </Target> +- <Target Name="AfterBuild"> +- </Target> +- --> +-</Project> +\ No newline at end of file ++</Project> +diff --git a/Word2Vec.Net/Word2Vec.cs b/Word2Vec.Net/Word2Vec.cs +index 968bf88..4142c7b 100644 +--- a/Word2Vec.Net/Word2Vec.cs ++++ b/Word2Vec.Net/Word2Vec.cs +@@ -57,7 +57,7 @@ namespace Word2Vec.Net + private const int TableSize = (int) 1e8; + private int[] _table; + +- internal Word2Vec( ++ public Word2Vec( + string trainFileName, + string outPutfileName, + string saveVocabFileName, +@@ -186,7 +186,7 @@ namespace Word2Vec.Net + for (var a = 0; a < VocabHashSize; a++) _vocabHash[a] = -1; + int size = _vocabSize; + _trainWords = 0; +- for (var a = 0; a < size; a++) ++ /*for (var a = 0; a < size; a++) + { + // Words occuring less than min_count times will be discarded from the vocab + if (_vocab[a].Cn < _minCount && (a != 0)) +@@ -203,7 +203,7 @@ namespace Word2Vec.Net + _trainWords += _vocab[a].Cn; + } + } +- Array.Resize(ref _vocab, _vocabSize + 1); ++ Array.Resize(ref _vocab, _vocabSize + 1);*/ + + // Allocate memory for the binary tree construction + for (var a = 0; a < _vocabSize; a++) +@@ -331,56 +331,48 @@ namespace Word2Vec.Net + + private void LearnVocabFromTrainFile() + { +- int i; +- for (var a = 0; a < VocabHashSize; a++) _vocabHash[a] = -1; +- using (var fin = File.OpenText(_trainFile)) ++ int i; ++ for (var a = 0; a < VocabHashSize; a++) _vocabHash[a] = -1; ++ string[] fin = System.IO.File.ReadAllLines(_trainFile); ++ _vocabSize = 0; ++ ++ Regex regex = new Regex("\\s"); ++ AddWordToVocab("</s>"); ++ foreach (string line in fin) ++ { ++ string[] words = regex.Split(line); ++ ++ foreach (var word in words) + { +- if (fin == StreamReader.Null) ++ if(string.IsNullOrWhiteSpace(word)) continue; ++ _trainWords++; ++ if ((_debugMode > 1) && (_trainWords%100000 == 0)) + { +- throw new InvalidOperationException("ERROR: training data file not found!\n"); ++ Console.Write("{0}K \r", _trainWords/1000); ++ //printf("%lldK%c", train_words / 1000, 13); ++ //fflush(stdout); + } +- _vocabSize = 0; +- +- string line; +- Regex regex = new Regex("\\s"); +- AddWordToVocab("</s>"); +- while ((line = fin.ReadLine()) != null) +- { +- if (fin.EndOfStream) break; +- string[] words = regex.Split(line); +- +- foreach (var word in words) +- { +- if(string.IsNullOrWhiteSpace(word)) continue; +- _trainWords++; +- if ((_debugMode > 1) && (_trainWords%100000 == 0)) +- { +- Console.Write("{0}K \r", _trainWords/1000); +- //printf("%lldK%c", train_words / 1000, 13); +- //fflush(stdout); +- } +- i = SearchVocab(word); +- if (i == -1) ++ i = SearchVocab(word); ++ if (i == -1) + { + var a = AddWordToVocab(word); + _vocab[a].Cn = 1; + } +- else +- _vocab[i].Cn++; +- if (_vocabSize > VocabHashSize*0.7) +- ReduceVocab(); +- } +- } +- SortVocab(); +- if (_debugMode > 0) +- { +- Console.WriteLine("Vocab size: {0}", _vocabSize); +- Console.WriteLine("Words in train file: {0}", _trainWords); +- } +- //file_size = ftell(fin); +- _fileSize = new FileInfo(_trainFile).Length; ++ else ++ _vocab[i].Cn++; ++ if (_vocabSize > VocabHashSize*0.7) ++ ReduceVocab(); + } + } ++ SortVocab(); ++ if (_debugMode > 0) ++ { ++ Console.WriteLine("Vocab size: {0}", _vocabSize); ++ Console.WriteLine("Words in train file: {0}", _trainWords); ++ } ++ //file_size = ftell(fin); ++ _fileSize = new FileInfo(_trainFile).Length; ++ } + + private void SaveVocab() + { +diff --git a/Word2Vec.Net/WordAnalogy.cs b/Word2Vec.Net/WordAnalogy.cs +index eaa35bf..8347c0f 100644 +--- a/Word2Vec.Net/WordAnalogy.cs ++++ b/Word2Vec.Net/WordAnalogy.cs +@@ -24,7 +24,7 @@ namespace Word2Vec.Net + for (b = 0; b < Words; b++) if (!new string(Vocab, (int)(b * max_w), (int)max_w).Equals(st[a])) break; + if (b == Words) b = -1; + bi[a] = b; +- Console.Write("\nWord: {0} Position in vocabulary: {1}\n", st[a], bi[a]); ++ //Console.Write("\nWord: {0} Position in vocabulary: {1}\n", st[a], bi[a]); + if (b == -1) + { + Console.Write("Out of dictionary word!\n"); +diff --git a/Word2VecScenario/App.config b/Word2VecScenario/App.config +new file mode 100644 +index 0000000..e8482b1 +--- /dev/null ++++ b/Word2VecScenario/App.config +@@ -0,0 +1,12 @@ ++<?xml version="1.0" encoding="utf-8" ?> ++<configuration> ++ ++ <runtime> ++ <gcAllowVeryLargeObjects enabled="true"/> ++ </runtime> ++ ++ <startup> ++ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> ++ </startup> ++ ++</configuration> +\ No newline at end of file +diff --git a/Word2VecScenario/Corpus.txt.ReadMe.txt b/Word2VecScenario/Corpus.txt.ReadMe.txt +new file mode 100644 +index 0000000..82c04e5 +--- /dev/null ++++ b/Word2VecScenario/Corpus.txt.ReadMe.txt +@@ -0,0 +1,5 @@ ++Please download and rename the following file: ++ ++http://mattmahoney.net/dc/text8.zip ++ ++Renaming the file inside the zip to: Corpus.txt - In place of this File! +diff --git a/Word2VecScenario/Program.cs b/Word2VecScenario/Program.cs +new file mode 100644 +index 0000000..7e9ad31 +--- /dev/null ++++ b/Word2VecScenario/Program.cs +@@ -0,0 +1,161 @@ ++namespace Word2VecScenario ++{ ++ using System; ++ using System.Diagnostics; ++ using System.Linq; ++ using Word2Vec.Net; ++ ++ class Program ++ { ++ static string path = @"Word2VectorOutputFile.bin"; ++ static Distance distance = null; ++ static WordAnalogy wordAnalogy = null; ++ ++ static void Main(string[] args) ++ { ++ // -train <file> Use text data from <file> to train the model ++ string train = "Corpus.txt"; ++ ++ // -output <file> Use <file> to save the resulting word vectors / word clusters ++ string output = "Vectors.bin"; ++ ++ // -save-vocab <file> The vocabulary will be saved to <file> ++ string savevocab = ""; ++ ++ // -read-vocab <file> The vocabulary will be read from <file>, not constructed from the training data ++ string readvocab = ""; ++ ++ // -size <int> Set size of word vectors; default is 100 ++ int size = 100; ++ ++ // -debug <int> Set the debug mode (default = 2 = more info during training) ++ int debug = 1; ++ ++ // -binary <int> Save the resulting vectors in binary moded; default is 0 (off) ++ int binary = 1; ++ ++ // -cbow <int> Use the continuous bag of words model; default is 1 (use 0 for skip-gram model) ++ int cbow = 1; ++ ++ // -alpha <float> Set the starting learning rate; default is 0.025 for skip-gram and 0.05 for CBOW ++ float alpha = 0.05f; ++ ++ // -sample <float> Set threshold for occurrence of words. Those that appear with higher frequency in the training data ++ float sample = 1e-4f; ++ ++ // -hs <int> Use Hierarchical Softmax; default is 0 (not used) ++ int hs = 0; ++ ++ // -negative <int> Number of negative examples; default is 5, common values are 3 - 10 (0 = not used) ++ int negative = 5; ++ ++ // -threads <int> Use <int> threads (default 12) ++ int threads = 12; ++ ++ // -iter <int> Run more training iterations (default 5) ++ long iter = 15; ++ ++ // -min-count <int> This will discard words that appear less than <int> times; default is 5 ++ int mincount = 5; ++ ++ // -classes <int> Output word classes rather than word vectors; default number of classes is 0 (vectors are written) ++ long classes = 0; ++ ++ // -window <int> Set max skip length between words; default is 5 ++ int window = 12; ++ ++ Word2Vec word2Vec = new Word2Vec(train, output, savevocab, readvocab, size, debug, binary, cbow, alpha, sample, hs, negative, threads, iter, mincount, classes, window); ++ ++ var totalTime = Stopwatch.StartNew(); ++ var highRes = Stopwatch.IsHighResolution; ++ ++ word2Vec.TrainModel(); ++ ++ totalTime.Stop(); ++ ++ var trainingTime = totalTime.ElapsedMilliseconds; ++ Console.WriteLine("Training took {0}ms", trainingTime); ++ ++ path = @"Vectors.bin"; ++ distance = new Distance(path); ++ wordAnalogy = new WordAnalogy(path); ++ ++ string[] wordList = new string[] {"paris france madrid" }; ++ ++ var searchTime = Stopwatch.StartNew(); ++ ++ foreach (string word in wordList) ++ { ++ distance.Search(word); ++ wordAnalogy.Search(word); ++ } ++ ++ searchTime.Stop(); ++ var firstSearchTime = searchTime.ElapsedMilliseconds; ++ Console.WriteLine("Search took {0}ms", firstSearchTime); ++ ++ int outerN = 5; ++ ++ for (int outer = 0; outer < outerN; outer++) ++ { ++ foreach (string word in wordList) ++ { ++ int N = 11; ++ var minSearchTime = long.MaxValue; ++ var maxSearchTime = long.MinValue; ++ long[] searchTimes = new long[N]; ++ ++ Console.WriteLine($"Batch {outer}, searching {word}: running {N} searches"); ++ ++ for (int inner = 0; inner < N; inner++) ++ { ++ searchTime.Restart(); ++ distance.Search(word); ++ BestWord[] result = wordAnalogy.Search(word); ++ searchTime.Stop(); ++ ++ /*foreach (var bestWord in result) ++ { ++ Console.WriteLine("{0}\t\t{1}", bestWord.Word, bestWord.Distance); ++ }*/ ++ ++ long interval = highRes ? searchTime.ElapsedTicks : searchTime.ElapsedMilliseconds; ++ searchTimes[inner] = interval; ++ ++ if (interval < minSearchTime) ++ { ++ minSearchTime = interval; ++ } ++ if (interval > maxSearchTime) ++ { ++ maxSearchTime = interval; ++ } ++ } ++ ++ if (highRes) ++ { ++ double averageSearch = 1000 * ((double)searchTimes.Sum() / N / Stopwatch.Frequency); ++ double medianSearch = 1000 * ((double)searchTimes.OrderBy(t => t).ElementAt(N / 2) / Stopwatch.Frequency); ++ Console.WriteLine("Steadystate min search time: {0:F2}ms", (1000 * minSearchTime) / Stopwatch.Frequency); ++ Console.WriteLine("Steadystate max search time: {0:F2}ms", (1000 * maxSearchTime) / Stopwatch.Frequency); ++ Console.WriteLine("Steadystate average search time: {0:F2}ms", averageSearch); ++ Console.WriteLine("Steadystate median search time: {0:F2}ms", medianSearch); ++ } ++ else ++ { ++ long averageSearch = searchTimes.Sum() / N; ++ long medianSearch = searchTimes.OrderBy(t => t).ElementAt(N / 2); ++ Console.WriteLine("Steadystate min search time: {0}ms", minSearchTime); ++ Console.WriteLine("Steadystate max search time: {0}ms", maxSearchTime); ++ Console.WriteLine("Steadystate average search time: {0}ms", (int)averageSearch); ++ Console.WriteLine("Steadystate median search time: {0}ms", (int)medianSearch); ++ } ++ ++ Console.WriteLine(""); ++ } ++ } ++ } ++ ++ } ++ ++} +diff --git a/Word2VecScenario/Word2VecScenario.csproj b/Word2VecScenario/Word2VecScenario.csproj +new file mode 100644 +index 0000000..cacd48a +--- /dev/null ++++ b/Word2VecScenario/Word2VecScenario.csproj +@@ -0,0 +1,34 @@ ++<Project Sdk="Microsoft.NET.Sdk.Web"> ++ <Import Project="..\build\common.props" /> ++ <PropertyGroup> ++ <Description>Test for Word2Vec</Description> ++ <TargetFramework>netcoreapp2.1</TargetFramework> ++ <DefineConstants>$(DefineConstants);DEMO</DefineConstants> ++ <WarningsAsErrors>true</WarningsAsErrors> ++ <PreserveCompilationContext>true</PreserveCompilationContext> ++ <AssemblyName>Word2VecScenario</AssemblyName> ++ <OutputType>Exe</OutputType> ++ ++ <!-- This will prevent our build system from trying to package this project. --> ++ <IsPackable>false</IsPackable> ++ ++ <!-- This will be set as an environment variable to pin the version. --> ++ <RuntimeFrameworkVersion>$(WORD2VEC_FRAMEWORK_VERSION)</RuntimeFrameworkVersion> ++ </PropertyGroup> ++ ++ <PropertyGroup Condition=" '$(RuntimeFrameworkVersion)' == '' "> ++ <RuntimeFrameworkVersion>2.1.0-*</RuntimeFrameworkVersion> ++ </PropertyGroup> ++ ++ <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> ++ <DefineConstants>$(DefineConstants);RELEASE</DefineConstants> ++ </PropertyGroup> ++ ++ <ItemGroup> ++ <ProjectReference Include="..\Word2Vec.Net\Word2Vec.Net.csproj"> ++ <Name>Word2Vec.Net</Name> ++ </ProjectReference> ++ </ItemGroup> ++ ++</Project> ++ +diff --git a/build/common.props b/build/common.props +new file mode 100644 +index 0000000..36d884c +--- /dev/null ++++ b/build/common.props +@@ -0,0 +1,5 @@ ++<Project> ++ ++ <Import Project="dependencies.props" /> ++ ++</Project> +diff --git a/build/dependencies.props b/build/dependencies.props +new file mode 100644 +index 0000000..95d79b3 +--- /dev/null ++++ b/build/dependencies.props +@@ -0,0 +1,5 @@ ++<Project> ++ <PropertyGroup> ++ <RuntimeFrameworkVersion>2.0.0-*</RuntimeFrameworkVersion> ++ </PropertyGroup> ++</Project> diff --git a/tests/src/performance/Scenario/JitBench/Runner/Benchmark.cs b/tests/src/performance/Scenario/JitBench/Runner/Benchmark.cs index 206cd556da..13554c896e 100644 --- a/tests/src/performance/Scenario/JitBench/Runner/Benchmark.cs +++ b/tests/src/performance/Scenario/JitBench/Runner/Benchmark.cs @@ -71,20 +71,18 @@ namespace JitBench startInfo.WorkingDirectory = WorkingDirPath; startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; - foreach (KeyValuePair<string, string> kv in config.EnvironmentVariables) + IEnumerable<KeyValuePair<string, string>> extraEnvVars = config.EnvironmentVariables.Concat(EnvironmentVariables).Append(new KeyValuePair<string, string>("DOTNET_MULTILEVEL_LOOKUP", "0")); + foreach (KeyValuePair<string, string> kv in extraEnvVars) { startInfo.Environment[kv.Key] = kv.Value; } - foreach (KeyValuePair<string, string> kv in EnvironmentVariables) - { - startInfo.Environment[kv.Key] = kv.Value; - } - startInfo.Environment["DOTNET_MULTILEVEL_LOOKUP"] = "0"; + output.WriteLine("XUnitPerfHarness doesn't log env vars it uses to run processes. To workaround, logging them here:"); + output.WriteLine(string.Join(", ", extraEnvVars.Select(kv => kv.Key + "=" + kv.Value))); BenchmarkRunResult result = new BenchmarkRunResult(this, config); StringBuilder stderr = new StringBuilder(); StringBuilder stdout = new StringBuilder(); - var scenarioConfiguration = new ScenarioTestConfiguration(TimeSpan.FromMinutes(1), startInfo) + var scenarioConfiguration = new ScenarioTestConfiguration(TimeSpan.FromMinutes(60), startInfo) { //XUnitPerformanceHarness writes files to disk starting with {runid}-{ScenarioBenchmarkName}-{TestName} TestName = (Name + "-" + config.Name).Replace(' ', '_'), @@ -143,6 +141,7 @@ namespace JitBench "dotnet.exe", "MusicStore.dll", "AllReady.dll", + "Word2VecScenario.dll", "ntoskrnl.exe", "System.Private.CoreLib.dll", "Unknown", diff --git a/tests/src/performance/Scenario/JitBench/Utilities/FileTasks.cs b/tests/src/performance/Scenario/JitBench/Utilities/FileTasks.cs index 5e9efa2ffb..e5391cafd0 100644 --- a/tests/src/performance/Scenario/JitBench/Utilities/FileTasks.cs +++ b/tests/src/performance/Scenario/JitBench/Utilities/FileTasks.cs @@ -178,6 +178,9 @@ namespace JitBench } try { + // On some systems, directories/files created programmatically are created with attributes + // that prevent them from being deleted. Set those attributes to be normal + SetAttributesNormal(path); Directory.Delete(path, true); return; } @@ -194,6 +197,18 @@ namespace JitBench } } + public static void SetAttributesNormal(string path) + { + foreach (var subDir in Directory.GetDirectories(path)) + { + SetAttributesNormal(subDir); + } + foreach (var file in Directory.GetFiles(path)) + { + File.SetAttributes(file, FileAttributes.Normal); + } + } + public static void MoveDirectory(string sourceDirName, string destDirName, ITestOutputHelper output) { if (output != null) @@ -225,6 +240,37 @@ namespace JitBench } } + public static void MoveFile(string sourceFileName, string destFileName, ITestOutputHelper output) + { + if (output != null) + { + output.WriteLine("Moving " + sourceFileName + " -> " + destFileName); + } + int retries = 10; + for (int i = 0; i < retries; i++) + { + if (!File.Exists(sourceFileName) && File.Exists(destFileName)) + { + return; + } + try + { + File.Move(sourceFileName, destFileName); + return; + } + catch (IOException e) when (i < retries - 1) + { + output.WriteLine($" Attempt #{i + 1} failed: {e.Message}"); + } + catch (UnauthorizedAccessException e) when (i < retries - 1) + { + output.WriteLine($" Attempt #{i + 1} failed: {e.Message}"); + } + // if something has a transient lock on the file waiting may resolve the issue + Thread.Sleep((i + 1) * 10); + } + } + public static void CreateDirectory(string path, ITestOutputHelper output) { output.WriteLine("Creating " + path); diff --git a/tests/src/performance/Scenario/JitBench/Utilities/ProcessRunner.cs b/tests/src/performance/Scenario/JitBench/Utilities/ProcessRunner.cs index 60d30e1af6..467ba7dbf7 100644 --- a/tests/src/performance/Scenario/JitBench/Utilities/ProcessRunner.cs +++ b/tests/src/performance/Scenario/JitBench/Utilities/ProcessRunner.cs @@ -67,7 +67,7 @@ namespace JitBench _p.StartInfo = psi; _p.EnableRaisingEvents = false; _loggers = new List<IProcessLogger>(); - _timeout = TimeSpan.FromMinutes(10); + _timeout = TimeSpan.FromMinutes(60); _cancelSource = new CancellationTokenSource(); _killReason = null; _waitForProcessStartTaskSource = new TaskCompletionSource<Process>(); diff --git a/tests/src/performance/Scenario/JitBench/unofficial_dotnet/JitBench.csproj b/tests/src/performance/Scenario/JitBench/unofficial_dotnet/JitBench.csproj index 009949ab1b..74e633a327 100644 --- a/tests/src/performance/Scenario/JitBench/unofficial_dotnet/JitBench.csproj +++ b/tests/src/performance/Scenario/JitBench/unofficial_dotnet/JitBench.csproj @@ -55,4 +55,10 @@ <!-- The CoreCLR test build system requires a target named RestorePackage in order to do BatchRestore --> <Target Name="RestorePackage" DependsOnTargets="Restore" /> + <Target Name="CustomCopyContent" AfterTargets="AfterBuild"> + <Copy SourceFiles="..\Resources\word2vecnet.patch" DestinationFolder="$(OutDir)" /> + </Target> + <Target Name="CustomCopyContentOnPublish" AfterTargets="AfterPublish"> + <Copy SourceFiles="..\Resources\word2vecnet.patch" DestinationFolder="$(PublishDir)" /> + </Target> </Project> diff --git a/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.cs b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.cs new file mode 100644 index 0000000000..85fbf02aa6 --- /dev/null +++ b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.cs @@ -0,0 +1,151 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; +using System.Reflection; +using System.Reflection.Emit; +using System.Threading; + +internal static class Program +{ + private static int Main() + { + // Verify crst levels with GCs triggered during R2R code lookup in the Prestub on the main thread, during which dynamic + // code from a background thread is deleted at the start of the GC in the main thread + + var t = new Thread(() => + { + for (uint i = 0; ; ++i) + { + DynamicMethod dynamicMethod = CreateDynamicMethod($"DynMethod{i}"); + var dynamicMethodDelegate = (Action)dynamicMethod.CreateDelegate(typeof(Action)); + dynamicMethodDelegate(); + } + }); + t.IsBackground = true; + t.Start(); + + for (int i = 0; i < 100; ++i) + { + typeof(Program).InvokeMember( + $"Func{i}", + BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Static, + null, + null, + Array.Empty<object>()); + } + + return 100; + } + + private static DynamicMethod CreateDynamicMethod(string name) + { + var dynamicMethod = new DynamicMethod(name, null, null); + ILGenerator ilGenerator = dynamicMethod.GetILGenerator(); + ilGenerator.Emit(OpCodes.Ret); + return dynamicMethod; + } + + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func0() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func1() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func2() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func3() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func4() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func5() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func6() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func7() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func8() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func9() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func10() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func11() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func12() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func13() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func14() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func15() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func16() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func17() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func18() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func19() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func20() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func21() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func22() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func23() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func24() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func25() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func26() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func27() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func28() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func29() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func30() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func31() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func32() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func33() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func34() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func35() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func36() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func37() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func38() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func39() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func40() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func41() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func42() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func43() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func44() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func45() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func46() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func47() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func48() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func49() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func50() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func51() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func52() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func53() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func54() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func55() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func56() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func57() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func58() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func59() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func60() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func61() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func62() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func63() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func64() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func65() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func66() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func67() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func68() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func69() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func70() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func71() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func72() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func73() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func74() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func75() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func76() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func77() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func78() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func79() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func80() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func81() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func82() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func83() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func84() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func85() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func86() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func87() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func88() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func89() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func90() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func91() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func92() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func93() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func94() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func95() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func96() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func97() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func98() {} + [MethodImpl(MethodImplOptions.NoInlining)] private static void Func99() {} +} diff --git a/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.csproj b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.csproj new file mode 100644 index 0000000000..cce52ccb09 --- /dev/null +++ b/tests/src/readytorun/DynamicMethodGCStress/DynamicMethodGCStress.csproj @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{8884AF49-72DA-44EC-B3E0-9FC8F9BCC1F9}</ProjectGuid> + <OutputType>Exe</OutputType> + <LangVersion>latest</LangVersion> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <Optimize>true</Optimize> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> + </PropertyGroup> + <ItemGroup> + <Compile Include="DynamicMethodGCStress.cs" /> + </ItemGroup> + <PropertyGroup> + <CLRTestBatchPreCommands><![CDATA[ +$(CLRTestBatchPreCommands) +%CORE_ROOT%\crossgen.exe /readytorun /platform_assemblies_paths %CORE_ROOT%%3B%25CD% /out DynamicMethodGCStress.ni.exe DynamicMethodGCStress.exe +set ExePath=DynamicMethodGCStress.ni.exe +set COMPlus_GCStress=3 +]]></CLRTestBatchPreCommands> + <BashCLRTestPreCommands><![CDATA[ +$(BashCLRTestPreCommands) +$CORE_ROOT/crossgen -readytorun -platform_assemblies_paths $CORE_ROOT:`pwd` -out DynamicMethodGCStress.ni.exe DynamicMethodGCStress.exe +ExePath=DynamicMethodGCStress.ni.exe +export COMPlus_GCStress=3 +]]></BashCLRTestPreCommands> + </PropertyGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> +</Project> diff --git a/tests/testsFailing.arm.txt b/tests/testsFailing.arm.txt index 68ad6a3226..1843b0a7e9 100644 --- a/tests/testsFailing.arm.txt +++ b/tests/testsFailing.arm.txt @@ -1 +1,3 @@ GC/API/GC/GetAllocatedBytesForCurrentThread/GetAllocatedBytesForCurrentThread.sh +GC/Scenarios/LeakWheel/leakwheel/leakwheel.sh +CoreMangLib/system/span/SlowTailCallArgs/SlowTailCallArgs.sh
\ No newline at end of file diff --git a/tests/testsUnsupportedOutsideWindows.txt b/tests/testsUnsupportedOutsideWindows.txt index fa7489e1a1..6335481055 100644 --- a/tests/testsUnsupportedOutsideWindows.txt +++ b/tests/testsUnsupportedOutsideWindows.txt @@ -122,6 +122,7 @@ CoreMangLib/cti/system/decimal/DecimalToInt32/DecimalToInt32.sh CoreMangLib/cti/system/reflection/emit/DynMethodJumpStubTests/DynMethodJumpStubTests/DynMethodJumpStubTests.sh CoreMangLib/system/collections/generic/hashset/Regression_Dev10_609271/Regression_Dev10_609271.sh CoreMangLib/system/collections/generic/hashset/Regression_Dev10_624201/Regression_Dev10_624201.sh +GC/Coverage/smalloom/smalloom.sh Interop/MarshalAPI/GetNativeVariantForObject/GetNativeVariantForObject/GetNativeVariantForObject.sh Interop/MarshalAPI/GetObjectForNativeVariant/GetObjectForNativeVariant/GetObjectForNativeVariant.sh Interop/MarshalAPI/GetObjectsForNativeVariants/GetObjectsForNativeVariants/GetObjectsForNativeVariants.sh |