[AMDGPU] Non hostcall printf support for HIP
authorVikram <Vikram.Hegde@amd.com>
Thu, 11 May 2023 09:00:17 +0000 (05:00 -0400)
committerVikram <Vikram.Hegde@amd.com>
Sat, 10 Jun 2023 13:55:00 +0000 (09:55 -0400)
commit631c965483e03355cdc1dba578e787b259c4d79d
treeab33b4937c83fd63cf97d8c6d869759e07a8673f
parent55aeb23fe0084d930ecd7335092d712bd71694c7
[AMDGPU] Non hostcall printf support for HIP

This is an alternative to currently existing hostcall implementation and uses printf buffer similar to OpenCL,
The data stored in the buffer (i.e the data frame) for each printf call are as follows,
1. Control DWord - contains info regarding stream, format string constness and size of data frame
2. Hash of the format string (if constant) else the format string itself
3. Printf arguments (each aligned to 8 byte boundary)

The format string Hash is generated using LLVM's MD5 Message-Digest Algorithm implementation and only low 64 bits are used.
The implementation still uses amdhsa metadata and hash is stored as part of format string itself to ensure
minimal changes in runtime.

Differential Revision: https://reviews.llvm.org/D150427
13 files changed:
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/TargetOptions.h
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGGPUBuiltin.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGenHIP/default-attributes.hip
clang/test/CodeGenHIP/printf-kind-module-flag.hip [new file with mode: 0644]
clang/test/CodeGenHIP/printf_nonhostcall.cpp [new file with mode: 0644]
clang/test/CodeGenHIP/sanitize-undefined-null.hip
clang/test/Driver/hip-options.hip
llvm/include/llvm/Transforms/Utils/AMDGPUEmitPrintf.h
llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp