Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const std = @import("std");
- var allocator = std.heap.page_allocator;
- const N = 1000; // number of [M]T
- const M = 10000; // length of each vector.
- pub fn main() !void {
- var vec_of_vecs = std.ArrayList([]u32).init(allocator);
- defer vec_of_vecs.deinit();
- try vec_of_vecs.ensureCapacity(@intCast(u32, N+3)) ;
- var j: u32 = 0;
- while (j<N) : (j+=1) {
- var inner_buf = try allocator.alloc(u32, M);
- // This line is more or less the entire runtime length of the program.
- // But getting rid of the cast or writing a while loop doesn't change
- // anything. Does this code fail to vectorize when zig cc succeeds or
- // something?
- for (inner_buf) |_, index| inner_buf[index] = @intCast(u32, index);
- vec_of_vecs.appendAssumeCapacity(inner_buf);
- }
- for (vec_of_vecs.items) |inner_buf| {
- allocator.free(inner_buf);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement