-
Notifications
You must be signed in to change notification settings - Fork 91
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
Fix dynamic cast leads the undefined symbol in clang/msys2/windows #1724
Conversation
ae83bd6
to
848adaf
Compare
667b9ad
to
d22eecc
Compare
core/base/batch_instantiation.hpp
Outdated
* | ||
* @note the second and third arguments only accept the base type.s | ||
*/ | ||
#define GKO_INSTANTIATE_FOR_BATCH_VALUE_MATRIX_PRECONDITIONER(_macro) \ |
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 think this needs to be unified with the changes from #1629, but I don't immediately see how to do that.
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 reuse the part in types.hpp.
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 update the macro usage a bit such that make the for-stack easy and clear.
I think it can not reuse the main stack of dispatch type.
one dispatches the device data structure which are only available in namespace cuda/hip/...
, but the other uses the main class.
3408b2b
to
c14d27b
Compare
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 have some smaller comments. The changes to the macro structure are quite nice, thanks for that!
core/solver/batch_cg.cpp
Outdated
run<batch::matrix::Dense<ValueType>, batch::matrix::Csr<ValueType>, | ||
batch::matrix::Ell<ValueType>>( | ||
this->system_matrix_.get(), [&](auto matrix) { | ||
if (this->preconditioner_ == nullptr) { |
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.
maybe just set preconditioner_
to identity, so we don't need an if here.
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.
It is already set to Identity if nullptr in generation.
set_preconditioner
will ignore nullptr not change the underlying preconditioner.
preconditioner can not be nullptr in any way.
core/base/batch_instantiation.hpp
Outdated
#define GKO_CALL(_macro, ...) _macro(__VA_ARGS__) | ||
|
||
#define GKO_BATCH_INSTANTIATE_PRECONDITIONER(_next, ...) \ | ||
_next(GKO_INDIRECT(__VA_ARGS__), gko::batch::matrix::Identity); \ |
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 GKO_INDIRECT
should only be necessary on the root macro (GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE
in this case). So maybe just add it there, it should not hurt other usages of that macro.
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 was using it wrongly.
no, I think it is required here.
in MSVC, they consider the VA_ARGS as one arguments by default.
GKO_CALL(A_loop, B_loop, ...)
-> A_loop("B_loop, ...").
will just be "B_loop, ..."(A_1)
"B_loop, ..."(A_2)
-> only the first one get expanded properly, the B_loop, ... is considered as one arguments. no __VA_ARGS__
in A_loop.
I need to use GKO_INDIRECT
to take the first arguments out of __VA_ARGS__
when it may have the nested call.
c645d8e
to
2fb4434
Compare
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.
LGTM! Just a naming nit
20b7e8b
to
0b7409e
Compare
In clang18 (at least), compiler will include convert_to/move_to/... as undefined symbol by dynamic_cast. It is not an issue in linux when building the shared library and OSX with `-undefined dynamic_lookup`. However, clang in msys2 (WINDOWS) does not have `--allow-shlib-undefined`, which should be enabled by default when building shared libraries.
Co-authored-by: Marcel Koch <[email protected]>
Co-authored-by: Marcel Koch <[email protected]>
0b7409e
to
2dfc7d6
Compare
Quality Gate failedFailed conditions |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1724 +/- ##
===========================================
+ Coverage 89.94% 91.63% +1.68%
===========================================
Files 782 782
Lines 63456 63243 -213
===========================================
+ Hits 57078 57952 +874
+ Misses 6378 5291 -1087 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
… in clang/msys2/windows This PR fixes dynamic cast leads the undefined symbol in clang/msys2/windows and update the stack macro usage Related PR: ginkgo-project#1724
It is reported in #1654 . We have some undefined symbol when building the shared library (libginkgo_reference) by the clang-18 from msys2 in windows.
In clang 18 (at least), the compiler include
convert_to
/move_to
/... virtual function as undefined symbols when we usedynamic_cast
. These symbols are fromConvertibleTo<..>
, which contain general function likeconvert_to
calling virtual functions, such that these functions are considered in the library.It can be observed with clang-18 on linux, too. However, there are different behaviors between systems.
-undefined dynamic_lookup
--allow-shlib-undefined
, which is enabled by default, but it seems to be available in Linux https://man.archlinux.org/man/extra/lld/ld.lld.1.en In the environment, I check the help documentation and the linker also reports unknown argument when passing the argument.The older compiler or gcc compiler put these function as weak symbol, so it does not complain undefined symbols.
This PR moves the matrix/preconditioner dispatch from the kernels to core such that there are no dynamic_cast in the codes.
It also needs to add
-fno-assume-unique-vtables
to clang/msys2/windowns to make the dynamic_cast to the class marked by final work.https://reviews.llvm.org/D154658 should be relevant
TODO: