Skip to content

Commit 8b3929e

Browse files
RakeshwarKRakeshwar Reddy Kambaiahgari
andauthored
Speccpu Compiler Check fix for Windows (#458)
* Installed Compiler Check fix for Windows * Update Path. * Move def. * Excluding version check for widows as we dont support compiler version for CompilerInstallation in windows. * Update tests * Update Doc --------- Co-authored-by: Rakeshwar Reddy Kambaiahgari <[email protected]>
1 parent 96c4a87 commit 8b3929e

File tree

3 files changed

+28
-41
lines changed

3 files changed

+28
-41
lines changed

src/VirtualClient/VirtualClient.Actions.UnitTests/SPEC/SpecCpuExecutorTests.cs

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin
119119
$"powershell -Command \"Mount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"",
120120
$"powershell -Command \"(Get-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso| Get-Volume).DriveLetter\"",
121121
$"cmd /c echo 1 | X:\\install.bat {this.mockPackage.Path}",
122-
"gcc -dumpversion",
123122
$"powershell -Command \"Dismount-DiskImage -ImagePath {this.mockPackage.Path}\\speccpu.iso\"",
124123
$"cmd /c runspeccpu.bat --config vc-win-x64.cfg --iterations 2 --copies 4 --threads 8 --tune all --noreportable intrate"
125124
};
@@ -135,36 +134,18 @@ public async Task SpecCpuExecutorExecutesTheCorrectCommandsWithInstallationInWin
135134
output.Append("X");
136135
}
137136

138-
if (exe == "gcc" && arguments == "-dumpversion")
139-
{
140-
return new InMemoryProcess
141-
{
142-
StartInfo = new ProcessStartInfo
143-
{
144-
FileName = exe,
145-
Arguments = arguments
146-
},
147-
ExitCode = 0,
148-
OnStart = () => true,
149-
OnHasExited = () => true,
150-
StandardOutput = new ConcurrentBuffer(new StringBuilder("10")),
151-
};
152-
}
153-
else
137+
return new InMemoryProcess
154138
{
155-
return new InMemoryProcess
139+
StartInfo = new ProcessStartInfo
156140
{
157-
StartInfo = new ProcessStartInfo
158-
{
159-
FileName = exe,
160-
Arguments = arguments
161-
},
162-
ExitCode = 0,
163-
OnStart = () => true,
164-
OnHasExited = () => true,
165-
StandardOutput = output
166-
};
167-
}
141+
FileName = exe,
142+
Arguments = arguments
143+
},
144+
ExitCode = 0,
145+
OnStart = () => true,
146+
OnHasExited = () => true,
147+
StandardOutput = output
148+
};
168149
};
169150

170151
using (TestSpecCpuExecutor specCpuExecutor = new TestSpecCpuExecutor(this.mockFixture.Dependencies, this.mockFixture.Parameters))

src/VirtualClient/VirtualClient.Actions/SPECcpu/SpecCpuExecutor.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,37 +413,41 @@ private async Task WriteSpecCpuConfigAsync(CancellationToken cancellationToken)
413413
this.PlatformSpecifics.GetScriptPath("speccpu", SpecCpuExecutor.SpecCpuRunShell),
414414
this.Combine(this.PackageDirectory, SpecCpuExecutor.SpecCpuRunShell),
415415
true);
416+
417+
string compilerVersion = await this.GetInstalledCompilerDumpVersionAsync("gcc", cancellationToken);
418+
419+
if (string.IsNullOrEmpty(compilerVersion))
420+
{
421+
throw new WorkloadException("gcc version not found.");
422+
}
423+
424+
templateText = templateText.Replace(
425+
SpecCpuConfigPlaceHolder.Gcc10Workaround,
426+
Convert.ToInt32(compilerVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
427+
StringComparison.OrdinalIgnoreCase);
416428
}
417429
else
418430
{
419431
this.fileSystem.File.Copy(
420432
this.PlatformSpecifics.GetScriptPath("speccpu", SpecCpuExecutor.SpecCpuRunBat),
421433
this.Combine(this.PackageDirectory, SpecCpuExecutor.SpecCpuRunBat),
422434
true);
423-
}
424435

425-
string compilerVersion = await this.GetInstalledCompilerDumpVersionAsync("gcc", cancellationToken);
426-
427-
if (string.IsNullOrEmpty(compilerVersion))
428-
{
429-
throw new WorkloadException("gcc version not found.");
436+
templateText = templateText.Replace(
437+
SpecCpuConfigPlaceHolder.Gcc10Workaround,
438+
SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent,
439+
StringComparison.OrdinalIgnoreCase);
430440
}
431441

432442
templateText = templateText.Replace(SpecCpuConfigPlaceHolder.BaseOptimizingFlags, this.BaseOptimizingFlags, StringComparison.OrdinalIgnoreCase);
433443
templateText = templateText.Replace(SpecCpuConfigPlaceHolder.PeakOptimizingFlags, this.PeakOptimizingFlags, StringComparison.OrdinalIgnoreCase);
434-
templateText = templateText.Replace(
435-
SpecCpuConfigPlaceHolder.Gcc10Workaround,
436-
Convert.ToInt32(compilerVersion) >= 10 ? SpecCpuConfigPlaceHolder.Gcc10WorkaroundContent : string.Empty,
437-
StringComparison.OrdinalIgnoreCase);
438-
439444
await this.fileSystem.File.WriteAllTextAsync(this.Combine(this.PackageDirectory, "config", configurationFile), templateText, cancellationToken);
440445
}
441446

442447
private async Task<string> GetInstalledCompilerDumpVersionAsync(string compilerName, CancellationToken cancellationToken)
443448
{
444449
string command = compilerName;
445450
string commandArguments = "-dumpversion";
446-
447451
string version = string.Empty;
448452

449453
using (IProcessProxy process = this.systemManager.ProcessManager.CreateElevatedProcess(this.Platform, command, commandArguments))

website/docs/workloads/speccpu/speccpu-profiles.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ for evaluating the performance of the CPU for processing calculations.
2020
* win-x64
2121
* win-arm64
2222

23+
**Note**: On Windows platform, the **gcc** compiler version is required to be 10 or higher.
24+
2325
* **Supports Disconnected Scenarios**
2426
* No. Internet connection required.
2527

0 commit comments

Comments
 (0)