Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the Vector512 and Vector512<T> types #76642

Merged
merged 39 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
eaa08e0
Adding the Vector512 and Vector512<T> types
tannergooding Oct 4, 2022
03dd856
Support properly packing Vector512<T>
tannergooding Oct 4, 2022
8d7791e
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Oct 26, 2022
3a80f29
Responding to PR feedback and ensure Vector512 is treated as an HFA f…
tannergooding Oct 28, 2022
0157044
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Oct 31, 2022
012084a
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Nov 4, 2022
13dc1df
Bring Vector512 inline with the new Vector64/128/256 APIs
tannergooding Nov 4, 2022
7d23e27
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Nov 11, 2022
5e64c5f
Adding support for generating the Vector512 tests
tannergooding Oct 26, 2022
6ed6758
Generate the Vector512 tests
tannergooding Nov 11, 2022
0525759
Ensure the ref assembly is up to date
tannergooding Nov 11, 2022
35f01e1
Fixing a couple JIT asserts
tannergooding Nov 11, 2022
bc8b497
Fixing tests to pass the right number of constructor parameters
tannergooding Nov 11, 2022
437134a
Ensure the HWIntrinsic test templates support 64-byte alignment
tannergooding Nov 12, 2022
b8f0a16
Ensure the vector Dot tests correctly sum using pairs
tannergooding Nov 13, 2022
783bb1f
Ensure the Dot test computes the result pairs correctly
tannergooding Nov 14, 2022
ac01ed5
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Nov 16, 2022
ab3afe9
Simplify the alignment check to avoid future churn
tannergooding Nov 16, 2022
6d50c9a
Don't churn the Vector64/128/256 tests on the Vector512 PR
tannergooding Nov 16, 2022
dc43d8d
Do update the Dot tests to have the updated validation
tannergooding Nov 16, 2022
1124f4e
Fix Vector128 divide by scalar
fanyang-mono Nov 23, 2022
67abfd0
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Dec 11, 2022
6377be7
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Dec 19, 2022
3914d6d
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Jan 3, 2023
60e6826
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Jan 5, 2023
c72c3e5
Ensure field layout tests exist for Vector256 and Vector512
tannergooding Jan 5, 2023
ec270ad
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Jan 9, 2023
ad7e03d
Updating the R2R version from 8.0 to 9.0
tannergooding Jan 9, 2023
b6b62fd
Ensure Vector512 tests are disabled in the same place as the Vector64…
tannergooding Jan 9, 2023
f2e95d9
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Jan 10, 2023
3457948
Remove a stray .
tannergooding Jan 10, 2023
1b0adc0
Fixing the NativeAOT field layout tests
tannergooding Jan 7, 2023
6be8dec
Update an addition location where the R2R version is defined
tannergooding Jan 10, 2023
8f001fa
Merge remote-tracking branch 'dotnet/main' into vector512
tannergooding Jan 10, 2023
2527bcd
Disable Vector512 tests for llvmfullaot due to https://github.com/dot…
tannergooding Jan 10, 2023
d1fc03d
Increase the value of ngsharedvt-trampolines
fanyang-mono Jan 11, 2023
399e4c5
Move various HWIntrinsics to outerloop for unaccelerated platforms
tannergooding Jan 11, 2023
9bb141c
Ensure the HardwareIntrinsics tests are being filtered to outerloop w…
tannergooding Jan 11, 2023
6b049e1
Merge branch 'dotnet:main' into vector512
tannergooding Jan 12, 2023
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
30 changes: 26 additions & 4 deletions src/coreclr/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
alignment = new LayoutInt(16);
}
}
else
else if (name == "Vector256`1")
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
{
Debug.Assert(name == "Vector256`1");
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
tannergooding marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -65,6 +65,27 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
alignment = new LayoutInt(32);
}
}
else
{
Debug.Assert(name == "Vector512`1");

if (defType.Context.Target.Architecture == TargetArchitecture.ARM)
{
// No such type exists for the Procedure Call Standard for ARM. We will default
// to the same alignment as __m128, which is supported by the ABI.
alignment = new LayoutInt(8);
}
else if (defType.Context.Target.Architecture == TargetArchitecture.ARM64)
{
// The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to
// 16-byte alignment for __m256.
alignment = new LayoutInt(16);
}
else
{
alignment = new LayoutInt(64);
}
}

ComputedInstanceFieldLayout layoutFromMetadata = _fallbackAlgorithm.ComputeInstanceLayout(defType, layoutKind);

