Skip to content

Instantly share code, notes, and snippets.

View tannergooding's full-sized avatar

Tanner Gooding tannergooding

View GitHub Profile
public static int Sum(ReadOnlySpan<int> x)
{
if (Vector128.IsHardwareAccelerated)
{
int result;
if (x.Length >= Vector128<int>.Count)
{
result = Vectorized128(x);
}
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using TerraFX.Interop;
using TerraFX.Interop.Windows;
using static TerraFX.Interop.Windows.E;
using static TerraFX.Interop.Windows.IID;
using static TerraFX.Interop.Windows.S;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
public unsafe class Proga
{
static void Main(string[] args)
@tannergooding
tannergooding / After.cs
Created October 1, 2021 01:59
Comparison of before xplat hwintrinsics and after
public float Sum(float[] values) {
if (values is null)
{
throw new ArgumentNullException();
}
if (Vector128.IsHardwareAccelerated)
{
ref var value = ref MemoryMarshal.GetArrayDataReference(values);
var vsum = Vector128<float>.Zero;
#include "lib.h"
#include "common.h"
#include <iostream>
void thing()
{
auto lib_id1 = get_next_lib_id_int32();
auto lib_id2 = get_next_lib_id_size();
using System;
using System.Threading;
using System.Threading.Tasks;
class Program
{
const int limit = 100_000_000;
static void Main(string[] args)
{
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.Text;
using TerraFX.CodeAnalysis.Source;
//------------------------------------------------------------------------
// gtFoldExprCast: see if a cast is foldable
//
// Arguments:
// cast - cast to examine
//
// Returns:
// The original cast if no folding happened.
// An alternative tree if folding happens.
//
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
public unsafe class NetStandardPlus
{
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void MyStdcallDelegate();
public static void Call(delegate*<void> action) => action();
using System;
using System.Runtime.CompilerServices;
public interface IComparer<T>
{
int CompareTo(T other);
}
public static class ArrayExtensions
{