| author | |
| committer | |
| log | c919e9a2806aed62f8fe7cb23da4aa14808daea8 |
| tree | 53922621121f0798550b4a21f76658909d6c37b6 |
| parent | f09313dbc46ae9dc6165cbfb3d0b18760db55752 |
4 files changed, 8 insertions(+), 8 deletions(-)
lib/std/http/protocol.zig+1-1| ... | ... | @@ -82,7 +82,7 @@ pub const HeadersParser = struct { |
| 82 | 82 | /// If the amount returned is less than `bytes.len`, you may assume that the parser is in a content state and the |
| 83 | 83 | /// first byte of content is located at `bytes[result]`. |
| 84 | 84 | pub fn findHeadersEnd(r: *HeadersParser, bytes: []const u8) u32 { |
| 85 | const vector_len: comptime_int = comptime @max(std.simd.suggestVectorSize(u8) orelse 1, 8); | |
| 85 | const vector_len: comptime_int = @max(std.simd.suggestVectorSize(u8) orelse 1, 8); | |
| 86 | 86 | const len = @as(u32, @intCast(bytes.len)); |
| 87 | 87 | var index: u32 = 0; |
| 88 | 88 |
lib/std/mem.zig+4-4| ... | ... | @@ -974,7 +974,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co |
| 974 | 974 | // The below branch assumes that reading past the end of the buffer is valid, as long |
| 975 | 975 | // as we don't read into a new page. This should be the case for most architectures |
| 976 | 976 | // which use paged memory, however should be confirmed before adding a new arch below. |
| 977 | .aarch64, .x86, .x86_64 => if (comptime std.simd.suggestVectorSize(T)) |block_len| { | |
| 977 | .aarch64, .x86, .x86_64 => if (std.simd.suggestVectorSize(T)) |block_len| { | |
| 978 | 978 | comptime std.debug.assert(std.mem.page_size % block_len == 0); |
| 979 | 979 | const Block = @Vector(block_len, T); |
| 980 | 980 | const mask: Block = @splat(sentinel); |
| ... | ... | @@ -1027,7 +1027,7 @@ test "indexOfSentinel vector paths" { |
| 1027 | 1027 | const allocator = std.testing.allocator; |
| 1028 | 1028 | |
| 1029 | 1029 | inline for (Types) |T| { |
| 1030 | const block_len = comptime std.simd.suggestVectorSize(T) orelse continue; | |
| 1030 | const block_len = std.simd.suggestVectorSize(T) orelse continue; | |
| 1031 | 1031 | |
| 1032 | 1032 | // Allocate three pages so we guarantee a page-crossing address with a full page after |
| 1033 | 1033 | const memory = try allocator.alloc(T, 3 * std.mem.page_size / @sizeOf(T)); |
| ... | ... | @@ -1118,11 +1118,11 @@ pub fn indexOfScalarPos(comptime T: type, slice: []const T, start_index: usize, |
| 1118 | 1118 | !@inComptime() and |
| 1119 | 1119 | (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T))) |
| 1120 | 1120 | { |
| 1121 | if (comptime std.simd.suggestVectorSize(T)) |block_len| { | |
| 1121 | if (std.simd.suggestVectorSize(T)) |block_len| { | |
| 1122 | 1122 | // For Intel Nehalem (2009) and AMD Bulldozer (2012) or later, unaligned loads on aligned data result |
| 1123 | 1123 | // in the same execution as aligned loads. We ignore older arch's here and don't bother pre-aligning. |
| 1124 | 1124 | // |
| 1125 | // Use `comptime std.simd.suggestVectorSize(T)` to get the same alignment as used in this function | |
| 1125 | // Use `std.simd.suggestVectorSize(T)` to get the same alignment as used in this function | |
| 1126 | 1126 | // however this usually isn't necessary unless your arch has a performance penalty due to this. |
| 1127 | 1127 | // |
| 1128 | 1128 | // This may differ for other arch's. Arm for example costs a cycle when loading across a cache |
lib/std/simd.zig+2-2| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | const std = @import("std"); |
| 7 | 7 | const builtin = @import("builtin"); |
| 8 | 8 | |
| 9 | pub fn suggestVectorSizeForCpu(comptime T: type, comptime cpu: std.Target.Cpu) ?usize { | |
| 9 | pub fn suggestVectorSizeForCpu(comptime T: type, comptime cpu: std.Target.Cpu) ?comptime_int { | |
| 10 | 10 | // This is guesswork, if you have better suggestions can add it or edit the current here |
| 11 | 11 | // This can run in comptime only, but stage 1 fails at it, stage 2 can understand it |
| 12 | 12 | const element_bit_size = @max(8, std.math.ceilPowerOfTwo(u16, @bitSizeOf(T)) catch unreachable); |
| ... | ... | @@ -55,7 +55,7 @@ pub fn suggestVectorSizeForCpu(comptime T: type, comptime cpu: std.Target.Cpu) ? |
| 55 | 55 | |
| 56 | 56 | /// Suggests a target-dependant vector size for a given type, or null if scalars are recommended. |
| 57 | 57 | /// Not yet implemented for every CPU architecture. |
| 58 | pub fn suggestVectorSize(comptime T: type) ?usize { | |
| 58 | pub fn suggestVectorSize(comptime T: type) ?comptime_int { | |
| 59 | 59 | return suggestVectorSizeForCpu(T, builtin.cpu); |
| 60 | 60 | } |
| 61 | 61 |
lib/std/unicode.zig+1-1| ... | ... | @@ -200,7 +200,7 @@ pub fn utf8CountCodepoints(s: []const u8) !usize { |
| 200 | 200 | pub fn utf8ValidateSlice(input: []const u8) bool { |
| 201 | 201 | var remaining = input; |
| 202 | 202 | |
| 203 | const V_len = comptime std.simd.suggestVectorSize(usize) orelse 1; | |
| 203 | const V_len = std.simd.suggestVectorSize(usize) orelse 1; | |
| 204 | 204 | const V = @Vector(V_len, usize); |
| 205 | 205 | const u8s_in_vector = @sizeOf(usize) * V_len; |
| 206 | 206 |