Closed t-sakashita closed 1 year ago
./rokko_solvers
の実行結果:
[serial dense solvers]
[parallel dense solvers]
[parallel sparse solvers]
ファクトリにstatic inlineを用いる直前のコミットに戻してみる。 81a6d19e5a53851f1dee3a312394c0446567ed14
Ubuntu + gccでも、rokko_solversの出力結果は正常:
[serial dense solvers]
eigen3
lapack
[parallel dense solvers]
eigenexa
elemental
scalapack
[parallel sparse solvers]
anasazi
original
slepc
gcc9を用いているが、バージョンが古い?
Ubuntu jammyにおいて、gcc11.4を用いても、ソルバは一つも登録されない。
test/factory/register_products.cppで試したら、segmentation faultが起きた。 register_products.cppは固有値ソルバを用いず、クラスの登録もregister_products.cppの中で行っているから、原因の切り分けに役立ちそう。
factory
クラスでは、instance_
だけでなく、全てのプライベートオブジェクトを、static inline
にして良い? すべきか?
private:
static inline std::unique_ptr<factory> instance_ = nullptr;
static inline creator_map_type creators_;
static inline int largest_priority_ = 0;
static inline std::string default_product_;
固有値ソルバの登録が一切されない問題の解決法:
main関数以前の、static変数の初期化は保証されるために、以下を試した。(規格として保証されるのかは不明だが。)
factory
クラスのlargest_priority_
にstatic inline
を指定した。
このゼロ初期化もコンストラクタではなく、= 0
と書いたので見やすくなった。
94df0f4e9a6448e6129f66837058a8bb7f2f62cd
Ubuntu jammyにおいて、gcc11.4を用いた場合にも、test/factory/register_products.cppが正常終了するようになった。 なぜ?
なお、serial_dense_evのファクトリの登録をするだけでも、正常終了した。 factoryの他のテンプレートによるderived classも実体化されたようだ。
メインプログラム側でインクルードするヘッダファイルdeclare_factory_instance.hpp
を用意した。
これは、factory
クラスのinstance_
オブジェクトの宣言を行う。
(その際、inline
が指定されているので、externは不要。)
(declare_factory_instance.hpp
を、ライブラリlibrokko.soの作成に用いるソースファイルでインクルードすると、リンクエラーとなることに注意。)
4f685d3197559084b6acb77083c90ef1b923c5f0
以上のコミットにより、Ubuntu jammyにおいて、gcc11.4を用いた場合にも、全てのソルバが登録されるようになった。
Githubのautorunでも、testディレクトリのプログラムでソルバが登録されるようになった。
Pythonバインディングではなく、C++で使用した場合の問題。
Ubuntu latest (focal)をVirtualBoxで立ち上げて使用。
Mac (clang++)では、正常動作。