-
Notifications
You must be signed in to change notification settings - Fork 11
Add a timer plugin #652
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
Open
Yushan-Wang
wants to merge
71
commits into
pdidev:main
Choose a base branch
from
Yushan-Wang:add-a-timer-report
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add a timer plugin #652
Changes from 57 commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
c552fb4
first step to compile
Yushan-Wang b39862f
Merge branch 'main' into add-a-timer-report
Yushan-Wang d0f3540
add a timer class
Yushan-Wang 925f489
add timer for pdi init and finalize
Yushan-Wang f64e41f
add timer option in cmake
Yushan-Wang 2771711
add timer for hdf5
Yushan-Wang 01c5e3f
add timer for netcdf
Yushan-Wang b532a08
add timer for json
Yushan-Wang e6be2ed
add timer for serialize
Yushan-Wang a72d07d
add timer for user_code
Yushan-Wang a4eda90
Merge branch 'main' into add-a-timer-report
Yushan-Wang fdbfc18
revert non-relevant change
Yushan-Wang bef38f9
revert non-relevant change
Yushan-Wang b7f00e2
revert non-relevant change
Yushan-Wang 194aeec
revert non-relevant change
Yushan-Wang 0e08740
fix indent
Yushan-Wang 9d19822
output cleanup
Yushan-Wang 5f843fe
add example yaml for timing multiple plugins.
Yushan-Wang cfc462d
add timer for pycall
Yushan-Wang e851c0c
indent
Yushan-Wang 141647e
fix copyright date
Yushan-Wang a7fc397
update changelog
Yushan-Wang ee0508b
make timer inside the context
Yushan-Wang 28e3bbc
update mock
Yushan-Wang 261c89e
fix indent
Yushan-Wang f69fc66
indent
Yushan-Wang 89f658c
remove old calls
Yushan-Wang e2c23d1
reactive unit tests
Yushan-Wang b82a3fb
Remove Apple-specific link options from CMakeLists
Yushan-Wang a543aa5
Remove Apple-specific link options from CMakeLists
Yushan-Wang 12ac8da
update changelog
Yushan-Wang f0f13dd
update copyright end date
Yushan-Wang b89a412
Merge branch 'add-a-timer-report' of https://github.com/Yushan-Wang/p…
Yushan-Wang 8875860
Add optional yaml config member to enable timer, and add an integrati…
JAuriac 04d73e3
rename example.yml to timer.yml
Yushan-Wang f3b62fa
code cleanup based on review notes
Yushan-Wang a6d2617
code cleanup [skip ci]
Yushan-Wang 6b8b829
Modify HDF5 configuration in CMakeLists.txt
Yushan-Wang 1717266
variable rename
Yushan-Wang fe20d6d
Merge branch 'add-a-timer-report' of https://github.com/Yushan-Wang/p…
Yushan-Wang 11da4ee
better check for calling timer
Yushan-Wang 5fe23ae
Merge branch 'main' into add-a-timer-report
Yushan-Wang 63f0ca7
implement timer as plugin
Yushan-Wang 50918db
Merge branch 'main' into add-a-timer-report
Yushan-Wang 5085017
implement timer as a plugin
Yushan-Wang 6378e6d
update
Yushan-Wang 0c9c4c7
remove unchanged files
Yushan-Wang 23094af
[skip ci]
Yushan-Wang 699a076
[skip ci]
Yushan-Wang 19cdfd1
update test
Yushan-Wang c90aa64
Merge branch 'main' into add-a-timer-report
Yushan-Wang 52c23ad
indent
Yushan-Wang a71a8ec
update readme [skip ci]
Yushan-Wang 920f9e7
check if both start and stop are provided
Yushan-Wang ba661f7
[skip ci]
Yushan-Wang 2ba83dd
include order
Yushan-Wang d7c01e8
[skip ci]
Yushan-Wang 6ef0b71
code refactor
Yushan-Wang b9965e6
update upon review
Yushan-Wang 371c94a
refactor timer_plugin to use context directly and improve logging
Yushan-Wang c7c7c9b
Remove 'timer' flag from timer.yml
Yushan-Wang 6950225
[skip ci]
Yushan-Wang cf64d65
Update timer plugin readme and remove unnecessary indent step
Yushan-Wang ab305f9
Apply suggestions from code review
Yushan-Wang 0606135
[skip ci]
Yushan-Wang 463bfc4
Merge branch 'add-a-timer-report' of https://github.com/Yushan-Wang/p…
Yushan-Wang b17327d
Fix target_compile_features placement for timer_test in CMakeLists.txt
Yushan-Wang aebc9f7
Add timer plugin support and update related configurations
Yushan-Wang bf5a8cd
Update copyright year in decl_hdf5.cxx
Yushan-Wang a04dadb
Update timer test conditions to include NETCDF_PARALLEL requirement
Yushan-Wang 90a858c
Merge branch 'add-a-timer-report' of https://github.com/Yushan-Wang/p…
Yushan-Wang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Yushan-Wang marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # duration in seconds | ||
| duration: 0.75 | ||
| # global [height, width] (excluding boundary conditions or ghosts) | ||
| datasize: [60, 12] | ||
| # degree of parallelism | ||
| parallelism: { height: 3, width: 1 } | ||
|
|
||
| # only the following config is passed to PDI | ||
| pdi: | ||
| metadata: # type of small values for which PDI keeps a copy | ||
| iter: int # current iteration id | ||
| dsize: { size: 2, type: array, subtype: int } # local data size including ghosts/boundary | ||
| psize: { size: 2, type: array, subtype: int } # number of processes in each dimension | ||
| pcoord: { size: 2, type: array, subtype: int } # coordinate of the process | ||
| data: # type of values for which PDI does not keep a copy | ||
| main_field: { size: [ '$dsize[0]', '$dsize[1]' ], type: array, subtype: double } | ||
| timer: true | ||
|
Yushan-Wang marked this conversation as resolved.
Outdated
|
||
| plugins: | ||
| trace: debug | ||
| timer: | ||
| - timer_h5: "decl_hdf5" | ||
| - timer_nc: | ||
| start: "decl_netcdf_start_timer" | ||
| stop: "decl_netcdf_stop_timer" | ||
| - timer_python: [pycall, user_code] | ||
| - timer_json: {start: "json_start_timer", stop: "json_stop_timer"} | ||
| - timer_pdi: "pdi" | ||
| mpi: | ||
| decl_hdf5: | ||
| file: data.h5 | ||
| communicator: $MPI_COMM_WORLD # the MPI communicator used for HDF5 parallel synchronized write | ||
| datasets: # type of the datasets to create in file | ||
| data: | ||
| type: array | ||
| subtype: double | ||
| size: [10, '$psize[0]*($dsize[0]-2)', '$psize[1]*($dsize[1]-2)'] | ||
| write: | ||
| main_field: # the name of the data to write | ||
| dataset: data | ||
| mpio: COLLECTIVE # or INDEPENDENT | ||
| when: '$iter<10' # do only write the first 10 iterations (0...9) | ||
| memory_selection: # exclude ghosts from the data in memory | ||
| size: ['$dsize[0]-2', '$dsize[1]-2'] | ||
| start: [1, 1] | ||
| dataset_selection: # only write into a single slice in time | ||
| size: [1, '$dsize[0]-2', '$dsize[1]-2'] | ||
| start: [$iter, '($dsize[0]-2)*$pcoord[0]', '($dsize[1]-2)*$pcoord[1]'] | ||
| decl_netcdf: | ||
| file: data.nc | ||
| communicator: $MPI_COMM_WORLD # the MPI communicator used for HDF5 parallel synchronized write | ||
| variables: # type of the datasets to create in file | ||
| v_data: | ||
| type: array | ||
| subtype: double | ||
| size: [10, '$psize[0]*$dsize[0]', '$psize[1]*$dsize[1]'] | ||
| write: | ||
| main_field: # the name of the data to write | ||
| variable: v_data | ||
| when: '$iter<10' # do only write the first 10 iterations (0...9) | ||
| variable_selection: # only write into a single slice in time | ||
| subsize: [1, '$dsize[0]', '$dsize[1]'] | ||
| start: [$iter, '$dsize[0]*$pcoord[0]', '$dsize[1]*$pcoord[1]'] | ||
| json: | ||
| file: data_${pcoord[0]}_${pcoord[1]}.json | ||
| when: '$iter<10' | ||
| write: [main_field] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #============================================================================= | ||
| # Copyright (C) 2026 Commissariat a l'energie atomique et aux energies alternatives (CEA) | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # * Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # * Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # * Neither the name of CEA nor the names of its contributors may be used to | ||
| # endorse or promote products derived from this software without specific | ||
| # prior written permission. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| # THE SOFTWARE. | ||
| #============================================================================= | ||
|
|
||
| cmake_minimum_required(VERSION 3.22...4.2) | ||
| project(pdi_timer_plugin LANGUAGES C CXX) | ||
|
|
||
| # Includes | ||
| include(CTest) | ||
| include(GNUInstallDirs) | ||
|
|
||
| # PDI | ||
| find_package(PDI REQUIRED COMPONENTS plugins) | ||
|
|
||
| # The plugin | ||
| add_library(pdi_timer_plugin MODULE timer.cxx) | ||
| target_link_libraries(pdi_timer_plugin PUBLIC PDI::PDI_plugins ) | ||
|
|
||
| # Installation | ||
| set(INSTALL_PDIPLUGINDIR "${PDI_DEFAULT_PLUGINDIR}" CACHE PATH "PDI plugins (${PDI_DEFAULT_PLUGINDIR})") | ||
| install(TARGETS pdi_timer_plugin | ||
| LIBRARY DESTINATION "${INSTALL_PDIPLUGINDIR}" | ||
| ) | ||
|
|
||
| # Tests | ||
| if("${BUILD_TESTING}") | ||
| add_subdirectory(tests/) | ||
| endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Timer plugin {#timer_plugin} | ||
|
|
||
| The timer plugin allows measuring time spent by PDI and its plugins. | ||
|
|
||
| ## Configuration {#timer_configuration} | ||
|
|
||
| Simple plugin build: | ||
| ```yaml | ||
| plugins: | ||
| timer: | ||
| - timer_A: {start: "decl_hdf5_start_timer", stop: "decl_hdf5_stop_timer"} | ||
| - timer_B: "decl_hdf5" | ||
| - timer_C: [toto, titi] | ||
| - timer_D: | ||
| start: "begin_timing" | ||
| stop: "end_timing" | ||
| ``` | ||
|
|
||
| The timer plugin configuration contains a list of timer names (e.g. `- timer_A`, `- timer_B`, etc). Each timer will record the time spent between the `start` and `stop` events. | ||
|
|
||
| `timer_A` uses a map-styled definition where both keys `start` and `stop` are mandatory. | ||
|
|
||
| `timer_B` uses a scalar-styled definition where only the prefix of the timer events is provided. The prefix can be wither a user-defined name, or the name of the PDI plugins, such as `decl_hdf5`, `decl_netcdf`, `pycall`, etc. If the prefix is the PDI plugin, internal events named with `prefix_start_timer` and `prefix_stop_timer` will be emitted inside the plugin (except `set_value`). In the above example, `timer_B` is equivalent to `timer_A`. | ||
|
Yushan-Wang marked this conversation as resolved.
Outdated
|
||
|
|
||
| `timer_C` uses a list-styled definition where a list of prefix is provided. If the name is not one of the PDI plugins' name, then it is the user's responsibility to emit the `prefix_start_timer` and `prefix_stop_timer` events. In this example, `timer_C` will recored the time spent between `toto_start_timer`, `toto_stop_timer`, and between `titi_start_timer`, `titi_stop_timer`. | ||
|
Yushan-Wang marked this conversation as resolved.
Outdated
|
||
|
|
||
| It is also possible to have different names for start and stop events such as `timer_D`. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #============================================================================= | ||
| # Copyright (C) 2026 Commissariat a l'energie atomique et aux energies alternatives (CEA) | ||
| # All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # * Redistributions of source code must retain the above copyright | ||
| # notice, this list of conditions and the following disclaimer. | ||
| # * Redistributions in binary form must reproduce the above copyright | ||
| # notice, this list of conditions and the following disclaimer in the | ||
| # documentation and/or other materials provided with the distribution. | ||
| # * Neither the name of CEA nor the names of its contributors may be used to | ||
| # endorse or promote products derived from this software without specific | ||
| # prior written permission. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLEq FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| # THE SOFTWARE. | ||
| #============================================================================= | ||
|
|
||
| cmake_minimum_required(VERSION 3.22...4.2) | ||
|
|
||
| set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" PROPERTY TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/TestPath.cmake") | ||
|
|
||
| file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/TestPath.cmake" | ||
| CONTENT " | ||
| set(PDI_PLUGIN_PATH \"\$ENV{PDI_PLUGIN_PATH}\")\n | ||
| if(\"x\${PDI_PLUGIN_PATH}x\" STREQUAL xx)\n | ||
| set(ENV{PDI_PLUGIN_PATH} \"\$<TARGET_FILE_DIR:pdi_timer_plugin>\")\n | ||
| else()\n | ||
| set(ENV{PDI_PLUGIN_PATH} \"\$<TARGET_FILE_DIR:pdi_timer_plugin>:\${PDI_PLUGIN_PATH}\")\n | ||
| endif() | ||
| " | ||
| ) | ||
|
|
||
| find_package(MPI REQUIRED) | ||
|
|
||
| # 3. Set the C++ standard (using the variable from your matrix) | ||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
Yushan-Wang marked this conversation as resolved.
Outdated
|
||
|
|
||
| add_executable(timer_test timer_test.cxx ) | ||
| target_link_libraries(timer_test PDI::PDI_C MPI::MPI_CXX) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.