zig/test/behavior/prefetch.zig
2021-12-11 00:29:31 +01:00

28 lines
1.2 KiB
Zig

const std = @import("std");
test "@prefetch()" {
var a: u32 = 42;
@prefetch(&a, .{});
@prefetch(&a, .{ .rw = .read, .locality = 3, .cache = .data });
@prefetch(&a, .{ .rw = .read, .locality = 2, .cache = .data });
@prefetch(&a, .{ .rw = .read, .locality = 1, .cache = .data });
@prefetch(&a, .{ .rw = .read, .locality = 0, .cache = .data });
@prefetch(&a, .{ .rw = .write, .locality = 3, .cache = .data });
@prefetch(&a, .{ .rw = .write, .locality = 2, .cache = .data });
@prefetch(&a, .{ .rw = .write, .locality = 1, .cache = .data });
@prefetch(&a, .{ .rw = .write, .locality = 0, .cache = .data });
@prefetch(&a, .{ .rw = .read, .locality = 3, .cache = .instruction });
@prefetch(&a, .{ .rw = .read, .locality = 2, .cache = .instruction });
@prefetch(&a, .{ .rw = .read, .locality = 1, .cache = .instruction });
@prefetch(&a, .{ .rw = .read, .locality = 0, .cache = .instruction });
@prefetch(&a, .{ .rw = .write, .locality = 3, .cache = .instruction });
@prefetch(&a, .{ .rw = .write, .locality = 2, .cache = .instruction });
@prefetch(&a, .{ .rw = .write, .locality = 1, .cache = .instruction });
@prefetch(&a, .{ .rw = .write, .locality = 0, .cache = .instruction });
}