authorgravatar for gwenzek@users.noreply.github.comGuillaume Wenzek <gwenzek@users.noreply.github.com> 2022-10-04 07:31:36+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-15 10:39:19-07:00
logb425d887375132a915a5cd2baf7958f273732ee1
tree27109965e744c8e63dcb2bf6e8efb2af30309c42
parent577f0aa54b49445d4248cf839346ce3f8632ea39

re-enable nvptx tests


2 files changed, 37 insertions(+), 7 deletions(-)

test/cases.zig+1-2
......@@ -4,6 +4,5 @@ const TestContext = @import("../src/test.zig").TestContext;
44pub fn addCases(ctx: *TestContext) !void {
55 try @import("compile_errors.zig").addCases(ctx);
66 try @import("stage2/cbe.zig").addCases(ctx);
7 // https://github.com/ziglang/zig/issues/10968
8 //try @import("stage2/nvptx.zig").addCases(ctx);
7 try @import("stage2/nvptx.zig").addCases(ctx);
98}
test/stage2/nvptx.zig+36-5
......@@ -23,11 +23,10 @@ pub fn addCases(ctx: *TestContext) !void {
2323 var case = addPtx(ctx, "nvptx: read special registers");
2424
2525 case.compiles(
26 \\fn threadIdX() usize {
27 \\ var tid = asm volatile ("mov.u32 \t$0, %tid.x;"
28 \\ : [ret] "=r" (-> u32),
29 \\ );
30 \\ return @as(usize, tid);
26 \\fn threadIdX() u32 {
27 \\ return asm ("mov.u32 \t%[r], %tid.x;"
28 \\ : [r] "=r" (-> utid),
29 \\ );
3130 \\}
3231 \\
3332 \\pub export fn special_reg(a: []const i32, out: []i32) callconv(.PtxKernel) void {
......@@ -49,6 +48,38 @@ pub fn addCases(ctx: *TestContext) !void {
4948 \\}
5049 );
5150 }
51
52 {
53 var case = addPtx(ctx, "nvptx: reduce in shared mem");
54 case.compiles(
55 \\fn threadIdX() u32 {
56 \\ return asm ("mov.u32 \t%[r], %tid.x;"
57 \\ : [r] "=r" (-> utid),
58 \\ );
59 \\}
60 \\
61 \\ var _sdata: [1024]f32 addrspace(.shared) = undefined;
62 \\ pub export fn reduceSum(d_x: []const f32, out: *f32) callconv(ptx.Kernel) void {
63 \\ var sdata = @addrSpaceCast(.generic, &_sdata);
64 \\ const tid: u32 = threadIdX();
65 \\ var sum = d_x[tid];
66 \\ sdata[tid] = sum;
67 \\ asm volatile ("bar.sync \t0;");
68 \\ var s: u32 = 512;
69 \\ while (s > 0) : (s = s >> 1) {
70 \\ if (tid < s) {
71 \\ sum += sdata[tid + s];
72 \\ sdata[tid] = sum;
73 \\ }
74 \\ asm volatile ("bar.sync \t0;");
75 \\ }
76 \\
77 \\ if (tid == 0) {
78 \\ out.* = sum;
79 \\ }
80 \\ }
81 );
82 }
5283}
5384
5485const nvptx_target = std.zig.CrossTarget{