Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- run: dotnet --info
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.x"
dotnet-version: "9.x"
- name: Install
run: |
echo '# placeholder' > $PROFILE
Expand Down Expand Up @@ -254,7 +254,7 @@ jobs:
- run: lscpu
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "8.x"
dotnet-version: "9.x"
- name: Install
run: |
dotnet --info
Expand Down
2 changes: 1 addition & 1 deletion .github/zig.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/sh

sudo snap install zig --classic --edge
sudo snap install zig --classic --beta
zig version
6 changes: 3 additions & 3 deletions bench/algorithm/binarytrees/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ fn check(node &Node) int {
fn create(n int) &Node {
if n == 0 {
return &Node{
left: 0
right: 0
left: unsafe { nil }
right: unsafe { nil }
}
}
return &Node{
left: create(n - 1)
left: create(n - 1)
right: create(n - 1)
}
}
Expand Down
6 changes: 2 additions & 4 deletions bench/algorithm/edigits/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import strconv
import math.big
import math

const (
one = big.integer_from_int(1)
ten = big.integer_from_int(10)
)
const one = big.integer_from_int(1)
const ten = big.integer_from_int(10)

fn main() {
mut n := 27
Expand Down
4 changes: 2 additions & 2 deletions bench/algorithm/fannkuch-redux/2-m.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ fn pfannkuchenStats(first: usize, last: usize, n: u8, res: *Stats) void {
stats.checksum += @as(i32, @intCast(flips)) * parity;
perm = nextPermutation(perm, count[0..n]) orelse break;
}
_ = @atomicRmw(u32, &res.max_flips, .Max, stats.max_flips, .SeqCst);
_ = @atomicRmw(i32, &res.checksum, .Add, stats.checksum, .SeqCst);
_ = @atomicRmw(u32, &res.max_flips, .Max, stats.max_flips, .seq_cst);
_ = @atomicRmw(i32, &res.checksum, .Add, stats.checksum, .seq_cst);
}

pub fn main() !void {
Expand Down
2 changes: 0 additions & 2 deletions bench/algorithm/fasta/1c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// contributed by TeXitoi
// add compile-time calculation by hanabi1224

#![feature(const_fn_floating_point_arithmetic)]

use std::cmp::min;
use std::io::{self, BufWriter, Write};

Expand Down
2 changes: 0 additions & 2 deletions bench/algorithm/fasta/5c-m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
// * cleaned up code a bit (reordering, renaming, formatting, etc.)
// add compile-time calculation by hanabi1224

#![feature(const_fn_floating_point_arithmetic)]

use std::cmp::min;
use std::io;
use std::io::{BufWriter, ErrorKind, Write};
Expand Down
4 changes: 2 additions & 2 deletions bench/algorithm/http-server/1-http2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ async function main() {
const server = Deno.listenTls({
hostname: hostname,
port: port,
certFile: "testcert.pem",
keyFile: "testkey.pem",
cert: Deno.readTextFileSync("testcert.pem"),
key: Deno.readTextFileSync("testkey.pem"),
alpnProtocols: ["h2"],
});
runServerAsync(server);
Expand Down
6 changes: 3 additions & 3 deletions bench/algorithm/json-serde/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ fn main() {
}

struct GeoData {
t string [json: 'type']
t string @[json: 'type']
features []Feature
}

struct Feature {
t string [json: 'type']
t string @[json: 'type']
properties Properties
geometry Geometry
}
Expand All @@ -34,6 +34,6 @@ struct Properties {
}

struct Geometry {
t string [json: 'type']
t string @[json: 'type']
coordinates [][][]f64
}
10 changes: 4 additions & 6 deletions bench/algorithm/lru/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ module main
import os
import strconv

const (
a = u32(1103515245)
c = u32(12345)
m = u32(1) << 31
)
const a = u32(1103515245)
const c = u32(12345)
const m = u32(1) << 31

struct LCG {
mut:
Expand Down Expand Up @@ -63,7 +61,7 @@ fn main() {
}
mut lru := LRU{
size: size
m: {}
m: {}
}

mut hit := 0
Expand Down
10 changes: 4 additions & 6 deletions bench/algorithm/lru/2.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ module main
import os
import strconv

const (
a = u32(1103515245)
c = u32(12345)
m = u32(1) << 31
)
const a = u32(1103515245)
const c = u32(12345)
const m = u32(1) << 31

struct LCG {
mut:
Expand Down Expand Up @@ -91,7 +89,7 @@ struct LRU[K, V] {
size int
mut:
_key_lookup map[K]&LinkedListNode[Pair[K, V]] = {}
_entries LinkedList[Pair[K, V]] = {}
_entries LinkedList[Pair[K, V]] = {}
}

fn (mut lru LRU) get(key u32) ?u32 {
Expand Down
8 changes: 3 additions & 5 deletions bench/algorithm/nbody/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import math
import strconv
import os

const (
solar_mass = 4.0 * math.pi * math.pi
days_per_year = 365.24
c_n = 5
)
const solar_mass = 4.0 * math.pi * math.pi
const days_per_year = 365.24
const c_n = 5

struct Body {
pub mut:
Expand Down
26 changes: 12 additions & 14 deletions bench/algorithm/nbody/2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// contributed by TeXitoi
// modified by hanabi1224 to use numeric_array, remove borrow checker hack, do not derive copy, more compile time calculation

use generic_array::{arr, typenum::consts::U4};
use generic_array::typenum::consts::U4;
use numeric_array::{geometry::Geometric, narr, NumericArray, NumericConstant};
use std::f64::consts::PI;

Expand All @@ -18,19 +18,17 @@ const N_BODIES: usize = 5;
const ADVANCE_DT: F64c = NumericConstant(0.01);

macro_rules! planet {
($x:expr, $y:expr, $z:expr, $vx:expr, $vy:expr, $vz:expr, $mass_ratio:expr) => {
{
let mass = $mass_ratio * SOLAR_MASS;
Planet {
position: narr![f64; $x, $y, $z, 0.0],
velocity: narr![f64; $vx, $vy, $vz, 0.0],
mass_ratio: NumericConstant($mass_ratio),
mass,
massc: NumericConstant(mass),
mass_half: mass * 0.5,
}
($x:expr, $y:expr, $z:expr, $vx:expr, $vy:expr, $vz:expr, $mass_ratio:expr) => {{
let mass = $mass_ratio * SOLAR_MASS;
Planet {
position: narr![$x, $y, $z, 0.0],
velocity: narr![$vx, $vy, $vz, 0.0],
mass_ratio: NumericConstant($mass_ratio),
mass,
massc: NumericConstant(mass),
mass_half: mass * 0.5,
}
};
}};
}

lazy_static::lazy_static! {
Expand Down Expand Up @@ -132,7 +130,7 @@ fn energy(bodies: &[Planet; N_BODIES]) -> f64 {

#[inline]
fn offset_momentum(bodies: &mut [Planet; N_BODIES]) {
let mut p = narr!(f64; 0, 0, 0, 0);
let mut p = narr!(0_f64, 0_f64, 0_f64, 0_f64);
for bi in bodies.iter() {
p -= bi.velocity * bi.mass_ratio;
}
Expand Down
6 changes: 3 additions & 3 deletions bench/algorithm/nbody/2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ const Body = struct {
};

fn offset_momentum(bodies: []Body) void {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
var pos = vec3{ 0, 0, 0 };
for (bodies) |b| pos += scale(b.vel, b.mass);
var sun = &bodies[0];
sun.vel = -scale(pos, 1.0 / solar_mass);
}

fn advance(bodies: []Body, dt: f64) void {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
for (bodies[0..], 0..) |*bi, i| {
var vel = bi.vel;
const mi = bi.mass;
Expand All @@ -60,7 +60,7 @@ fn advance(bodies: []Body, dt: f64) void {
}

fn energy(bodies: []const Body) f64 {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
var e: f64 = 0.0;
for (bodies, 0..) |bi, i| {
e += 0.5 * length_sq(bi.vel) * bi.mass;
Expand Down
14 changes: 6 additions & 8 deletions bench/algorithm/pidigits/2.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import strconv
import math.big
import strings

const (
zero = big.integer_from_int(0)
one = big.integer_from_int(1)
two = big.integer_from_int(2)
three = big.integer_from_int(3)
four = big.integer_from_int(4)
ten = big.integer_from_int(10)
)
const zero = big.integer_from_int(0)
const one = big.integer_from_int(1)
const two = big.integer_from_int(2)
const three = big.integer_from_int(3)
const four = big.integer_from_int(4)
const ten = big.integer_from_int(10)

fn main() {
mut n := 27
Expand Down
2 changes: 1 addition & 1 deletion bench/algorithm/regex-redux/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
'agggta[cgt]a|t[acg]taccct',
'agggtaa[cgt]|[acg]ttaccct',
] {
println('${p} ${var_find(content, p)?}')
println('${p} ${var_find(content, p)!}')
}
for p, r in {
'tHa[Nt]': '<4>'
Expand Down
11 changes: 7 additions & 4 deletions bench/algorithm/spectral-norm/1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
// contributed by Ryohei Machida
// modified to single thread version by hanabi1224

#[macro_use]
extern crate generic_array;
#[macro_use]
extern crate numeric_array;

Expand Down Expand Up @@ -79,7 +77,7 @@ where
let ix4 = I32x4::splat(4 * i + k);

// column indices of A (equivarent to indices of v)
let mut jx4 = narr![i32; 0, 1, 2, 3];
let mut jx4 = narr![0, 1, 2, 3];
let mut sum = F64x4::default();

// Each slot in the pair gets its own sum, which is further computed in
Expand All @@ -102,7 +100,12 @@ fn inv_a(i: I32x4, j: I32x4) -> F64x4 {
let one = nconstant!(1);
let two = nconstant!(2);
let a_ij = (i + j) * (i + j + one) / two + i + one;
narr![f64; a_ij[0] as f64, a_ij[1] as f64, a_ij[2] as f64, a_ij[3] as f64]
narr![
a_ij[0] as f64,
a_ij[1] as f64,
a_ij[2] as f64,
a_ij[3] as f64
]
}

/// Vectorised form of inner product
Expand Down
10 changes: 5 additions & 5 deletions bench/algorithm/spectral-norm/2-m.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ fn runInParallel(tasks: []std.Thread, len: usize, comptime f: anytype, args: any
}

fn baseIdx(i: vec4) vec4 {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
return i * (i + vec1to4(1)) * vec1to4(0.5) + vec1to4(1);
}

fn multAvGeneric(comptime transpose: bool, first: usize, dst: []vec4, src: []const vec4) void {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
const srcVals = std.mem.bytesAsSlice(f64, std.mem.sliceAsBytes(src));
var ti = vec1to4(@as(f64, @floatFromInt(first * 4))) + if (transpose) vec4{ 1, 2, 3, 4 } else vec4{ 0, 1, 2, 3 };
for (dst) |*res| {
Expand Down Expand Up @@ -56,15 +56,15 @@ fn setOnes(first: usize, last: usize, dst: []vec4) void {
}

fn aggregateResults(first: usize, last: usize, u: []const vec4, v: []const vec4, total_vbv: *f64, total_vv: *f64) void {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
var vbv = vec1to4(0);
var vv = vec1to4(0);
for (v[first..last], 0..) |f, i| {
vbv += u[first + i] * f;
vv += f * f;
}
_ = @atomicRmw(f64, total_vbv, .Add, @reduce(.Add, vbv), .SeqCst);
_ = @atomicRmw(f64, total_vv, .Add, @reduce(.Add, vv), .SeqCst);
_ = @atomicRmw(f64, total_vbv, .Add, @reduce(.Add, vbv), .seq_cst);
_ = @atomicRmw(f64, total_vv, .Add, @reduce(.Add, vv), .seq_cst);
}

pub fn main() !void {
Expand Down
6 changes: 3 additions & 3 deletions bench/algorithm/spectral-norm/2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ fn vec1to4(f: f64) vec4 {
}

fn baseIdx(i: vec4) vec4 {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
return i * (i + vec1to4(1)) * vec1to4(0.5) + vec1to4(1);
}

fn multAvGeneric(comptime transpose: bool, dst: []vec4, src: []const vec4) void {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
const srcVals = std.mem.bytesAsSlice(f64, std.mem.sliceAsBytes(src));
var ti = if (transpose) vec4{ 1, 2, 3, 4 } else vec4{ 0, 1, 2, 3 };
for (dst) |*res| {
Expand Down Expand Up @@ -41,7 +41,7 @@ fn multAtAv(dest: []vec4, src: []const vec4, temp: []vec4) void {
}

fn aggregateResults(u: []const vec4, v: []const vec4) f64 {
@setFloatMode(.Optimized);
@setFloatMode(.optimized);
var vbv = vec1to4(0);
var vv = vec1to4(0);
for (v, 0..) |f, i| {
Expand Down
Loading
Loading