Change History 2025#
- Author:
Yasuhiro Inamura
- Last Update:
Feb 25, 2025
4.0.250224 or later#
- Feb 24 2025
[bugfix:Utsusemi:4.0] The problem that the functions using multh-threads with OpenMP does not work correctly on C++ library build by CMake.
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
CMakeでコンパイルした空蝉だと、ヒストグラム化などでのmulti-threads (openmp)が正しく機能しないことが判明した。例えばCPU使用率が100%以上上がらない、など。
調査
$ VERBOSE=1 make install でログを確認してわかったこと
SWIGを利用して”_wrap.cxx”コードが作成されるが、各C++コードの後に行われるwrapコードのコンパイルの時に -fopenmp オプションが使用されていない
同様に -DMULTH= マクロ定義の設定も使用されていない
これらの結果、openmp関連の挙動がおかしいようだ。そこで、CMakeLists.txtの中での指定を見直すことにした。
マクロ定義 -DMULTH= の設定はtarget_compile_definitionsを使って定義し、PUBLICキーワードで指定
target_compile_optionsでの -fopemmp を”_wrap.cxx”のコンパイルにも引き継がれるようにキーワードPRIVATEをPUBLICに変更
空蟬のC++コンパイルに必要な全てのオプションをひとまとめにして使用
現状の解として下記のようにしている。
# Find OpenMP find_package(OpenMP) # Set compile options for Utsusemi set(UTSUSEMI_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -O3 -shared -pthread) target_compile_options(Utsusemi PUBLIC ${UTSUSEMI_CXX_FLAGS}) target_compile_definitions(Utsusemi PUBLIC MULTH=${MANYO_MULTH}) target_compile_features(Utsusemi PRIVATE cxx_std_11) target_include_directories(Utsusemi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${HDF5_INCLUDE_DIRS} ${MANYO_NEXUS_PATH} ${CMAKE_INSTALL_PREFIX}/include ${CMAKE_INSTALL_PREFIX}/include/MLF) target_link_directories(Utsusemi PUBLIC ${CMAKE_INSTALL_PREFIX}/lib) target_link_libraries(Utsusemi NeXus gsl boost_serialization boost_filesystem boost_system python3.12 util dl Manyo MLF) # target_link_options(Utsusemi PRIVATE ${UTSUSEMI_CXX_FLAGS}) # need to add this if this CMakeLists is for Manyo core .
変更点
find_package(OpenMP)
これで`${OpenMP_CXX_FLAGS}`が使用できる(無用な直書き設定が減る)。
target_compile_definitionsの設定とPUBLIC効果
この設定でさまざまなところでマクロ定義が有効化される。
target_compile_options()のPUBLIC効果
PUBLICキーワードを使用することで
[ 98%] Building CXX object manyo/CMakeFiles/ManyoUtsusemi.dir/__/UtsusemiPYTHON_wrap.cxx.o ... -fPIC -fopenmp -O3 -shared -pthread ...
とオプションが引き継がれる。
target_link_options設定の効果
Linking CXX shared module _ManyoUtsusemi.so の時にオプションが引き継がれる。
ただし、これはUtsusemi/manyoやmanyo/MLFでは不要であった(なくても動作している模様)。 一方、manyo/coreではこれがないと下記のようなImportErrorが発生する。
>>> import Manyo ... from . import _ManyoCore ImportError: /opt/mlfsoft/manyo/lib/libManyo.so: undefined symbol: omp_get_thread_num
manyo/coreでもtarget_link_libraryにOpenMP::OpenMP_CXXを加えるとImportErrorは消えるが、Shared Libraryを増やすのは不満なので、これは採用しなかった。
結果
結局SWIGを用いる場合、いくつかのオプション等をPUBLICにしないとSWIG生成コードのコンパイルでは使用されないことがわかった
この修正の結果、通常のMakefileを利用したコンパイルした空蝉とも対等な速度が出るようになった
- Feb 24 2025
[bugfix:manyo:0.3.4] The problem that the functions using multh-threads with OpenMP does not work correctly on C++ library build by CMake.
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
CMakeでコンパイルした空蝉だと、ヒストグラム化などでのmulti-threads (openmp)が正しく機能しないことが判明した。例えばCPU使用率が100%以上上がらない、など。これへの対応は万葉コア本体にも必要である。
find_package(OpenMP)の使用
target_compile_definitionsの採用とPUBLIC設定
target_compile_options()のPUBLIC設定
target_link_options指定(これがないと、下記のImportError)
>>> import Manyo ... from . import _ManyoCore ImportError: /opt/mlfsoft/manyo/lib/libManyo.so: undefined symbol: omp_get_thread_num
詳細は、空蟬での更新を参照のこと。
- Feb 23 2025
[bugfix:manyo:0.3.4] The problem that default values of argument –numth in do_make_Manyo.py does not use inner default value of NUM_OF_THREAD
- Feb 23 2025
[update:manyo:0.3.4] Simplify cords of #ifdef MULTH blocks in SearchInHeader
- Feb 20 2025
[bugfix:Utsusemi:4.0] The problem that AddToMPlot function in SequenceEidtor’s Visualize dialog occurs run-time error.
DATA_RDCT-298 空蝉4:SequenceEditorのVisualize問題
SequenceEditorのVisualizeパネルで、あらかじめ表示したMPlotに対して、AddToMPlotでプロットを追加しようとすると “Run-time error!” が出現する問題に対応した。 この処理はpython-utsusemi-AMRとpython-utsusemi-SIKのVisualModule.pyに対して行った。
また、python-utsusemi-HPNやpython-utsusemi-VNRのVisualModuleQ.pyも、新しいSequenceEditorのVisualizeに対応するように置き換えた。
- Feb 19 2025
[bugfix:manyo:0.3.4] The problem that compiling on macOS causes the warning like (warning: delete called on ‘EventDataMonitorBase’ that is abstract but has non-virtual destructor)
- Feb 17 2025
[update:Utsusemi:4.0] Improve to show some comments on DetectMap only when Utsusemi debug mode is on.
- Feb 17 2025
[bugfix:Utsusemi:4.0] The problem that the azimuth angle calculation for selected pixels by Append Sum on DetectMap is sometimes not correct.
DATA_RDCT-295 空蝉4:DetectMapにおける領域選択してMPlot表示時のAzimuth角度平均値計算の問題
DetectMapで領域を選択し、MPlotでTOF方向の”Append Sum”ボタンでプロットを行った時に、2thetaとAzimAngleを領域内で平均化してMPlotのタイトル部分に表示するが、その領域が水平面内を含む場合、Azimuth角度がプラスとマイナスの領域がそのまま平均化され、本来からかけ離れた値になってしまう。
各PixelのAzimAngleを平均するのではなく、平均のPixel位置からAzimAngleを計算するようにした。
ついでに一部ElementContaienrのヘッダ用のキーをリテラルで書いていた部分があったので、UtssuemiHeader::UTSUSEMI_KEY_HEAD_PIXELPOSITIONなどで置き換えた。
- Feb 17 2025
[bugfix:uGao:master] The problem that the rotation of the axes indication types for selected point on MPlot graph.
DATA_RDCT-296 夕顔:MPlotで座標表示の変更がローテーションしない
MPlotでプロット上の点を指定して座標情報(”X”とか”Y”, “X, Y”など)をプロット上に表示する機能のうち、表示の方式を変更するアイコンをクリックすると表示方式が切り替わり、本来6種類の方式が一巡するようになっていた。 しかし、現状そうなっていないので、修正した。
- Feb 14 2025
[update:Utsusemi:4.0] Improved CMakeLists.txt to use include(FindHDF5) and add new argument NEXUS_PATH to cmake procedure to give the path for the nexus format library
- Feb 14 2025
[update:manyo:0.3.4] Add new argument NEXUS_PATH to cmake procedure to give the path for the nexus format library
- Feb 14 2025
[update:manyo:0.3.4] Improved CMakeLists.txt to use include(FindHDF5)
- Feb 13 2025
[update:uGao:master] Improve the order of movements for current GUI objects in MPlot by tab key.
- Feb 7 2025
[update:Utsusemi:4.0] Improve CMakeLists.txt (move the Swig including commands)
- Feb 2 2025
[update:Utsusemi:4.0] Improve scripts for the installation on macOS and README.
4.0.250131 or later#
- Jan 31 2025
[update:uGao:devRefactoring01] Update to ignore the warning message
- Jan 29 2025
[bugfix:Utsusemi:4.0] The problem that SumOfPixel function does not handle the masked PSDs and pixels correctly.
DATA_RDCT-293 空蝉4:SumOfPixelでマスク(Pixel, PSD)が効かない
SumOfPixelの中で、マスクのかかったPSDやPixelを正しく扱えない、すなわちSumするときにマスクのPixelなどを除外していなかったので、修正した。なお、以前のSumOfPixelコードはSumOfPixelOldと名前を変更して残してある。
- Jan 28 2025
[update:Utsusemi:4.0] Improve codes to avoid warning messages on compiling on Windows (warning for cast of values types)(2).
Windowsでのコンパイルにおいて、変数の型変換はキャストを明示しないとWarningが出るので、それに対処した。
- Jan 28 2025
[update:Utsusemi:4.0] Improve codes to avoid warning messages on compiling on Windows (warning for cast of values types).
Windowsでのコンパイルにおいて、変数の型変換はキャストを明示しないとWarningが出るので、それに対処した。
あと、使用しない変数の定義もWarningとなるので、コードから削除した。
- Jan 28 2025
[bugfix:Utsusemi:4.0] The problems DumpAsText function in D4Mat2Slicer does not work correctly (All values in the output text are zero).
DATA_RDCT-292 空蝉4:D4Mat2Slicerの問題2025-01
D4Mat2Slicerで、DumpAsTextに関連する下記のような問題のうち、Windows版でDumpAsText機能でデータがおかしい(全部の軸の値や強度やエラー値が初期値のまま)問題に対処した。
Windowsで挙動を確認したところ、内部でfor文を使用した配列のコピーに失敗していたことがわかった。 その理由はfor文で使用する変数の初期化ができていなかったためだったので、その修正を行なった。
- Jan 28 2025
[bugfix:Utsusemi:4.0] The problems around D4Mat2Slicer and its DumpAsText function
DATA_RDCT-292 空蝉4:D4Mat2Slicerの問題2025-01
D4Mat2Slicerで、DumpAsTextに関連する下記のような問題が報告されたので、対応した。
Memory Save ModeででDumpAsText機能でデータが空となる
これは内部で出力用のデータを作成している”MakeSlicedD4MatrixInner”関数内で、Memory Save Modeにおいて正しい挙動をしていなかったため、機能追加した。
Windows版でDumpAsText機能でデータが空になる
これは未確認だが、内部でfloat -> Doubleへのキャストに失敗している可能性がある(過去にWindows版で遭遇した記憶)ので、キャストを明示した(動作確認は別途行う)
DumpAsText機能で出力されたファイルに欠損がある
欠損はファイルの末尾近傍で突然起こるので、値がないなどの内部でエラーではないようだ
なんとなくキャッシュが最後まで書き出されていない雰囲気
よくコードを見ていると fopen で開いているのに fclose していないことがわかったので修正した
D4Mat形式に書き出すときTOFマスクが有効ではない
D4matrix形式で書き出すときに、TOFマスクを考慮していないことがわかったので、機能追加した
あと、関数名にtypoがあったので修正した。
- Jan 17 2025
[update:Utsusemi:4.0] Improve CMakeLists.txt to use FindSWIG and UseSWIG
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
CMakeLists.txt内でSWIGの設定に使用する find_package および include(${SWIG_USE_FILE}) を include で置き換えた。
#find_package(SWIG REQUIRED) #include(${SWIG_USE_FILE}) include(FindSWIG) include(UseSWIG)
- Jan 17 2025
[update:Utsusemi:4.0] Update files for compiling.
- Jan 17 2025
[bugfix:Utsusemi:4.0] Remove meaningless command.
- Jan 17 2025
[bugfix:manyo/0.3.4] Fixed CMakeLists.txt for ImportError.
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
import時に下記のようなエラーが出る。
>>> import Manyo Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/mlfsoft/manyo/Manyo/__init__.py", line 1, in <module> from .core import * File "/opt/mlfsoft/manyo/Manyo/core.py", line 10, in <module> from . import _ManyoCore ImportError: /opt/mlfsoft/manyo/lib/libManyo.so: undefined symbol: _ZN11CppToPython18VectorStringToListESt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS6_EE
CppToPython.ccの中で PyMaj を使うプリプロセッサがあったがCMakeLists.txt内のcompile_optionsで -DPyMaj=3 の指定していなかったため発生した。 これを修正した。
またついでにCMakeLists.txt内でSWIGの設定に使用する find_package および include(${SWIG_USE_FILE}) を include で置き換えた。
#find_package(SWIG REQUIRED) #include(${SWIG_USE_FILE}) include(FindSWIG) include(UseSWIG)
- Jan 8 2025
[updateUtsusemi:4.0] Improve CMakeLists.txt to enable to change MULTH in codes by given cmake argument
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
これまで固定されていたMULTHの値をcmakeの引数で変更( -DMULTH=n )できるようにした。
$ cd build $ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/mlfsoft/manyo -DMULTH=4
- Jan 8 2025
[updateUtsusemi:4.0] Improve CMakeLists.txt according to guideline.
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
ガイドラインにしたがって、非推奨な書き方をなくす取り組みを行う。
参照:https://qiita.com/shohirose/items/5b406f060cd5557814e9
今回の改変
set(CMAKE_CXX_FLAGS)を使用しない
target_compile_options, target_compile_features, target_link_options
include_directories()を使用しない
target_include_directories
set_property(SOURCE Utsusemi. PROPERTY INCLUDE_DIRECTORIES)
file(GLOB)を使用しない
target_sources
install(FILES)
CMAKE_SOURCE_DIRを使用しない
PROJECT_BINARY_DIR
- Jan 8 2025
[update:manyo:devCMake] Improve CMakeLists.txt to enable to change MULTH in codes by given cmake argument (MLF/CMakeLists.txt)
- Jan 8 2025
[update:manyo:devCMake] Improve CMakeLists.txt to enable to change MULTH in codes by given cmake argument
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
これまで固定されていたMULTHの値をcmakeの引数で変更( -DMULTH=n )できるようにした。
$ cd build $ cmake .. -DCMAKE_INSTALL_PREFIX=/opt/mlfsoft/manyo -DMULTH=4
あと、不要な -DPyMaj=3 のオプションも削除した。
- Jan 7 2025
[update:manyo:0.3.4] Update do_make_Manyo.py to treat Ubuntu 24 and improve the logic to define DIST_NAME.
- Jan 7 2025
[update:manyo:devCMake] Improve CMakeLilsts.txt according to guideline(4)
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
ガイドラインにしたがって、非推奨な書き方をなくす取り組みを行う。
参照: https://qiita.com/shohirose/items/5b406f060cd5557814e9
今回の改変
コード整理
公開用ヘッダファイル収集やPythonモジュール等のインストールに使用していた FILE(GROB) の置き換え
include(UseSWIG)関連のコマンドをmanyo/CMakeLists.txtに移動し共有化
不要なコメント文の削除
PRIVATE/PUBLIC/INTERFACEを適切に使う
コード内全てのPUBLICをPRIVATEに変更した
Manyo3PYTHON_wrap.cxx.o作成時に “fatal error: Header.hh: No such file”エラーが出た
target_include_directories のPUBLICだけを残したところ、上記のエラーがなくなった
他にもコンパイルの総数が減って高速化した(無駄なPUBLICはだめらしい)
- Jan 7 2025
[update:manyo:devCMake] Improve CMakeLilsts.txt according to guideline(3)
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
ガイドラインにしたがって、非推奨な書き方をなくす取り組みを行う。
参照: https://qiita.com/shohirose/items/5b406f060cd5557814e9
今回の改変
コード整理
公開用ヘッダファイル収集やPythonモジュール等のインストールに使用していた FILE(GROB) の置き換え
include(UseSWIG)関連のコマンドをmanyo/CMakeLists.txtに移動し共有化
不要なコメント文の削除
今後の対応
PRIVATE/PUBLIC/INTERFACEを適切に使う
- Jan 7 2025
[update:manyo:devCMake] Improve CMakeLilsts.txt according to guideline(2)
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
ガイドラインにしたがって、非推奨な書き方をなくす取り組みを行う。
参照:https://qiita.com/shohirose/items/5b406f060cd5557814e9
今回の改変
target_compile_options使用を進める
manyo/CMakeLists.txtからset(CMAKE_CXX_FLAGS “…”)を削除
manyo/core/CMakeLists.txt, manyo/MLF/CMakeLists.txt にtarget_compile_optionsを追加
同時にtarget_link_optionsも必要(前回うまくいかなかったエラーへの対処)
うまくいかなかった部分
>>> import Manyo Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yinamura/dev/works/241125CMake/mlfsoft/manyo/Manyo/__init__.py", line 1, in <module> from .core import * File "/home/yinamura/dev/works/241125CMake/mlfsoft/manyo/Manyo/core.py", line 10, in <module> from . import _ManyoCore ImportError: /home/yinamura/dev/works/241125CMake/mlfsoft/manyo/Manyo/_ManyoCore.so: undefined symbol: omp_get_thread_num
今後の対応
PRIVATE/PUBLIC/INTERFACEを適切に使う
コード整理
- Jan 6 2025
[update:manyo:devCMake] Improve CMakeLilsts.txt according to guideline
DATA_RDCT-289 万葉ライブラリ:cmakeで書き換える
ガイドラインにしたがって、非推奨な書き方をなくす取り組みを行う。
参照:https://qiita.com/shohirose/items/5b406f060cd5557814e9
今回の改変
target_compile_optionsにstd=c++11などを追加しない -> target_compile_featuresを使用
file(GLOB …)を使用しない
target_sourcesを使用
CMAKE_SOURCE_DIRを使わない
主にinclude_directoriesやinstallに使用していたが、それぞれ削除したり、PROJECT_BINARY_DIRを使用
うまくいかなかった部分
set(CMAKE_CXX_FLAGS, “…”)のように直接コンパイルオプションを足さない -> target_compile_options使用
これの修正を試みた。
target_compile_options(Manyo PUBLIC -O2 -fPIC -fopenmp ...)
という感じで、ManyoやManyoCore, MLF, ManyoMLFなどを置き換えたが、下記のように undefined symbol でエラーとなる。
>>> import Manyo Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/yinamura/dev/works/241125CMake/mlfsoft/manyo/Manyo/__init__.py", line 1, in <module> from .core import * File "/home/yinamura/dev/works/241125CMake/mlfsoft/manyo/Manyo/core.py", line 10, in <module> from . import _ManyoCore ImportError: /home/yinamura/dev/works/241125CMake/mlfsoft/manyo/Manyo/_ManyoCore.so: undefined symbol: omp_get_thread_num
_ManyoCore.soを作成する時点でのコンパイルオプション -fopenmp が渡されていないようだ。
今後の対応
target_compile_options使用を進める
PRIVATE/PUBLIC/INTERFACEを適切に使う