Skip to content

Instantly share code, notes, and snippets.

@williamyang98
williamyang98 / clpeak.py
Created March 5, 2025 12:34
OpenCL python benchmark tool equivalent to clpeak
from collections import namedtuple
from pprint import pprint
from tabulate import tabulate
import argparse
import math
import numpy as np
import pyopencl as cl
import sys
import time
@williamyang98
williamyang98 / me3_auto_pullups.py
Created March 3, 2025 11:02
Script to automate minigame for Jame's 183 pullups in Citadel DLC
import pynput
import threading
import time
class App:
def __init__(self):
self.is_running = True
self.is_pullup = False
self.pullup_thread = None
self.keyboard_thread = None
@williamyang98
williamyang98 / benchmark_fast_inverse_square_root.cpp
Last active June 5, 2024 18:27
Fast inverse square root explanation
#include <cmath>
#include <stdint.h>
#include <stdio.h>
// | idx | mae | description |
// |-----|----------|-------------------|
// | 0 | 1.008427 | Naiive with k0=0 |
// | 1 | 0.144398 | Original Quake |
// | 2 | 0.099314 | Our grad descent |
// | 3 | 0.060105 | Jan Kadlec (wiki) |
@williamyang98
williamyang98 / aligned_allocator.hpp
Created February 25, 2024 07:34
Aligned allocator for C++17 STL
#pragma once
#include <assert.h>
#include <cstddef>
#include <new>
#include <type_traits>
// C++17 aligned allocator
// Sources: https://en.cppreference.com/w/cpp/named_req/Allocator
// https://en.cppreference.com/w/cpp/memory/allocator_traits
@williamyang98
williamyang98 / calculate_horner_polynomial_gradient_descent.cpp
Last active May 29, 2024 00:42
Calculate chebyshev polynomial that will approximate f(x) = sin(kx). where k = π/root. Uses gradient descent.
// Compiling with clang or gcc
// clang main.cpp -o main -march=native -O3 -ffast-math -Wextra -Werror -Wunused-parameter -lm
// Use "-march=native -ffast-math -O3" for faster gradient descent
// Use "-lm" if linking to glibc math libraries on Linux
// Remove "-W*" warning flags if you don't need checks
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <cmath>
#include <vector>