Skip to content
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

[SYCL][clang] Emit default template arguments in integration header #16005

Merged
merged 10 commits into from
Nov 18, 2024

Commits on Nov 6, 2024

  1. [SYCL][clang] Emit default template arguments in integration header

    For free function kernels support clang forward declares the kernel
    itself as well as its parameter types. In case a free function kernel has a
    parameter that is templated and has a default template argument, all
    template arguments including arguments that match default arguments must
    be printed in kernel's forward declarations, for example
    
    ```
    template <typename T, typename = int> struct Arg {
      T val;
    };
    
    // For the kernel
    SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
        (ext::oneapi::experimental::nd_range_kernel<1>)) void foo(Arg<int> arg) {
      arg.val = 42;
    }
    
    // Integration header must contain
    void foo(Arg<int, int> arg);
    ```
    
    Unfortunately, even though integration header emission already has
    extensive support for forward declarations priting,
    some modifications to clang's type printing are still required.
    infrastructure, since neither of existing PrintingPolicy flags help to
    reach the correct result.
    Using `SuppressDefaultTemplateArgs = true` doesn't help without printing
    canonical types, printing canonical types for the case like
    ```
    template <typename T>
    SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
        (ext::oneapi::experimental::nd_range_kernel<1>)) void foo(Arg<T> arg) {
      arg.val = 42;
    }
    // Printing canonical types is causing the following integration header
    template <typename T>
    void foo(Arg<type-parameter-0-0, int> arg);
    ```
    
    Using `SkipCanonicalizationOfTemplateTypeParms` field of printing policy
    doesn't help here since at the one point where it is checked we take
    canonical type of `Arg`, not its parameters and it will contain template
    argument types in canonical type after that.
    Fznamznon committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    c3cdacb View commit details
    Browse the repository at this point in the history
  2. Groom TypePrinter.cpp

    Fznamznon committed Nov 6, 2024
    Configuration menu
    Copy the full SHA
    da51a19 View commit details
    Browse the repository at this point in the history

Commits on Nov 8, 2024

  1. Force namespace printing

    Fznamznon committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    6ba5063 View commit details
    Browse the repository at this point in the history
  2. [WIP] Add test

    Fznamznon committed Nov 8, 2024
    Configuration menu
    Copy the full SHA
    3e0e4bb View commit details
    Browse the repository at this point in the history

Commits on Nov 11, 2024

  1. Configuration menu
    Copy the full SHA
    4f091c0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7e2272f View commit details
    Browse the repository at this point in the history
  3. Fix format

    Fznamznon committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    e206684 View commit details
    Browse the repository at this point in the history
  4. Fix format again

    Fznamznon committed Nov 11, 2024
    Configuration menu
    Copy the full SHA
    aded78e View commit details
    Browse the repository at this point in the history

Commits on Nov 14, 2024

  1. Configuration menu
    Copy the full SHA
    30ff224 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e2779e8 View commit details
    Browse the repository at this point in the history