This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public readonly struct GenerationalHandle | |
| { | |
| public readonly uint Generation; | |
| public readonly uint Handle; | |
| public GenerationalHandle(uint generation, uint handle) | |
| { | |
| Generation = generation; | |
| Handle = handle; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public unsafe class FileSystemDictionary<TValue> : IDictionary<string, TValue> | |
| { | |
| private DirectoryInfo _directory; | |
| public string Name { get; private set; } | |
| public FileSystemDictionary(string? name = null) | |
| { | |
| Name = name ?? Guid.NewGuid().ToString(); | |
| _directory = Directory.CreateDirectory(Path.Join(Path.GetTempPath(), Name)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class IsPow2Benchmark | |
| { | |
| private const int Iterations = 1024; | |
| public int[] Values { get; } = new int[Iterations]; | |
| private volatile bool _result; | |
| public enum DataType { Zero, Random, UniformPow2, UniformNonPow2, UniformNegative, Alternating, AlternatingSign } | |
| [Params(DataType.Zero, DataType.Random, DataType.UniformPow2, DataType.UniformNonPow2, DataType.UniformNegative, DataType.Alternating, DataType.AlternatingSign)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from enum import Enum | |
| from random import choice | |
| from typing import List | |
| from tkinter import * | |
| class PlayerState(Enum): | |
| PLAYING = 0 | |
| LOST = 1 | |
| WIN = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fixed (int* pSrcA = &MemoryMarshal.GetArrayDataReference(a)) | |
| fixed (int* pSrcB = &MemoryMarshal.GetArrayDataReference(b)) | |
| fixed (int* pRes = &MemoryMarshal.GetArrayDataReference(res)) | |
| { | |
| var alignedRes = (int*)(((ulong)pRes + 31) & ~31ul); | |
| var diff = alignedRes - pRes; | |
| // unaligned block | |
| { | |
| var block0 = Avx2.LoadVector256(pSrcA); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class InvokeBenchmark | |
| { | |
| [Benchmark] | |
| public void Native() => NativeDivDivDiv(uint.MaxValue, 15, 16, 55); | |
| [DllImport(@"C:\Users\johnk\source\repos\InvokeBenchmarkNative.exe")] | |
| [SuppressGCTransition] | |
| public static extern uint NativeDivDivDiv(uint a, uint b, uint c, uint d); | |
| [Benchmark] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * K, quick debrief on how PIX works cuz y'all gonna need to know to understand this codebase. | |
| * | |
| * I am certainly going to be wrong at least somwhere here. Please correct if you realise I am | |
| * | |
| * First and foremost, perf is absolutely critical here. Don't get clever and start optimising the generics | |
| * with params object[] | |
| * | |
| * PIX has 2 types of events/markers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Rider debugger (the https://github.com/samsung/netcoredbg one) doesn't play well with native output | |
| // to debug console (OutputDebugString() in C). It works fine in VS19 with native code debugging turned on, | |
| // but this allows it to play nicely with other debuggers. | |
| // All debug layer messages are written to this queue. This isn't a very customisable shim *yet* (TODO) | |
| // and it currently just filters out info/other messages, and makes external code throw | |
| // an SEHException when an error/warning is emitted. 'WriteAllMessages' is called by various error handler | |
| // code and will give out all the input for inspection | |
| internal static unsafe class D3D12DebugShim | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Licensed to the .NET Foundation under one or more agreements. | |
| // The .NET Foundation licenses this file to you under the MIT license. | |
| // The MIT License (MIT) | |
| // Copyright (c) .NET Foundation and Contributors | |
| // All rights reserved. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # creates a big file with all the C# intrinsics. perfect for CTRL F'ing either C style intrinsics names or raw instructions | |
| import os | |
| print("generating your magic file of intrinsics") | |
| path = "{your path to the runtime here}" | |
| intrinsicspath = "src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics" |