[all-commits] [llvm/llvm-project] d1923c: [AMDGPU][OpenMP] Support linking of math libraries

Jon Chesterfield via All-commits all-commits at lists.llvm.org
Mon Aug 23 11:21:46 PDT 2021


  Branch: refs/heads/release/13.x
  Home:   https://github.com/llvm/llvm-project
  Commit: d1923cb0aec257f5cd2ba5fc249a1932317e65d1
      https://github.com/llvm/llvm-project/commit/d1923cb0aec257f5cd2ba5fc249a1932317e65d1
  Author: Pushpinder Singh <Pushpinder.Singh at amd.com>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M clang/lib/Driver/ToolChains/AMDGPU.cpp
    M clang/lib/Driver/ToolChains/AMDGPU.h
    M clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
    M clang/lib/Driver/ToolChains/HIP.cpp
    M clang/test/Driver/amdgpu-openmp-toolchain.c

  Log Message:
  -----------
  [AMDGPU][OpenMP] Support linking of math libraries

Math libraries are linked only when -lm is specified. This is because
host system could be missing rocm-device-libs.

Reviewed By: JonChesterfield, yaxunl

Differential Revision: https://reviews.llvm.org/D105981

(cherry picked from commit 9830f902e4d087ecb1706912b730c046f20600ee)


  Commit: 512c57ea97aea710f95b1d23f497299d476f90b6
      https://github.com/llvm/llvm-project/commit/512c57ea97aea710f95b1d23f497299d476f90b6
  Author: Pushpinder Singh <Pushpinder.Singh at amd.com>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Headers/__clang_hip_cmath.h
    M clang/lib/Headers/__clang_hip_math.h
    M clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
    M clang/lib/Headers/openmp_wrappers/cmath
    M clang/lib/Headers/openmp_wrappers/math.h
    A clang/test/Headers/Inputs/include/algorithm
    M clang/test/Headers/Inputs/include/cstdlib
    A clang/test/Headers/Inputs/include/utility
    A clang/test/Headers/amdgcn_openmp_device_math.c
    M clang/test/Headers/openmp_device_math_isnan.cpp

  Log Message:
  -----------
  [OpenMP][AMDGCN] Initial math headers support

With this patch, OpenMP on AMDGCN will use the math functions
provided by ROCm ocml library. Linking device code to the ocml will be
done in the next patch.

Reviewed By: JonChesterfield, jdoerfert, scchan

Differential Revision: https://reviews.llvm.org/D104904

(cherry picked from commit 713a5d12cde58a5dff90cc3e2d1e67c2a78fe52f)


  Commit: 573858e9805e6e347cce66226f9706659e6fa42c
      https://github.com/llvm/llvm-project/commit/573858e9805e6e347cce66226f9706659e6fa42c
  Author: Pushpinder Singh <pushpinderdhaliwal00 at gmail.com>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
    M clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
    M clang/test/Driver/amdgpu-openmp-toolchain.c

  Log Message:
  -----------
  [AMDGPU][OpenMP] Use llvm-link to link ocml libraries

This fixes the 'unused linker option: -lm' warning when compiling
program with -c.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D107952

(cherry picked from commit 60e07a9568625a196f1ed8ed9e502c8c4d56da7f)


  Commit: 47bbdbecb039bc9117b0f6e16867014e7d12001b
      https://github.com/llvm/llvm-project/commit/47bbdbecb039bc9117b0f6e16867014e7d12001b
  Author: Pushpinder Singh <Pushpinder.Singh at amd.com>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h

  Log Message:
  -----------
  [AMDGPU][OpenMP] Wrap amdgcn declare variant inside ifdef

This fixes the issue https://bugs.llvm.org/show_bug.cgi?id=51337

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D107468

(cherry picked from commit f3eb5f900d2ae6c8e1c03d1b250415a7b7aa39b1)


  Commit: d6944303acfdfeae434e33ae6bb0b5b41362dc7f
      https://github.com/llvm/llvm-project/commit/d6944303acfdfeae434e33ae6bb0b5b41362dc7f
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M clang/lib/Headers/__clang_hip_math.h
    A clang/test/Headers/Inputs/include/omp.h

  Log Message:
  -----------
  [openmp] Annotate tmp variables with omp_thread_mem_alloc

Fixes miscompile of calls into ocml. Bug 51445.

The stack variable `double __tmp` is moved to dynamically allocated shared
memory by CGOpenMPRuntimeGPU. This is usually fine, but when the variable
is passed to a function that is explicitly annotated address_space(5) then
allocating the variable off-stack leads to a miscompile in the back end,
which cannot decide to move the variable back to the stack from shared.

This could be fixed by removing the AS(5) annotation from the math library
or by explicitly marking the variables as thread_mem_alloc. The cast to
AS(5) is still a no-op once IR is reached.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D107971

(cherry picked from commit dbd7bad9ad9bc32538e324417c23387bf4ac7747)


  Commit: 3020229e73ecf3050ed3064ea4c320ac199c00d1
      https://github.com/llvm/llvm-project/commit/3020229e73ecf3050ed3064ea4c320ac199c00d1
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M clang/lib/Headers/__clang_cuda_device_functions.h

  Log Message:
  -----------
  [clang] Replace asm with __asm__ in cuda header

Asm is a gnu extension for C, so at present -fopenmp -std=c99
and similar fail to compile on nvptx, bug 51344

Changing to `__asm__` or `__asm` works for openmp, all three appear to work
for cuda. Suggesting `__asm__` here as `__asm` is used by MSVC with different
syntax, so this should make for better error diagnostics if the header is
passed to a compiler other than clang.

Reviewed By: tra, emankov

Differential Revision: https://reviews.llvm.org/D107492

(cherry picked from commit 509854b69cea0c9261ac21ceb22012a53e7a800b)


  Commit: ab2d8f0749745663d1f029ee4c88fbc492bef00f
      https://github.com/llvm/llvm-project/commit/ab2d8f0749745663d1f029ee4c88fbc492bef00f
  Author: Joachim Protze <protze at itc.rwth-aachen.de>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt

  Log Message:
  -----------
  [libomptarget][amdcgn] Add build dependency for opt

This patch should fix the build we observe when building LLVM from scratch.

Differential Revision: https://reviews.llvm.org/D107156

(cherry picked from commit 4ffa1478fd1bbfdea9382786c0afc4e1303bbd06)


  Commit: 1f0b043ae709cca71fa26bc962bcd2eefb930b6f
      https://github.com/llvm/llvm-project/commit/1f0b043ae709cca71fa26bc962bcd2eefb930b6f
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2021-08-23 (Mon, 23 Aug 2021)

  Changed paths:
    M openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt

  Log Message:
  -----------
  [libomptarget] Apply D106710 to amdgcn devicertl

(cherry picked from commit f420939b82766e371695e54abca4a7fadda6f801)


Compare: https://github.com/llvm/llvm-project/compare/7f2f829479dc...1f0b043ae709


More information about the All-commits mailing list