Detecting Divergence Using PCAST to Compare GPU to CPU Results

Parallel Compiler Assisted Software Testing (PCAST) is a feature available in the NVIDIA HPC Fortran, C++, and C compilers. PCAST has two use cases.

Michael Wolfe
14 min readintermediate
--
View Original

Overview

The article discusses the Parallel Compiler Assisted Software Testing (PCAST) feature in NVIDIA's HPC compilers, focusing on its use cases for comparing GPU and CPU results. It highlights how PCAST can help ensure the correctness of program modifications by comparing intermediate results against a known good state, using both golden files and OpenACC implementations.

What You'll Learn

1

How to use PCAST to compare GPU and CPU results effectively

2

Why using golden files can enhance software testing accuracy

3

When to apply the PCAST_COMPARE environment variable for better control

Prerequisites & Requirements

  • Familiarity with parallel programming concepts
  • Access to NVIDIA HPC SDK

Key Questions Answered

What is PCAST and how does it help in software testing?
PCAST, or Parallel Compiler Assisted Software Testing, is a feature in NVIDIA's HPC compilers that allows developers to compare results from modified programs against a known good state. It helps identify discrepancies in computational results, ensuring that changes do not introduce errors.
How can PCAST be used with OpenACC for GPU testing?
PCAST can be used with OpenACC by enabling redundant execution, where both CPU and GPU code run simultaneously. This allows for direct comparison of results in memory without the need for golden files, simplifying the testing process for GPU kernels.
What are the key features of the PCAST_COMPARE environment variable?
The PCAST_COMPARE environment variable allows users to control various aspects of the PCAST comparison process, such as specifying the golden file name, tolerating small differences, and limiting the number of reported discrepancies. This flexibility aids in fine-tuning the testing process.
What common pitfalls should developers be aware of when using PCAST?
Developers should be cautious of potential differences in floating-point computations due to changes in compiler optimizations or processor architectures. It's important to distinguish between significant and insignificant differences to avoid unnecessary debugging efforts.

Technologies & Tools

Software
Nvidia Hpc SDK
Provides the compilers and tools necessary to implement PCAST for software testing.
Parallel Computing
Openacc
Facilitates the comparison of GPU and CPU computations in a simplified manner.

Key Actionable Insights

1
Implement PCAST in your testing workflow to ensure accuracy when modifying code.
By integrating PCAST, you can systematically verify that changes to your program do not introduce errors, especially when transitioning to new libraries or compilers.
2
Utilize the PCAST_COMPARE environment variable to customize your testing parameters.
This allows you to tailor the comparison process to your specific needs, such as adjusting tolerance levels for floating-point discrepancies, which can be crucial in high-performance computing applications.
3
Consider using golden files for critical computations to establish a reliable baseline.
Golden files serve as a reference point, helping to quickly identify deviations in results that may indicate bugs or unintended changes in behavior.

Common Pitfalls

1
Assuming all floating-point computations will yield identical results after code modifications.
Differences can arise from changes in compiler optimizations or processor architectures, making it essential to evaluate the significance of any discrepancies rather than expecting bit-exact matches.
2
Neglecting to account for stale data in parallel computations.
When using PCAST, ensure that both CPU and GPU are working with the most current data to avoid misleading comparison results.