MCMini: Monte Carlo on GPGPU

Ryan Marcus2012

Abstract

MCMini is a proof of concept that demonstrates the possibility for Monte Carlo neutron transport using OpenCL with a focus on performance. This implementation, written in C, shows that tracing particles and calculating reactions on a 3D mesh can be done in a highly scalable fashion. These results demonstrate a potential path forward for MCNP or other Monte Carlo codes.

Introduction

Monte Carlo (MC) methods serve as the "gold standard" for simulating particle transport, particularly for neutrons in nuclear physics applications. However, these methods are notoriously computationally intensive. As the high-performance computing (HPC) landscape shifts toward exascale architectures, traditional CPU-bound codes like MCNP (Monte Carlo N-Particle) face significant performance bottlenecks. MCMini was developed at Los Alamos National Laboratory as a "mini-app" to explore the feasibility of porting these complex simulations to General-Purpose Graphics Processing Units (GPGPUs).

Problem Statement

The primary challenge in porting Monte Carlo algorithms to GPUs lies in the stochastic nature of the simulation. Particles follow independent, highly branching paths based on random interactions. GPUs are designed for Single Instruction, Multiple Data (SIMD) workloads, where uniform and predictable execution paths are preferred. Branch divergence—where different threads in a warp take different execution paths—can severely degrade performance. Furthermore, to ensure longevity and flexibility, the implementation needed to be hardware-agnostic, avoiding vendor-specific lock-in to support hardware from NVIDIA, AMD, and Intel.

Methodology

MCMini utilizes a tiered parallelism strategy to maximize throughput across diverse hardware:

  • OpenCL: Employed for core GPU kernels to maintain hardware agnosticism.
  • OpenMP: Used for on-node CPU acceleration in sections of the code less suited for GPU execution.
  • MPI: Facilitates scaling across multiple networked nodes in a cluster.

Technical innovations were required to manage the irregular workload. A Buffered Iteration Pattern was implemented using a double-buffering scheme. This allows the device to compute one step while the host concurrently reads the results of the previous step, effectively reducing space complexity from $O(n^2)$ to $O(n)$. Additionally, the team optimized the random number generation (RNG) by implementing a 64-bit linear generator with a bitwise "skip-ahead" function. This ensures that each parallel thread accesses an independent stream of random numbers with minimal overhead.

Experimental Results

The performance of MCMini was evaluated using the MCNP DAWWG testing suite on various hardware, including AMD Cypress GPUs, NVIDIA Tesla C2070 GPUs, and AMD Opteron CPUs.

CPU vs. GPU Performance

Benchmarks revealed that as the number of particles increases, the GPU's parallel processing capabilities provide a widening performance lead over traditional CPUs. At high particle counts, the GPU implementation achieved over a 2x speedup compared to the CPU baseline.

Figure 1: Comparison of execution times between CPU and GPU as particle counts increase.

Scalability and Multi-GPU Performance

Because Monte Carlo simulations are "embarrassingly parallel," the workload scales effectively with additional hardware. MCMini demonstrated near-linear scaling when moving from a single GPU to a dual-GPU configuration, nearly halving execution times for large batches.

Figure 2: Multi-GPU scaling results demonstrating near-linear performance improvements.

The system also proved capable of handling massive datasets. In a large-scale test, MCMini successfully traced $10^5$ particles through a $10,000^3$ mesh across 8 nodes (16 GPUs) in approximately 6 minutes.

Discussion and Future Work

While MCMini demonstrates significant performance gains, it currently operates as a proof-of-concept with simplified physics. It utilizes fabricated cross-section data and Newtonian mechanics rather than the full relativistic physics found in production-grade MCNP. Furthermore, memory capacity remains a constraint; while GPUs offer superior speed, their memory is often smaller than that of CPUs, limiting the maximum size of the geometry mesh that can be stored on-device without performance-degrading host-memory swapping.

Future work will focus on integrating more complex physics and exploring double-precision performance optimizations. The insights gained from MCMini provide a clear roadmap for the evolution of full-scale Monte Carlo codes for the next generation of supercomputers.

Summary updated

BibTeX
@misc{marcus2012mcmini,
  author = {Ryan Marcus and Ryan Marcus},
  title = {{MCMini: Monte Carlo on GPGPU}},
  year = {2012},
  doi = {10.2172/1047072},
}
Figure