[PATCH] D139045: [HIP] use detected GPU in --offload-arch

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 13:49:38 PST 2022


tra added a comment.

In D139045#3962354 <https://reviews.llvm.org/D139045#3962354>, @yaxunl wrote:

> I understand your point. However, when users use gcc or clang and do not specify target or CPU, the compiled program will execute on their system. 
> This is because gcc or clang has a default target and CPU that works for the system. 
> This is not the case for HIP since the default gfx803 will not work for the system unless the system happens to have a gfx803. 
> To let the users have a similar experience with the default target/CPU as gcc/clang, HIP needs to assume the system GPU as the default. Users could specify --offload-arch explicitly if they want to compile for certain GPU's.

This is not a new problem. I had the same problem with the choice of defaults for CUDA compilation and came to the conclusion that there's no such thing for GPUs and that the best we can do is to pick the most 'conservative' target. It may have worked for CUDA as PTX for an old GPU could in theory be JIT-compiled if the executable ran on a newer GPU, but the user is generally expected to specify the architectures they want to target. The default is, essentially, equally bad for everyone who happens to use it. In that sense `gfx803` or any other architecture would do that job just fine.

The auto-detection assumes that the host where the build is done is also the target the executable is going to run on. This is not true in many cases. 
I'd go as far as to say that in absolute terms most builds for GPUs out there are done on the machines without GPUs. 
Given the lack of a universally sensible default, I would prefer to require the user to explicitly specify the targets they want, with `auto/native` as an option.

On the other hand, OpenMP already appears to do some automagic detection of GPUs, so perhaps it is useful enough to do for HIP, too.

In any case, I think this is something that may need a wider forum.  Ask on LLVM discourse?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139045/new/

https://reviews.llvm.org/D139045



More information about the cfe-commits mailing list