Skip to content

Commit

Permalink
Minor R2RTest improvements (dotnet#58144)
Browse files Browse the repository at this point in the history
*) While working on Crossgen2 perfmap support I hit the need to
make R2RTest support creating perfmaps during CG2 compilation.

*) While I was there I also added a new command-line switch
--iterations to request each test be run given number of times;
this is based on Maoni's ask from some time ago.

Thanks

Tomas
  • Loading branch information
trylek authored Aug 26, 2021
1 parent 3f61d42 commit 8bfb45a
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 95 deletions.
36 changes: 23 additions & 13 deletions src/coreclr/tools/r2rtest/BuildFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class BuildFolder

private string _outputFolder;

private readonly List<ProcessInfo[]> _executions;
private readonly List<ProcessInfo[][]> _executions;

public string IssueID;

Expand All @@ -61,7 +61,7 @@ public BuildFolder(
_outputFolder = outputFolder;

_compilations = new List<ProcessInfo[]>();
_executions = new List<ProcessInfo[]>();
_executions = new List<ProcessInfo[][]>();

if (options.Composite)
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public BuildFolder(
{
foreach (string script in _executionScripts ?? Enumerable.Empty<string>())
{
ProcessInfo[] scriptExecutions = new ProcessInfo[(int)CompilerIndex.Count];
ProcessInfo[][] scriptExecutions = new ProcessInfo[(int)CompilerIndex.Count][];
_executions.Add(scriptExecutions);

foreach (CompilerRunner runner in compilerRunners)
Expand All @@ -107,7 +107,14 @@ public BuildFolder(
folders.Add(Path.GetDirectoryName(script));
folders.UnionWith(runner.ReferenceFolders);

scriptExecutions[(int)runner.Index] = new ProcessInfo(new ScriptExecutionProcessConstructor(runner, _outputFolder, script, modules, folders));
ProcessConstructor constructor = new ScriptExecutionProcessConstructor(runner, _outputFolder, script, modules, folders);
ProcessInfo[] iterations = new ProcessInfo[options.Iterations];
for (int iterationIndex = 0; iterationIndex < options.Iterations; iterationIndex++)
{
iterations[iterationIndex] = new ProcessInfo(constructor);
}

scriptExecutions[(int)runner.Index] = iterations;
}
}
}
Expand Down Expand Up @@ -200,18 +207,21 @@ public static BuildFolder FromDirectory(string inputDirectory, IEnumerable<Compi

public void AddModuleToJittedMethodsMapping(Dictionary<string, HashSet<string>> moduleToJittedMethods, int executionIndex, CompilerIndex compilerIndex)
{
ProcessInfo executionProcess = _executions[executionIndex][(int)compilerIndex];
if (executionProcess != null && executionProcess.JittedMethods != null)
ProcessInfo[] executionProcesses = _executions[executionIndex][(int)compilerIndex];
if (executionProcesses != null)
{
foreach (KeyValuePair<string, HashSet<string>> moduleMethodKvp in executionProcess.JittedMethods)
foreach (ProcessInfo executionProcess in executionProcesses.Where(ep => ep.JittedMethods != null))
{
HashSet<string> jittedMethodsPerModule;
if (!moduleToJittedMethods.TryGetValue(moduleMethodKvp.Key, out jittedMethodsPerModule))
foreach (KeyValuePair<string, HashSet<string>> moduleMethodKvp in executionProcess.JittedMethods)
{
jittedMethodsPerModule = new HashSet<string>();
moduleToJittedMethods.Add(moduleMethodKvp.Key, jittedMethodsPerModule);
HashSet<string> jittedMethodsPerModule;
if (!moduleToJittedMethods.TryGetValue(moduleMethodKvp.Key, out jittedMethodsPerModule))
{
jittedMethodsPerModule = new HashSet<string>();
moduleToJittedMethods.Add(moduleMethodKvp.Key, jittedMethodsPerModule);
}
jittedMethodsPerModule.UnionWith(moduleMethodKvp.Value);
}
jittedMethodsPerModule.UnionWith(moduleMethodKvp.Value);
}
}
}
Expand Down Expand Up @@ -281,6 +291,6 @@ public void WriteJitStatistics(Dictionary<string, HashSet<string>>[] perCompiler

public IList<ProcessInfo[]> Compilations => _compilations;

public IList<ProcessInfo[]> Executions => _executions;
public IList<ProcessInfo[][]> Executions => _executions;
}
}
Loading

0 comments on commit 8bfb45a

Please sign in to comment.