forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Arm64] Vector64<double>.CreateScalar, Vector64<ulong>CreateScalar an…
…d Vector64<long>.CreateScalar (dotnet#38139)
- Loading branch information
Showing
7 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/coreclr/tests/src/JIT/HardwareIntrinsics/General/Vector64/CreateScalar.Double.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
/****************************************************************************** | ||
* This file is auto-generated from a template file by the GenerateTests.csx * | ||
* script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * | ||
* changes, please update the corresponding template and run according to the * | ||
* directions listed in the file. * | ||
******************************************************************************/ | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Intrinsics; | ||
|
||
namespace JIT.HardwareIntrinsics.General | ||
{ | ||
public static partial class Program | ||
{ | ||
private static void CreateScalarDouble() | ||
{ | ||
var test = new VectorCreate__CreateScalarDouble(); | ||
|
||
// Validates basic functionality works | ||
test.RunBasicScenario(); | ||
|
||
// Validates calling via reflection works | ||
test.RunReflectionScenario(); | ||
|
||
if (!test.Succeeded) | ||
{ | ||
throw new Exception("One or more scenarios did not complete as expected."); | ||
} | ||
} | ||
} | ||
|
||
public sealed unsafe class VectorCreate__CreateScalarDouble | ||
{ | ||
private static readonly int LargestVectorSize = 8; | ||
|
||
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Double>>() / sizeof(Double); | ||
|
||
public bool Succeeded { get; set; } = true; | ||
|
||
public void RunBasicScenario() | ||
{ | ||
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); | ||
|
||
Double value = TestLibrary.Generator.GetDouble(); | ||
Vector64<Double> result = Vector64.CreateScalar(value); | ||
|
||
ValidateResult(result, value); | ||
} | ||
|
||
public void RunReflectionScenario() | ||
{ | ||
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario)); | ||
|
||
Double value = TestLibrary.Generator.GetDouble(); | ||
object result = typeof(Vector64) | ||
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(Double) }) | ||
.Invoke(null, new object[] { value }); | ||
|
||
ValidateResult((Vector64<Double>)(result), value); | ||
} | ||
|
||
private void ValidateResult(Vector64<Double> result, Double expectedValue, [CallerMemberName] string method = "") | ||
{ | ||
Double[] resultElements = new Double[ElementCount]; | ||
Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref resultElements[0]), result); | ||
ValidateResult(resultElements, expectedValue, method); | ||
} | ||
|
||
private void ValidateResult(Double[] resultElements, Double expectedValue, [CallerMemberName] string method = "") | ||
{ | ||
bool succeeded = true; | ||
|
||
if (resultElements[0] != expectedValue) | ||
{ | ||
succeeded = false; | ||
} | ||
else | ||
{ | ||
for (var i = 1; i < ElementCount; i++) | ||
{ | ||
if (resultElements[i] != 0) | ||
{ | ||
succeeded = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (!succeeded) | ||
{ | ||
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(Double): {method} failed:"); | ||
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}"); | ||
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})"); | ||
TestLibrary.TestFramework.LogInformation(string.Empty); | ||
|
||
Succeeded = false; | ||
} | ||
} | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
src/coreclr/tests/src/JIT/HardwareIntrinsics/General/Vector64/CreateScalar.Int64.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
/****************************************************************************** | ||
* This file is auto-generated from a template file by the GenerateTests.csx * | ||
* script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * | ||
* changes, please update the corresponding template and run according to the * | ||
* directions listed in the file. * | ||
******************************************************************************/ | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Intrinsics; | ||
|
||
namespace JIT.HardwareIntrinsics.General | ||
{ | ||
public static partial class Program | ||
{ | ||
private static void CreateScalarInt64() | ||
{ | ||
var test = new VectorCreate__CreateScalarInt64(); | ||
|
||
// Validates basic functionality works | ||
test.RunBasicScenario(); | ||
|
||
// Validates calling via reflection works | ||
test.RunReflectionScenario(); | ||
|
||
if (!test.Succeeded) | ||
{ | ||
throw new Exception("One or more scenarios did not complete as expected."); | ||
} | ||
} | ||
} | ||
|
||
public sealed unsafe class VectorCreate__CreateScalarInt64 | ||
{ | ||
private static readonly int LargestVectorSize = 8; | ||
|
||
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Int64>>() / sizeof(Int64); | ||
|
||
public bool Succeeded { get; set; } = true; | ||
|
||
public void RunBasicScenario() | ||
{ | ||
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); | ||
|
||
Int64 value = TestLibrary.Generator.GetInt64(); | ||
Vector64<Int64> result = Vector64.CreateScalar(value); | ||
|
||
ValidateResult(result, value); | ||
} | ||
|
||
public void RunReflectionScenario() | ||
{ | ||
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario)); | ||
|
||
Int64 value = TestLibrary.Generator.GetInt64(); | ||
object result = typeof(Vector64) | ||
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(Int64) }) | ||
.Invoke(null, new object[] { value }); | ||
|
||
ValidateResult((Vector64<Int64>)(result), value); | ||
} | ||
|
||
private void ValidateResult(Vector64<Int64> result, Int64 expectedValue, [CallerMemberName] string method = "") | ||
{ | ||
Int64[] resultElements = new Int64[ElementCount]; | ||
Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref resultElements[0]), result); | ||
ValidateResult(resultElements, expectedValue, method); | ||
} | ||
|
||
private void ValidateResult(Int64[] resultElements, Int64 expectedValue, [CallerMemberName] string method = "") | ||
{ | ||
bool succeeded = true; | ||
|
||
if (resultElements[0] != expectedValue) | ||
{ | ||
succeeded = false; | ||
} | ||
else | ||
{ | ||
for (var i = 1; i < ElementCount; i++) | ||
{ | ||
if (resultElements[i] != 0) | ||
{ | ||
succeeded = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (!succeeded) | ||
{ | ||
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(Int64): {method} failed:"); | ||
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}"); | ||
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})"); | ||
TestLibrary.TestFramework.LogInformation(string.Empty); | ||
|
||
Succeeded = false; | ||
} | ||
} | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
src/coreclr/tests/src/JIT/HardwareIntrinsics/General/Vector64/CreateScalar.UInt64.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
/****************************************************************************** | ||
* This file is auto-generated from a template file by the GenerateTests.csx * | ||
* script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make * | ||
* changes, please update the corresponding template and run according to the * | ||
* directions listed in the file. * | ||
******************************************************************************/ | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Intrinsics; | ||
|
||
namespace JIT.HardwareIntrinsics.General | ||
{ | ||
public static partial class Program | ||
{ | ||
private static void CreateScalarUInt64() | ||
{ | ||
var test = new VectorCreate__CreateScalarUInt64(); | ||
|
||
// Validates basic functionality works | ||
test.RunBasicScenario(); | ||
|
||
// Validates calling via reflection works | ||
test.RunReflectionScenario(); | ||
|
||
if (!test.Succeeded) | ||
{ | ||
throw new Exception("One or more scenarios did not complete as expected."); | ||
} | ||
} | ||
} | ||
|
||
public sealed unsafe class VectorCreate__CreateScalarUInt64 | ||
{ | ||
private static readonly int LargestVectorSize = 8; | ||
|
||
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64); | ||
|
||
public bool Succeeded { get; set; } = true; | ||
|
||
public void RunBasicScenario() | ||
{ | ||
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); | ||
|
||
UInt64 value = TestLibrary.Generator.GetUInt64(); | ||
Vector64<UInt64> result = Vector64.CreateScalar(value); | ||
|
||
ValidateResult(result, value); | ||
} | ||
|
||
public void RunReflectionScenario() | ||
{ | ||
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario)); | ||
|
||
UInt64 value = TestLibrary.Generator.GetUInt64(); | ||
object result = typeof(Vector64) | ||
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(UInt64) }) | ||
.Invoke(null, new object[] { value }); | ||
|
||
ValidateResult((Vector64<UInt64>)(result), value); | ||
} | ||
|
||
private void ValidateResult(Vector64<UInt64> result, UInt64 expectedValue, [CallerMemberName] string method = "") | ||
{ | ||
UInt64[] resultElements = new UInt64[ElementCount]; | ||
Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref resultElements[0]), result); | ||
ValidateResult(resultElements, expectedValue, method); | ||
} | ||
|
||
private void ValidateResult(UInt64[] resultElements, UInt64 expectedValue, [CallerMemberName] string method = "") | ||
{ | ||
bool succeeded = true; | ||
|
||
if (resultElements[0] != expectedValue) | ||
{ | ||
succeeded = false; | ||
} | ||
else | ||
{ | ||
for (var i = 1; i < ElementCount; i++) | ||
{ | ||
if (resultElements[i] != 0) | ||
{ | ||
succeeded = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if (!succeeded) | ||
{ | ||
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(UInt64): {method} failed:"); | ||
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}"); | ||
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})"); | ||
TestLibrary.TestFramework.LogInformation(string.Empty); | ||
|
||
Succeeded = false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.