From 60d469fea1a270ad1b62e407b66faaae5d92a719 Mon Sep 17 00:00:00 2001 From: Vikram Date: Fri, 12 May 2023 00:55:00 -0400 Subject: [PATCH] SWDEV-354050 - Helper function for HIP non hostcall printf Relates to https://reviews.llvm.org/D150427 Change-Id: Iccc991abcbdab957799f59b7015da18c05e49375 --- ockl/src/cprintf.cl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ockl/src/cprintf.cl b/ockl/src/cprintf.cl index 6975bae..25ec5a4 100644 --- a/ockl/src/cprintf.cl +++ b/ockl/src/cprintf.cl @@ -41,6 +41,15 @@ __printf_alloc(uint bytes) return ptr + OFFSET + offset; } +// Return a controlDWord for nonhostcall printf scheme, format as follows +// Bit 0 (LSB) -> stream (1 if stderr, 0 if stdout) +// Bit 1 -> constant format string (1 if constant) +// Bit 2 - 31 -> size of printf data frame (controlDWord + format string/hash + args) + +uint __printf_control_dword(uint len, bool is_const_fmt_str, bool is_stderr) { + return (len << 2) | (is_const_fmt_str ? (uint)2 : 0) | (uint)is_stderr ; +} + // printf stub to resolve link time dependencies. // Will be replaced by the compiler. __attribute__((noinline))