ANARI Capability Analysis Tool

In this blog post, we’ll introduce a cool performance analysis application that Kitware developed and contributed to the Khronos Group’s ANARI-SDK.

Kitware’s open source projects, VTK, ParaView and trame, are widely used visualization tools in High-Performance Computing (HPC). These tools stand to gain from the advancements brought about by ANARI and its ongoing development. The integration of an ANARI rendering backend within VTK (Kitware Adds ANARI Support to VTK to Simplify Access to Accelerated 3D Rendering Engines) shows how the work invested in this area can substantially enhance the visualization capabilities, leading to improved performance, efficiency, and rendering quality within HPC environments. This ultimately benefits a wide range of scientific and engineering applications that rely on these visualization tools for data analysis and interpretation.

Our primary objective was to equip ANARI implementers with a Capability Analysis Tool (CAT) designed to identify performance bottlenecks and limitations. This tool addresses critical questions that arise during development, such as:

  • Animated Vertices: How does the renderer perform when dealing with vertices that are animated (changing positions over time)?
  • Material Switching: Is the renderer capable of rapidly switching between different materials assigned to objects?
  • Surface Limits: What is the maximum number of surfaces the renderer can handle before experiencing a significant drop in framerate?
  • Structural Changes: Can the renderer efficiently handle frequent updates to the objects within the scene?
  • Instance Rendering: How many instances of a given object can the renderer efficiently process?
  • Latency Stability: Does the renderer maintain stable latency under various workloads and scene complexities?

By generating procedural scenes and systematically varying parameters related to these questions, the CAT provides implementers insights into the performance characteristics and limitations of their ANARI implementations. This information can be used to optimize the renderer, identify areas for improvement, and ensure that the renderer meets the desired performance targets.

Visualization of performance metrics

We took the existing ANARI viewer and added real-time performance metric visualization (using ImPlot). anariCat can be used with a GUI or in a non-interactive mode. This work was recently merged into the next_release branch of the ANARI-SDK repo in KhronosGroup/ANARI-SDK!301

The overlay has been extended to now show new shaded plots that visualize latencies in real time. Additionally, it also displays the min, max and average of all values.

Overlay showing the performance statistics and realtime plots of different latencies
  1. Device: Visualizes the time ANARI device took to render the frame. It corresponds to the duration property on ANARIFrame.
  2. Dropped: This metric indicates if the ANARI renderer is able to keep up with the rate of render requests made by the application.
  3. Present: Plots the time taken by OpenGL pipeline to copy pixels from the ANARI frame into the ImGUI window that provides the user interface.
  4. App: Measures the perceived latency in the interactive application. It includes all internal computations, scene updates, rendering tasks and OS event polling.
  5. UI: Total time consumed to draw the user interface (ImGUI)
  6. Scene update: Total time taken to update a parameter, and commit the scene.
  7. Scene build: Time taken to build a scene and commit parameters to ANARI.

The metrics overlay tracks animated scenes that involve parameter updates with the “Scene Update” metric. On the other hand, scene build times are not plotted because building a scene is a one-time operation.

Procedural scenes

A new perf (for performance) category has been added to the scene selector. This category contains procedurally generated scenes designed to test the capabilities of an ANARI renderer in various ways.

New performance category

The scene dropdown box displays all the scenes that you can pick from. Here are the new scenes:

Dropdown listing scenes in the new performance category

Materials

The scene changes material on a surface by looping through a predetermined set of materials. For instance, the normal property of some materials might employ a texture sampler, whereas others might use a vertex attribute. Likewise, the base color could be determined by a texture sampler, a uniform RGB tuple, a vertex attribute, or a primitive attribute. This applies to all ANARI material properties. A slider can be used to adjust the speed at which materials are changed.

Animation that changes the active material on static geometry

Particles

The particles scene’s objective is to analyze an ANARI renderer’s response to animated vertex positions. The scene simulates near-massless spheres falling along the -Z axis through an ANARI logo-shaped object. Velocity and position are calculated using fundamental laws of motion and Euler’s method to solve the first-order differential equation. The velocity and position computations are parallelized using Kokkos’ thread backend due to the spheres being massless. CUDA is avoided in this scene to prevent GPU oversubscription when the tool utilizes VisRTX. Two sliders can be used to adjust the total number of spheres and the time step.

