From 37151bb03cc8f9e030889dd8e588685c33974d75 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 28 Feb 2019 16:28:14 -0800 Subject: [PATCH] Removing the ExtractVector128 and InsertVector128 APIs that take an address. (dotnet/coreclr#22886) * Removing the InsertVector128 and ExtractVector128 overloads that take an address from S.P.Corelib * Removing the ExtractStore and InsertLoad tests. * Fixing the PacketTracer test to use the appropriate Extract/InsertVector128 overloads * Removing the JIT support for the Extract/InsertVector128 overloads that take an address. Commit migrated from https://github.com/dotnet/coreclr/commit/d06becc2658b2130c152d0f6c34a358441dd0f8e --- src/coreclr/src/jit/gentree.cpp | 31 +- src/coreclr/src/jit/hwintrinsiccodegenxarch.cpp | 79 ---- src/coreclr/src/jit/hwintrinsiclistxarch.h | 10 +- src/coreclr/src/jit/hwintrinsicxarch.cpp | 23 -- .../JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj | 20 - .../JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj | 20 - .../X86/Avx/ExtractVector128.Byte.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.Double.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.Int16.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.Int32.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.Int64.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.SByte.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.Single.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.UInt16.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.UInt32.1.Store.cs | 379 ------------------- .../X86/Avx/ExtractVector128.UInt64.1.Store.cs | 379 ------------------- .../X86/Avx/InsertVector128.Byte.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.Double.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.Int16.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.Int32.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.Int64.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.SByte.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.Single.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.UInt16.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.UInt32.1.Load.cs | 421 --------------------- .../X86/Avx/InsertVector128.UInt64.1.Load.cs | 421 --------------------- .../JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs | 20 - .../JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj | 16 - .../JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj | 16 - .../X86/Avx2/ExtractVector128.Byte.1.Store.cs | 379 ------------------- .../X86/Avx2/ExtractVector128.Int16.1.Store.cs | 379 ------------------- .../X86/Avx2/ExtractVector128.Int32.1.Store.cs | 379 ------------------- .../X86/Avx2/ExtractVector128.Int64.1.Store.cs | 379 ------------------- .../X86/Avx2/ExtractVector128.SByte.1.Store.cs | 379 ------------------- .../X86/Avx2/ExtractVector128.UInt16.1.Store.cs | 379 ------------------- .../X86/Avx2/ExtractVector128.UInt32.1.Store.cs | 379 ------------------- .../X86/Avx2/ExtractVector128.UInt64.1.Store.cs | 379 ------------------- .../X86/Avx2/InsertVector128.Byte.1.Load.cs | 421 --------------------- .../X86/Avx2/InsertVector128.Int16.1.Load.cs | 421 --------------------- .../X86/Avx2/InsertVector128.Int32.1.Load.cs | 421 --------------------- .../X86/Avx2/InsertVector128.Int64.1.Load.cs | 421 --------------------- .../X86/Avx2/InsertVector128.SByte.1.Load.cs | 421 --------------------- .../X86/Avx2/InsertVector128.UInt16.1.Load.cs | 421 --------------------- .../X86/Avx2/InsertVector128.UInt32.1.Load.cs | 421 --------------------- .../X86/Avx2/InsertVector128.UInt64.1.Load.cs | 421 --------------------- .../HardwareIntrinsics/X86/Avx2/Program.Avx2.cs | 16 - .../X86/Shared/ExtractStoreTest.template | 379 ------------------- .../X86/Shared/GenerateTests.csx | 36 -- .../X86/Shared/InsertLoadTest.template | 421 --------------------- .../HWIntrinsic/X86/PacketTracer/VectorPacket.cs | 6 +- .../Intrinsics/X86/Avx.PlatformNotSupported.cs | 102 ----- .../src/System/Runtime/Intrinsics/X86/Avx.cs | 102 ----- .../Intrinsics/X86/Avx2.PlatformNotSupported.cs | 80 ---- .../src/System/Runtime/Intrinsics/X86/Avx2.cs | 81 ---- 54 files changed, 13 insertions(+), 15845 deletions(-) delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template delete mode 100644 src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template diff --git a/src/coreclr/src/jit/gentree.cpp b/src/coreclr/src/jit/gentree.cpp index f197d24..a9dd539 100644 --- a/src/coreclr/src/jit/gentree.cpp +++ b/src/coreclr/src/jit/gentree.cpp @@ -17887,7 +17887,8 @@ bool GenTreeHWIntrinsic::OperIsMemoryLoad() } else if (HWIntrinsicInfo::MaybeMemoryLoad(gtHWIntrinsicId)) { - // Some AVX intrinsic (without HW_Category_MemoryLoad) also have MemoryLoad semantics + // Some intrinsics (without HW_Category_MemoryLoad) also have MemoryLoad semantics + if (category == HW_Category_SIMDScalar) { // Avx2.BroadcastScalarToVector128/256 have vector and pointer overloads both, e.g., @@ -17906,26 +17907,9 @@ bool GenTreeHWIntrinsic::OperIsMemoryLoad() { return false; } - else // We have 3 or more operands/args + else if (HWIntrinsicInfo::isAVX2GatherIntrinsic(gtHWIntrinsicId)) { - // All the Avx2.Gather* are "load" instructions - if (HWIntrinsicInfo::isAVX2GatherIntrinsic(gtHWIntrinsicId)) - { - return true; - } - - GenTreeArgList* argList = gtOp.gtOp1->AsArgList(); - - // Avx/Avx2.InsertVector128 have vector and pointer overloads both, e.g., - // Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) - // Vector256 InsertVector128(Vector256 value, sbyte* address, byte index) - // So, we need to check the second argument's type is memory-reference (TYP_I_IMPL) or not - if ((gtHWIntrinsicId == NI_AVX_InsertVector128 || gtHWIntrinsicId == NI_AVX2_InsertVector128) && - (argList->Rest()->Current()->TypeGet() == TYP_I_IMPL)) // Is the type of the second arg TYP_I_IMPL? - { - // This is Avx/Avx2.InsertVector128 - return true; - } + return true; } } } @@ -17946,11 +17930,8 @@ bool GenTreeHWIntrinsic::OperIsMemoryStore() else if (HWIntrinsicInfo::MaybeMemoryStore(gtHWIntrinsicId) && (category == HW_Category_IMM || category == HW_Category_Scalar)) { - // Some AVX intrinsic (without HW_Category_MemoryStore) also have MemoryStore semantics + // Some intrinsics (without HW_Category_MemoryStore) also have MemoryStore semantics - // Avx/Avx2.InsertVector128 have vector and pointer overloads both, e.g., - // Vector128 ExtractVector128(Vector256 value, byte index) - // void ExtractVector128(sbyte* address, Vector256 value, byte index) // Bmi2/Bmi2.X64.MultiplyNoFlags may return the lower half result by a out argument // unsafe ulong MultiplyNoFlags(ulong left, ulong right, ulong* low) // @@ -17959,8 +17940,6 @@ bool GenTreeHWIntrinsic::OperIsMemoryStore() { switch (gtHWIntrinsicId) { - case NI_AVX_ExtractVector128: - case NI_AVX2_ExtractVector128: case NI_BMI2_MultiplyNoFlags: case NI_BMI2_X64_MultiplyNoFlags: return true; diff --git a/src/coreclr/src/jit/hwintrinsiccodegenxarch.cpp b/src/coreclr/src/jit/hwintrinsiccodegenxarch.cpp index 84ca477..ae1a80e 100644 --- a/src/coreclr/src/jit/hwintrinsiccodegenxarch.cpp +++ b/src/coreclr/src/jit/hwintrinsiccodegenxarch.cpp @@ -2139,85 +2139,6 @@ void CodeGen::genAvxOrAvx2Intrinsic(GenTreeHWIntrinsic* node) break; } - case NI_AVX_ExtractVector128: - case NI_AVX_InsertVector128: - case NI_AVX2_ExtractVector128: - case NI_AVX2_InsertVector128: - { - GenTree* lastOp = nullptr; - if (numArgs == 2) - { - assert(intrinsicId == NI_AVX_ExtractVector128 || NI_AVX_ExtractVector128); - op2Reg = op2->gtRegNum; - lastOp = op2; - } - else - { - assert(numArgs == 3); - assert(op1->OperIsList()); - assert(op1->gtGetOp2()->OperIsList()); - assert(op1->gtGetOp2()->gtGetOp2()->OperIsList()); - - GenTreeArgList* argList = op1->AsArgList(); - op1 = argList->Current(); - genConsumeRegs(op1); - op1Reg = op1->gtRegNum; - - argList = argList->Rest(); - op2 = argList->Current(); - genConsumeRegs(op2); - op2Reg = op2->gtRegNum; - - argList = argList->Rest(); - lastOp = argList->Current(); - genConsumeRegs(lastOp); - } - - regNumber op3Reg = lastOp->gtRegNum; - - auto emitSwCase = [&](int8_t i) { - if (numArgs == 3) - { - if (intrinsicId == NI_AVX_ExtractVector128 || intrinsicId == NI_AVX2_ExtractVector128) - { - emit->emitIns_AR_R_I(ins, attr, op1Reg, 0, op2Reg, i); - } - else if (op2->TypeGet() == TYP_I_IMPL) - { - emit->emitIns_SIMD_R_R_AR_I(ins, attr, targetReg, op1Reg, op2Reg, i); - } - else - { - assert(op2->TypeGet() == TYP_SIMD16); - emit->emitIns_SIMD_R_R_R_I(ins, attr, targetReg, op1Reg, op2Reg, i); - } - } - else - { - assert(numArgs == 2); - assert(intrinsicId == NI_AVX_ExtractVector128 || intrinsicId == NI_AVX2_ExtractVector128); - emit->emitIns_SIMD_R_R_I(ins, attr, targetReg, op1Reg, i); - } - }; - - if (lastOp->IsCnsIntOrI()) - { - ssize_t ival = lastOp->AsIntCon()->IconValue(); - assert((ival >= 0) && (ival <= 255)); - emitSwCase((int8_t)ival); - } - else - { - // We emit a fallback case for the scenario when the imm-op is not a constant. This should - // normally happen when the intrinsic is called indirectly, such as via Reflection. However, it - // can also occur if the consumer calls it directly and just doesn't pass a constant value. - regNumber baseReg = node->ExtractTempReg(); - regNumber offsReg = node->GetSingleTempReg(); - genHWIntrinsicJumpTableFallback(intrinsicId, op3Reg, baseReg, offsReg, emitSwCase); - } - break; - } - default: unreached(); break; diff --git a/src/coreclr/src/jit/hwintrinsiclistxarch.h b/src/coreclr/src/jit/hwintrinsiclistxarch.h index 69fb795..5903a69 100644 --- a/src/coreclr/src/jit/hwintrinsiclistxarch.h +++ b/src/coreclr/src/jit/hwintrinsiclistxarch.h @@ -419,11 +419,11 @@ HARDWARE_INTRINSIC(AVX_Divide, "Divide", HARDWARE_INTRINSIC(AVX_DotProduct, "DotProduct", AVX, -1, 32, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_dpps, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX_DuplicateEvenIndexed, "DuplicateEvenIndexed", AVX, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movsldup, INS_movddup}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_DuplicateOddIndexed, "DuplicateOddIndexed", AVX, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movshdup, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) -HARDWARE_INTRINSIC(AVX_ExtractVector128, "ExtractVector128", AVX, -1, 32, -1, {INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128}, HW_Category_IMM, HW_Flag_MaybeMemoryStore|HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_FullRangeIMM) +HARDWARE_INTRINSIC(AVX_ExtractVector128, "ExtractVector128", AVX, -1, 32, 2, {INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128, INS_vextractf128}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX_Floor, "Floor", AVX, 9, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_roundps, INS_roundpd}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_HorizontalAdd, "HorizontalAdd", AVX, -1, 32, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_haddps, INS_haddpd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX_HorizontalSubtract, "HorizontalSubtract", AVX, -1, 32, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_hsubps, INS_hsubpd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(AVX_InsertVector128, "InsertVector128", AVX, -1, 32, 3, {INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128}, HW_Category_IMM, HW_Flag_MaybeMemoryLoad|HW_Flag_FullRangeIMM|HW_Flag_SpecialCodeGen) +HARDWARE_INTRINSIC(AVX_InsertVector128, "InsertVector128", AVX, -1, 32, 3, {INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128, INS_vinsertf128}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX_LoadAlignedVector256, "LoadAlignedVector256", AVX, -1, 32, 1, {INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movaps, INS_movapd}, HW_Category_MemoryLoad, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_LoadDquVector256, "LoadDquVector256", AVX, -1, 32, 1, {INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_LoadVector256, "LoadVector256", AVX, -1, 32, 1, {INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movups, INS_movupd}, HW_Category_MemoryLoad, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) @@ -477,7 +477,7 @@ HARDWARE_INTRINSIC(AVX2_BroadcastScalarToVector256, "BroadcastSc HARDWARE_INTRINSIC(AVX2_BroadcastVector128ToVector256, "BroadcastVector128ToVector256", AVX2, -1, 32, 1, {INS_vbroadcasti128, INS_vbroadcasti128, INS_vbroadcasti128, INS_vbroadcasti128, INS_vbroadcasti128, INS_vbroadcasti128, INS_vbroadcasti128, INS_vbroadcasti128, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_NoContainment) HARDWARE_INTRINSIC(AVX2_CompareEqual, "CompareEqual", AVX2, -1, 32, 2, {INS_pcmpeqb, INS_pcmpeqb, INS_pcmpeqw, INS_pcmpeqw, INS_pcmpeqd, INS_pcmpeqd, INS_pcmpeqq, INS_pcmpeqq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) HARDWARE_INTRINSIC(AVX2_CompareGreaterThan, "CompareGreaterThan", AVX2, -1, 32, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_pcmpgtq, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(AVX2_ExtractVector128, "ExtractVector128", AVX2, -1, 32, -1, {INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_MaybeMemoryStore|HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_FullRangeIMM) +HARDWARE_INTRINSIC(AVX2_ExtractVector128, "ExtractVector128", AVX2, -1, 32, 2, {INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_ConvertToInt32, "ConvertToInt32", AVX2, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_mov_xmm2i, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialCodeGen|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX2_ConvertToUInt32, "ConvertToUInt32", AVX2, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_mov_xmm2i, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialCodeGen|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX2_ConvertToVector256Int16, "ConvertToVector256Int16", AVX2, -1, 32, 1, {INS_pmovsxbw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg) @@ -486,7 +486,7 @@ HARDWARE_INTRINSIC(AVX2_ConvertToVector256Int32, "ConvertToVe HARDWARE_INTRINSIC(AVX2_ConvertToVector256UInt32, "ConvertToVector256UInt32", AVX2, -1, 32, 1, {INS_invalid, INS_pmovzxbd, INS_invalid, INS_pmovzxwd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(AVX2_ConvertToVector256Int64, "ConvertToVector256Int64", AVX2, -1, 32, 1, {INS_pmovsxbq, INS_invalid, INS_pmovsxwq, INS_invalid, INS_pmovsxdq, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(AVX2_ConvertToVector256UInt64, "ConvertToVector256UInt64", AVX2, -1, 32, 1, {INS_invalid, INS_pmovzxbq, INS_invalid, INS_pmovzxwq, INS_invalid, INS_pmovzxdq, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(AVX2_GatherVector128, "GatherVector128", AVX2, -1, 16, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpgatherdd, INS_vpgatherdd, INS_vpgatherdq, INS_vpgatherdq, INS_vgatherdps, INS_vgatherdpd}, HW_Category_IMM, HW_Flag_MaybeMemoryLoad|HW_Flag_SpecialCodeGen|HW_Flag_NoContainment) +HARDWARE_INTRINSIC(AVX2_GatherVector128, "GatherVector128", AVX2, -1, 16, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpgatherdd, INS_vpgatherdd, INS_vpgatherdq, INS_vpgatherdq, INS_vgatherdps, INS_vgatherdpd}, HW_Category_IMM, HW_Flag_SpecialCodeGen|HW_Flag_NoContainment) HARDWARE_INTRINSIC(AVX2_GatherVector256, "GatherVector256", AVX2, -1, 32, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpgatherdd, INS_vpgatherdd, INS_vpgatherdq, INS_vpgatherdq, INS_vgatherdps, INS_vgatherdpd}, HW_Category_IMM, HW_Flag_MaybeMemoryLoad|HW_Flag_SpecialCodeGen|HW_Flag_NoContainment) HARDWARE_INTRINSIC(AVX2_GatherMaskVector128, "GatherMaskVector128", AVX2, -1, 16, 5, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpgatherdd, INS_vpgatherdd, INS_vpgatherdq, INS_vpgatherdq, INS_vgatherdps, INS_vgatherdpd}, HW_Category_IMM, HW_Flag_MaybeMemoryLoad|HW_Flag_SpecialCodeGen|HW_Flag_SpecialImport|HW_Flag_NoContainment) HARDWARE_INTRINSIC(AVX2_GatherMaskVector256, "GatherMaskVector256", AVX2, -1, 32, 5, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpgatherdd, INS_vpgatherdd, INS_vpgatherdq, INS_vpgatherdq, INS_vgatherdps, INS_vgatherdpd}, HW_Category_IMM, HW_Flag_MaybeMemoryLoad|HW_Flag_SpecialCodeGen|HW_Flag_SpecialImport|HW_Flag_NoContainment) @@ -494,7 +494,7 @@ HARDWARE_INTRINSIC(AVX2_HorizontalAdd, "HorizontalA HARDWARE_INTRINSIC(AVX2_HorizontalAddSaturate, "HorizontalAddSaturate", AVX2, -1, 32, 2, {INS_invalid, INS_invalid, INS_phaddsw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX2_HorizontalSubtract, "HorizontalSubtract", AVX2, -1, 32, 2, {INS_invalid, INS_invalid, INS_phsubw, INS_invalid, INS_phsubd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX2_HorizontalSubtractSaturate, "HorizontalSubtractSaturate", AVX2, -1, 32, 2, {INS_invalid, INS_invalid, INS_phsubsw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(AVX2_InsertVector128, "InsertVector128", AVX2, -1, 32, 3, {INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_MaybeMemoryLoad|HW_Flag_FullRangeIMM|HW_Flag_SpecialCodeGen) +HARDWARE_INTRINSIC(AVX2_InsertVector128, "InsertVector128", AVX2, -1, 32, 3, {INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_vinserti128, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_LoadAlignedVector256NonTemporal, "LoadAlignedVector256NonTemporal", AVX2, -1, 32, 1, {INS_movntdqa, INS_movntdqa, INS_movntdqa, INS_movntdqa, INS_movntdqa, INS_movntdqa, INS_movntdqa, INS_movntdqa, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_NoContainment) HARDWARE_INTRINSIC(AVX2_MaskLoad, "MaskLoad", AVX2, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpmaskmovd, INS_vpmaskmovd, INS_vpmaskmovq, INS_vpmaskmovq, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_NoContainment|HW_Flag_UnfixedSIMDSize) HARDWARE_INTRINSIC(AVX2_MaskStore, "MaskStore", AVX2, -1, 0, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpmaskmovd, INS_vpmaskmovd, INS_vpmaskmovq, INS_vpmaskmovq, INS_invalid, INS_invalid}, HW_Category_MemoryStore, HW_Flag_NoContainment|HW_Flag_UnfixedSIMDSize|HW_Flag_BaseTypeFromSecondArg) diff --git a/src/coreclr/src/jit/hwintrinsicxarch.cpp b/src/coreclr/src/jit/hwintrinsicxarch.cpp index 14a76de..a0008e5 100644 --- a/src/coreclr/src/jit/hwintrinsicxarch.cpp +++ b/src/coreclr/src/jit/hwintrinsicxarch.cpp @@ -1769,29 +1769,6 @@ GenTree* Compiler::impAvxOrAvx2Intrinsic(NamedIntrinsic intrinsic, switch (intrinsic) { - case NI_AVX_ExtractVector128: - case NI_AVX2_ExtractVector128: - { - GenTree* lastOp = impPopStack().val; - assert(lastOp->IsCnsIntOrI() || mustExpand); - GenTree* vectorOp = impSIMDPopStack(TYP_SIMD32); - if (sig->numArgs == 2) - { - baseType = getBaseTypeOfSIMDType(sig->retTypeSigClass); - retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, vectorOp, lastOp, intrinsic, baseType, 32); - } - else - { - assert(sig->numArgs == 3); - op1 = impPopStack().val; - CORINFO_ARG_LIST_HANDLE secondArg = info.compCompHnd->getArgNext(sig->args); - CORINFO_CLASS_HANDLE secondArgClass = info.compCompHnd->getArgClass(sig, secondArg); - baseType = getBaseTypeOfSIMDType(secondArgClass); - retNode = gtNewSimdHWIntrinsicNode(TYP_VOID, op1, vectorOp, lastOp, intrinsic, baseType, 32); - } - break; - } - case NI_AVX2_PermuteVar8x32: { baseType = getBaseTypeOfSIMDType(sig->retTypeSigClass); diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj index 39b42f4..748f20c 100644 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj +++ b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj @@ -59,16 +59,6 @@ - - - - - - - - - - @@ -79,16 +69,6 @@ - - - - - - - - - - diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj index 2577556..84d60ff 100644 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj +++ b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj @@ -59,16 +59,6 @@ - - - - - - - - - - @@ -79,16 +69,6 @@ - - - - - - - - - - diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs deleted file mode 100644 index 3e42e55..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Byte1Store() - { - var test = new ExtractStoreTest__ExtractVector128Byte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Byte1 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Byte1 testClass) - { - Avx.ExtractVector128((Byte*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); - - private static Byte[] _data = new Byte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Byte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Byte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Byte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Byte*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Byte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Byte*)), - Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Byte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Byte*)), - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Byte1(); - Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray = new Byte[Op1ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray = new Byte[Op1ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Byte[] firstOp, Byte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[16]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 16])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs deleted file mode 100644 index 5b26a53..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Double1Store() - { - var test = new ExtractStoreTest__ExtractVector128Double1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Double1 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Double1 testClass) - { - Avx.ExtractVector128((Double*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Double); - - private static Double[] _data = new Double[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Double1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Double1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (Double*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (Double*)_dataTable.outArrayPtr, - Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (Double*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Double*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Double*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Double*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Double*)), - Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Double*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Double*)), - Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (Double*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Double1(); - Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Double[] inArray = new Double[Op1ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Double[] inArray = new Double[Op1ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[2])) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(firstOp[i + 2]))) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs deleted file mode 100644 index 1a3fb55..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int161Store() - { - var test = new ExtractStoreTest__ExtractVector128Int161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Int161 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int161 testClass) - { - Avx.ExtractVector128((Int16*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Int161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Int161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int16*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int16*)), - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int16*)), - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Int161(); - Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[8]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 8])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs deleted file mode 100644 index 9accfba..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int321Store() - { - var test = new ExtractStoreTest__ExtractVector128Int321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Int321 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int321 testClass) - { - Avx.ExtractVector128((Int32*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); - - private static Int32[] _data = new Int32[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Int321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Int321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)), - Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)), - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Int321(); - Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray = new Int32[Op1ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray = new Int32[Op1ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int32[] firstOp, Int32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[4]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 4])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs deleted file mode 100644 index d27e003..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int641Store() - { - var test = new ExtractStoreTest__ExtractVector128Int641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Int641 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int641 testClass) - { - Avx.ExtractVector128((Int64*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int64); - - private static Int64[] _data = new Int64[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Int641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Int641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int64*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int64*)), - Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Int64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int64*)), - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Int641(); - Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray = new Int64[Op1ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray = new Int64[Op1ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int64[] firstOp, Int64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[2]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 2])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs deleted file mode 100644 index 194eb51..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128SByte1Store() - { - var test = new ExtractStoreTest__ExtractVector128SByte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128SByte1 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128SByte1 testClass) - { - Avx.ExtractVector128((SByte*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128SByte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128SByte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(SByte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(SByte*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(SByte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(SByte*)), - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(SByte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(SByte*)), - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128SByte1(); - Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[16]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 16])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs deleted file mode 100644 index 9b4133e..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Single1Store() - { - var test = new ExtractStoreTest__ExtractVector128Single1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Single1 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Single1 testClass) - { - Avx.ExtractVector128((Single*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Single1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Single1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (Single*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (Single*)_dataTable.outArrayPtr, - Avx.LoadVector256((Single*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (Single*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Single*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Single*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Single*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Single*)), - Avx.LoadVector256((Single*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(Single*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Single*)), - Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (Single*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Single1(); - Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[4])) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i + 4]))) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs deleted file mode 100644 index 5b18af83..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt161Store() - { - var test = new ExtractStoreTest__ExtractVector128UInt161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128UInt161 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt161 testClass) - { - Avx.ExtractVector128((UInt16*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - - private static UInt16[] _data = new UInt16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128UInt161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128UInt161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt16*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt16*)), - Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt16*)), - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128UInt161(); - Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray = new UInt16[Op1ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray = new UInt16[Op1ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt16[] firstOp, UInt16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[8]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 8])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs deleted file mode 100644 index 04890df..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt321Store() - { - var test = new ExtractStoreTest__ExtractVector128UInt321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128UInt321 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt321 testClass) - { - Avx.ExtractVector128((UInt32*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - - private static UInt32[] _data = new UInt32[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128UInt321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128UInt321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), - Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128UInt321(); - Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray = new UInt32[Op1ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray = new UInt32[Op1ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt32[] firstOp, UInt32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[4]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 4])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs deleted file mode 100644 index c29d5c6..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt641Store() - { - var test = new ExtractStoreTest__ExtractVector128UInt641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128UInt641 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt641 testClass) - { - Avx.ExtractVector128((UInt64*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - - private static UInt64[] _data = new UInt64[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128UInt641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128UInt641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt64*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt64*)), - Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx).GetMethod(nameof(Avx.ExtractVector128), new Type[] { typeof(UInt64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt64*)), - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)); - Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128UInt641(); - Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray = new UInt64[Op1ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray = new UInt64[Op1ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt64[] firstOp, UInt64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[2]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 2])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs deleted file mode 100644 index 34f6fe8..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Byte1Load() - { - var test = new InsertLoadTest__InsertVector128Byte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Byte1 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Byte1 testClass) - { - var result = Avx.InsertVector128(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); - - private static Byte[] _data1 = new Byte[Op1ElementCount]; - private static Byte[] _data2 = new Byte[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Byte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Byte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Byte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)), - (Byte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)), - (Byte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Byte*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Byte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Byte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Byte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Byte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Byte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (Byte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Byte*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Byte*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)); - var right = (Byte*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)); - var right = (Byte*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Byte1(); - var result = Avx.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (Byte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray1 = new Byte[Op1ElementCount]; - Byte[] inArray2 = new Byte[Op2ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray1 = new Byte[Op1ElementCount]; - Byte[] inArray2 = new Byte[Op2ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 15 ? result[i] != right[i - 16] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs deleted file mode 100644 index e7e9912..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Double1Load() - { - var test = new InsertLoadTest__InsertVector128Double1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Double1 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Double1 testClass) - { - var result = Avx.InsertVector128(_fld1, (Double*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Double*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Double); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Double); - - private static Double[] _data1 = new Double[Op1ElementCount]; - private static Double[] _data2 = new Double[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Double1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Double1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Double*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)), - (Double*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)), - (Double*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Double*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Double*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Double*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Double*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Double*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Double*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (Double*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Double*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Double*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Double*)(_dataTable.inArray1Ptr)); - var right = (Double*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Double*)(_dataTable.inArray1Ptr)); - var right = (Double*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Double1(); - var result = Avx.InsertVector128(test._fld1, (Double*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Double*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (Double*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Double*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (Double*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Double*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Double[] inArray1 = new Double[Op1ElementCount]; - Double[] inArray2 = new Double[Op2ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Double[] inArray1 = new Double[Op1ElementCount]; - Double[] inArray2 = new Double[Op2ElementCount]; - Double[] outArray = new Double[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Double[] left, Double[] right, Double[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[0])) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(right[i - 2]) : BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i]))) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs deleted file mode 100644 index 31b74a6..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int161Load() - { - var test = new InsertLoadTest__InsertVector128Int161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Int161 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Int161 testClass) - { - var result = Avx.InsertVector128(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data1 = new Int16[Op1ElementCount]; - private static Int16[] _data2 = new Int16[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Int161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Int161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Int16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), - (Int16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), - (Int16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int16*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (Int16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Int16*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Int16*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)); - var right = (Int16*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)); - var right = (Int16*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Int161(); - var result = Avx.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (Int16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray1 = new Int16[Op1ElementCount]; - Int16[] inArray2 = new Int16[Op2ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray1 = new Int16[Op1ElementCount]; - Int16[] inArray2 = new Int16[Op2ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 7 ? result[i] != right[i - 8] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs deleted file mode 100644 index 33fd52f..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int321Load() - { - var test = new InsertLoadTest__InsertVector128Int321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Int321 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Int321 testClass) - { - var result = Avx.InsertVector128(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); - - private static Int32[] _data1 = new Int32[Op1ElementCount]; - private static Int32[] _data2 = new Int32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Int321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Int321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Int32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - (Int32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - (Int32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int32*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (Int32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Int32*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Int32*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = (Int32*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = (Int32*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Int321(); - var result = Avx.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (Int32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? result[i] != right[i - 4] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs deleted file mode 100644 index 14a7df2..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int641Load() - { - var test = new InsertLoadTest__InsertVector128Int641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Int641 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Int641 testClass) - { - var result = Avx.InsertVector128(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int64); - - private static Int64[] _data1 = new Int64[Op1ElementCount]; - private static Int64[] _data2 = new Int64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Int641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Int641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Int64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - (Int64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - (Int64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int64*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Int64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (Int64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Int64*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Int64*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = (Int64*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = (Int64*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Int641(); - var result = Avx.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (Int64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int64[] left, Int64[] right, Int64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? result[i] != right[i - 2] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs deleted file mode 100644 index 381ff2a..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128SByte1Load() - { - var test = new InsertLoadTest__InsertVector128SByte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128SByte1 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128SByte1 testClass) - { - var result = Avx.InsertVector128(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data1 = new SByte[Op1ElementCount]; - private static SByte[] _data2 = new SByte[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128SByte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128SByte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (SByte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), - (SByte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), - (SByte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(SByte*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(SByte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(SByte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(SByte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(SByte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(SByte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (SByte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (SByte*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (SByte*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)); - var right = (SByte*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)); - var right = (SByte*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128SByte1(); - var result = Avx.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (SByte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray1 = new SByte[Op1ElementCount]; - SByte[] inArray2 = new SByte[Op2ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray1 = new SByte[Op1ElementCount]; - SByte[] inArray2 = new SByte[Op2ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(SByte[] left, SByte[] right, SByte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 15 ? result[i] != right[i - 16] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs deleted file mode 100644 index 9bd5797..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Single1Load() - { - var test = new InsertLoadTest__InsertVector128Single1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Single1 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Single1 testClass) - { - var result = Avx.InsertVector128(_fld1, (Single*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Single*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data1 = new Single[Op1ElementCount]; - private static Single[] _data2 = new Single[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Single1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Single1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Single*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)), - (Single*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)), - (Single*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Single*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Single*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Single*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Single*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(Single*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Single*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (Single*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Single*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Single*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Single*)(_dataTable.inArray1Ptr)); - var right = (Single*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Single*)(_dataTable.inArray1Ptr)); - var right = (Single*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Single1(); - var result = Avx.InsertVector128(test._fld1, (Single*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Single*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (Single*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Single*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (Single*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Single*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Single[] inArray1 = new Single[Op1ElementCount]; - Single[] inArray2 = new Single[Op2ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Single[] inArray1 = new Single[Op1ElementCount]; - Single[] inArray2 = new Single[Op2ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[i - 4]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i]))) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs deleted file mode 100644 index 7aa6c20..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt161Load() - { - var test = new InsertLoadTest__InsertVector128UInt161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128UInt161 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt161 testClass) - { - var result = Avx.InsertVector128(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - - private static UInt16[] _data1 = new UInt16[Op1ElementCount]; - private static UInt16[] _data2 = new UInt16[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128UInt161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128UInt161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (UInt16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), - (UInt16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), - (UInt16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt16*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (UInt16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (UInt16*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (UInt16*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)); - var right = (UInt16*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)); - var right = (UInt16*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128UInt161(); - var result = Avx.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray1 = new UInt16[Op1ElementCount]; - UInt16[] inArray2 = new UInt16[Op2ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray1 = new UInt16[Op1ElementCount]; - UInt16[] inArray2 = new UInt16[Op2ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt16[] left, UInt16[] right, UInt16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 7 ? result[i] != right[i - 8] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs deleted file mode 100644 index ba246d9..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt321Load() - { - var test = new InsertLoadTest__InsertVector128UInt321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128UInt321 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt321 testClass) - { - var result = Avx.InsertVector128(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - - private static UInt32[] _data1 = new UInt32[Op1ElementCount]; - private static UInt32[] _data2 = new UInt32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128UInt321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128UInt321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (UInt32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - (UInt32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - (UInt32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt32*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (UInt32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (UInt32*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (UInt32*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = (UInt32*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = (UInt32*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128UInt321(); - var result = Avx.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? result[i] != right[i - 4] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs deleted file mode 100644 index 4d32c2e..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt641Load() - { - var test = new InsertLoadTest__InsertVector128UInt641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128UInt641 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt641 testClass) - { - var result = Avx.InsertVector128(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - - private static UInt64[] _data1 = new UInt64[Op1ElementCount]; - private static UInt64[] _data2 = new UInt64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128UInt641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128UInt641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (UInt64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx.InsertVector128( - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - (UInt64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx.InsertVector128( - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - (UInt64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt64*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx).GetMethod(nameof(Avx.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx.InsertVector128( - _clsVar1, - (UInt64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (UInt64*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (UInt64*)_dataTable.inArray2Ptr; - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = (UInt64*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = (UInt64*)(_dataTable.inArray2Ptr); - var result = Avx.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128UInt641(); - var result = Avx.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx.InsertVector128(_fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? result[i] != right[i - 2] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx)}.{nameof(Avx.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs index 01555f3..028884d 100644 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs +++ b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs @@ -44,16 +44,6 @@ namespace JIT.HardwareIntrinsics.X86 ["ExtractVector128.UInt32.1"] = ExtractVector128UInt321, ["ExtractVector128.Int64.1"] = ExtractVector128Int641, ["ExtractVector128.UInt64.1"] = ExtractVector128UInt641, - ["ExtractVector128.Byte.1.Store"] = ExtractVector128Byte1Store, - ["ExtractVector128.SByte.1.Store"] = ExtractVector128SByte1Store, - ["ExtractVector128.Int16.1.Store"] = ExtractVector128Int161Store, - ["ExtractVector128.UInt16.1.Store"] = ExtractVector128UInt161Store, - ["ExtractVector128.Int32.1.Store"] = ExtractVector128Int321Store, - ["ExtractVector128.UInt32.1.Store"] = ExtractVector128UInt321Store, - ["ExtractVector128.Int64.1.Store"] = ExtractVector128Int641Store, - ["ExtractVector128.UInt64.1.Store"] = ExtractVector128UInt641Store, - ["ExtractVector128.Single.1.Store"] = ExtractVector128Single1Store, - ["ExtractVector128.Double.1.Store"] = ExtractVector128Double1Store, ["InsertVector128.Byte.1"] = InsertVector128Byte1, ["InsertVector128.SByte.1"] = InsertVector128SByte1, ["InsertVector128.Int16.1"] = InsertVector128Int161, @@ -64,16 +54,6 @@ namespace JIT.HardwareIntrinsics.X86 ["InsertVector128.UInt64.1"] = InsertVector128UInt641, ["InsertVector128.Single.1"] = InsertVector128Single1, ["InsertVector128.Double.1"] = InsertVector128Double1, - ["InsertVector128.Byte.1.Load"] = InsertVector128Byte1Load, - ["InsertVector128.SByte.1.Load"] = InsertVector128SByte1Load, - ["InsertVector128.Int16.1.Load"] = InsertVector128Int161Load, - ["InsertVector128.UInt16.1.Load"] = InsertVector128UInt161Load, - ["InsertVector128.Int32.1.Load"] = InsertVector128Int321Load, - ["InsertVector128.UInt32.1.Load"] = InsertVector128UInt321Load, - ["InsertVector128.Int64.1.Load"] = InsertVector128Int641Load, - ["InsertVector128.UInt64.1.Load"] = InsertVector128UInt641Load, - ["InsertVector128.Single.1.Load"] = InsertVector128Single1Load, - ["InsertVector128.Double.1.Load"] = InsertVector128Double1Load, ["Floor.Double"] = FloorDouble, ["Floor.Single"] = FloorSingle, ["LoadVector256.Single"] = LoadVector256Single, diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj index d6544de..e23c63b 100644 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj +++ b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj @@ -141,14 +141,6 @@ - - - - - - - - @@ -157,14 +149,6 @@ - - - - - - - - diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj index c92b2c7..bfb260b 100644 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj +++ b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj @@ -141,14 +141,6 @@ - - - - - - - - @@ -157,14 +149,6 @@ - - - - - - - - diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs deleted file mode 100644 index 5ee652f..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Byte1Store() - { - var test = new ExtractStoreTest__ExtractVector128Byte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Byte1 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Byte1 testClass) - { - Avx2.ExtractVector128((Byte*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); - - private static Byte[] _data = new Byte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Byte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Byte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetByte(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Byte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Byte*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Byte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Byte*)), - Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Byte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Byte*)), - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (Byte*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Byte1(); - Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray = new Byte[Op1ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray = new Byte[Op1ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Byte[] firstOp, Byte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[16]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 16])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs deleted file mode 100644 index 7dfbc74..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int161Store() - { - var test = new ExtractStoreTest__ExtractVector128Int161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Int161 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int161 testClass) - { - Avx2.ExtractVector128((Int16*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Int161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Int161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt16(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int16*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int16*)), - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int16*)), - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (Int16*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Int161(); - Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[8]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 8])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs deleted file mode 100644 index a788e6c..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int321Store() - { - var test = new ExtractStoreTest__ExtractVector128Int321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Int321 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int321 testClass) - { - Avx2.ExtractVector128((Int32*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); - - private static Int32[] _data = new Int32[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Int321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Int321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt32(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)), - Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int32*)), - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (Int32*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Int321(); - Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray = new Int32[Op1ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray = new Int32[Op1ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int32[] firstOp, Int32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[4]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 4])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs deleted file mode 100644 index 9fa82be..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128Int641Store() - { - var test = new ExtractStoreTest__ExtractVector128Int641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128Int641 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int641 testClass) - { - Avx2.ExtractVector128((Int64*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int64); - - private static Int64[] _data = new Int64[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128Int641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128Int641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetInt64(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int64*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int64*)), - Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(Int64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(Int64*)), - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (Int64*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128Int641(); - Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray = new Int64[Op1ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray = new Int64[Op1ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int64[] firstOp, Int64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[2]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 2])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs deleted file mode 100644 index 9527f2a..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128SByte1Store() - { - var test = new ExtractStoreTest__ExtractVector128SByte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128SByte1 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128SByte1 testClass) - { - Avx2.ExtractVector128((SByte*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128SByte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128SByte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSByte(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(SByte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(SByte*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(SByte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(SByte*)), - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(SByte*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(SByte*)), - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (SByte*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128SByte1(); - Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[16]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 16])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs deleted file mode 100644 index 2cd2ba1..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt161Store() - { - var test = new ExtractStoreTest__ExtractVector128UInt161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128UInt161 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt161 testClass) - { - Avx2.ExtractVector128((UInt16*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - - private static UInt16[] _data = new UInt16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128UInt161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128UInt161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt16(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt16*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt16*)), - Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt16*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt16*)), - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (UInt16*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128UInt161(); - Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray = new UInt16[Op1ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray = new UInt16[Op1ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt16[] firstOp, UInt16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[8]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 8])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs deleted file mode 100644 index 0ec2752..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt321Store() - { - var test = new ExtractStoreTest__ExtractVector128UInt321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128UInt321 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt321 testClass) - { - Avx2.ExtractVector128((UInt32*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - - private static UInt32[] _data = new UInt32[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128UInt321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128UInt321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt32(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), - Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt32*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt32*)), - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (UInt32*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128UInt321(); - Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray = new UInt32[Op1ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray = new UInt32[Op1ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt32[] firstOp, UInt32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[4]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 4])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs deleted file mode 100644 index cbcab42..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractVector128UInt641Store() - { - var test = new ExtractStoreTest__ExtractVector128UInt641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__ExtractVector128UInt641 - { - private struct TestStruct - { - public Vector256 _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt641 testClass) - { - Avx2.ExtractVector128((UInt64*)testClass._dataTable.outArrayPtr, _fld, 1); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - - private static UInt64[] _data = new UInt64[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static ExtractStoreTest__ExtractVector128UInt641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public ExtractStoreTest__ExtractVector128UInt641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetUInt64(); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - Avx2.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - Avx2.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - Avx2.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)), - 1 - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt64*)), - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt64*)), - Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof(Avx2).GetMethod(nameof(Avx2.ExtractVector128), new Type[] { typeof(UInt64*), typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof(UInt64*)), - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - Avx2.ExtractVector128( - (UInt64*)_dataTable.outArrayPtr, - _clsVar, - 1 - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)); - Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__ExtractVector128UInt641(); - Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, _fld, 1); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray = new UInt64[Op1ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray = new UInt64[Op1ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(UInt64[] firstOp, UInt64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != firstOp[2]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((result[i] != firstOp[i + 2])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.ExtractVector128)}(Vector256<9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs deleted file mode 100644 index bbb79b6..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Byte1Load() - { - var test = new InsertLoadTest__InsertVector128Byte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Byte1 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Byte1 testClass) - { - var result = Avx2.InsertVector128(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); - - private static Byte[] _data1 = new Byte[Op1ElementCount]; - private static Byte[] _data2 = new Byte[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Byte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Byte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetByte(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetByte(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Byte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)), - (Byte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)), - (Byte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Byte*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Byte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Byte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Byte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Byte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Byte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (Byte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Byte*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Byte*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)); - var right = (Byte*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)); - var right = (Byte*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Byte1(); - var result = Avx2.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (Byte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray1 = new Byte[Op1ElementCount]; - Byte[] inArray2 = new Byte[Op2ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Byte[] inArray1 = new Byte[Op1ElementCount]; - Byte[] inArray2 = new Byte[Op2ElementCount]; - Byte[] outArray = new Byte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 15 ? result[i] != right[i - 16] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs deleted file mode 100644 index 8ef4733..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int161Load() - { - var test = new InsertLoadTest__InsertVector128Int161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Int161 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Int161 testClass) - { - var result = Avx2.InsertVector128(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data1 = new Int16[Op1ElementCount]; - private static Int16[] _data2 = new Int16[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Int161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Int161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt16(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt16(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Int16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), - (Int16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), - (Int16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int16*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (Int16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Int16*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Int16*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)); - var right = (Int16*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)); - var right = (Int16*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Int161(); - var result = Avx2.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (Int16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray1 = new Int16[Op1ElementCount]; - Int16[] inArray2 = new Int16[Op2ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray1 = new Int16[Op1ElementCount]; - Int16[] inArray2 = new Int16[Op2ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 7 ? result[i] != right[i - 8] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs deleted file mode 100644 index 1f9468a..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int321Load() - { - var test = new InsertLoadTest__InsertVector128Int321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Int321 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Int321 testClass) - { - var result = Avx2.InsertVector128(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); - - private static Int32[] _data1 = new Int32[Op1ElementCount]; - private static Int32[] _data2 = new Int32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Int321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Int321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt32(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt32(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Int32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - (Int32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - (Int32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int32*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (Int32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Int32*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Int32*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = (Int32*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); - var right = (Int32*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Int321(); - var result = Avx2.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (Int32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int32[] inArray1 = new Int32[Op1ElementCount]; - Int32[] inArray2 = new Int32[Op2ElementCount]; - Int32[] outArray = new Int32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? result[i] != right[i - 4] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs deleted file mode 100644 index 36e12c3..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128Int641Load() - { - var test = new InsertLoadTest__InsertVector128Int641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128Int641 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128Int641 testClass) - { - var result = Avx2.InsertVector128(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int64); - - private static Int64[] _data1 = new Int64[Op1ElementCount]; - private static Int64[] _data2 = new Int64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128Int641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128Int641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetInt64(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetInt64(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (Int64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - (Int64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - (Int64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int64*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(Int64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(Int64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (Int64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (Int64*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (Int64*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = (Int64*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)); - var right = (Int64*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128Int641(); - var result = Avx2.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (Int64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - Int64[] inArray1 = new Int64[Op1ElementCount]; - Int64[] inArray2 = new Int64[Op2ElementCount]; - Int64[] outArray = new Int64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(Int64[] left, Int64[] right, Int64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? result[i] != right[i - 2] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs deleted file mode 100644 index 4c6e8e9..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128SByte1Load() - { - var test = new InsertLoadTest__InsertVector128SByte1(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128SByte1 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128SByte1 testClass) - { - var result = Avx2.InsertVector128(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data1 = new SByte[Op1ElementCount]; - private static SByte[] _data2 = new SByte[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128SByte1() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128SByte1() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSByte(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSByte(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (SByte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), - (SByte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), - (SByte*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(SByte*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(SByte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(SByte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(SByte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(SByte*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(SByte*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (SByte*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (SByte*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (SByte*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)); - var right = (SByte*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)); - var right = (SByte*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128SByte1(); - var result = Avx2.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (SByte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray1 = new SByte[Op1ElementCount]; - SByte[] inArray2 = new SByte[Op2ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray1 = new SByte[Op1ElementCount]; - SByte[] inArray2 = new SByte[Op2ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(SByte[] left, SByte[] right, SByte[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 15 ? result[i] != right[i - 16] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs deleted file mode 100644 index bc5cacc..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt161Load() - { - var test = new InsertLoadTest__InsertVector128UInt161(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128UInt161 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt161 testClass) - { - var result = Avx2.InsertVector128(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - - private static UInt16[] _data1 = new UInt16[Op1ElementCount]; - private static UInt16[] _data2 = new UInt16[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128UInt161() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128UInt161() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt16(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt16(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (UInt16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), - (UInt16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), - (UInt16*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt16*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt16*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt16*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (UInt16*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (UInt16*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (UInt16*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)); - var right = (UInt16*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)); - var right = (UInt16*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128UInt161(); - var result = Avx2.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray1 = new UInt16[Op1ElementCount]; - UInt16[] inArray2 = new UInt16[Op2ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt16[] inArray1 = new UInt16[Op1ElementCount]; - UInt16[] inArray2 = new UInt16[Op2ElementCount]; - UInt16[] outArray = new UInt16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt16[] left, UInt16[] right, UInt16[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 7 ? result[i] != right[i - 8] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs deleted file mode 100644 index 267d5e8..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt321Load() - { - var test = new InsertLoadTest__InsertVector128UInt321(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128UInt321 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt321 testClass) - { - var result = Avx2.InsertVector128(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - - private static UInt32[] _data1 = new UInt32[Op1ElementCount]; - private static UInt32[] _data2 = new UInt32[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128UInt321() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128UInt321() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt32(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt32(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (UInt32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - (UInt32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - (UInt32*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt32*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt32*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt32*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (UInt32*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (UInt32*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (UInt32*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = (UInt32*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); - var right = (UInt32*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128UInt321(); - var result = Avx2.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt32[] inArray1 = new UInt32[Op1ElementCount]; - UInt32[] inArray2 = new UInt32[Op2ElementCount]; - UInt32[] outArray = new UInt32[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 3 ? result[i] != right[i - 4] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs deleted file mode 100644 index 6c3e08d..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertVector128UInt641Load() - { - var test = new InsertLoadTest__InsertVector128UInt641(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__InsertVector128UInt641 - { - private struct TestStruct - { - public Vector256 _fld1; - public Vector128 _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt641 testClass) - { - var result = Avx2.InsertVector128(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, 1); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - - private static UInt64[] _data1 = new UInt64[Op1ElementCount]; - private static UInt64[] _data2 = new UInt64[Op2ElementCount]; - - private static Vector256 _clsVar1; - private static Vector128 _clsVar2; - - private Vector256 _fld1; - private Vector128 _fld2; - - private SimpleBinaryOpTest__DataTable _dataTable; - - static InsertLoadTest__InsertVector128UInt641() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - } - - public InsertLoadTest__InsertVector128UInt641() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetUInt64(); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetUInt64(); } - _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt64[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = Avx2.InsertVector128( - Unsafe.Read>(_dataTable.inArray1Ptr), - (UInt64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = Avx2.InsertVector128( - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - (UInt64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = Avx2.InsertVector128( - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - (UInt64*)(_dataTable.inArray2Ptr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt64*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof(Avx2).GetMethod(nameof(Avx2.InsertVector128), new Type[] { typeof(Vector256), typeof(UInt64*), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof(UInt64*)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = Avx2.InsertVector128( - _clsVar1, - (UInt64*)_dataTable.inArray2Ptr, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, (UInt64*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read>(_dataTable.inArray1Ptr); - var right = (UInt64*)_dataTable.inArray2Ptr; - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = (UInt64*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)); - var right = (UInt64*)(_dataTable.inArray2Ptr); - var result = Avx2.InsertVector128(left, right, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__InsertVector128UInt641(); - var result = Avx2.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = Avx2.InsertVector128(_fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = Avx2.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult(Vector256 left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - UInt64[] inArray1 = new UInt64[Op1ElementCount]; - UInt64[] inArray2 = new UInt64[Op2ElementCount]; - UInt64[] outArray = new UInt64[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(UInt64[] left, UInt64[] right, UInt64[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if (result[0] != left[0]) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ((i > 1 ? result[i] != right[i - 2] : result[i] != left[i])) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof(Avx2)}.{nameof(Avx2.InsertVector128)}(Vector256, Vector128.1): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs index b52e89f..87b405c 100644 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs +++ b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs @@ -124,14 +124,6 @@ namespace JIT.HardwareIntrinsics.X86 ["ExtractVector128.UInt32.1"] = ExtractVector128UInt321, ["ExtractVector128.Int64.1"] = ExtractVector128Int641, ["ExtractVector128.UInt64.1"] = ExtractVector128UInt641, - ["ExtractVector128.Byte.1.Store"] = ExtractVector128Byte1Store, - ["ExtractVector128.SByte.1.Store"] = ExtractVector128SByte1Store, - ["ExtractVector128.Int16.1.Store"] = ExtractVector128Int161Store, - ["ExtractVector128.UInt16.1.Store"] = ExtractVector128UInt161Store, - ["ExtractVector128.Int32.1.Store"] = ExtractVector128Int321Store, - ["ExtractVector128.UInt32.1.Store"] = ExtractVector128UInt321Store, - ["ExtractVector128.Int64.1.Store"] = ExtractVector128Int641Store, - ["ExtractVector128.UInt64.1.Store"] = ExtractVector128UInt641Store, ["InsertVector128.Byte.1"] = InsertVector128Byte1, ["InsertVector128.SByte.1"] = InsertVector128SByte1, ["InsertVector128.Int16.1"] = InsertVector128Int161, @@ -140,14 +132,6 @@ namespace JIT.HardwareIntrinsics.X86 ["InsertVector128.UInt32.1"] = InsertVector128UInt321, ["InsertVector128.Int64.1"] = InsertVector128Int641, ["InsertVector128.UInt64.1"] = InsertVector128UInt641, - ["InsertVector128.Byte.1.Load"] = InsertVector128Byte1Load, - ["InsertVector128.SByte.1.Load"] = InsertVector128SByte1Load, - ["InsertVector128.Int16.1.Load"] = InsertVector128Int161Load, - ["InsertVector128.UInt16.1.Load"] = InsertVector128UInt161Load, - ["InsertVector128.Int32.1.Load"] = InsertVector128Int321Load, - ["InsertVector128.UInt32.1.Load"] = InsertVector128UInt321Load, - ["InsertVector128.Int64.1.Load"] = InsertVector128Int641Load, - ["InsertVector128.UInt64.1.Load"] = InsertVector128UInt641Load, ["MaskLoad.Int32"] = MaskLoadInt32, ["MaskLoad.UInt32"] = MaskLoadUInt32, ["MaskLoad.Int64"] = MaskLoadInt64, diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template deleted file mode 100644 index 74032ef..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template +++ /dev/null @@ -1,379 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void {Method}{RetBaseType}{Imm}Store() - { - var test = new ExtractStoreTest__{Method}{RetBaseType}{Imm}(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if ({LoadIsa}.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if ({LoadIsa}.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if ({LoadIsa}.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class ExtractStoreTest__{Method}{RetBaseType}{Imm} - { - private struct TestStruct - { - public {Op1VectorType}<{Op1BaseType}> _fld; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - - return testStruct; - } - - public void RunStructFldScenario(ExtractStoreTest__{Method}{RetBaseType}{Imm} testClass) - { - {Isa}.{Method}(({Op1BaseType}*)testClass._dataTable.outArrayPtr, _fld, {Imm}); - testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = {LargestVectorSize}; - - private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); - private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); - - private static {Op1BaseType}[] _data = new {Op1BaseType}[Op1ElementCount]; - - private static {Op1VectorType}<{Op1BaseType}> _clsVar; - - private {Op1VectorType}<{Op1BaseType}> _fld; - - private SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}> _dataTable; - - static ExtractStoreTest__{Method}{RetBaseType}{Imm}() - { - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - } - - public ExtractStoreTest__{Method}{RetBaseType}{Imm}() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } - _dataTable = new SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}>(_data, new {RetBaseType}[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => {Isa}.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - {Isa}.{Method}( - ({Op1BaseType}*)_dataTable.outArrayPtr, - Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr), - {Imm} - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - {Isa}.{Method}( - ({Op1BaseType}*)_dataTable.outArrayPtr, - {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)), - {Imm} - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - {Isa}.{Method}( - ({Op1BaseType}*)_dataTable.outArrayPtr, - {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)), - {Imm} - ); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1BaseType}*), typeof({Op1VectorType}<{Op1BaseType}>), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof({Op1BaseType}*)), - Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr), - (byte){Imm} - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1BaseType}*), typeof({Op1VectorType}<{Op1BaseType}>), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof({Op1BaseType}*)), - {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)), - (byte){Imm} - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1BaseType}*), typeof({Op1VectorType}<{Op1BaseType}>), typeof(byte) }) - .Invoke(null, new object[] { - Pointer.Box(_dataTable.outArrayPtr, typeof({Op1BaseType}*)), - {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)), - (byte){Imm} - }); - - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - {Isa}.{Method}( - ({Op1BaseType}*)_dataTable.outArrayPtr, - _clsVar, - {Imm} - ); - - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var firstOp = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr); - {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, firstOp, {Imm}); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var firstOp = {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)); - {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, firstOp, {Imm}); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var firstOp = {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)); - {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, firstOp, {Imm}); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new ExtractStoreTest__{Method}{RetBaseType}{Imm}(); - {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, test._fld, {Imm}); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, _fld, {Imm}); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, test._fld, {Imm}); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult({Op1VectorType}<{Op1BaseType}> firstOp, void* result, [CallerMemberName] string method = "") - { - {Op1BaseType}[] inArray = new {Op1BaseType}[Op1ElementCount]; - {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - {Op1BaseType}[] inArray = new {Op1BaseType}[Op1ElementCount]; - {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult({Op1BaseType}[] firstOp, {RetBaseType}[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if ({ValidateFirstResult}) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ({ValidateRemainingResults}) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}><9>): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx index 4cd96c2..db492c0 100644 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx +++ b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx @@ -575,16 +575,6 @@ private static readonly (string templateFileName, Dictionary tem ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "result[i] != firstOp[i+4]"}), ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "result[i] != firstOp[i+2]"}), ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "result[i] != firstOp[i+2]"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[4])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i + 4]))"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[2])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(firstOp[i + 2]))"}), ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "result[i] != (i < 16 ? left[i] : right[i-16])"}), ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "result[i] != (i < 16 ? left[i] : right[i-16])"}), ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "result[i] != (i < 8 ? left[i] : right[i-8])"}), @@ -595,16 +585,6 @@ private static readonly (string templateFileName, Dictionary tem ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "result[i] != (i < 2 ? left[i] : right[i-2])"}), ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (i < 4 ? BitConverter.SingleToInt32Bits(left[i]) : BitConverter.SingleToInt32Bits(right[i-4]))"}), ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (i < 2 ? BitConverter.DoubleToInt64Bits(left[i]) : BitConverter.DoubleToInt64Bits(right[i-2]))"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])", ["ValidateRemainingResults"] = "(i > 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[i - 4]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i]))"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[0])", ["ValidateRemainingResults"] = "(i > 1 ? BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(right[i - 2]) : BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i]))"}), ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Floor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Floor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), ("LoadUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["Method"] = "LoadVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), @@ -811,14 +791,6 @@ private static readonly (string templateFileName, Dictionary tem ("ExtractVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), ("ExtractVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), ("ExtractVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), @@ -827,14 +799,6 @@ private static readonly (string templateFileName, Dictionary tem ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), ("LoadBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "MaskLoad", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != ((right[0] < 0) ? left[0] : 0)", ["ValidateRemainingResults"] = "result[i] != ((right[i] < 0) ? left[i] : 0)"}), ("LoadBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "MaskLoad", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != (((right[0] & (1U << 31)) != 0) ? left[0] : 0)", ["ValidateRemainingResults"] = "result[i] != (((right[i] & (1U << 31)) != 0) ? left[i] : 0)"}), ("LoadBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "MaskLoad", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["NextValueOp2"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != ((right[0] < 0) ? left[0] : 0)", ["ValidateRemainingResults"] = "result[i] != ((right[i] < 0) ? left[i] : 0)"}), diff --git a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template b/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template deleted file mode 100644 index 4f49a63..0000000 --- a/src/coreclr/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template +++ /dev/null @@ -1,421 +0,0 @@ -// 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\X86\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.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; -using static System.Runtime.Intrinsics.X86.Sse2; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void {Method}{RetBaseType}{Imm}Load() - { - var test = new InsertLoadTest__{Method}{RetBaseType}{Imm}(); - - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if ({LoadIsa}.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if ({LoadIsa}.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if ({LoadIsa}.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local class works - test.RunClassLclFldScenario(); - - // Validates passing an instance member of a class works - test.RunClassFldScenario(); - - // Validates passing the field of a local struct works - test.RunStructLclFldScenario(); - - // Validates passing an instance member of a struct works - test.RunStructFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class InsertLoadTest__{Method}{RetBaseType}{Imm} - { - private struct TestStruct - { - public {Op1VectorType}<{Op1BaseType}> _fld1; - public {Op2VectorType}<{Op2BaseType}> _fld2; - - public static TestStruct Create() - { - var testStruct = new TestStruct(); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); - - return testStruct; - } - - public void RunStructFldScenario(InsertLoadTest__{Method}{RetBaseType}{Imm} testClass) - { - var result = {Isa}.{Method}(_fld1, ({Op2BaseType}*)testClass._dataTable.inArray2Ptr, {Imm}); - - Unsafe.Write(testClass._dataTable.outArrayPtr, result); - testClass.ValidateResult(_fld1, ({Op2BaseType}*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); - } - } - - private static readonly int LargestVectorSize = {LargestVectorSize}; - - private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); - private static readonly int Op2ElementCount = Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>() / sizeof({Op2BaseType}); - private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); - - private static {Op1BaseType}[] _data1 = new {Op1BaseType}[Op1ElementCount]; - private static {Op2BaseType}[] _data2 = new {Op2BaseType}[Op2ElementCount]; - - private static {Op1VectorType}<{Op1BaseType}> _clsVar1; - private static {Op2VectorType}<{Op2BaseType}> _clsVar2; - - private {Op1VectorType}<{Op1BaseType}> _fld1; - private {Op2VectorType}<{Op2BaseType}> _fld2; - - private SimpleBinaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}, {Op2BaseType}> _dataTable; - - static InsertLoadTest__{Method}{RetBaseType}{Imm}() - { - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _clsVar2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); - } - - public InsertLoadTest__{Method}{RetBaseType}{Imm}() - { - Succeeded = true; - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } - _dataTable = new SimpleBinaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}, {Op2BaseType}>(_data1, _data2, new {RetBaseType}[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => {Isa}.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); - - var result = {Isa}.{Method}( - Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), - ({Op2BaseType}*)_dataTable.inArray2Ptr, - {Imm} - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); - - var result = {Isa}.{Method}( - {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), - ({Op2BaseType}*)(_dataTable.inArray2Ptr), - {Imm} - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); - - var result = {Isa}.{Method}( - {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), - ({Op2BaseType}*)(_dataTable.inArray2Ptr), - {Imm} - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); - - var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2BaseType}*), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), - Pointer.Box(_dataTable.inArray2Ptr, typeof({Op2BaseType}*)), - (byte){Imm} - }); - - Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); - - var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2BaseType}*), typeof(byte) }) - .Invoke(null, new object[] { - {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof({Op2BaseType}*)), - (byte){Imm} - }); - - Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); - - var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2BaseType}*), typeof(byte) }) - .Invoke(null, new object[] { - {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)), - Pointer.Box(_dataTable.inArray2Ptr, typeof({Op2BaseType}*)), - (byte){Imm} - }); - - Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); - ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); - - var result = {Isa}.{Method}( - _clsVar1, - ({Op2BaseType}*)_dataTable.inArray2Ptr, - {Imm} - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar1, ({Op2BaseType}*)_dataTable.inArray2Ptr, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); - - var left = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr); - var right = ({Op2BaseType}*)_dataTable.inArray2Ptr; - var result = {Isa}.{Method}(left, right, {Imm}); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); - - var left = {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)); - var right = ({Op2BaseType}*)(_dataTable.inArray2Ptr); - var result = {Isa}.{Method}(left, right, {Imm}); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); - - var left = {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArray1Ptr)); - var right = ({Op2BaseType}*)(_dataTable.inArray2Ptr); - var result = {Isa}.{Method}(left, right, {Imm}); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(left, right, _dataTable.outArrayPtr); - } - - public void RunClassLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); - - var test = new InsertLoadTest__{Method}{RetBaseType}{Imm}(); - var result = {Isa}.{Method}(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), {Imm}); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunClassFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); - - var result = {Isa}.{Method}(_fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), {Imm}); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructLclFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); - - var test = TestStruct.Create(); - var result = {Isa}.{Method}(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), {Imm}); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); - } - - public void RunStructFldScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); - - var test = TestStruct.Create(); - test.RunStructFldScenario(this); - } - - public void RunUnsupportedScenario() - { - TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); - - bool succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - succeeded = true; - } - - if (!succeeded) - { - Succeeded = false; - } - } - - private void ValidateResult({Op1VectorType}<{Op1BaseType}> left, void* right, void* result, [CallerMemberName] string method = "") - { - {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; - {Op2BaseType}[] inArray2 = new {Op2BaseType}[Op2ElementCount]; - {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), left); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2BaseType}, byte>(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") - { - {Op1BaseType}[] inArray1 = new {Op1BaseType}[Op1ElementCount]; - {Op2BaseType}[] inArray2 = new {Op2BaseType}[Op2ElementCount]; - {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2BaseType}, byte>(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); - - ValidateResult(inArray1, inArray2, outArray, method); - } - - private void ValidateResult({Op1BaseType}[] left, {Op2BaseType}[] right, {RetBaseType}[] result, [CallerMemberName] string method = "") - { - bool succeeded = true; - - if ({ValidateFirstResult}) - { - succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ({ValidateRemainingResults}) - { - succeeded = false; - break; - } - } - } - - if (!succeeded) - { - TestLibrary.TestFramework.LogInformation($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>, {Op2VectorType}<{Op2BaseType}>.{Imm}): {method} failed:"); - TestLibrary.TestFramework.LogInformation($" left: ({string.Join(", ", left)})"); - TestLibrary.TestFramework.LogInformation($" right: ({string.Join(", ", right)})"); - TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); - TestLibrary.TestFramework.LogInformation(string.Empty); - - Succeeded = false; - } - } - } -} diff --git a/src/coreclr/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/VectorPacket.cs b/src/coreclr/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/VectorPacket.cs index 6cbc79b..dbd6571 100644 --- a/src/coreclr/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/VectorPacket.cs +++ b/src/coreclr/tests/src/JIT/Performance/CodeQuality/HWIntrinsic/X86/PacketTracer/VectorPacket.cs @@ -58,9 +58,9 @@ internal struct VectorPacket256 Vector256 m03 = LoadVector128(&vectors[0]).ToVector256(); // load lower halves Vector256 m14 = LoadVector128(&vectors[4]).ToVector256(); Vector256 m25 = LoadVector128(&vectors[8]).ToVector256(); - m03 = InsertVector128(m03, &vectors[12], 1); // load higher halves - m14 = InsertVector128(m14, &vectors[16], 1); - m25 = InsertVector128(m25, &vectors[20], 1); + m03 = InsertVector128(m03, LoadVector128(&vectors[12]), 1); // load higher halves + m14 = InsertVector128(m14, LoadVector128(&vectors[16]), 1); + m25 = InsertVector128(m25, LoadVector128(&vectors[20]), 1); var xy = Shuffle(m14, m25, 2 << 6 | 1 << 4 | 3 << 2 | 2); var yz = Shuffle(m03, m14, 1 << 6 | 0 << 4 | 2 << 2 | 1); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs index 5b8054c..85c5a8b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs @@ -291,57 +291,6 @@ namespace System.Runtime.Intrinsics.X86 public static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(byte* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(sbyte* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(short* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(ushort* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(int* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(uint* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(long* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(ulong* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128 _mm256_extractf128_ps (__m256 a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(float* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128d _mm256_extractf128_pd (__m256d a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(double* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - - /// /// __m256 _mm256_floor_ps (__m256 a) /// VROUNDPS ymm, ymm/m256, imm8(9) /// @@ -435,57 +384,6 @@ namespace System.Runtime.Intrinsics.X86 public static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, sbyte* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, byte* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, short* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, ushort* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, int* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, uint* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, long* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, ulong* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256 _mm256_insertf128_ps (__m256 a, __m128 b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, float* address, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256d _mm256_insertf128_pd (__m256d a, __m128d b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, double* address, byte index) { throw new PlatformNotSupportedException(); } - - /// /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr) /// VMOVDQU ymm, m256 /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.cs index 02c31d0..79c97b8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.cs @@ -294,57 +294,6 @@ namespace System.Runtime.Intrinsics.X86 public static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(byte* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(sbyte* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(short* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(ushort* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(int* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(uint* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(long* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128i _mm256_extractf128_si256 (__m256i a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(ulong* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128 _mm256_extractf128_ps (__m256 a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(float* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - /// - /// __m128d _mm256_extractf128_pd (__m256d a, const int imm8) - /// VEXTRACTF128 m128, ymm, imm8 - /// - public static unsafe void ExtractVector128(double* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - - /// /// __m256 _mm256_floor_ps (__m256 a) /// VROUNDPS ymm, ymm/m256, imm8(9) /// @@ -438,57 +387,6 @@ namespace System.Runtime.Intrinsics.X86 public static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, sbyte* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, byte* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, short* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, ushort* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, int* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, uint* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, long* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256i _mm256_insertf128_si256 (__m256i a, __m128i b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, ulong* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256 _mm256_insertf128_ps (__m256 a, __m128 b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, float* address, byte index) => InsertVector128(value, address, index); - /// - /// __m256d _mm256_insertf128_pd (__m256d a, __m128d b, int imm8) - /// VINSERTF128 ymm, ymm, m128, imm8 - /// - public static unsafe Vector256 InsertVector128(Vector256 value, double* address, byte index) => InsertVector128(value, address, index); - - /// /// __m256i _mm256_loadu_si256 (__m256i const * mem_addr) /// VMOVDQU ymm, m256 /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs index 6f444bb..dfe2f62 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs @@ -736,88 +736,48 @@ namespace System.Runtime.Intrinsics.X86 /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(sbyte* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(byte* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(short* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(ushort* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(int* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(uint* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(long* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(ulong* address, Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_i32gather_epi32 (int const* base_addr, __m128i vindex, const int scale) @@ -1148,88 +1108,48 @@ namespace System.Runtime.Intrinsics.X86 /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, xm128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, sbyte* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, byte* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, short* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, ushort* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, int* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, uint* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, long* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, ulong* address, byte index) { throw new PlatformNotSupportedException(); } /// /// __m256i _mm256_stream_load_si256 (__m256i const* mem_addr) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.cs index 4ab81e7..240d654 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.cs @@ -740,86 +740,45 @@ namespace System.Runtime.Intrinsics.X86 /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(sbyte* address, Vector256 value, byte index) => ExtractVector128(address, value, index); - - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(byte* address, Vector256 value, byte index) => ExtractVector128(address, value, index); /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(short* address, Vector256 value, byte index) => ExtractVector128(address, value, index); /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(ushort* address, Vector256 value, byte index) => ExtractVector128(address, value, index); /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(int* address, Vector256 value, byte index) => ExtractVector128(address, value, index); /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(uint* address, Vector256 value, byte index) => ExtractVector128(address, value, index); /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(long* address, Vector256 value, byte index) => ExtractVector128(address, value, index); /// /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) /// VEXTRACTI128 xmm, ymm, imm8 /// public new static Vector128 ExtractVector128(Vector256 value, byte index) => ExtractVector128(value, index); - /// - /// __m128i _mm256_extracti128_si256 (__m256i a, const int imm8) - /// VEXTRACTI128 m128, ymm, imm8 - /// - public new static unsafe void ExtractVector128(ulong* address, Vector256 value, byte index) => ExtractVector128(address, value, index); /// /// __m128i _mm_i32gather_epi32 (int const* base_addr, __m128i vindex, const int scale) @@ -1870,88 +1829,48 @@ namespace System.Runtime.Intrinsics.X86 /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, xm128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, sbyte* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, byte* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, short* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, ushort* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, int* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, uint* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, long* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) /// VINSERTI128 ymm, ymm, xmm, imm8 /// public new static Vector256 InsertVector128(Vector256 value, Vector128 data, byte index) => InsertVector128(value, data, index); - /// - /// __m256i _mm256_inserti128_si256 (__m256i a, __m128i b, const int imm8) - /// VINSERTI128 ymm, ymm, m128, imm8 - /// - public new static unsafe Vector256 InsertVector128(Vector256 value, ulong* address, byte index) => InsertVector128(value, address, index); /// /// __m256i _mm256_stream_load_si256 (__m256i const* mem_addr) -- 2.7.4