mlir icon indicating copy to clipboard operation
mlir copied to clipboard

[ROCm] Adding pass to generate the HSACO binary blob from the GPU kernel function

Open deven-amd opened this issue 6 years ago • 2 comments

This is the first of four PRs to add support for the ROCm backend for AMD GPUs. This PR adds the pass to generate the HSA Code objects corresponding the GPU kernels. This PR builds on the work done by @whchung in PR #63

This PR is a follow-up to request in PR #169. It addresses all but two of the code-review comments made in that PR for the ConvertKernelFuncToHSACO.cpp file.

  1. https://github.com/tensorflow/mlir/pull/169#discussion_r332618425

Why are you wrapping the vector in a unique_ptr instead of just using vector by value?

There are a bunch of places where the code could be simplified, for instance:

   const char data[] = "HSACO";
   return std::make_unique<std::vector<char>>(data, data + sizeof(data) - 1);

would likely become:

  return "HSACO";

Two reasons for this.

  • The binary blob owned by this variable could potentially be large, and hence pass-by-pointer instead of pass-by-value (Note that the "HSACO" string is only returned in the "test" scenario)

  • Consistency with the CUDA side (where we OwnedCubin, which is also unique_ptr wrapper on a vector of chars)

  1. https://github.com/tensorflow/mlir/pull/169#discussion_r332617848

Do we have to go through files? Isn't lld usable as a library?

At least for the time being, it is easier to go through files. Dumping out the .ll file is helpful for debugging purposes, so that is something we would like to keep regardless. Also I am still trying to figure out how to invoke lld as an API call, within the mlir setup :(


@joker-eph @whchung

deven-amd avatar Oct 10 '19 17:10 deven-amd

@joker-eph , gentle ping

deven-amd avatar Oct 24 '19 13:10 deven-amd

@joker-eph , gentle ping

Sorry, I missed the update (and LLVM Dev Meeting happened). I'm catching up on everything and will get to it this week. Ping on Monday if you don't see an update!

joker-eph avatar Oct 24 '19 18:10 joker-eph