Expand Down Expand Up @@ -116,9 +137,10 @@ public static bool IsVectorType(DefType type)
{
return type.IsIntrinsic &&
type.Namespace == "System.Runtime.Intrinsics" &&
(type.Name == "Vector64`1" ||
type.Name == "Vector128`1" ||
type.Name == "Vector256`1");
((type.Name == "Vector64`1") ||
(type.Name == "Vector128`1") ||
(type.Name == "Vector256`1") ||
(type.Name == "Vector512`1"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ public enum SimdVectorLength
/// Specifies that native vectors are 256 bit (e.g. AVX on x86).
/// </summary>
Vector256Bit,

/// <summary>
/// Specifies that native vectors are 512 bit (e.g. AVX512 on x86).
/// </summary>
Vector512Bit,
}
}
12 changes: 6 additions & 6 deletions src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,21 @@ public int MaximumAlignment
{
if (Architecture == TargetArchitecture.ARM)
{
// Corresponds to alignment required for __m128 (there's no __m256)
// Corresponds to alignment required for __m128 (there's no __m256/__m512)
return 8;
}
else if (Architecture == TargetArchitecture.ARM64)
{
// Corresponds to alignmet required for __m256
// Corresponds to alignmet required for __m128 (there's no __m256/__m512)
return 16;
}
else if (Architecture == TargetArchitecture.LoongArch64)
{
return 16;
}

// 256-bit vector is the type with the highest alignment we support
return 32;
// 512-bit vector is the type with the highest alignment we support
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
return 64;
}
}

Expand All @@ -136,8 +136,8 @@ public int DefaultPackingSize
{
get
{
// We use default packing size of 32 irrespective of the platform.
return 32;
// We use default packing size of 64 irrespective of the platform.
return 64;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,15 @@ private static bool IsValidForGenericMarshalling(
// * Vector64<T>: Represents the __m64 ABI primitive which requires currently unimplemented handling
// * Vector128<T>: Represents the __m128 ABI primitive which requires currently unimplemented handling
// * Vector256<T>: Represents the __m256 ABI primitive which requires currently unimplemented handling
// * Vector512<T>: Represents the __m512 ABI primitive which requires currently unimplemented handling
// * Vector<T>: Has a variable size (either __m128 or __m256) and isn't readily usable for interop scenarios
return !InteropTypes.IsSystemNullable(type.Context, type)
&& !InteropTypes.IsSystemSpan(type.Context, type)
&& !InteropTypes.IsSystemReadOnlySpan(type.Context, type)
&& !InteropTypes.IsSystemRuntimeIntrinsicsVector64T(type.Context, type)
&& !InteropTypes.IsSystemRuntimeIntrinsicsVector128T(type.Context, type)
&& !InteropTypes.IsSystemRuntimeIntrinsicsVector256T(type.Context, type)
&& !InteropTypes.IsSystemRuntimeIntrinsicsVector512T(type.Context, type)
&& !InteropTypes.IsSystemNumericsVectorT(type.Context, type);
}

Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/tools/Common/TypeSystem/Interop/InteropTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ public static bool IsSystemRuntimeIntrinsicsVector256T(TypeSystemContext context
return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector256`1");
}

public static bool IsSystemRuntimeIntrinsicsVector512T(TypeSystemContext context, TypeDesc type)
{
return IsCoreNamedType(context, type, "System.Runtime.Intrinsics", "Vector512`1");
}

public static bool IsSystemNumericsVectorT(TypeSystemContext context, TypeDesc type)
{
return IsCoreNamedType(context, type, "System.Numerics", "Vector`1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
{
instanceFieldSize = new LayoutInt(32);
}
else if (targetDetails.MaximumSimdVectorLength == SimdVectorLength.Vector512Bit)
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
{
instanceFieldSize = new LayoutInt(64);
}
else
{
Debug.Assert(targetDetails.MaximumSimdVectorLength == SimdVectorLength.None);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public ReadyToRunCompilerContext(TargetDetails details, SharedGenericsMode gener
matchingVectorType = "Vector128`1";
else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector256Bit)
matchingVectorType = "Vector256`1";
else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector512Bit)
matchingVectorType = "Vector512`1";

// No architecture has completely stable handling of Vector<T> in the abi (Arm64 may change to SVE)
_vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, _vectorFieldLayoutAlgorithm, matchingVectorType, bubbleIncludesCorelib);
Expand Down
4 changes: 3 additions & 1 deletion src/coreclr/vm/classlayoutinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ namespace
case 8:
case 16:
case 32:
case 64:
break;
default:
COMPlusThrowHR(COR_E_INVALIDPROGRAM, BFA_METADATA_CORRUPT);
Expand Down Expand Up @@ -979,7 +980,8 @@ EEClassNativeLayoutInfo* EEClassNativeLayoutInfo::CollectNativeLayoutFieldMetada
pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__UINT128)) ||
pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR64T)) ||
pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR128T)) ||
pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR256T)))
pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR256T)) ||
pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR512T)))
{
pNativeLayoutInfo->m_alignmentRequirement = pEEClassLayoutInfo->m_ManagedLargestAlignmentRequirementOfAllMembers;
}
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/vm/classnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#define g_Vector256ClassName "System.Runtime.Intrinsics.Vector256`1"
#define g_Vector256Name "Vector256`1"

