Skip to main content

quick guide

installation

python3 -m pip install phlop -U

cmake test runner for cmake project with 20 cores

python3 -m phlop.run.test_cases -c 20 -i build --cmake

keeping the CPU cool

A command paused while the CPU is too hot (psutil's sensor, linux): every process of it, MPI ranks and their helpers included, stopped at --high and continued at --low (C):

python3 -m phlop.app.thermal --high 88 --low 78 -- make -j 16

The test runner holds back new jobs while hot (running ones go on): PHLOP_THERMAL_MAX=88 (and PHLOP_THERMAL_RESUME, default 10 below it).

etc

python3 -m phlop
Available:
    phlop.app
    phlop.os
    phlop.proc
    phlop.reflection
    phlop.run
    phlop.string
    phlop.testing
python3 -m phlop.run
Available:
    phlop.run.mpirun_stats_man -h
    phlop.run.perf -h
    phlop.run.stats_man -h
    phlop.run.test_cases -h
    phlop.run.valgrind -h
    phlop.run.mpi_valgrind -h
    phlop.run.nsys -h
    phlop.run.mpi_nsys -h
    phlop.run.csan -h
    phlop.run.mpi_csan -h
    phlop.run.ncu -h
    phlop.run.mpi_ncu -h
# valgrind with a short answer, files kept under .phlop/valgrind
python3 -m phlop.run.valgrind ./app args            # memcheck: errors and leaks, where
python3 -m phlop.run.valgrind -t massif ./app args  # heap peak, and what holds it
python3 -m phlop.run.valgrind --show --md -         # the latest run again, as markdown
python3 -m phlop.run.valgrind --compare RUN1 RUN2 --plot cmp.png  # eg master vs a branch
mpirun -n 4 python3 -m phlop.run.mpi_valgrind -t massif ./app  # per rank, one report
# Nsight Systems with a short answer, files kept under .phlop/nsys: where GPU time
#  goes, GPU idle gaps and the NVTX range they fall in, pageable copies, exposed
#  NCCL, then hints
python3 -m phlop.run.nsys ./app args
python3 -m phlop.run.nsys -t cuda,nvtx,osrt,cublas ./app   # nsys --trace
python3 -m phlop.run.nsys --show job.nsys-rep --md -       # a profile from a cluster
python3 -m phlop.run.nsys --compare RUN1 RUN2              # eg master vs a branch
mpirun -n 4 python3 -m phlop.run.mpi_nsys ./app  # per rank, MPI traced: the straggler
srun python3 -m phlop.run.mpi_nsys ./app         #  and how long the others wait for it
# compute-sanitizer, grouped: the same error from 10000 threads is one line, with
#  the kernel's source line, an example thread and the host caller. Exit code 99
#  on errors. Build with -lineinfo (device lines) and -g (host lines)
python3 -m phlop.run.csan ./app args                 # memcheck, with leaks
python3 -m phlop.run.csan -t racecheck ./app         # or initcheck, synccheck
mpirun -n 4 python3 -m phlop.run.mpi_csan ./app      # each error once, with its ranks
# Nsight Compute, per kernel: what bounds it (compute, memory and which level,
#  or latency), occupancy, coalescing, the main warp stall, then hints: phlop's
#  and ncu's own rules ranked by estimated speedup. Each distinct launch is
#  profiled once, but ~30 replays each: the desktop may stall on a display GPU
python3 -m phlop.run.ncu ./app args
python3 -m phlop.run.ncu -k 'gemm|axpy' -c 3 ./app   # kernel regex, launches each
python3 -m phlop.run.ncu --show job.ncu-rep --md -   # a report from a cluster
python3 -m phlop.run.ncu --compare RUN1 RUN2         # eg master vs a branch
mpirun -n 4 python3 -m phlop.run.mpi_ncu -k work ./app  # kernels slower on one rank
# ERR_NVGPUCTRPERM: options nvidia NVreg_RestrictProfilingToAdminUsers=0 in
#  /etc/modprobe.d, reboot
# hardware counter analysis via libpfm event sets (./sh/setup_pfm.sh first)
python3 -m phlop.app.pfm.stat --list
python3 -m phlop.app.pfm.stat -s topdown,vector,flops -- ./app args
# unprivileged counting needs kernel.perf_event_paranoid <= 2, warnings say how
# per kernel registers, stack, shared and local memory from a built binary (no
#  GPU needed), and the largest block size each kernel can launch with
python3 -m phlop.app.nvidia.cuobjdump bin/app
python3 -m phlop.app.nvidia.cuobjdump -t 512 bin/app            # kernels that can't launch 512
python3 -m phlop.app.nvidia.cuobjdump dbg=bin/a rel=bin/b       # compare builds
// four timers, one source to link: src/phlop/timing/scope_timer.cpp
//   phlop::              serial                 scope_timer.hpp
//   phlop::para::        multithread capable    para_scope_timer.hpp
//   phlop::mpi::         serial, MPI_Wtime      mpi_scope_timer.hpp
//   phlop::mpi::para::   multithread, MPI_Wtime mpi_para_scope_timer.hpp
// the header picks which one PHLOP_SCOPE records into, eg phlop::para::scope_timer().init()
// per scope hardware counters in all of them. para: each thread counts only itself,
//  opening its counters on first use
PHLOP_SCOPE("solve", time, perf_all);   // time + PHLOP_PERF_ALL events
PHLOP_SCOPE("step", time, perf_light);  // time + PHLOP_PERF_LIGHT events
PHLOP_SCOPE("io");                      // PHLOP_SCOPE_DEFAULT, time
// the calling thread's I/O over the scope, /proc/thread-self/io (linux), when
// enabled: phlop::scope_timer().io() or PHLOP_SCOPE_IO=1. Bytes and calls through
// read/write, bytes to/from the block layer, shown by: scope_timer times <file>
PHLOP_SCOPE("h5_write", time, io);
// mpi_scope_timer.hpp: scopes on one thread per rank, PHLOP_SCOPE_MEM=peak per scope
// mpi_para_scope_timer.hpp: scopes on several threads per rank (opt in), phlop::mpi::para::
//  sync_clock() and scope_timer(). No per scope peaks: PHLOP_SCOPE_MEM=peak is =1
// MPI_Wtime may differ per rank, a barrier gives a common point
MPI_Init(&argc, &argv);
phlop::mpi::sync_clock();  // collective, after MPI_Init
// ... run ...
phlop::mpi::sync_clock();  // before MPI_Finalize: corrects drift between the two
// variance across ranks then compares starts from the sync, not each rank's first scope:
// python3 -m phlop.timing.scope_timer variance 'phlop_scope_timers.*.bin'
# -DPHLOP_NVTX: every PHLOP_SCOPE / PHLOP_SCOPE_TIMER is also an NVTX range in domain
#  "phlop", so scopes show on the Nsight Systems timeline next to their kernels
g++ -DPHLOP_NVTX -I/usr/local/cuda/include ... -ldl   # nvtx3 is header only
nsys profile --trace=cuda,nvtx ./app
ncu --nvtx --nvtx-include "phlop@step/" ./app         # only kernels inside scope "step"
# choose the event sets per level, then run as usual
eval "$(python3 -m phlop.app.pfm.stat --env perf_light=light --env perf_all=topdown)"
./app  # writes counts into the scope timer file, read with:
python3 -m phlop.timing.scope_timer perf .phlop_scope_times.txt -v  # scope_timer.hpp
python3 -m phlop.timing.scope_timer perf .phlop_para_scope_times.txt -v  # para, same format
# opt in: count kernel space too (eg I/O scopes), needs perf_event_paranoid <= 1
eval "$(python3 -m phlop.app.pfm.stat --env perf_light=light --kernel)"
python3 -m phlop.run.test_cases -h
usage: test_cases.py [-h] [--cmake] [-c CORES] [-i INPUT] [-p] [--prefix PREFIX] [--postfix POSTFIX] [--dump DUMP] [--load LOAD] [-r REGEX] [-R] [--rerun RERUN] [--logging LOGGING]

Flexible parallel test runner

options:
  -h, --help            show this help message and exit
  --cmake               Enable cmake build config tests extraction (default: False)
  -c CORES, --cores CORES
                        Parallism core/thread count (default: 1)
  -i INPUT, --input INPUT
                        Input file or directory. (default: .)
  -p, --print_only      Print only, no execution (default: False)
  --prefix PREFIX       Prepend string to execution string (default: )
  --postfix POSTFIX     Append string to execution string (default: )
  --dump DUMP           Dump discovered tests to filepath (hex-encoded dill pickle), no execution (default: None)
  --load LOAD           globbing filepath for files exported from dump (default: None)
  -r REGEX, --regex REGEX
                        Filter out non-matching execution strings (default: None)
  -R, --reverse         reverse order - higher core count tests preferred (default: False)
  --rerun RERUN         number of times to re-execute discovered tests (default: 1)
  --logging LOGGING     0=off, 1=on non zero exit code, 2=always (default: 1)

Metadata

Release files for phlop 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for phlop 0.1.1
File Size Uploaded Provenance Actions
phlop-0.1.1.tar.gz 168.7 kB Without provenance Details for phlop-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for phlop 0.1.1
File Interpreter ABI Platform Actions
phlop-0.1.1-py3-none-any.whl Python 3 none any Details for phlop-0.1.1-py3-none-any.whl

Total release size: 370.2 kB

Release files / phlop-0.1.1.tar.gz

Download URL phlop-0.1.1.tar.gz
Size 168.7 kB
Tags Source
SHA-256 checksum
How to use checksums
660e967e99b9c224a0594882541a618799829d66e04bab37e3c75109be0db070
BLAKE2b-256 checksum
How to use checksums
2b023aaf5dbeac1e1bbc97f5e4bfc9dd7d8f24216d63270728e48dfdb9e84be6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / phlop-0.1.1-py3-none-any.whl

Download URL phlop-0.1.1-py3-none-any.whl
Size 201.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c87dd22c146ba400fc18f95756a1230b4950a81c2ff12a5867cd2c77975c98e
BLAKE2b-256 checksum
How to use checksums
75c765a1b963e9f0833eda951f1c5032742e81101a4f141aa2454558e7514317
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for phlop 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page