Repository navigation
COMP: Compile each ImageProcessing filter executor once - #1963
imikejackson merged 3 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
46c5297 to
2be2ec8
Compare
imikejackson
left a comment
There was a problem hiding this comment.
Verified this is a pure code move: executor bodies, type sets and error codes are unchanged, and the only new code is what the move needs (declarations, exports, includes, CMake lists, link test). Rebased on develop after #1942 (one include added to Algorithms/NormalizeImage.cpp) and updated four test comments to the new SafeBorderPadRadius location. In-core: ImageProcessing tests 1128/1128 pass. Out-of-core: ImageProcessing ooc-labeled tests 140/140 pass.
The NXImageProcessing filters included one 5,891-line header that held all of the executor templates and 23 engine headers. Each filter compiled again the executor code that it shared with other filters. For example, five morphology filters each compiled the same 2.3 MB of machine code. This change gives each executor family one translation unit in the NXImageProcessing plugin. * Move the 30 executors that use only their default type set to exported functions in NXImageProcessing/utils/ImageFilterExecutors.hpp with one .cpp file for each engine family. * Move the 7 executors whose template arguments change with the caller to NXImageProcessing/utils/ImageFilterTemplateExecutors.hpp. * Move the helpers that more than one family or a test uses to NXImageProcessing/utils/ImageFilterExecutorDetail.hpp. * Move MorphOp, ObjectMorphOp, ReconstructOp and RegionalExtremaOp to the new ImageProcessingOperationTypes.hpp. The engine headers include it, so their users see the same enums. * Keep only the shared preflight helpers, input checks and type-set policies in ImageProcessingFilterUtilities.hpp (770 lines). * Add ImageFilterExecutorsLinkTest, which references each exported executor, so a missing export fails the link on every platform. * Remove StreamBinaryThreshold, which had no caller. The executor bodies, type sets, error codes and messages do not change. Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
SafeBorderPadRadius moved to NXImageProcessing/utils/ImageFilterExecutorDetail.hpp. Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
PR BlueQuartzSoftware#1947 added ValidateMorphologyLayout preflight checks to the morphology filters. They reached it through ImageProcessingFilterUtilities.hpp, which no longer includes MorphologyEngine.hpp. Move the two overloads and their error codes, unchanged, into MorphologyLayout.hpp so the filters can include them without the morphology engine. Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
2be2ec8 to
5ab1f1d
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
@joeykleingers I rebased this PR onto develop tonight so it could merge with the other approved PRs. #1947 merged first and conflicted with it, so here is what changed on your branch. Rebase onto #1947 (folded into
New commit Other
If you would rather |
Summary
The NXImageProcessing filters included one 5,891-line header,
ImageProcessingFilterUtilities.hpp, that held all of the executor templates and 23 engine headers. Each filter translation unit compiled the executor code again for the same type sets. For example, the Black Top Hat, White Top Hat, Morphological Gradient and grayscale opening and closing objects each held about 2.3 MB of the same machine code. This change compiles each executor family once, in its own source file in the NXImageProcessing plugin. The executor bodies, type sets, error codes and messages do not change. 110 files changed, +5,889 / −5,178 lines.1. Executors move into the plugin
src/Plugins/NXImageProcessing/src/NXImageProcessing/utils/ImageFilterExecutors.hppdeclares the 30 executors that always use their default type set as exported plain functions (NXIMAGEPROCESSING_EXPORT).src/Plugins/NXImageProcessing/src/NXImageProcessing/utils/*ImageFilterExecutors.cpp(11 files, one for each engine family: mask, adaptive histogram equalization, morphology, object morphology, binary morphology, reconstruction, regional extrema, distance map, Gaussian, component and watershed) define them and instantiate each type set once.src/Plugins/NXImageProcessing/src/NXImageProcessing/utils/ImageFilterTemplateExecutors.hppkeeps the 7 executors whose template arguments change with the caller (point-wise, two-pass, box-neighborhood, contour, histogram, axis projection and finite-difference) as header templates.src/Plugins/NXImageProcessing/src/NXImageProcessing/utils/ImageFilterExecutorDetail.hppholds the helpers that more than one family or a test uses.Each filter includes only the executor header that it calls. Helpers that only one family uses stay in that family's source file with internal linkage.
2. Shared header reduced to preflight code
src/simplnx/Utilities/ImageProcessing/ImageProcessingFilterUtilities.hpp(5,891 → 770 lines) keeps only the type-set policies, the input checks, the preflight helpers andSaturateCastFromDouble. It no longer includes engine headers.src/simplnx/Utilities/ImageProcessing/ImageProcessingOperationTypes.hppholdsMorphOp,ObjectMorphOp,ReconstructOpandRegionalExtremaOp. The engine headers include it, so their users see the same enums.Only NXImageProcessing sources include
ImageProcessingFilterUtilities.hpp, so no other plugin needs a change. The unusedStreamBinaryThresholdhelper is removed.3. Export check
src/Plugins/NXImageProcessing/test/ImageFilterExecutorsLinkTest.cpptakes the address of each of the 30 exported executors through avolatilepointer. A missing export macro then fails the link ofNXImageProcessingUnitTeston every platform, also on Windows, where a missing__declspec(dllexport)would otherwise only show in a caller outside the plugin.Measured effect
Serial compile CPU time for each object, macOS arm64, AppleClang 21, Release:
NXImageProcessingUnitTestobjects: no significant change.This is about 4–5% of the compile work of a full simplnx and DREAM3D-NX build.
Test plan
SIMPLNX_TEST_ALGORITHM_PATH=0: full build passes; all 1117ctest -R ImageProcessingtests pass.ctest -R ImageProcessingtests pass.ctest -R ImageProcessingtests pass. The link test confirms that all 30 executors are exported.NXImageProcessing_test_profile_isolationfails on that machine only because its build folder path is longer than the 260-character Windows path limit; the test does not use the changed code, and it passes on macOS and Linux.ctest -R ImageProcessingtests pass.Related Issue