Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add predefined cpu names for --instruction-set (e.g. haswell) #71911

Merged
merged 30 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e32afa0
Add known cpu families as group of instruction sets
EgorBo Jul 10, 2022
2edf8b8
Address feedback
EgorBo Jul 10, 2022
c55ce52
Fix help
EgorBo Jul 10, 2022
bf3febe
Clean up
EgorBo Jul 10, 2022
17b7fdd
Update CorInfoInstructionSet.cs
EgorBo Jul 10, 2022
50490f1
Update CorInfoInstructionSet.cs
EgorBo Jul 10, 2022
8a04be4
Update CorInfoInstructionSet.cs
EgorBo Jul 10, 2022
3e9129c
add "ampere"
EgorBo Jul 11, 2022
f0b175c
Address feedback around llc
EgorBo Jul 11, 2022
2bda735
llc doesn't have SR
EgorBo Jul 11, 2022
21fc10e
Set apple-a1 as a baseline for osx-arm64
EgorBo Jul 11, 2022
eee4fb2
Change ampere to ampere-altra
EgorBo Jul 11, 2022
6707106
Drop implied ISAs
EgorBo Jul 11, 2022
7d7dc11
Address feedback
EgorBo Jul 11, 2022
512983f
Fix ILC
EgorBo Jul 11, 2022
e5a8fac
Clean up
EgorBo Jul 11, 2022
1133ba2
Merge branch 'main' of github.com:dotnet/runtime into crossgen-known-…
EgorBo Jul 11, 2022
91bdc59
drop generic
EgorBo Jul 11, 2022
e79d798
regenerate CorInfoInstructionSet.cs
EgorBo Jul 11, 2022
32ed4e4
Address feedback
EgorBo Jul 12, 2022
21852fe
clean up
EgorBo Jul 12, 2022
17c224e
oops
EgorBo Jul 12, 2022
fa4ce66
Address feedback
EgorBo Jul 12, 2022
445c8fd
Address feedback
EgorBo Jul 12, 2022
58c5d17
Address feedback
EgorBo Jul 12, 2022
8ae07b7
Address feedback
EgorBo Jul 12, 2022
6bc0ca4
Address feedback
EgorBo Jul 12, 2022
cbb4dda
Address feedback
EgorBo Jul 12, 2022
af58650
Address feedback
EgorBo Jul 12, 2022
12f13f1
bug-fixes from testing the PR
EgorBo Jul 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ public InstructionSetSupportBuilder(TargetArchitecture architecture)
/// <returns>returns "false" if instruction set isn't valid on this architecture</returns>
public bool AddSupportedInstructionSet(string instructionSet)
{
// First, check if it's a "known cpu family" group of instruction sets e.g. "skylake"
var sets = InstructionSetFlags.CpuFamilyToInstructionSets(instructionSet, _architecture);
if (sets != null)
{
foreach (string set in sets)
{
if (!s_instructionSetSupport[_architecture].ContainsKey(set))
return false;
_supportedInstructionSets.Add(set);
_unsupportedInstructionSets.Remove(set);
}
return true;
}

if (!s_instructionSetSupport[_architecture].ContainsKey(instructionSet))
return false;

Expand Down
48 changes: 48 additions & 0 deletions src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,54 @@ public InstructionSetInfo(string name, string managedName, InstructionSet instru
}
}

public static IEnumerable<string> AllCpuFamilies()
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
{
// Only report these in the help, others are added to CpuFamilyToInstructionSets just for muscle memory after clang/llvm
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
yield return "generic";
yield return "sandybridge";
yield return "haswell";
yield return "ampere";
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
yield return "apple-m1";
}

public static IEnumerable<string> CpuFamilyToInstructionSets(string cpu, TargetArchitecture arch)
{
string sets = null;

if (arch == TargetArchitecture.ARM64)
{
sets = cpu switch
{
"generic" => "base,neon",

"ampere" => "base,neon,lse",

"apple-m1" => "base,neon,aes,crc,dotprod,rdma,sha1,sha2,lse,rcpc",
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
_ => null
};
}
else if (arch == TargetArchitecture.X64 || arch == TargetArchitecture.X86)
{
sets = cpu switch
{
"generic" => "base,sse",

"sandybridge" or
"ivybridge" => "base,sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,popcnt",

"haswell" or
"broadwell" or
"skylake" or
"cannonlake" => "base,sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,bmi,fma,lzcnt,pclmul,popcnt,movbe,serialize",

// Rosetta2
"apple-m1" => "base,sse,sse2,sse3,ssse3,sse4.1,sse4.2,pclmul",
_ => null
};
}
return sets?.Split(',');
}

public static IEnumerable<InstructionSetInfo> ArchitectureToValidInstructionSets(TargetArchitecture architecture)
{
switch (architecture)
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/tools/aot/crossgen2/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ public CommandLineOptions(string[] args)
extraHelp.Add(archString.ToString());
}

extraHelp.Add("");
extraHelp.Add(SR.CpuFamilies);
extraHelp.Add(string.Join(", ", Internal.JitInterface.InstructionSetFlags.AllCpuFamilies()));
EgorBo marked this conversation as resolved.
Show resolved Hide resolved

argSyntax.ExtraHelpParagraphs = extraHelp;

HelpText = argSyntax.GetHelpText();
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/tools/aot/crossgen2/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,7 @@
<data name="ErrorNonLocalGenericsModule" xml:space="preserve">
<value>"{0}" was specified to the --non-local-generics-module switch, but was not in the set of modules associated with the compile</value>
</data>
<data name="CpuFamilies" xml:space="preserve">
<value>The following CPU names are predefined groups of instruction sets and can be used in --instruction-set too:</value>
</data>
</root>