| 1 | const builtin = @import("builtin"); |
| 2 | const std = @import("std"); |
| 3 | |
| 4 | test "@prefetch()" { |
| 5 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 6 | |
| 7 | var a: [2]u32 = .{ 42, 42 }; |
| 8 | var a_len = a.len; |
| 9 | _ = &a_len; |
| 10 | |
| 11 | @prefetch(&a, .{}); |
| 12 | |
| 13 | @prefetch(&a[0], .{ .rw = .read, .locality = 3, .cache = .data }); |
| 14 | @prefetch(&a, .{ .rw = .read, .locality = 2, .cache = .data }); |
| 15 | @prefetch(a[0..].ptr, .{ .rw = .read, .locality = 1, .cache = .data }); |
| 16 | @prefetch(a[0..a_len], .{ .rw = .read, .locality = 0, .cache = .data }); |
| 17 | |
| 18 | @prefetch(&a[0], .{ .rw = .write, .locality = 3, .cache = .data }); |
| 19 | @prefetch(&a, .{ .rw = .write, .locality = 2, .cache = .data }); |
| 20 | @prefetch(a[0..].ptr, .{ .rw = .write, .locality = 1, .cache = .data }); |
| 21 | @prefetch(a[0..a_len], .{ .rw = .write, .locality = 0, .cache = .data }); |
| 22 | |
| 23 | @prefetch(&a[0], .{ .rw = .read, .locality = 3, .cache = .instruction }); |
| 24 | @prefetch(&a, .{ .rw = .read, .locality = 2, .cache = .instruction }); |
| 25 | @prefetch(a[0..].ptr, .{ .rw = .read, .locality = 1, .cache = .instruction }); |
| 26 | @prefetch(a[0..a_len], .{ .rw = .read, .locality = 0, .cache = .instruction }); |
| 27 | |
| 28 | @prefetch(&a[0], .{ .rw = .write, .locality = 3, .cache = .instruction }); |
| 29 | @prefetch(&a, .{ .rw = .write, .locality = 2, .cache = .instruction }); |
| 30 | @prefetch(a[0..].ptr, .{ .rw = .write, .locality = 1, .cache = .instruction }); |
| 31 | @prefetch(a[0..a_len], .{ .rw = .write, .locality = 0, .cache = .instruction }); |
| 32 | } |