-
Notifications
You must be signed in to change notification settings - Fork 790
[SYCL] Fix library destructor priority value #3054
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] Fix library destructor priority value #3054
Conversation
__attribute__((destructor(65535))) static void syclUnload() { shutdown(); } | ||
// Setting minimal priority on destructor ensures it runs after all other global | ||
// destructors. Priorities 0-100 are reserved by the compiler. | ||
__attribute__((destructor(101))) static void syclUnload() { shutdown(); } |
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.
What about setting something like 110 to let other libraries to have a destructor which works after SYCL one.
@smaslov-intel @alexbatashev What do you think?
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.
Makes sense, I think
// destructors. Priorities 0-100 are reserved by the compiler. The priority | ||
// value 110 allows SYCL users to run their destructors after runtime library | ||
// deinitialization. | ||
__attribute__((destructor(110))) static void syclUnload() { shutdown(); } |
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.
Should we document it somewhere what priority are for what? And how it interacts with no priority specified?
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.
I conducted a small experiment:
#include <iostream>
__attribute__((destructor(101))) static void syclUnload101() {
std::cout << "101\n";
}
__attribute__((destructor(102))) static void syclUnload102() {
std::cout << "102\n";
}
__attribute__((destructor(110))) static void syclUnload110() {
std::cout << "110\n";
}
__attribute__((destructor(105))) static void syclUnload105() {
std::cout << "105\n";
}
__attribute__((destructor)) static void syclUnload() {
std::cout << "default\n";
}
int main() {
std::cout << "Hi\n";
return 0;
}
The result is the same for both GCC and Clang:
Hi
default
110
105
102
101
No description provided.