Skip to content

Commit

Permalink
Add support for LoongArch64.
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckyXu-HF committed Mar 29, 2022
1 parent 9c1c27b commit 43eaf48
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ The measured data can be exported to different formats (md, html, csv, xml, json
*Supported runtimes:* .NET 5+, .NET Framework 4.6.1+, .NET Core 2.0+, Mono, NativeAOT
*Supported languages:* C#, F#, Visual Basic
*Supported OS:* Windows, Linux, macOS
*Supported architectures:* x86, x64, ARM, ARM64 and Wasm
*Supported architectures:* x86, x64, ARM, ARM64, Wasm and LoongArch64

## Features

Expand Down
2 changes: 1 addition & 1 deletion docs/articles/guides/console-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ dotnet run -c Release -- --filter * --runtimes netcoreapp2.0 netcoreapp2.1 --sta
* `--maxWidth` max parameter column width, the default is 20.
* `--envVars` colon separated environment variables (key:value).
* `--strategy` the RunStrategy that should be used. Throughput/ColdStart/Monitoring.
* `--platform` the Platform that should be used. If not specified, the host process platform is used (default). AnyCpu/X86/X64/Arm/Arm64.
* `--platform` the Platform that should be used. If not specified, the host process platform is used (default). AnyCpu/X86/X64/Arm/Arm64/LoongArch64.
* `--runOncePerIteration` run the benchmark exactly once per iteration.
* `--buildTimeout` build timeout in seconds.
* `--wasmEngine` full path to a java script engine used to run the benchmarks, used by Wasm toolchain.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ The measured data can be exported to different formats (md, html, csv, xml, json
*Supported runtimes:* .NET 5+, .NET Framework 4.6.1+, .NET Core 2.0+, Mono, NativeAOT
*Supported languages:* C#, F#, Visual Basic
*Supported OS:* Windows, Linux, macOS
*Supported architectures:* x86, x64, ARM, ARM64 and Wasm
*Supported architectures:* x86, x64, ARM, ARM64, Wasm and LoongArch64

## Features

Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/ConsoleArguments/CommandLineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class CommandLineOptions
[Option("strategy", Required = false, HelpText = "The RunStrategy that should be used. Throughput/ColdStart/Monitoring.")]
public RunStrategy? RunStrategy { get; set; }

[Option("platform", Required = false, HelpText = "The Platform that should be used. If not specified, the host process platform is used (default). AnyCpu/X86/X64/Arm/Arm64.")]
[Option("platform", Required = false, HelpText = "The Platform that should be used. If not specified, the host process platform is used (default). AnyCpu/X86/X64/Arm/Arm64/LoongArch64.")]
public Platform? Platform { get; set; }

[Option("runOncePerIteration", Required = false, Default = false, HelpText = "Run the benchmark exactly once per iteration.")]
Expand Down
9 changes: 7 additions & 2 deletions src/BenchmarkDotNet/Environments/Platform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public enum Platform
/// <summary>
/// S390x
/// </summary>
S390x
S390x,

/// <summary>
/// LOONGARCH64
/// </summary>
LoongArch64
}
}
}
4 changes: 3 additions & 1 deletion src/BenchmarkDotNet/Extensions/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public static string ToConfig(this Platform platform)
return "ARM64";
case Platform.S390x:
return "S390x";
case Platform.LoongArch64:
return "LOONGARCH64";
default:
return "AnyCPU";
}
}

public static string ToConfig(this Jit jit) => jit == Jit.LegacyJit ? "1" : "0";
}
}
}
3 changes: 3 additions & 0 deletions src/BenchmarkDotNet/Portability/RuntimeInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public static Platform GetCurrentPlatform()
// https://github.com/dotnet/runtime/blob/d81ad044fa6830f5f31f6b6e8224ebf66a3c298c/src/libraries/System.Runtime.InteropServices.RuntimeInformation/src/System/Runtime/InteropServices/RuntimeInformation/Architecture.cs#L12-L13
const Architecture Wasm = (Architecture)4;
const Architecture S390x = (Architecture)5;
const Architecture LoongArch64 = (Architecture)6;

switch (ProcessArchitecture)
{
Expand All @@ -249,6 +250,8 @@ public static Platform GetCurrentPlatform()
return Platform.Wasm;
case S390x:
return Platform.S390x;
case LoongArch64:
return Platform.LoongArch64;
default:
throw new ArgumentOutOfRangeException();
}
Expand Down
1 change: 1 addition & 0 deletions tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ public void UserCanSpecifyEnvironmentVariables()
[InlineData(Platform.X64)]
[InlineData(Platform.Arm)]
[InlineData(Platform.Arm64)]
[InlineData(Platform.LoongArch64)]
public void UserCanSpecifyProcessPlatform(Platform platform)
{
var parsedConfig = ConfigParser.Parse(new[] { "--platform", platform.ToString() }, new OutputLogger(Output)).config;
Expand Down

0 comments on commit 43eaf48

Please sign in to comment.