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
| /* | |
| * Thread-local cache for meshoptimizer allocations. Planned for inclusion into future meshoptimizer versions. | |
| * | |
| * Copyright (C) 2016-2025, by Arseny Kapoulkine ([email protected]) | |
| * This code is distributed under the MIT License. | |
| */ | |
| // reconfigure thread cache for meshopt_ allocations for N threads x M bytes per thread | |
| // can't be called concurrently with meshopt_ or clod functions | |
| void clodUseThreadCache(size_t thread_count, size_t size_per_thread) |
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
| // To build: | |
| // clang++ metalbvh.mm src/scene.cpp extern/meshoptimizer/src/*.cpp src/extern.cpp -I extern/glm -I extern/fast_obj -I extern/cgltf -I extern/meshoptimizer/src -framework Metal -framework Foundation -framework QuartzCore -lobjc -O2 -o metalbvh | |
| #include "common.h" | |
| #include "scene.h" | |
| #import <Metal/Metal.h> | |
| #import <MetalKit/MetalKit.h> | |
| #import <Foundation/Foundation.h> |
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
| // clang++ -fsanitize=fuzzer -ffp-contract=off -O1 ./lerpfuzz.cpp -o lerpfuzz && ./lerpfuzz | |
| #include <assert.h> | |
| #include <math.h> | |
| #include <stdint.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| using real_t = float; |
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
| import argparse | |
| import json | |
| import os | |
| import safetensors | |
| import safetensors.torch | |
| import sys | |
| import time | |
| import torch | |
| def fast_save_file(tensors, filename, metadata=None): |
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
| // brew install libomp | |
| // cc -o matbench matbench.c -O3 -ffast-math -Xclang -fopenmp -I/opt/homebrew/opt/libomp/include -L/opt/homebrew/opt/libomp/lib -lomp | |
| // ./matbench | |
| #include <assert.h> | |
| #include <math.h> | |
| #include <omp.h> | |
| #include <stdio.h> | |
| #include <time.h> |
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
| // This code looks at precision impact of transforming a vector repeatedly by a slightly-non-unit quaternion | |
| // Slightly-non-unit quaternions are important: they result in the process of quaternion computations naturally | |
| // Repeated transformations are important: they may occur during simulation or complex long chains of computation | |
| // Note that because this code runs in JS in double precision, this doesn't model floating-point roundoff. | |
| function applyQuaternion1( q, v ) { | |
| const x = v.x, y = v.y, z = v.z; | |
| const qx = q.x, qy = q.y, qz = q.z, qw = q.w; |
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
| #version 450 | |
| // 2D Polyhedral Bounds of a Clipped, Perspective-Projected 3D Sphere. Michael Mara, Morgan McGuire. 2013 | |
| bool projectSphereView(vec3 c, float r, float znear, float P00, float P11, out vec4 aabb) | |
| { | |
| if (c.z < r + znear) return false; | |
| vec3 cr = c * r; | |
| float czr2 = c.z * c.z - r * r; |
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
| /* | |
| The Nature paper about sorting algorithms has an "improvement" for sort3 that saves a mov. | |
| Thread for context: https://mastodon.gamedev.place/@zeux/110510029570470184 | |
| This code is experimentally verifying that the proposed optimization is perf neutral | |
| (aka is not improving performance). You'll need to remove the mov from all 3 versions | |
| and retest; feel free to test one version at a time. | |
| Cycle count established by using 'perf stat' on Ryzen 7 5900X - it does not depend on | |
| whether the mov is there. |
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
| tl = 512 | |
| for vl in [32, 64, 96, 128, 256]: | |
| bestx = 0 | |
| besty = 0 | |
| bests = vl | |
| for x in range(1, vl): | |
| for y in range(1, vl): | |
| v = (x+1)*(y+1) |
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
| --!strict | |
| --[[ | |
| BSD Zero Clause License | |
| Copyright (c) 2022 Arseny Kapoulkine | |
| Permission to use, copy, modify, and/or distribute this software for any | |
| purpose with or without fee is hereby granted. |
NewerOlder