Skip to content

Commit ab119ad

Browse files
authored
[Arm64] Vector64<double>.CreateScalar, Vector64<ulong>CreateScalar and Vector64<long>.CreateScalar (#38139)
1 parent 8552b6d commit ab119ad

File tree

7 files changed

+384
-0
lines changed

7 files changed

+384
-0
lines changed

src/coreclr/tests/src/JIT/HardwareIntrinsics/General/Shared/GenerateTests.csx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ private static readonly (string templateFileName, Dictionary<string, string> tem
3232
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "Create", ["VectorType"] = "Vector64", ["BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != expectedValue" }),
3333
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "Create", ["VectorType"] = "Vector64", ["BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != expectedValue" }),
3434
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
35+
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "Double", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
3536
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
3637
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
38+
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "Int64", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
3739
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "SByte", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
3840
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "Single", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
3941
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "UInt16", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
4042
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "UInt32", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
43+
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalar", ["VectorType"] = "Vector64", ["BaseType"] = "UInt64", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "resultElements[i] != 0" }),
4144
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalarUnsafe", ["VectorType"] = "Vector64", ["BaseType"] = "Byte", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "false /* value is uninitialized */" }),
4245
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalarUnsafe", ["VectorType"] = "Vector64", ["BaseType"] = "Int16", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "false /* value is uninitialized */" }),
4346
("VectorCreateTest.template", new Dictionary<string, string> { ["Isa"] = "Vector64", ["Method"] = "CreateScalarUnsafe", ["VectorType"] = "Vector64", ["BaseType"] = "Int32", ["LargestVectorSize"] = "8", ["NextValueOp"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "resultElements[0] != expectedValue", ["ValidateRemainingResults"] = "false /* value is uninitialized */" }),
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
/******************************************************************************
6+
* This file is auto-generated from a template file by the GenerateTests.csx *
7+
* script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make *
8+
* changes, please update the corresponding template and run according to the *
9+
* directions listed in the file. *
10+
******************************************************************************/
11+
12+
using System;
13+
using System.Runtime.CompilerServices;
14+
using System.Runtime.InteropServices;
15+
using System.Runtime.Intrinsics;
16+
17+
namespace JIT.HardwareIntrinsics.General
18+
{
19+
public static partial class Program
20+
{
21+
private static void CreateScalarDouble()
22+
{
23+
var test = new VectorCreate__CreateScalarDouble();
24+
25+
// Validates basic functionality works
26+
test.RunBasicScenario();
27+
28+
// Validates calling via reflection works
29+
test.RunReflectionScenario();
30+
31+
if (!test.Succeeded)
32+
{
33+
throw new Exception("One or more scenarios did not complete as expected.");
34+
}
35+
}
36+
}
37+
38+
public sealed unsafe class VectorCreate__CreateScalarDouble
39+
{
40+
private static readonly int LargestVectorSize = 8;
41+
42+
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Double>>() / sizeof(Double);
43+
44+
public bool Succeeded { get; set; } = true;
45+
46+
public void RunBasicScenario()
47+
{
48+
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
49+
50+
Double value = TestLibrary.Generator.GetDouble();
51+
Vector64<Double> result = Vector64.CreateScalar(value);
52+
53+
ValidateResult(result, value);
54+
}
55+
56+
public void RunReflectionScenario()
57+
{
58+
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
59+
60+
Double value = TestLibrary.Generator.GetDouble();
61+
object result = typeof(Vector64)
62+
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(Double) })
63+
.Invoke(null, new object[] { value });
64+
65+
ValidateResult((Vector64<Double>)(result), value);
66+
}
67+
68+
private void ValidateResult(Vector64<Double> result, Double expectedValue, [CallerMemberName] string method = "")
69+
{
70+
Double[] resultElements = new Double[ElementCount];
71+
Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref resultElements[0]), result);
72+
ValidateResult(resultElements, expectedValue, method);
73+
}
74+
75+
private void ValidateResult(Double[] resultElements, Double expectedValue, [CallerMemberName] string method = "")
76+
{
77+
bool succeeded = true;
78+
79+
if (resultElements[0] != expectedValue)
80+
{
81+
succeeded = false;
82+
}
83+
else
84+
{
85+
for (var i = 1; i < ElementCount; i++)
86+
{
87+
if (resultElements[i] != 0)
88+
{
89+
succeeded = false;
90+
break;
91+
}
92+
}
93+
}
94+
95+
if (!succeeded)
96+
{
97+
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(Double): {method} failed:");
98+
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}");
99+
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})");
100+
TestLibrary.TestFramework.LogInformation(string.Empty);
101+
102+
Succeeded = false;
103+
}
104+
}
105+
}
106+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
/******************************************************************************
6+
* This file is auto-generated from a template file by the GenerateTests.csx *
7+
* script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make *
8+
* changes, please update the corresponding template and run according to the *
9+
* directions listed in the file. *
10+
******************************************************************************/
11+
12+
using System;
13+
using System.Runtime.CompilerServices;
14+
using System.Runtime.InteropServices;
15+
using System.Runtime.Intrinsics;
16+
17+
namespace JIT.HardwareIntrinsics.General
18+
{
19+
public static partial class Program
20+
{
21+
private static void CreateScalarInt64()
22+
{
23+
var test = new VectorCreate__CreateScalarInt64();
24+
25+
// Validates basic functionality works
26+
test.RunBasicScenario();
27+
28+
// Validates calling via reflection works
29+
test.RunReflectionScenario();
30+
31+
if (!test.Succeeded)
32+
{
33+
throw new Exception("One or more scenarios did not complete as expected.");
34+
}
35+
}
36+
}
37+
38+
public sealed unsafe class VectorCreate__CreateScalarInt64
39+
{
40+
private static readonly int LargestVectorSize = 8;
41+
42+
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<Int64>>() / sizeof(Int64);
43+
44+
public bool Succeeded { get; set; } = true;
45+
46+
public void RunBasicScenario()
47+
{
48+
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
49+
50+
Int64 value = TestLibrary.Generator.GetInt64();
51+
Vector64<Int64> result = Vector64.CreateScalar(value);
52+
53+
ValidateResult(result, value);
54+
}
55+
56+
public void RunReflectionScenario()
57+
{
58+
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
59+
60+
Int64 value = TestLibrary.Generator.GetInt64();
61+
object result = typeof(Vector64)
62+
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(Int64) })
63+
.Invoke(null, new object[] { value });
64+
65+
ValidateResult((Vector64<Int64>)(result), value);
66+
}
67+
68+
private void ValidateResult(Vector64<Int64> result, Int64 expectedValue, [CallerMemberName] string method = "")
69+
{
70+
Int64[] resultElements = new Int64[ElementCount];
71+
Unsafe.WriteUnaligned(ref Unsafe.As<Int64, byte>(ref resultElements[0]), result);
72+
ValidateResult(resultElements, expectedValue, method);
73+
}
74+
75+
private void ValidateResult(Int64[] resultElements, Int64 expectedValue, [CallerMemberName] string method = "")
76+
{
77+
bool succeeded = true;
78+
79+
if (resultElements[0] != expectedValue)
80+
{
81+
succeeded = false;
82+
}
83+
else
84+
{
85+
for (var i = 1; i < ElementCount; i++)
86+
{
87+
if (resultElements[i] != 0)
88+
{
89+
succeeded = false;
90+
break;
91+
}
92+
}
93+
}
94+
95+
if (!succeeded)
96+
{
97+
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(Int64): {method} failed:");
98+
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}");
99+
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})");
100+
TestLibrary.TestFramework.LogInformation(string.Empty);
101+
102+
Succeeded = false;
103+
}
104+
}
105+
}
106+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
/******************************************************************************
6+
* This file is auto-generated from a template file by the GenerateTests.csx *
7+
* script in tests\src\JIT\HardwareIntrinsics\General\Shared. In order to make *
8+
* changes, please update the corresponding template and run according to the *
9+
* directions listed in the file. *
10+
******************************************************************************/
11+
12+
using System;
13+
using System.Runtime.CompilerServices;
14+
using System.Runtime.InteropServices;
15+
using System.Runtime.Intrinsics;
16+
17+
namespace JIT.HardwareIntrinsics.General
18+
{
19+
public static partial class Program
20+
{
21+
private static void CreateScalarUInt64()
22+
{
23+
var test = new VectorCreate__CreateScalarUInt64();
24+
25+
// Validates basic functionality works
26+
test.RunBasicScenario();
27+
28+
// Validates calling via reflection works
29+
test.RunReflectionScenario();
30+
31+
if (!test.Succeeded)
32+
{
33+
throw new Exception("One or more scenarios did not complete as expected.");
34+
}
35+
}
36+
}
37+
38+
public sealed unsafe class VectorCreate__CreateScalarUInt64
39+
{
40+
private static readonly int LargestVectorSize = 8;
41+
42+
private static readonly int ElementCount = Unsafe.SizeOf<Vector64<UInt64>>() / sizeof(UInt64);
43+
44+
public bool Succeeded { get; set; } = true;
45+
46+
public void RunBasicScenario()
47+
{
48+
TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario));
49+
50+
UInt64 value = TestLibrary.Generator.GetUInt64();
51+
Vector64<UInt64> result = Vector64.CreateScalar(value);
52+
53+
ValidateResult(result, value);
54+
}
55+
56+
public void RunReflectionScenario()
57+
{
58+
TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario));
59+
60+
UInt64 value = TestLibrary.Generator.GetUInt64();
61+
object result = typeof(Vector64)
62+
.GetMethod(nameof(Vector64.CreateScalar), new Type[] { typeof(UInt64) })
63+
.Invoke(null, new object[] { value });
64+
65+
ValidateResult((Vector64<UInt64>)(result), value);
66+
}
67+
68+
private void ValidateResult(Vector64<UInt64> result, UInt64 expectedValue, [CallerMemberName] string method = "")
69+
{
70+
UInt64[] resultElements = new UInt64[ElementCount];
71+
Unsafe.WriteUnaligned(ref Unsafe.As<UInt64, byte>(ref resultElements[0]), result);
72+
ValidateResult(resultElements, expectedValue, method);
73+
}
74+
75+
private void ValidateResult(UInt64[] resultElements, UInt64 expectedValue, [CallerMemberName] string method = "")
76+
{
77+
bool succeeded = true;
78+
79+
if (resultElements[0] != expectedValue)
80+
{
81+
succeeded = false;
82+
}
83+
else
84+
{
85+
for (var i = 1; i < ElementCount; i++)
86+
{
87+
if (resultElements[i] != 0)
88+
{
89+
succeeded = false;
90+
break;
91+
}
92+
}
93+
}
94+
95+
if (!succeeded)
96+
{
97+
TestLibrary.TestFramework.LogInformation($"Vector64.CreateScalar(UInt64): {method} failed:");
98+
TestLibrary.TestFramework.LogInformation($" value: {expectedValue}");
99+
TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", resultElements)})");
100+
TestLibrary.TestFramework.LogInformation(string.Empty);
101+
102+
Succeeded = false;
103+
}
104+
}
105+
}
106+
}

src/coreclr/tests/src/JIT/HardwareIntrinsics/General/Vector64/Program.Vector64.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ static Program()
2323
["Create.UInt32"] = CreateUInt32,
2424
["Create.UInt64"] = CreateUInt64,
2525
["CreateScalar.Byte"] = CreateScalarByte,
26+
["CreateScalar.Double"] = CreateScalarDouble,
2627
["CreateScalar.Int16"] = CreateScalarInt16,
2728
["CreateScalar.Int32"] = CreateScalarInt32,
29+
["CreateScalar.Int64"] = CreateScalarInt64,
2830
["CreateScalar.SByte"] = CreateScalarSByte,
2931
["CreateScalar.Single"] = CreateScalarSingle,
3032
["CreateScalar.UInt16"] = CreateScalarUInt16,
3133
["CreateScalar.UInt32"] = CreateScalarUInt32,
34+
["CreateScalar.UInt64"] = CreateScalarUInt64,
3235
["CreateScalarUnsafe.Byte"] = CreateScalarUnsafeByte,
3336
["CreateScalarUnsafe.Int16"] = CreateScalarUnsafeInt16,
3437
["CreateScalarUnsafe.Int32"] = CreateScalarUnsafeInt32,

0 commit comments

Comments
 (0)