Benchmark infrastructure for APIs ported to the execution backend
The purpose of this PR is to create (some initial vision of) benchmarking infrastructure that is flexible enough to test arbitrary execution:: code. This should help us quantify performance improvements as we port existing portions of the codebase to use execution::. We discussed comparing performance across different execution policies, scaling to different data sizes and data types, and measuring data transfer overhead (host <--> device vs. same <--> same).
Currently has:
- Benchmark infra that iterates over code to be benchmarked for all possible configs of host <--> device.
- Mesh transform (coordset conversion) benchmarks.
- Changes to enable
conduit_blueprint_mesh.cppto be built as a CUDA/HIP TU. - Caliper outputs using the hatchet profile (allowing it to be consumed by hatchet or thicket).
Still need to do:
- ~Add support for iteratively ramping up data sizes. We want to understand how the algorithms perform at varying input sizes ranging from very small to very large.~
- ~Validate that all of the caliper annotations are in correct places. There doesn't seem to be a need to produce multiple .cali files per Cyrus.~
- ~I discovered that the changes to
conduit_blueprint_mesh.cppfor GPU TU compilation only make NVCC happy, but HIP still has compilation errors. Those will need to be fixed.~ - ~Create a python script for making scaling plots out of these .cali files. It can live next to the other test files per Cyrus. Ascent has a python script like this that gets called automatically via cmake, so that could perhaps give some inspiration.~
Mark brought up a good point during today's Visit meeting: are we interested in getting benchmark data for the APIs as they existed before they were ported to the execution model (to compare old vs new)?
After discussing this, it sounds like yes, we want to try to get this working.
At this point:
- The benchmarking code seems to work well and has most (if not all) of the features implemented that we've discussed. Of course, it may need refinement as we create new benchmarks and have to accommodate their differences.
- Fixes are in place to get both CUDA/HIP compiling
conduit_blueprint_mesh.cppas a TU. This was done so that we could properly perform host vs device benchmarking, and I've been able to collect/plot host vs device results from both matrix and tuolumne. - I've included a python script to get us started on plotting the benchmark data that this produces (AI did most of the work but I reviewed it and refined it).
What seems to remain:
- Get feedback about how the plots look. Get feedback about what other types of plots would be useful to have. Improve the plotting script based on that feedback.
- Do more empirical testing to see what good defaults should be for warmup iterations, benchmark iterations, and data sizes that we iterate over.
- Address feedback about the PR itself.
I took a pass at porting the topology conversions to the execution model in #1640. It depends on this PR, which I only mention because it should give you a rough idea for how future API ports + benchmarks would look using the current infra.
The ascent team gave me verbal feedback with respect to improving the plots, so I'll be making some changes to address their feedback.
Not related to this PR (probably), but there's currently a big discrepancy between CUDA and HIP performance. We came to the conclusion that it would help to print some basic system information, e.g. the number of GPUs and OpenMP threads being used in a run, to help assure us that the comparisons are apples to apples.
I've updated the plots based on feedback:
- Changes to make it easier to see trends/reduce overlapping lines.
- More plot variants (e.g. device only, host only).
- The number of openmp threads is now included in the caliper output (if built with openmp), and the plots now include that number if available.
#include "conduit_execution.hpp"
#include "conduit_blueprint_mesh_examples.hpp"
using namespace conduit;
static void copy_numeric_arrays_to_device(const Node &src,
Node &dst,
index_t device_alloc)
{
if(src.dtype().is_object())
{
NodeConstIterator itr = src.children();
while(itr.has_next())
{
const Node &src_child = itr.next();
copy_numeric_arrays_to_device(src_child, dst[itr.name()], device_alloc);
}
}
else if(src.dtype().is_list())
{
NodeConstIterator itr = src.children();
while(itr.has_next())
{
const Node &src_child = itr.next();
copy_numeric_arrays_to_device(src_child, dst.append(), device_alloc);
}
}
else if(src.dtype().is_number() && src.dtype().number_of_elements() > 1)
{
dst.set_allocator(device_alloc);
dst.set(src); // requires a device-aware memcpy handler
}
else
{
dst.set(src); // keep strings, dims, small metadata on host
}
}
Node braid_host;
blueprint::mesh::examples::braid("hexs", 32, 32, 32, braid_host);
Node braid_dev;
copy_numeric_arrays_to_device(braid_host,
braid_dev,
execution::get_device_allocator_id());