Skip to content

[libclc] Move log1p/asinh/acosh/atanh to the CLC library #132956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 27, 2025

Conversation

frasercrmck
Copy link
Contributor

@frasercrmck frasercrmck commented Mar 25, 2025

These four functions all related in that they share tables and helper functions. Furthermore, the acosh and atanh builtins call log1p.

As with other work in this area, these builtins are now vectorized. To enable this, there are new table accessor functions which return a vector of table values using a vector of indices. These are internally scalarized, in the absence of gather operations. Some tables which were tables of multiple entries (e.g., double2) are split into two separate "low" and "high" tables. This might affect the performance of memory operations but are hopefully mitigated by better codegen overall.

These three functions all relatedin that they share tables and helper
functions. Furthermore, the acosh builtins calls log1p.

As with other work in this area, these builtins are now vectorized. To
enable this, there are new table accessor functions which return a
vector of table values using a vector of indices. These are internally
scalarized, in the absense of gather operations. Some tables which were
tables of multiple entries (e.g., double2) are split into two separate
"low" and "high" tables. This might affect the performance of memory
operations but are hopefully mitigated by better codegen overall.
@frasercrmck frasercrmck added the libclc libclc OpenCL library label Mar 25, 2025
@frasercrmck frasercrmck requested a review from arsenm March 25, 2025 17:08
@frasercrmck frasercrmck changed the title [libclc] Move log1p/asinh/acosh to the CLC library [libclc] Move log1p/asinh/acosh/atanh to the CLC library Mar 25, 2025
@frasercrmck frasercrmck merged commit db98e29 into llvm:main Mar 27, 2025
11 checks passed
@frasercrmck frasercrmck deleted the libclc-clc-log1p-asinh-acosh branch March 27, 2025 09:19
@mgorny
Copy link
Member

mgorny commented Mar 29, 2025

This change seems to have broken the test suite:

ctest -j 32 --test-load 32
Test project /var/tmp/portage/llvm-core/libclc-21.0.0.9999/work/libclc_build
    Start 1: external-calls-tahiti-amdgcn--.bc
    Start 2: external-calls-amdgcn--amdhsa.bc
    Start 3: external-calls-tahiti-amdgcn-mesa-mesa3d.bc
1/3 Test #1: external-calls-tahiti-amdgcn--.bc .............***Failed    2.67 sec
2/3 Test #3: external-calls-tahiti-amdgcn-mesa-mesa3d.bc ...***Failed    2.79 sec
3/3 Test #2: external-calls-amdgcn--amdhsa.bc ..............***Failed    2.95 sec

0% tests passed, 3 tests failed out of 3

Total Test time (real) =   2.96 sec

The following tests FAILED:
          1 - external-calls-tahiti-amdgcn--.bc (Failed)
          2 - external-calls-amdgcn--amdhsa.bc (Failed)
          3 - external-calls-tahiti-amdgcn-mesa-mesa3d.bc (Failed)
Errors while running CTest
Output from these tests are in: /var/tmp/portage/llvm-core/libclc-21.0.0.9999/work/libclc_build/Testing/Temporary/LastTest.log
Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely.

LastTest is pretty big:

Start testing: Mar 29 12:40 UTC
----------------------------------------------------------
1/3 Testing: external-calls-tahiti-amdgcn--.bc
1/3 Test: external-calls-tahiti-amdgcn--.bc
Command: "/var/tmp/portage/llvm-core/libclc-21.0.0.9999/work/libclc/check_external_calls.sh" "/var/tmp/portage/llvm-core/libclc-21.0.0.
9999/work/libclc_build/tahiti-amdgcn--.bc" "/usr/lib/llvm/21/bin"
Directory: /var/tmp/portage/llvm-core/libclc-21.0.0.9999/work/libclc
"external-calls-tahiti-amdgcn--.bc" start time: Mar 29 12:40 UTC
Output:
----------------------------------------------------------
ERROR: 918 unresolved calls detected in /var/tmp/portage/llvm-core/libclc-21.0.0.9999/work/libclc_build/tahiti-amdgcn--.bc
  %call39.i = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i) #25
  %call39.i86 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i85) #25
  %call39.i142 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i141) #25
  %call39.i257 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i256) #25
  %call39.i198 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i197) #25
  %call39.i286 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i285) #25
  %call39.i227 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i226) #25
  %call39.i171 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i170) #25
  %call39.i115 = tail call <2 x double> @__clc_ln_tbl(i64 noundef %conv38.i114) #25
[…]

LastTest.log

@frasercrmck
Copy link
Contributor Author

Thanks for the heads up, @mgorny - we really need this tested in PRs.

I've fixed forward in #133691.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libclc libclc OpenCL library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants