-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
spirv: OpenCL printf support #24321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
spirv: OpenCL printf support #24321
Conversation
Currently, PoCL works, rusticl does not (nor llvmpipe, nor radeonsi), probably because of extra Currently, Details
I am not sure about the design (Zig formatting and |
I suggest you to not integrate it with |
3e47a71
to
6dd9d83
Compare
Rebased. |
0c054bd
to
bac5e1f
Compare
const result = switch (args.len) { | ||
// zig fmt: off | ||
0 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt)), | ||
1 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0])), | ||
2 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1])), | ||
3 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1]), [arg2] "" (args[2])), | ||
4 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1]), [arg2] "" (args[2]), [arg3] "" (args[3])), | ||
5 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1]), [arg2] "" (args[2]), [arg3] "" (args[3]), [arg4] "" (args[4])), | ||
6 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1]), [arg2] "" (args[2]), [arg3] "" (args[3]), [arg4] "" (args[4]), [arg5] "" (args[5])), | ||
7 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1]), [arg2] "" (args[2]), [arg3] "" (args[3]), [arg4] "" (args[4]), [arg5] "" (args[5]), [arg6] "" (args[6])), | ||
8 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1]), [arg2] "" (args[2]), [arg3] "" (args[3]), [arg4] "" (args[4]), [arg5] "" (args[5]), [arg6] "" (args[6]), [arg7] "" (args[7])), | ||
9 => asm volatile (expr : [ret] "" (-> u32), : [fmt] "c" (fmt), [arg0] "" (args[0]), [arg1] "" (args[1]), [arg2] "" (args[2]), [arg3] "" (args[3]), [arg4] "" (args[4]), [arg5] "" (args[5]), [arg6] "" (args[6]), [arg7] "" (args[7]), [arg8] "" (args[8])), | ||
// zig fmt: on | ||
else => @compileError("too many arguments"), | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#compiler > spirv printf discussing on how to replace this switch expression with comptime generated asm expression to allow as many arguments as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some edge cases like this one with constant mixed with a variable do not compile, i.e.:
var a: i32 = 10;
_ = &a;
_ = printf("%d %d\n", .{ 10, a });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few nitpicks that i can fix myself but otherwise LGTM. Hopefully we can switch to an std.format
version later
Tell me when you want to merge this. Expect no further changes from me. |
I want to have
std.debug.printf()
implemented for GPGPU, because it lowers entry point for newcomers, and this feature allows to catch bugs faster (like I had withsigned_integer - 0
).To test this PR you need to clone zig-spirv-test-executor in root dir and run: