Urgent.News

What's breaking now, across thousands of outlets.

Tech

Backends 101: Choosing the Right Measurement Surface

Why this lesson exists When a program runs on a GPU, the only way to know where the real cost lies is to measure that GPU. Defaulting to the CPU surface is a common mistake that can waste days of debugging. This episode shows how to use csperf to discover the right backend and switch when necessary. Recap — where we are in the series Ep 1 : Why a single ./a.out time misleads – we learned that…

In this episode, we explore the importance of selecting the correct measurement surface when profiling GPU programs. Many developers mistakenly assume that the CPU is the primary source of performance, running csperf with the CPU backend and interpreting the results as the only relevant data. However, this overlooks the fact that the GPU often handles the bulk of the work. To truly understand performance, one must measure the GPU directly.

The csperf tool provides a straightforward way to list available backends, enumerate devices for a chosen backend, and execute workloads on any backend. By examining the artifacts generated, you can decide whether to continue using the CPU or switch to the GPU for better performance.

The process involves three main steps:

1. List all backends csperf knows about using `csperf list-backends`.

2. For the CPU backend, list the devices that can be used with `csperf list-devices --backend cpu`.

3. Run the workload on the CPU backend using `csperf run --input examples/cpp/matrix_traversal.cpp --backend cpu --output results/cpu.json`.

This lab exercise mirrors the commands used in Episode 8, where the cpu.json artifact was generated. The lab results on an AMD Ryzen 7 9700X machine with 16 logical CPUs show a mean execution time of 5.162 ms with a standard deviation of 0.020 ms across three trials.

The JSON artifact contains three key sections: pipeline, metrics, and execution_time_summary_ms. By examining the file in a JSON viewer, you’ll notice the backend field is set to cpu. To switch to a GPU backend, simply change this field to gpu and rerun the command.

Common mistakes include assuming CPU metrics are the whole story, running only one trial, ignoring device enumeration, and overlooking the profiler used. To avoid these pitfalls, always check the backend field, use the --repeat flag for statistical results, enumerate available devices with `csperf list-devices`, and review the profiler information listed in the artifact.

For homework, try running the matrix traversal example on the GPU backend (if available) and compare the execution_time_ms to the CPU result. Document whether the GPU truly dominates the cost. The next episode will delve into stability metrics, providing a more comprehensive view of performance variance.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

What breaks after you ship a vibe-coded app (and what we're doing about it)

Vibe coding made building an app ridiculously fast. You describe what you want, the AI writes it, and a few days later you have something live.

  • Critical bugs emerge post-launch, causing user churn
  • Code that was easy to work with becomes intimidating
  • continuevibe initiative launched to handle post-launch maintenance

How to Decode Base64 in JavaScript (and a Free Tool That Does It Instantly)

Base64 shows up everywhere in JavaScript work: API tokens, data URLs for images, email attachments, even the odd query parameter.

  • btoa() and atob() functions in JavaScript handle Base64 encoding and decoding
  • btoa() limited to Latin1 characters, causing errors with UTF-8 characters
  • Recommended approach uses TextEncoder and TextDecoder for reliable UTF-8 handling

How to Write an Effective Software Project Brief for Kerala Developers and Remote Clients

Introduction: Why Most Software Briefs Fail As a Senior Software Developer and Solution Architect operating out of Kochi, Kerala, I frequently review project briefs submitted by founders, product…

  • Executive summary and business objective must state core value proposition and success criteria
  • Technical constraints, architecture, and preferred tech stack must be explicitly defined

More from Monday 5 October →