summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-10-29 07:15:02 +1000
committerDave Airlie <airlied@redhat.com>2020-12-29 09:07:23 +1000
commit95527fe22926af9e2d7cbcffe23216ab2837cd85 (patch)
treea8cb1e5d58119209b2055ce8450c9670a9d3abb9
parent77b70fa35d4802af06c40ba82af8976e2938c5b0 (diff)
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 <currojerez@riseup.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8254>
-rw-r--r--src/gallium/frontends/clover/core/module.cpp13
-rw-r--r--src/gallium/frontends/clover/core/module.hpp8
2 files changed, 21 insertions, 0 deletions
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<module::printf_info> {
+ template<typename S, typename QT>
+ static void
+ proc(S & s, QT &x) {
+ _proc(s, x.arg_sizes);
+ _proc(s, x.strings);
+ }
+ };
+
/// (De)serialize a module::section.
template<>
struct _serializer<module::section> {
@@ -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<char> data;
};
+ struct printf_info {
+ std::vector<uint32_t> arg_sizes;
+ std::vector<uint8_t> 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<symbol> syms;
std::vector<section> secs;
+ std::vector<printf_info> printf_infos;
+ // printfs strings stored in output buffer
+ uint32_t printf_strings_in_buffer;
};
}