Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
SWDEV-354050 - Helper function for HIP non hostcall printf
Browse files Browse the repository at this point in the history
Relates to https://reviews.llvm.org/D150427

Change-Id: Iccc991abcbdab957799f59b7015da18c05e49375
  • Loading branch information
vikramRH authored and searlmc1 committed Jun 9, 2023
1 parent e0bc015 commit 60d469f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ockl/src/cprintf.cl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 60d469f

Please sign in to comment.