Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void SetupTest()
this.Parameters = new Dictionary<string, IConvertible>()
{
{ nameof(LMbenchExecutor.PackageName), "lmbench" },
{ nameof(LMbenchExecutor.CompilerFlags), "CPPFLAGS=\"-I /usr/include/tirpc\"" }
{ nameof(LMbenchExecutor.CompilerFlags), "CPPFLAGS=\"-I /usr/include/tirpc\"" },
{ nameof(LMbenchExecutor.Scenario), "Scenario" }
};

this.ProcessManager.OnProcessCreated = (process) =>
Expand All @@ -60,6 +61,27 @@ public async Task LMbenchExecutorExecutesTheExpectedWorkloadCommands()
}
}

[Test]
public async Task LMbenchExecutorExecutesTheExpectedCommandForLatMemRd()
{
this.Parameters[nameof(LMbenchExecutor.BinaryName)] = "lat_mem_rd";
this.ProcessManager.OnProcessCreated = (process) =>
{
string lmbenchOutput = System.IO.File.ReadAllText(this.Combine(LMbenchExecutorTests.Examples, "latmemrd_example_results.txt"));
process.StandardOutput.Append(lmbenchOutput);
};
using (TestLMbenchExecutor lmbenchExecutor = new TestLMbenchExecutor(this.Dependencies, this.Parameters))
{
await lmbenchExecutor.ExecuteAsync(EventContext.None, CancellationToken.None);

Assert.IsTrue(this.ProcessManager.CommandsExecuted(
$"sudo chmod -R 2777 \"{this.mockPackage.Path}/scripts\"",
$"make build CPPFLAGS=\"-I /usr/include/tirpc\"",
$"bash -c \"echo -e '\n\n\n\n\n\n\n\n\n\n\n\n\nnone' | make results\"",
$"make summary"));
}
}

[Test]
public async Task LMbenchExecutorExecutesTheExpectedLMbenchBenchmarks()
{
Expand Down
45 changes: 30 additions & 15 deletions src/VirtualClient/VirtualClient.Actions/LMbench/LMbenchExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel
await this.LogProcessDetailsAsync(executeBinary, telemetryContext);
executeBinary.ThrowIfErrored<WorkloadException>(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed);
LatMemRdMetricsParser latMemRdMetricsParser = new LatMemRdMetricsParser($"{executeBinary.StandardOutput.ToString()}{executeBinary.StandardError.ToString()}");
this.CaptureMetrics(executeBinary, latMemRdMetricsParser, telemetryContext, this.BinaryName);
IList<Metric> metrics = latMemRdMetricsParser.Parse();

foreach (Metric metric in metrics)
{
IConvertible arraySize = null, strideSizeInBytes = null;
metric.Metadata.TryGetValue("ArraySize", out arraySize);
metric.Metadata.TryGetValue("StrideSizeInBytes", out strideSizeInBytes);
string scenario = $"StrideSize_{strideSizeInBytes ?? string.Empty}_B_ArraySize_{arraySize ?? string.Empty}";
this.CaptureMetric(metric, executeBinary, telemetryContext, $"LMBench\\{this.BinaryName}", scenario);
}
}
}
}
Expand Down Expand Up @@ -238,7 +247,7 @@ private Task BuildSourceCodeAsync(EventContext telemetryContext, CancellationTok
});
}

private void CaptureMetrics(IProcessProxy process, MetricsParser metricsParser, EventContext telemetryContext, string scenario)
private void CaptureMetric(Metric metric, IProcessProxy process, EventContext telemetryContext, string toolName, string scenarioName)
{
this.MetadataContract.AddForScenario(
"LMbench",
Expand All @@ -247,18 +256,18 @@ private void CaptureMetrics(IProcessProxy process, MetricsParser metricsParser,

this.MetadataContract.Apply(telemetryContext);

IList<Metric> metrics = metricsParser.Parse();

this.Logger.LogMetrics(
toolName: "LMbench",
scenarioName: scenario,
process.StartTime,
process.ExitTime,
metrics,
metricCategorization: null,
scenarioArguments: process.FullCommand(),
this.Tags,
telemetryContext);
this.Logger.LogMetric(
toolName: toolName,
scenarioName: scenarioName,
process.StartTime,
process.ExitTime,
metric.Name,
metric.Value,
metric.Unit,
metricCategorization: null,
scenarioArguments: process.FullCommand(),
this.Tags,
telemetryContext);
}

private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationToken cancellationToken)
Expand Down Expand Up @@ -326,7 +335,13 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok
// The use of the original telemetry context created at the top
// is purposeful.
LMbenchMetricsParser lmbenchMetricsParser = new LMbenchMetricsParser(process.StandardOutput.ToString());
this.CaptureMetrics(process, lmbenchMetricsParser, relatedContext, "Memory Benchmark");
IList<Metric> metrics = lmbenchMetricsParser.Parse();

foreach (Metric metric in metrics)
{
string scenario = "Memory Benchmark";
this.CaptureMetric(metric, process, telemetryContext, $"LMBench", scenario);
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ public override IList<Metric> Parse()
{
var values = line.Split(' ');
string strideSize = section.Key.Split('=')[1];
var metadata = new Dictionary<string, IConvertible>();
metadata.Add("StrideSizeBytes", strideSize);
metadata.Add("ArraySizeInMiB", values[0]);
long arraySizeInBytes = this.RoundOffToNearest512Multiple(double.Parse(values[0]) * 1024 * 1024) * 512;
metrics.Add(new Metric($"Latency_StrideBytes_{strideSize}_Array_{this.MetricNameSuffix(arraySizeInBytes)}", double.Parse(values[1]), "ns", MetricRelativity.LowerIsBetter, null, $"Latency for memory read operation for Array size in MB {values[0]} & stride size {strideSize} in nano seconds", metadata));
var metadata = new Dictionary<string, IConvertible>();

metadata.Add("StrideSizeInBytes", strideSize);
metadata.Add("ArraySize", this.ArraySizeWithUnit(arraySizeInBytes));
metadata.Add("ArraySizeInBytes", arraySizeInBytes);

metrics.Add(new Metric($"Latency", double.Parse(values[1]), "ns", MetricRelativity.LowerIsBetter, null, $"Latency for memory read operation for Array size in MB {values[0]} & stride size {strideSize} in nano seconds", metadata));
}
}

Expand All @@ -65,7 +68,7 @@ private long RoundOffToNearest512Multiple(double number)
return (long)Math.Round(number / 512.0);
}

private string MetricNameSuffix(double bytes)
private string ArraySizeWithUnit(double bytes)
{
if (bytes >= 1024 * 1024)
{
Expand All @@ -79,7 +82,6 @@ private string MetricNameSuffix(double bytes)
{
return $"{bytes}_B";
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"Parameters": {
"CompilerName": "gcc",
"CompilerVersion": "10",
"CompilerFlags": "CPPFLAGS=\"-I /usr/include/tirpc\""
"CompilerVersion": "13",
"CompilerFlags": "CPPFLAGS=\" -O2 -Wall -march=native -I /usr/include/tirpc\""
},
"Actions": [
{
Expand Down
Loading