bench: rewrite latency perf test into a ping-pong (backend-generic support)#242
bench: rewrite latency perf test into a ping-pong (backend-generic support)#242dssgabriel wants to merge 2 commits into
Conversation
|
@nicoleavans This is the PR with the backend-agnostic OSU lat implementation. For some reason, I cannot add you as a reviewer 🤷♂️ And here are the results we've obtained on a GH200 + Bull eXascale Interconnect v2 (BXI) system:
|
bb2cb9d to
c26ca59
Compare
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
c26ca59 to
c81b0fd
Compare
cedricchevalier19
left a comment
There was a problem hiding this comment.
Looks ok, just a few comments.
|
|
||
| using DES = Kokkos::DefaultExecutionSpace; | ||
| #ifdef KOKKOSCOMM_ENABLE_NCCL | ||
| // If NCCL is enabled, then `KOKKOS_ENABLE_CUDA` must be defined. |
There was a problem hiding this comment.
You can add a check or change must be by is.
| BENCHMARK(bench_KC_MpiSpace)->UseManualTime()->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); | ||
| BENCHMARK(bench_KC_mpi)->UseManualTime()->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); | ||
| BENCHMARK(bench_MPI)->UseManualTime()->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); | ||
| BENCHMARK(bench_MPI_nb)->UseManualTime()->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); | ||
| #ifdef KOKKOSCOMM_ENABLE_NCCL | ||
| BENCHMARK(bench_KC_NcclSpace)->UseManualTime()->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); | ||
| BENCHMARK(bench_KC_nccl)->UseManualTime()->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); | ||
| BENCHMARK(bench_NCCL)->UseManualTime()->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); |
There was a problem hiding this comment.
Can we group a little bit the post treatment?
->Unit(benchmark::kMicrosecond)->RangeMultiplier(8)->Range(1, 1 << 28); is quite heavy to read.
There was a problem hiding this comment.
I agree, will look into how we can achieve this.
Alternatively, we may consider porting all our test/benchmark infrastructure to a more modern framework, such as Catch2. We definitely need to rethink how we validate multi-rank tests anyway.
| FetchContent_Declare( | ||
| fmt | ||
| GIT_REPOSITORY https://github.com/fmtlib/fmt.git | ||
| GIT_TAG | ||
| 407c905e45ad75fc29bf0f9bb7c5c2fd3475976f #v12.1.0 | ||
| ) | ||
| FetchContent_MakeAvailable(fmt) |
There was a problem hiding this comment.
I am not a huge fan of using FetchContent. Can we test if it is available locally or can we avoid making it mandatory ?
|
|
||
| double max_elapsed_second; | ||
| double elapsed_seconds = elapsed.count(); | ||
| MPI_Allreduce(&elapsed_seconds, &max_elapsed_second, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); |
There was a problem hiding this comment.
Ideally can we keep all ? Or can we at least compute the average too ?
There was a problem hiding this comment.
Not sure if we can keep all (I don't know if it's possible to attach an array of results to the custom counters), but we can certainly compute the average (as well as min, median, stddev, etc.).
Note that the average isn't necessarily meaningful here, since it is the average latency of all ranks. I had tried to report all these metrics at some point, but the results varied so much across ranks that I didn't see the point in keeping them, so I reverted everything back to how it is here.
|
Thanks for the review @cedricchevalier19. I think this still needs quite a bit of work before we can merge it into Kokkos Comm, and I am not sure the "OSU latency" naming fits. |
4b8bd79 to
175faf4
Compare
Signed-off-by: Gabriel Dos Santos <gabriel.dossantos@cea.fr>
175faf4 to
9ed7be1
Compare
|
Commands to run config/build/run this benchmark: # Load dependencies via `module` or `spack`
spack load cmake cuda mpi nccl
# Fetch + configure + build + install Kokkos (if not available on your machine, else load via module/spack directly)
export KOKKOS_VERSION=5.1.1
export KOKKOS_DOWNLOAD_URL=https://github.com/kokkos/kokkos/releases/download/${KOKKOS_VERSION}
mkdir -p _deps && cd _deps && curl -sLO ${KOKKOS_DOWNLOAD_URL}/kokkos-${KOKKOS_VERSION}.tar.gz && cd ..
tar xzf _deps/kokkos-${KOKKOS_VERSION}.tar.gz -C _deps/
cmake -S _deps/kokkos-${KOKKOS_VERSION} -B _deps/kokkos-${KOKKOS_VERSION}-build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-mcpu=native" -DKokkos_ENABLE_CUDA=ON -DKokkos_ARCH_<SYSTEM_ARCH>=ON
cmake --build _deps/kokkos-${KOKKOS_VERSION}-build -j
cmake --install _deps/kokkos-${KOKKOS_VERSION}-build --prefix _deps/kokkos-${KOKKOS_VERSION}-install
# Configure Kokkos Comm with just-installed Kokkos
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-mcpu=native" -DCMAKE_CXX_COMPILER="$(pwd)/_deps/kokkos-${KOKKOS_VERSION}/bin/nvcc_wrapper" -DKokkos_ROOT="$(pwd)/_deps/kokkos-${KOKKOS_VERSION}-install" -DKokkosComm_ENABLE_NCCL=ON -DKokkosComm_ENABLE_PERFTESTS=ON
# Build
cmake --build build --target bench.core.latency -j
# Run the benchmark (via ctest)
ctest --test-dir build -R bench.core.latency
# (or manually)
mpirun -n 2 build/perf_tests/bench.core.latency
# (or via a job scheduler for internode/intranode; here assuming GH200 core counts to see the GPUs correctly)
srun -p <PARTITION> -N2 -n2 -c72 build/perf_tests/bench.core.latency
srun -p <PARTITION> -N1 -n2 -c144 build/perf_tests/bench.core.latency |
| auto s_req = KC::send(comm, sv, 1); | ||
| auto r_req = KC::recv(comm, rv, 1); | ||
| s_req.wait(); | ||
| r_req.wait(); | ||
| } else { | ||
| auto r_req = KC::recv(comm, rv, 0); | ||
| // Actually wait for the ping reception before sending the pong | ||
| r_req.wait(); | ||
| auto s_req = KC::send(comm, sv, 0); | ||
| s_req.wait(); |
There was a problem hiding this comment.
Perhaps we should add another comm to measure a ping from 1 :
sequenceDiagram
0->>1: send1
activate 0
1->>0: send2
deactivate 0
activate 1
0->>1: send 3
deactivate 1
We time the grey boxes.
There was a problem hiding this comment.
Good idea. How do we report that, though? Currently, only rank 0 writes the results (hence we reported "iteration" time as the max on all ranks).


Description
This PR is a first draft of a backend-generic ping-pong latency benchmark for Kokkos Comm, fixing #244.
It replaces
bench.mpi.osu_latencywith a newbench.core.latencyperf test that compares the Kokkos Comm APIs against direct backend calls (both MPI and NCCL).One important difference from the existing MPI-only implementation in
perf_tests/mpi/test_osu_latency.cppis that this version measures a true ping-pong: rank 0 sends to rank 1, then receives the response. The existing MPI benchmark measured only one-way latency.Changes
List:
perf_tests/bench_latency.cpp.do_iterationhelper inperf_tests/utils.hppwithhigh_resolution_clockinstead ofsteady_clock, and removeMPI_Commparam.perf_tests/CMakeLists.txtasbench.core.latency.kc_add_perf_testso core perf tests can link the same Kokkos Comm/MPI/NCCL support used by core unit tests (ugly but avoids duplicating NCCL init logic across unit and perf tests).Checklist