From 95527fe22926af9e2d7cbcffe23216ab2837cd85 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 29 Oct 2020 07:15:02 +1000 Subject: clover/module: add a printf support to module (v5) This adds storage for printf formats encoded as number of argument sizes + the printf format string, and storage for sideband printf strings if the backend wants them. It adds a flag that decides if the backend wants AMD (LLVM) behaviour or NIR wrt the format of the global buffer and how to decode strings. Based on work by EdB in his printf support, but made useful to be generic. I'm not a huge fan of the buffer format flag, but this was the easiest way to denote the llvm abi buffer format. v3: rename buffer fmt v4: use a single strings storage and one struct v5: move printf_info into module, cleanup serialisation struct Reviewed-by: Francisco Jerez Part-of: --- src/gallium/frontends/clover/core/module.cpp | 13 +++++++++++++ src/gallium/frontends/clover/core/module.hpp | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/src/gallium/frontends/clover/core/module.cpp b/src/gallium/frontends/clover/core/module.cpp index b9510168558..0071ebef8e3 100644 --- a/src/gallium/frontends/clover/core/module.cpp +++ b/src/gallium/frontends/clover/core/module.cpp @@ -155,6 +155,17 @@ namespace { } }; + /// (De)serialize a printf format + template<> + struct _serializer { + template + static void + proc(S & s, QT &x) { + _proc(s, x.arg_sizes); + _proc(s, x.strings); + } + }; + /// (De)serialize a module::section. template<> struct _serializer { @@ -206,6 +217,8 @@ namespace { proc(S &s, QT &x) { _proc(s, x.syms); _proc(s, x.secs); + _proc(s, x.printf_infos); + _proc(s, x.printf_strings_in_buffer); } }; }; diff --git a/src/gallium/frontends/clover/core/module.hpp b/src/gallium/frontends/clover/core/module.hpp index 92c090f70d7..01694b83222 100644 --- a/src/gallium/frontends/clover/core/module.hpp +++ b/src/gallium/frontends/clover/core/module.hpp @@ -55,6 +55,11 @@ namespace clover { std::vector data; }; + struct printf_info { + std::vector arg_sizes; + std::vector strings; + }; + struct arg_info { arg_info(const std::string &arg_name, const std::string &type_name, const cl_kernel_arg_type_qualifier type_qualifier, @@ -153,6 +158,9 @@ namespace clover { std::vector syms; std::vector
secs; + std::vector printf_infos; + // printfs strings stored in output buffer + uint32_t printf_strings_in_buffer; }; } -- cgit v1.2.3