#define g_Vector512ClassName "System.Runtime.Intrinsics.Vector512`1"
#define g_Vector512Name "Vector512`1"

#define g_EnumeratorToEnumClassName "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler"
#define g_ExceptionClassName "System.Exception"
#define g_ExecutionEngineExceptionClassName "System.ExecutionEngineException"
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/corelib.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ DEFINE_METHOD(NATIVELIBRARY, LOADLIBRARYCALLBACKSTUB, LoadLibraryCallback
DEFINE_CLASS(VECTOR64T, Intrinsics, Vector64`1)
DEFINE_CLASS(VECTOR128T, Intrinsics, Vector128`1)
DEFINE_CLASS(VECTOR256T, Intrinsics, Vector256`1)
DEFINE_CLASS(VECTOR512T, Intrinsics, Vector512`1)

DEFINE_CLASS(VECTORT, Numerics, Vector`1)

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/fieldmarshaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MethodTable;
// Currently we set this to the packing size of the largest supported
// fundamental type and let the field marshaller downsize where needed.
//=======================================================================
#define DEFAULT_PACKING_SIZE 32
#define DEFAULT_PACKING_SIZE 64
tannergooding marked this conversation as resolved.
Show resolved Hide resolved

//=======================================================================
// This structure contains information about where a field is placed in a structure, as well as it's size and alignment.
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2237,8 +2237,8 @@ bool MethodTable::ClassifyEightBytesWithManagedLayout(SystemVStructRegisterPassi
LPCUTF8 namespaceName;
LPCUTF8 className = GetFullyQualifiedNameInfo(&namespaceName);

if ((strcmp(className, "Vector256`1") == 0) || (strcmp(className, "Vector128`1") == 0) ||
(strcmp(className, "Vector64`1") == 0))
if ((strcmp(className, "Vector512`1") == 0) || (strcmp(className, "Vector256`1") == 0) ||
(strcmp(className, "Vector128`1") == 0) || (strcmp(className, "Vector64`1") == 0))
{
assert(strcmp(namespaceName, "System.Runtime.Intrinsics") == 0);

Expand Down Expand Up @@ -2487,8 +2487,8 @@ bool MethodTable::ClassifyEightBytesWithNativeLayout(SystemVStructRegisterPassin
LPCUTF8 namespaceName;
LPCUTF8 className = GetFullyQualifiedNameInfo(&namespaceName);

if ((strcmp(className, "Vector256`1") == 0) || (strcmp(className, "Vector128`1") == 0) ||
(strcmp(className, "Vector64`1") == 0))
if ((strcmp(className, "Vector512`1") == 0) || (strcmp(className, "Vector256`1") == 0) ||
(strcmp(className, "Vector128`1") == 0) || (strcmp(className, "Vector64`1") == 0))
{
assert(strcmp(namespaceName, "System.Runtime.Intrinsics") == 0);

Expand Down
16 changes: 16 additions & 0 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9884,6 +9884,22 @@ void MethodTableBuilder::CheckForSystemTypes()
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
#else
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 32; // sizeof(__m256)
#endif // TARGET_ARM elif TARGET_ARM64
}
else if (strcmp(name, g_Vector512Name) == 0)
{
#ifdef TARGET_ARM
// No such type exists for the Procedure Call Standard for ARM. We will default
// to the same alignment as __m128, which is supported by the ABI.

pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 8;
#elif defined(TARGET_ARM64)
// The Procedure Call Standard for ARM 64-bit (with SVE support) defaults to
// 16-byte alignment for __m256.

pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 16;
#else
pLayout->m_ManagedLargestAlignmentRequirementOfAllMembers = 64; // sizeof(__m512)
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
#endif // TARGET_ARM elif TARGET_ARM64
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/vm/mlinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1081,13 +1081,15 @@ namespace
// * Vector64<T>: Represents the __m64 ABI primitive which requires currently unimplemented handling
// * Vector128<T>: Represents the __m128 ABI primitive which requires currently unimplemented handling
// * Vector256<T>: Represents the __m256 ABI primitive which requires currently unimplemented handling
// * Vector512<T>: Represents the __m512 ABI primitive which requires currently unimplemented handling
// * Vector<T>: Has a variable size (either __m128 or __m256) and isn't readily usable for interop scenarios
return !pMT->HasSameTypeDefAs(g_pNullableClass)
&& !pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__SPAN))
&& !pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__READONLY_SPAN))
&& !pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR64T))
&& !pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR128T))
&& !pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR256T))
&& !pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTOR512T))
&& !pMT->HasSameTypeDefAs(CoreLibBinder::GetClass(CLASS__VECTORT));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,9 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector256.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector256_1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector256DebugView_1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector512.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector512_1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector512DebugView_1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector64.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector64_1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Intrinsics\Vector64DebugView_1.cs" />
Expand Down
Loading