Skip to content

[New offload driver][sycl-post-link] Move sycl-post-link target specific options generation to linker wrapper #14101

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

Conversation

asudarsa
Copy link
Contributor

@asudarsa asudarsa commented Jun 8, 2024

There are some sycl-post-link options that are dependent on target triples and some options that are dependent on user options and some options that are dependent on both.
In this change, we set up all the sycl-post-link options in the driver and then pass them to the clang-linker-wrapper tool. Before calling sycl-post-link functionality, the clang-linker-wrapper will update these options based on the target triple of the image being processed.

Several tests have been updated as ordering of options have changed.

Thanks

…specific options generation to linker wrapper

Signed-off-by: Arvind Sudarsanam <[email protected]>
@asudarsa asudarsa requested review from a team as code owners June 8, 2024 21:25
@asudarsa asudarsa temporarily deployed to WindowsCILock June 8, 2024 21:58 — with GitHub Actions Inactive
Signed-off-by: Arvind Sudarsanam <[email protected]>
CmdArgs.end());
};

// specialization constants processing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can limit the cases where we have to remove or replace args as much as possible. In the ideal world, the driver would only pass these options as ClangLinkerWrapper options (and not any tool options) and ClangLinkerWrapper would know how to create the tool options based on the ClangLinkerWrapper options. Having the driver set tool options but then replacing/removing them in ClangLinkerWrapper seems like something we should try to minimize. It looks like we are stopping the driver from passing some options when the new offload driver is on, but I wonder if we plan to reduce the things this function is doing even more in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sarnex. This is a good observation. I did spend some cycles trying to think of a better way. Following are the factors behind my current design. I will take -emit-only-kernel-as-entry-points as an example.
This option to sycl-post-link is controlled by two factors:

  1. The -fsycl option passed by the user. This information is only available in the driver.
  2. Target triple of the device image that is being post-linked. This information is embedded in the device image and is parsed by the linker wrapper just before sycl-post-link. Again, this information is available only inside the linker wrapper.

We already have many sycl-specific options being passed into the linker wrapper. I think the trade-off here is between number of sycl-specific options passed into the linker wrapper versus adding logic to update options inside the '--sycl-post-link-options' based on the current target. I have gone with adding logic to update options.

May be we can document this and try to revisit at a later time if agreeable?

Thanks
Sincerely

Copy link
Contributor

@sarnex sarnex Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation. Let's assume for discussion clang-linker-wrapper has a way to get the offload kind and the option value (so it knows the current image is SYCL and it knows emit-only-kernel-as-entry-points was passed by the user to clang++).

So I guess the discussion is, should these options be first-class to clang-linker-wrapper (meaning we need to add a new clang-linker-wrapper option for all of the SYCL options that effect device linking) or should they be opaque to clang-linker-wrapper (meaning they are blindly passed as a string from the driver and clang-linker-wrapper will have to do string manipulation on those options). My intuition is the first-class option is cleaner, but I'd like to get opinions from others (@bader @AlexeySachkov etc).

This discussion doesn't necessarily have to block this PR but I think we should make a design decision at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have strong opinion on either option. Surely, +1 on the fact that passing new options is a cleaner solution. I will create a tracker for adding new linker wrapper options for such cases. Hopefully, it need not block this PR.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @sarnex. clang-linker-wrapper doesn't seem like the right tool to update sycl-post-link options based on LLVM target triple. sycl-post-link tools itself should be able do that. Why can't we move this logic there?

Copy link
Contributor Author

@asudarsa asudarsa Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bader,

It's a really good idea to move it inside sycl-post-link. @sarnex, it will be great to hear your take on this.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good to me, but I still would like to minimize string manipulation and rather combine triple information with option value information to decide behavior.

@asudarsa asudarsa requested a review from sarnex June 10, 2024 17:06
Copy link
Contributor

@sarnex sarnex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we can have the design discussions separately

Copy link
Contributor

@mdtoguchi mdtoguchi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@asudarsa
Copy link
Contributor Author

@intel/llvm-gatekeepers This is ready for merging. Can you please help?

Thanks

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Driver/sycl-offload-new-driver.c is failing in post-commit after #14091. I am blocking this PR until the patch has either been reverted or the test failure has been addressed.

Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert was merged. Retracting my blocking comment.

@steffenlarsen
Copy link
Contributor

Testing was done prior to merging the breaking PR, so this should be good to merge.

@steffenlarsen steffenlarsen merged commit c2cdfcc into intel:sycl Jun 11, 2024
14 checks passed
ianayl pushed a commit to ianayl/sycl that referenced this pull request Jun 13, 2024
…fic options generation to linker wrapper (intel#14101)

There are some sycl-post-link options that are dependent on target
triples and some options that are dependent on user options and some
options that are dependent on both.
In this change, we set up all the sycl-post-link options in the driver
and then pass them to the clang-linker-wrapper tool. Before calling
sycl-post-link functionality, the clang-linker-wrapper will update these
options based on the target triple of the image being processed.

Several tests have been updated as ordering of options have changed.

Thanks

---------

Signed-off-by: Arvind Sudarsanam <[email protected]>
asudarsa added a commit that referenced this pull request Jun 18, 2024
…ted (#14177)

In an earlier PR (#14101), we added
support to generate sycl-post-link options (that partly depend on target
triple) in clang Driver and then update the options using target triple
information in the clang-linker-wrapper.
This PR cleans up that implementation by fully generating these options
inside the clang-linker-wrapper. This requires some more user-specified
options to be passed into the clang-linker-wrapper.

Thanks
------

Signed-off-by: Arvind Sudarsanam <[email protected]>
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.

5 participants