Skip to content

Commit

Permalink
fix: ci build
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Jul 12, 2023
1 parent 8f8a9f7 commit d70acc7
Show file tree
Hide file tree
Showing 25 changed files with 90 additions and 102 deletions.
18 changes: 9 additions & 9 deletions .github/dart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ sudo ln -sf $PWD/dart-sdk/bin/dart /usr/local/bin/dart
popd

# dart3
mkdir dart3sdk
pushd dart3sdk
wget https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-linux-x64-release.zip -O dartsdk.zip
unzip -o dartsdk.zip
sudo ln -sf $PWD/dart-sdk/bin/dart /usr/local/bin/dart3
popd
popd
dart --version
dart3 --version
# mkdir dart3sdk
# pushd dart3sdk
# wget https://storage.googleapis.com/dart-archive/channels/dev/release/latest/sdk/dartsdk-linux-x64-release.zip -O dartsdk.zip
# unzip -o dartsdk.zip
# sudo ln -sf $PWD/dart-sdk/bin/dart /usr/local/bin/dart3
# popd
# popd
# dart --version
# dart3 --version
2 changes: 1 addition & 1 deletion .github/odin.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/sh

VERSION=dev-2023-04
VERSION=dev-2023-05
FILE_NAME=odin-ubuntu-amd64-$VERSION.zip
sudo apt-get install -y aria2
mkdir /tmp/odin
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: bench
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
merge_group:
schedule:
- cron: "0 0 1 * *"
env:
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/cancel-stale.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/site.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: site

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
# push:
# branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
merge_group:
jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions bench/algorithm/binarytrees/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const global_allocator = std.heap.c_allocator;
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
const n = try get_n();
const max_depth = math.max(MIN_DEPTH + 2, n);
const max_depth = @max(MIN_DEPTH + 2, n);
{
const stretch_depth = max_depth + 1;
const stretch_tree = Node.make(stretch_depth, global_allocator).?;
Expand All @@ -21,7 +21,7 @@ pub fn main() !void {

var depth: usize = MIN_DEPTH;
while (depth <= max_depth) : (depth += 2) {
const iterations = @intCast(usize, 1) << @intCast(u6, max_depth - depth + MIN_DEPTH);
const iterations = @as(usize, 1) << @as(u6, @intCast(max_depth - depth + MIN_DEPTH));
var sum: usize = 0;
var i: usize = 0;
while (i < iterations) : (i += 1) {
Expand Down
8 changes: 4 additions & 4 deletions bench/algorithm/edigits/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ pub fn main() !void {
defer a.deinit();
var ten = try bigint.Managed.initSet(global_allocator, 10);
defer ten.deinit();
try bigint.Managed.pow(&a, &ten, @bitCast(u32, n - 1));
try bigint.Managed.pow(&a, &ten, @as(u32, @bitCast(n - 1)));
var tmp = try bigint.Managed.init(global_allocator);
defer tmp.deinit();
try bigint.Managed.mul(&tmp, &answer, &a);
try bigint.Managed.divFloor(&answer, &a, &tmp, &q);
var str = try answer.toString(global_allocator, 10, std.fmt.Case.lower);
var i: usize = 0;
var n_usize = @as(usize, @bitCast(u32, n));
var n_usize = @as(usize, @as(u32, @bitCast(n)));
while (i < n_usize) {
var sb = [10:0]u8{ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
var j: usize = i;
Expand Down Expand Up @@ -99,8 +99,8 @@ fn test_k(n: i32, k: i32) bool {
if (k < 0) {
return false;
}
var float_k = @intToFloat(f64, k);
var float_n = @intToFloat(f64, n);
var float_k: f64 = @floatFromInt(k);
var float_n: f64 = @floatFromInt(n);
var ln_k_factorial = float_k * (math.ln(float_k) - 1.0) + 0.5 * math.ln(math.tau);
var log_10_k_factorial = ln_k_factorial / math.ln10;
return log_10_k_factorial >= float_n + 50.0;
Expand Down
6 changes: 3 additions & 3 deletions bench/algorithm/fannkuch-redux/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ pub fn main() !void {
flips_count += 1;
}

max_flips_count = std.math.max(max_flips_count, flips_count);
max_flips_count = @max(max_flips_count, flips_count);
if (perm_count % 2 == 0) {
checksum += @intCast(isize, flips_count);
checksum += @intCast(flips_count);
} else {
checksum -= @intCast(isize, flips_count);
checksum -= @intCast(flips_count);
}

while (true) : (r += 1) {
Expand Down
14 changes: 7 additions & 7 deletions bench/algorithm/fannkuch-redux/2-m.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const std = @import("std");

const max_n = 12;
const Vec = std.meta.Vector(max_n, u8);
const Vec = @Vector(max_n, u8);

fn runInParallel(tasks: []std.Thread, len: usize, comptime f: anytype, args: anytype) !void {
const len_per_task = @divTrunc(len, tasks.len + 1);
Expand Down Expand Up @@ -73,7 +73,7 @@ fn countAtPos(n: u8, start: usize) [max_n]u8 {
while (i > 0) {
i -= 1;
const total_perms = factorialComptime(i);
count[i] = i + 1 - @intCast(u8, r / total_perms);
count[i] = i + 1 - @as(u8, @intCast(r / total_perms));
r %= total_perms;
}
return count;
Expand All @@ -94,11 +94,11 @@ const Stats = struct {

fn nextPermutation(perm: Vec, count: []u8) ?Vec {
const r = for (count, 0..) |v, i| {
if (v != 1) break @intCast(u8, i);
if (v != 1) break @as(u8, @intCast(i));
} else return null;
const next_perm = applyMask(perm, r + 1, nextPermMask);
count[r] -= 1;
for (count[0..r], 0..) |*v, i| v.* = @intCast(u8, i + 1);
for (count[0..r], 0..) |*v, i| v.* = @intCast(i + 1);
return next_perm;
}

Expand All @@ -109,9 +109,9 @@ fn pfannkuchenStats(first: usize, last: usize, n: u8, res: *Stats) void {
var i = first;
while (i < last) : (i += 1) {
const flips = pfannkuchen(perm);
const parity = 1 - @intCast(i32, i % 2) * 2;
stats.max_flips = std.math.max(stats.max_flips, flips);
stats.checksum += @intCast(i32, flips) * parity;
const parity = 1 - @as(i32, @intCast(i % 2)) * 2;
stats.max_flips = @max(stats.max_flips, flips);
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);
Expand Down
10 changes: 5 additions & 5 deletions bench/algorithm/fannkuch-redux/2.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");

const Vec = std.meta.Vector(16, u8);
const Vec = @Vector(16, u8);

fn reverse_mask(n: u8) Vec {
// global constant is not used to workaround a compiler bug
Expand Down Expand Up @@ -52,14 +52,14 @@ pub fn main() !void {
var parity: u1 = 0;
while (true) : (parity +%= 1) {
const flip_count = pfannkuchen(perm);
max_flip_count = std.math.max(max_flip_count, flip_count);
checksum += @intCast(i32, flip_count) * (1 - @intCast(i32, parity) * 2);
max_flip_count = @max(max_flip_count, flip_count);
checksum += @as(i32, @intCast(flip_count)) * (1 - @as(i32, @intCast(parity)) * 2);
const r = for (count[0..n], 0..) |v, i| {
if (v != 1) break @intCast(u8, i);
if (v != 1) break @as(u8, @intCast(i));
} else break;
perm = apply_mask(perm, r + 1, next_perm_mask);
count[r] -= 1;
for (count[1..r], 0..) |*v, i| v.* = @intCast(u8, i + 2);
for (count[1..r], 0..) |*v, i| v.* = @intCast(i + 2);
}

const stdout = std.io.getStdOut().writer();
Expand Down
10 changes: 5 additions & 5 deletions bench/algorithm/fannkuch-redux/3-i.zig
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ inline fn reverse_array(array: u128, n: u4) u128 {
0x0F_00_01_02_03_04_05_06_07_08_09_0A_0B_0C_0D_0E,
0x00_01_02_03_04_05_06_07_08_09_0A_0B_0C_0D_0E_0F,
};
return @bitCast(u128, shuffle_epi8(@bitCast(u8x16, array), @bitCast(u8x16, MASK[n])));
return @bitCast(shuffle_epi8(@bitCast(array), @bitCast(MASK[n])));
}

inline fn rotate_array(array: u128, n: u4) u128 {
Expand All @@ -97,7 +97,7 @@ inline fn rotate_array(array: u128, n: u4) u128 {
0x0F_00_0E_0D_0C_0B_0A_09_08_07_06_05_04_03_02_01,
0x00_0F_0E_0D_0C_0B_0A_09_08_07_06_05_04_03_02_01,
};
return @bitCast(u128, shuffle_epi8(@bitCast(u8x16, array), @bitCast(u8x16, MASK[n])));
return @bitCast(shuffle_epi8(@bitCast(array), @bitCast(MASK[n])));
}

inline fn advance_array(_array: u128, count: *[16]u8) u128 {
Expand Down Expand Up @@ -156,11 +156,11 @@ fn fannkuchRedux(n: u4) [2]i32 {
while (count2[n - 2] == rotate_count2) {
var tmp = current2;
var rev_count: i32 = 0;
var first = @bitCast(u8x16, tmp)[0];
var first = @as(u8x16, @bitCast(tmp))[0];
if (first > 0) {
while (first > 0) {
const next = @bitCast(u8x16, tmp)[first];
tmp = reverse_array(tmp, @truncate(u4, first));
const next = @as(u8x16, @bitCast(tmp))[first];
tmp = reverse_array(tmp, @as(u4, @truncate(first)));
first = next;
rev_count += 1;
}
Expand Down
6 changes: 3 additions & 3 deletions bench/algorithm/fasta/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ic = 29573;
var seed: u32 = 42;
fn nextRandom(max: f64) f64 {
seed = (seed * ia + ic) % im;
return max * @intToFloat(f64, seed) / @intToFloat(f64, im);
return max * @as(f64, @floatFromInt(seed)) / @as(f64, @floatFromInt(im));
}

const AminoAcid = struct {
Expand All @@ -28,7 +28,7 @@ fn repeatAndWrap(out: anytype, comptime sequence: []const u8, count: usize) void
var idx: usize = 0;
while (idx < count) {
const rem = count - idx;
const line_length = std.math.min(@as(usize, max_line_length), rem);
const line_length = @min(@as(usize, max_line_length), rem);

_ = out.write(padded_sequence[off .. off + line_length]) catch unreachable;
_ = out.writeByte('\n') catch unreachable;
Expand All @@ -55,7 +55,7 @@ fn generateAndWrap(out: anytype, comptime nucleotides: []const AminoAcid, count:
var idx: usize = 0;
while (idx < count) {
const rem = count - idx;
const line_length = std.math.min(@as(usize, max_line_length), rem);
const line_length = @min(@as(usize, max_line_length), rem);

for (line[0..line_length]) |*col| {
const r = nextRandom(im);
Expand Down
17 changes: 6 additions & 11 deletions bench/algorithm/json-serde/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,21 @@ pub fn main() !void {
const json_str = try file.readToEndAlloc(global_allocator, std.math.maxInt(u32));
defer global_allocator.free(json_str);
{
var tokens = json.TokenStream.init(json_str);
const data = try json.parse(GeoData, &tokens, .{ .allocator = global_allocator });
defer json.parseFree(GeoData, data, .{ .allocator = global_allocator });
const parsed = try json.parseFromSlice(GeoData, global_allocator, json_str, .{});
defer parsed.deinit();
const data = parsed.value;
var json_str_des = std.ArrayList(u8).init(global_allocator);
defer json_str_des.deinit();
try json.stringify(data, .{}, json_str_des.writer());
try printHash(json_str_des.items, stdout);
}
{
var array = std.ArrayList(GeoData).init(global_allocator);
defer {
for (array.items) |data|
json.parseFree(GeoData, data, .{ .allocator = global_allocator });
array.deinit();
}
var i: usize = 0;
while (i < n) : (i += 1) {
var tokens = json.TokenStream.init(json_str);
const data = try json.parse(GeoData, &tokens, .{ .allocator = global_allocator });
try array.append(data);
const parsed = try json.parseFromSlice(GeoData, global_allocator, json_str, .{});
// defer parsed.deinit();
try array.append(parsed.value);
}
var json_str_des = std.ArrayList(u8).init(global_allocator);
defer json_str_des.deinit();
Expand Down
8 changes: 4 additions & 4 deletions bench/algorithm/knucleotide/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Code = struct {
}

pub inline fn makeMask(frame: usize) u64 {
return (@as(u64, 1) << @intCast(u6, (2 * frame))) - 1;
return (@as(u64, 1) << @as(u6, @intCast(2 * frame))) - 1;
}

pub inline fn push(self: *Code, c: u8, mask: u64) void {
Expand All @@ -32,7 +32,7 @@ const Code = struct {
var code = self.data;
var i: usize = 0;
while (i < frame) : (i += 1) {
const c: u8 = switch (@truncate(u8, code) & 0b11) {
const c: u8 = switch (@as(u8, @truncate(code)) & 0b11) {
Code.encodeByte('A') => 'A',
Code.encodeByte('T') => 'T',
Code.encodeByte('G') => 'G',
Expand Down Expand Up @@ -141,13 +141,13 @@ fn printMap(self: usize, map: Map) !void {
try v.append(.{ .count = count, .code = it.key_ptr.* });
}

std.sort.sort(CountCode, v.items, {}, comptime CountCode.asc);
std.mem.sort(CountCode, v.items, {}, comptime CountCode.asc);
var i = v.items.len - 1;
while (true) : (i -= 1) {
const cc = v.items[i];
try stdout.print("{!s} {d:.3}\n", .{
cc.code.toString(self),
@intToFloat(f32, cc.count) / @intToFloat(f32, total) * 100.0,
@as(f32, @floatFromInt(cc.count)) / @as(f32, @floatFromInt(total)) * 100.0,
});
if (i == 0) break;
}
Expand Down
10 changes: 5 additions & 5 deletions bench/algorithm/mandelbrot/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ const ArrayList = std.ArrayList;
const md5 = std.crypto.hash.Md5;

const VEC_SIZE = 8;
const Vec = std.meta.Vector(VEC_SIZE, f64);
const Vec = @Vector(VEC_SIZE, f64);

const global_allocator = std.heap.c_allocator;

pub fn main() !void {
const n = try get_n();
const size = (n + VEC_SIZE - 1) / VEC_SIZE * VEC_SIZE;
const chunk_size = size / VEC_SIZE;
const inv = 2.0 / @intToFloat(f64, size);
const inv = 2.0 / @as(f64, @floatFromInt(size));
var xloc = ArrayList(Vec).init(global_allocator);
try xloc.ensureTotalCapacityPrecise(chunk_size);
var i: usize = 0;
Expand All @@ -37,7 +37,7 @@ pub fn main() !void {
try pixels.ensureTotalCapacityPrecise(size * chunk_size);
var y: usize = 0;
while (y < size) : (y += 1) {
const ci = @intToFloat(f64, y) * inv - 1.0;
const ci = @as(f64, @floatFromInt(y)) * inv - 1.0;
var x: usize = 0;
while (x < chunk_size) : (x += 1) {
const r = mbrot8(xloc.items[x], ci);
Expand Down Expand Up @@ -87,14 +87,14 @@ fn mbrot8(cr: Vec, civ: f64) u8 {
while (i < VEC_SIZE) : (i += 1) {
if (absz[i] <= 4.0) {
const lhs: u8 = 0x80;
accu |= (lhs >> @intCast(u3, i));
accu |= (lhs >> @as(u3, @intCast(i)));
}
}
return accu;
}

fn init_xloc(i: usize, inv: f64) f64 {
return @intToFloat(f64, i) * inv - 1.5;
return @as(f64, @floatFromInt(i)) * inv - 1.5;
}

fn get_n() !usize {
Expand Down
4 changes: 2 additions & 2 deletions bench/algorithm/merkletrees/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const global_allocator = std.heap.c_allocator;
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
const n = try get_n();
const max_depth = math.max(MIN_DEPTH + 2, n);
const max_depth = @max(MIN_DEPTH + 2, n);
{
const stretch_depth = max_depth + 1;
const stretch_tree = Node.make(stretch_depth, global_allocator).?;
Expand All @@ -22,7 +22,7 @@ pub fn main() !void {

var depth: usize = MIN_DEPTH;
while (depth <= max_depth) : (depth += 2) {
const iterations = @intCast(usize, 1) << @intCast(u6, max_depth - depth + MIN_DEPTH);
const iterations = @as(usize, 1) << @as(u6, @intCast(max_depth - depth + MIN_DEPTH));
var sum: i64 = 0;
var i: usize = 0;
while (i < iterations) : (i += 1) {
Expand Down
Loading

0 comments on commit d70acc7

Please sign in to comment.