Skip to content

Move known_callables from ASTBuilderBase to TargetBase (split into host/device variants)#989

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/move-known-callables-to-targetbase
Draft

Move known_callables from ASTBuilderBase to TargetBase (split into host/device variants)#989
Copilot wants to merge 4 commits intomainfrom
copilot/move-known-callables-to-targetbase

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

  • Add known_callables property to TargetBase returning {}
  • Update ASTBuilderBase.known_callables to delegate to self.target.known_device_callables
  • Add known_callables override to DummyHostASTBuilder delegating to self.target.known_host_callables
  • Add known_callables override to PythonASTBuilderBase delegating to self.target.known_host_callables
  • Move CFamilyASTBuilder.known_callablesCFamilyTarget.known_device_callables
  • Move CUDACASTBuilder.known_callablesCudaTarget.known_device_callables
  • Move OpenCLCASTBuilder.known_callablesOpenCLTarget.known_device_callables
  • Move PyOpenCLCASTBuilder.known_callablesPyOpenCLTarget.known_device_callables; add PyOpenCLTarget.known_host_callables returning C callables for Python host builder
  • Move CWithGNULibcASTBuilder.known_callablesCWithGNULibcTarget.known_device_callables
  • Fix ExecutableCWithGNULibcTarget to also override known_device_callables with GNU libc callables (fixes test_glibc_bessel_functions)
  • Update translation_unit.py to use t_unit.target.known_device_callables
  • Update tools.py to use self.target.known_device_callables
  • Update library/reduction.py to use target.known_device_callables["max/min"]
Original prompt

This section details on the original issue you should resolve

<issue_title>Move known_callables into TargetBase, from ASTBuilder</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: inducer <352067+inducer@users.noreply.github.com>
Copilot AI changed the title [WIP] Move known_callables into TargetBase from ASTBuilder Move known_callables from ASTBuilderBase to TargetBase Mar 10, 2026
@inducer
Copy link
Owner

inducer commented Mar 10, 2026

@copilot Note that there should be two versions of known_callables on the target, one for host code, and another for device code.

…ables on TargetBase

Co-authored-by: inducer <352067+inducer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot Note that there should be two versions of known_callables on the target, one for host code, and another for device code.

Done in 91bbd26. TargetBase now has both known_host_callables and known_device_callables (each returning {} by default).

  • ASTBuilderBase.known_callables delegates to target.known_device_callables (device is the default)
  • DummyHostASTBuilder.known_callables and PythonASTBuilderBase.known_callables delegate to target.known_host_callables
  • PyOpenCLTarget overrides known_host_callables to return C callables (for the Python host builder)
  • All target subclasses now override known_device_callables instead of a single known_callables

Copilot AI changed the title Move known_callables from ASTBuilderBase to TargetBase Move known_callables from ASTBuilderBase to TargetBase (split into host/device variants) Mar 10, 2026
@inducer
Copy link
Owner

inducer commented Mar 10, 2026

@copilot Why does test_glibc_bessel_functions fail with these changes?

Co-authored-by: inducer <352067+inducer@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 10, 2026

@copilot Why does test_glibc_bessel_functions fail with these changes?

ExecutableCWithGNULibcTarget extends ExecutableCTarget (not CWithGNULibcTarget), so it didn't inherit the known_device_callables override that adds get_gnu_libc_callables(). Previously this worked because both shared the same CWithGNULibcASTBuilder device builder that had the callables. Fixed in 844de53 by adding the known_device_callables override to ExecutableCWithGNULibcTarget as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move known_callables into TargetBase, from ASTBuilder

2 participants