aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/prefetch.zig
blob: 98dc72a9765472b148c13a568f69c44ca38c5da8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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 });
}