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
const std = @import("std"); | |
const mem = std.mem; | |
const json = std.json; | |
const Allocator = mem.Allocator; | |
const Thread = std.Thread; | |
// Constants | |
pub const MIN_PARALLEL_TEXT_SIZE = 10_000; | |
pub const DEFAULT_CHUNK_SIZE = 1024 * 64; | |
pub const MAX_THREADS = 8; |
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
const std = @import("std"); | |
const builtin = @import("builtin"); | |
const time = std.time; | |
const atomic = std.atomic; | |
const CACHE_LINE_SIZE: usize = atomic.cache_line; | |
const CHUNK_SIZE: usize = 1; | |
const NEON_ALIGNMENT = 16; | |
// For ARM NEON, we use 4-wide vectors as that's the native SIMD width | |
const Vec4f = @Vector(4, f32); |
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 run tests, do : | |
// zig test -OReleaseSafe -Dcpu=native -Dtarget=native matmul.zig | |
// To run main, do : | |
// zig build-exe -OReleaseFast -Dcpu=native -Dtarget=native matmul.zig | |
// ./matmul | |
// | |
// โโโโ โโโโ โโโโโโ โโโโโโโโโโโโโ โโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโ โโโโโโโ | |
// โโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโ |
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 React, { useState, useEffect, useCallback, useRef } from 'react'; | |
/** | |
* Represents a point in 3D space within the Lorenz system. | |
*/ | |
interface Point { | |
x: number; | |
y: number; | |
z: number; | |
} |
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 React, { useState, useEffect, useCallback, useRef } from 'react'; | |
type ColoredChar = { | |
char: string; | |
color: string; | |
}; | |
const defaultConfig = { | |
scale: 0.05, |
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
const std = @import("std"); | |
const c = @cImport({ | |
@cInclude("stb_image.h"); | |
}); | |
fn cubic(x: f32) f32 { | |
const a = -0.5; | |
const abs_x = @abs(x); | |
if (abs_x <= 1.0) { | |
return (a + 2.0) * abs_x * abs_x * abs_x - (a + 3.0) * abs_x * abs_x + 1.0; |
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
const std = @import("std"); | |
// Can also try: | |
// 8 x 64 | |
// 16 x 64 | |
// Top GFLOPs/s on an Intelยฎ Coreโข i7-13620H Processor = 300.9 GFLOPs/s | |
// Comments were added using Claude. | |
// To run simply run zig build-exe -O ReleaseFast matmul_FP32.zig, then run the binary ./matmul_FP32 | |
// To test simply run zig test -O ReleaseFast matmul_FP32.zig | |
// To test performance on a generated binary, run : sudo perf stat -e cache-misses,cache-references,instructions,cycles ./matmul_FP32 |