-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Remove TORCH_API from inline at::internal::lazy_init_num_thread #89511
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/89511
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 2 PendingAs of commit 7ae1144: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
Note that this VS 17.4.0 regression is being tracked as thread_local causing fatal error LNK1161: invalid export specification on VS 2022 - Visual Studio Feedback |
@@ -29,7 +29,7 @@ TORCH_API bool in_parallel_region(); | |||
namespace internal { | |||
|
|||
// Initialise num_threads lazily at first parallel call | |||
inline TORCH_API void lazy_init_num_threads() { | |||
inline void lazy_init_num_threads() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change seems OK in a sense that it makes the code compile. Albeit I am not so sure if it won't break the DLL interface when the __declspec(dllexport)
would be missing. According to my search through the codebase, it does not seem that this function is actually used accross the DLL interface but my knowledge here is limited.
cc @kit1980
@ankurvdev Is it possible to make the change affect only that specific compiler version? Otherwise the change seems to be too broad as it will affect every compiler on every platform. |
Thanks for providing the reference to the bug. However, that said, IMO the semantics this piece of code tries to express (inlining as well as importing) are extremely weird. The code change here would simply imply that Even so ... if there are concerns The semantics in its current state make it unclear which mode we'll get
So choosing one way or the other should be done regardless of the VS bugfix. Thoughts ? |
With that in mind, removing Imo a better change , would be to move |
FYI - a MS C++ bug fix is underway, but it may not be included until version 17.4.4. |
Ping ... |
@pytorchbot rebase |
@pytorchbot successfully started a rebase job. Check the current status here |
Do not try to export inline apis as that causes linking issues
Successfully rebased |
a7822db
to
7ae1144
Compare
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…rch#89511) The function signature in its current state is ambiguous. Its an inline function that is also declared to be imported from the DLL. which leaves it subject to compilers decision to choose one or the other and depending on what the compiler/linker may choose we may get one of the two behaviors for the `aten::init_num_threads` call: 1. Once-per-dll-in-a-thread (if its inlined) 2. Once-per-thread (if its imported) I suspect once-per-dll-in-a-thread is already the case currently because it being tagged inline So removing the inline will simply make it a little more consistent and clear. The function exists to avoid repeated calls to aten::init_num_threads. Being in an "internal" namespace, the function isnt expected to be called by external plugins which means that the "once-per-dll-in-a-thread" behavior isn't that much of a problem anyway Pull Request resolved: pytorch#89511 Approved by: https://github.com/malfet
This adds VS 2022 to Windows AMI. The line with [https://aka.ms/](https://aka.ms/) link might be reverted once `vs16.11.21_BuildTools.exe` and `vs17.4.1_BuildTools.exe` files will be uploaded to [https://s3.amazonaws.com/ossci-windows/](https://s3.amazonaws.com/ossci-windows/.). Note that there is a fix of [thread\_local causing fatal error LNK1161: invalid export specification on VS 2022 - Visual Studio Feedback](https://developercommunity.visualstudio.com/t/thread_local-causing-fatal-error-LNK1161/10199441) pending, required e.g. for pytorch/pytorch#89511, which will require another VS 2022 version update. Alternatively, the VS 2022 version installed by this change can be downgraded to 16.3.6 which does not suffer this issue. This is needed to finish pytorch/pytorch#86591
The function signature in its current state is ambiguous.
Its an inline function that is also declared to be imported from the DLL.
which leaves it subject to compilers decision to choose one or the other and depending on what the compiler/linker may choose we may get one of the two behaviors for the
aten::init_num_threads
call:I suspect once-per-dll-in-a-thread is already the case currently because it being tagged inline
So removing the inline will simply make it a little more consistent and clear.
The function exists to avoid repeated calls to aten::init_num_threads.
Being in an "internal" namespace, the function isnt expected to be called by external plugins which means that the "once-per-dll-in-a-thread" behavior isn't that much of a problem anyway