Files
TheRock/rocm-systems/projects/rocprofiler-systems/external/timemory/examples/ex-gotcha
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00
..

ex-gotcha

These examples demonstrate the use of GOTCHA wrappers by wrapping puts and MPI routines and then instrumenting them using timemory. The ex-gotcha-replacement demonstrates an example of replacing the STDLIB's exp function with a gotcha wrapped expf function.

Build

See examples. Further, these examples require timemory MPI and GOTCHA support to be enabled by enabling -DTIMEMORY_USE_GOTCHA=ON and -DTIMEMORY_USE_MPI=ON flags in timemory cmake build.

Expected Output

$ ./ex_gotcha
#------------------------- tim::manager initialized [id=0][pid=9347] -------------------------#

put gotcha is available: true
mpi gotcha is available: true

size = 1
rank = 0
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   511.47
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   510.71
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   499.13
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   511.18
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   501.40
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   487.90
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   507.49
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   511.22
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   512.39
Testing puts gotcha wraper...

[iterations=15]>      single-precision exp = 1915398520832.000000
[iterations=15]>      double-precision exp = 1915398474579.756592

[0]> sum =   511.55
[peak_rss]|0> Outputting 'timemory-ex-gotcha-output/peak_rss.json'...
[peak_rss]|0> Outputting 'timemory-ex-gotcha-output/peak_rss.txt'...
Opening 'timemory-ex-gotcha-output/peak_rss.jpeg' for output...
Closed 'timemory-ex-gotcha-output/peak_rss.jpeg'...

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                           MEASURES CHANGES IN THE HIGH-WATER MARK FOR THE AMOUNT OF MEMORY ALLOCATED IN RAM. MAY FLUCTUATE IF SWAP IS ENABLED                         |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|               LABEL                 |   COUNT    |   DEPTH    |   METRIC   |   UNITS    |    SUM     |    MEAN    |    MIN     |    MAX     |   STDDEV   |   % SELF   |
|-------------------------------------|------------|------------|------------|------------|------------|------------|------------|------------|------------|------------|
| >>> ./ex_gotcha                     |         10 |          0 | peak_rss   | KB         | 356.000000 |  35.600000 |   0.000000 | 356.000000 | 112.577085 |      100.0 |
| >>> |_Testing puts gotcha wraper... |         10 |          1 | peak_rss   | KB         |   0.000000 |   0.000000 |   0.000000 |   0.000000 |   0.000000 |        0.0 |
| >>> |_MPI_Barrier                   |         20 |          1 | peak_rss   | KB         |   0.000000 |   0.000000 |   0.000000 |   0.000000 |   0.000000 |        0.0 |
| >>> |_MPI_Allreduce                 |         10 |          1 | peak_rss   | KB         |   0.000000 |   0.000000 |   0.000000 |   0.000000 |   0.000000 |        0.0 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|

[cpu]|0> Outputting 'timemory-ex-gotcha-output/cpu.flamegraph.json'...
[cpu]|0> Outputting 'timemory-ex-gotcha-output/cpu.json'...
[cpu]|0> Outputting 'timemory-ex-gotcha-output/cpu.txt'...
Opening 'timemory-ex-gotcha-output/cpu.jpeg' for output...
Closed 'timemory-ex-gotcha-output/cpu.jpeg'...

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                           TOTAL CPU TIME SPENT IN BOTH USER- AND KERNEL-MODE                                                          |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|               LABEL                 |   COUNT    |   DEPTH    |   METRIC   |   UNITS    |    SUM     |    MEAN    |    MIN     |    MAX     |   STDDEV   |   % SELF   |
|-------------------------------------|------------|------------|------------|------------|------------|------------|------------|------------|------------|------------|
| >>> ./ex_gotcha                     |         10 |          0 | cpu        | msec       |  10.000000 |   1.000000 |   0.000000 |  10.000000 |   3.162278 |      100.0 |
| >>> |_Testing puts gotcha wraper... |         10 |          1 | cpu        | msec       |   0.000000 |   0.000000 |   0.000000 |   0.000000 |   0.000000 |        0.0 |
| >>> |_MPI_Barrier                   |         20 |          1 | cpu        | msec       |   0.000000 |   0.000000 |   0.000000 |   0.000000 |   0.000000 |        0.0 |
| >>> |_MPI_Allreduce                 |         10 |          1 | cpu        | msec       |   0.000000 |   0.000000 |   0.000000 |   0.000000 |   0.000000 |        0.0 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|

[wall]|0> Outputting 'timemory-ex-gotcha-output/wall.flamegraph.json'...
[wall]|0> Outputting 'timemory-ex-gotcha-output/wall.json'...
[wall]|0> Outputting 'timemory-ex-gotcha-output/wall.txt'...
Opening 'timemory-ex-gotcha-output/wall.jpeg' for output...
Closed 'timemory-ex-gotcha-output/wall.jpeg'...

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                REAL-CLOCK TIMER (I.E. WALL-CLOCK TIMER)                                                                |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|               LABEL                 |   COUNT    |   DEPTH    |   METRIC   |   UNITS    |    SUM      |    MEAN    |    MIN     |    MAX     |   STDDEV   |   % SELF   |
|-------------------------------------|------------|------------|------------|------------|-------------|------------|------------|------------|------------|------------|
| >>> ./ex_gotcha                     |         10 |          0 | wall       | msec       | 5006.735103 | 500.673510 | 500.343106 | 503.562931 |   1.015317 |      100.0 |
| >>> |_Testing puts gotcha wraper... |         10 |          1 | wall       | msec       |    0.150961 |   0.015096 |   0.014567 |   0.016830 |   0.000715 |      100.0 |
| >>> |_MPI_Barrier                   |         20 |          1 | wall       | msec       |    0.097922 |   0.004896 |   0.002705 |   0.008961 |   0.001192 |      100.0 |
| >>> |_MPI_Allreduce                 |         10 |          1 | wall       | msec       |    0.179468 |   0.017947 |   0.014507 |   0.042923 |   0.008874 |      100.0 |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|


[metadata::manager::finalize]> Outputting 'timemory-ex-gotcha-output/metadata.json'...


#---------------------- tim::manager destroyed [rank=0][id=0][pid=9347] ----------------------#