public void RunBasicScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); Int64[] values = new Int64[ElementCount]; for (int i = 0; i < ElementCount; i++) { values[i] = TestLibrary.Generator.GetInt64(); } Vector64 <Int64> value = Vector64.Create(values[0]); Int64 result = value.ToScalar(); ValidateResult(result, values); }
public void RunBasicScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); Byte[] values = new Byte[ElementCount]; for (int i = 0; i < ElementCount; i++) { values[i] = TestLibrary.Generator.GetByte(); } Vector64 <Byte> value = Vector64.Create(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]); Byte result = value.ToScalar(); ValidateResult(result, values); }
public void RunBasicScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario)); UInt16[] values = new UInt16[ElementCount]; for (int i = 0; i < ElementCount; i++) { values[i] = TestLibrary.Generator.GetUInt16(); } Vector64 <UInt16> value = Vector64.Create(values[0], values[1], values[2], values[3]); UInt16 result = value.ToScalar(); ValidateResult(result, values); }
public static int PopCount(uint value) { if (Popcnt.IsSupported) { return((int)Popcnt.PopCount(value)); } if (AdvSimd.Arm64.IsSupported) { // PopCount works on vector so convert input value to vector first. Vector64 <uint> input = Vector64.CreateScalar(value); Vector64 <byte> aggregated = AdvSimd.Arm64.AddAcross(AdvSimd.PopCount(input.AsByte())); return(aggregated.ToScalar()); } return(SoftwareFallback(value));
public static int PopCount(uint value) { if (Popcnt.IsSupported) { return((int)Popcnt.PopCount(value)); } if (AdvSimd.Arm64.IsSupported) { // PopCount works on vector so convert input value to vector first. // Vector64.CreateScalar(uint) generates suboptimal code by storing and // loading the result to memory. // See https://github.com/dotnet/runtime/issues/35976 for details. // Hence use Vector64.Create(ulong) to create Vector64<ulong> and operate on that. Vector64 <ulong> input = Vector64.Create((ulong)value); Vector64 <byte> aggregated = AdvSimd.Arm64.AddAcross(AdvSimd.PopCount(input.AsByte())); return(aggregated.ToScalar()); } return(SoftwareFallback(value));