Author Topic: AMD OpenCL / ROCm  (Read 217 times)

chatcannon

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
    • View Profile
AMD OpenCL / ROCm
« on: October 22, 2021, 01:35:41 pm »
I'm trying to get OpenCL working on a recent AMD graphics card (Navi 14 chipset). I have tried downloading and compiling the Radeon Open Compute (ROCm) framework from https://github.com/RadeonOpenCompute .

There are a number of hardcoded -D__x86_64__ declarations in the CMakeLists.txt. After clearing those out there are maybe five or six places where functions include a couple of lines of x86 assembly, doing things that ought to be equally possible on POWER9.

Does anyone know of any existing efforts to port ROCm or another OpenCL runtime to POWER9?

Failing that, can someone suggest a good place to learn the basics of POWER9 assembly (whatever dialect is used by GCC)?

ClassicHasClass

  • Full Member
  • ***
  • Posts: 237
  • Karma: +16/-0
  • Talospace Earth Orbit
    • View Profile
    • Floodgap
Re: AMD OpenCL / ROCm
« Reply #1 on: October 22, 2021, 07:58:15 pm »
Can you post a couple links to the specific places in the source you're looking at?

Modern OpenPOWER is a superset of PowerPC, so any 64-bit PowerPC instruction reference will broadly apply. POWER9 is compliant to ISA 3.0. https://openpowerfoundation.org/?resource_lib=power-isa-version-3-0

chatcannon

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
    • View Profile
Re: AMD OpenCL / ROCm
« Reply #2 on: October 24, 2021, 09:49:19 am »
There are several short assembly snippets in "os_posix.cpp", one example is https://github.com/ROCm-Developer-Tools/ROCclr/blob/df870b565cf7f7d6d5fc8dd66aa07cd868874f9b/os/os_posix.cpp#L694

Another assembly snippet is https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/blob/12d926d06d36fe74876a82f8f8e1ce8ce7902728/amdocl/glibc_functions.cpp#L30 which seems to be requiring the memcpy ABI from a particular version of Glibc, with no explanation as to why that particular ABI is needed.

ClassicHasClass

  • Full Member
  • ***
  • Posts: 237
  • Karma: +16/-0
  • Talospace Earth Orbit
    • View Profile
    • Floodgap
Re: AMD OpenCL / ROCm
« Reply #3 on: October 24, 2021, 06:18:33 pm »
The first one you may not actually need. Note that the ARM version is in fact unimplemented. The return address is always in the link register in ABI-compliant code for both ARM and Power, but in x86(_64) it's on the stack. Similarly, Os::cpuid and Os::xgetbv seem only to compile on x86_64, not ARM. I'd just make sure your logic follows ARM (and have appropriate assertions to enforce this for unimplemented functions).

The memcpy situation is actually because the semantics changed between glibc versions. Here's an explanation: https://stackoverflow.com/questions/35656696/explanation-of-memcpy-memmove-glibc-2-14-2-2-5#35678441
« Last Edit: October 24, 2021, 06:20:14 pm by ClassicHasClass »

chatcannon

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
    • View Profile
Re: AMD OpenCL / ROCm
« Reply #4 on: October 24, 2021, 11:25:33 pm »
Thanks for the tips. While following the link you gave about memcpy I found this comment: https://stackoverflow.com/questions/8823267/linking-against-older-symbol-version-in-a-so-file?rq=1#comment100378482_8862631

Quote
This doesn't work if you're compiling on an architecture that wasn't built back in 2002 when x86-64 was first added - you'll get an error that the requested versioned symbols are not available.

I guess ppc64le didn't exist in 2002 so the 2.2.5 symbol version does not exist.

I will try omitting the .symver assembly and see how it behaves - if everything is being built from source then maybe it will be OK. If that doesn't work then I guess I can try adding a source file with an implementation of a simple non-IFUNC memcpy so that the ROCm library will use that instead of the glibc one.

MPC7500

  • Sr. Member
  • ****
  • Posts: 346
  • Karma: +20/-1
    • View Profile
    • Twitter
Re: AMD OpenCL / ROCm
« Reply #5 on: October 28, 2021, 04:17:03 pm »

chatcannon

  • Newbie
  • *
  • Posts: 6
  • Karma: +1/-0
    • View Profile
Re: AMD OpenCL / ROCm
« Reply #6 on: October 29, 2021, 12:04:27 am »
I assume this is already outdated?
https://wiki.nikhef.nl/grid/AMD_GPU_on_IBM_POWER

Also I found this:
https://www.phoronix.com/scan.php?page=news_item&px=AMD-AOMP-On-POWER

Both those links refer to the AOMP compiler. I don't remember if I specifically tried AOMP, but my experience was that compilers like "llvm-roc" would build without any problems - the issues with x86 assembly or intrinsics are all in the "runtime" parts.

Once I have a full development environment set up to my liking then I will look into this in more detail.