Animation updates the position of particles represented as spheres

Primitives

The primitives scene contains static geometry without copmlex materials. It lets you select a geometry subtype and increase the number of primitives up to 220.

Spinning cubes

In the spinning cubes scene, you can adjust the number of cubes that each spin at a random rate around an arbitrary axis. It uses instanced rendering to repeat a single cube geometry with a different instance transform matrix. You can adjust a slider to set the number of instances.

Each individual cube is associated with an instance rotation transform that rotates around a random axis

Surfaces

This scene is meant to observe the impact on performance when there are rapid structural changes in an ANARI world. The surfaces scene features a specified number of animated 3D ANARI logos, each composed of 192 triangles and 80 points. Initially, the objects are randomly positioned within a sphere and start moving out towards the imaginary sphere wall at a random velocity.  As the animation progresses, the objects move away from the origin and eventually disappear. Upon disappearing, the objects immediately respawn at the origin with a new randomized velocity.

Animation of multiple ANARI surface objects continuously entering and leaving the ANARI world.

Using the command line interface

Ultimately, anariCat can also run without a GUI! Here’s how you can render the particles scene, animate 100 frames and save every 10th frame to disk. At the end the metrics are saved into a CSV file.

./anariCat run -l visrtx -a -n 1000 -s perf:surfaces
1000/1000 frames  6.5s/60.0s elapsed

===================
Performance Summary
===================
Total # frames rendered	1000
Scene build	2.0ms
Device
	Avg	2.2ms
	Min	1.8ms
	Max	46.4ms
Scene update
	Avg	0.7ms
	Min	0.6ms
	Max	1.8ms
Saved performance metrics to "/data/ANARI-SDK/build/metrics.csv"

You can also check different subcommands like list which can display all names of the scenes, renderers and devices.

List scenes

.\anariCat.exe list scenes
Available scenes:
0       demo:cornell_box
1       demo:gravity_spheres_volume
2       file:obj
3       perf:materials
4       perf:particles
5       perf:primitives
6       perf:spinning_cubes
7       perf:surfaces
8       test:instanced_cubes
9       test:pbr_spheres
10      test:random_cylinders
11      test:random_spheres
12      test:textured_cube
13      test:triangle_attributes

List renderers

.\anariCat.exe list renderers -l visrtx
Available renderers on device 'default'
0       default
1       ao
2       dpt
3       raycast
4       debug

List devices

.\anariCat.exe list devices
Available devices:
0       default

Finally, here’s different options you can pass to the run subcommand.

.\anariCat.exe run --help  

OPTIONS:
  -h,     --help              Print this help message and exit
  -a,     --animate           Play animation
  -g,     --gui               Enable GUI
  -o,     --orthographic      Enable orthographic camera
          --size UINT [[1920,1080]]  x 2
                              In interactive mode, the entered values correspond to the
                              dimensions for GUI window. In non-interactive mode, the entered
                              values correspond to the dimensions of the frame. Ex: --size 1920
                              1080
  -d,     --device UINT [0]   Device ID
  -l,     --library TEXT [helide]
                              ANARI implementation name
  -m,     --log-metrics TEXT [metrics.csv]
                              Save performance metric information to a CSV file.
  -r,     --renderer TEXT [default]
                              ANARI renderer subtype
  -s,     --scene TEXT [perf:particles]
                              Scene name. Ex: <category:scene>

non-interactive-only:
  -t,     --timespan FLOAT [60]
                              Continuously render frames for the specified timespan (seconds).
                              Exits the application if the frame timestamp exceeds timespan.
  -n,     --num-frames UINT [0]
                              Render at least specified number of frames.
  -c,     --capture-screenshot UINT [0]
                              Save screenshot every N frames. Uses PNG format.

Kokkos:
          --kokkos-num-threads UINT [32]
                              No. of threads for kokkos

Future work

  • Clean up the primitive generator to generate non-overlapping, visually appealing geometry.
  • Add a scene for volumes.
  • Customize scene parameters from the command line. This feature would improve the non-interactive mode.
  • Save performance plots to images in non-interactive mode.

Acknowledgement

We thank the Khronos Group for letting us contribute this tool to the ANARI SDK. The work presented here was funded by the Khronos Group through its Request for Proposals (RFP) process – https://www.khronos.org/rfp/anari-capability-analysis-tool

Leave a Reply