|
1 | | -//! Benchmarks for pecos-cuquantum GPU simulators |
| 1 | +// Copyright 2026 The PECOS Developers |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
| 4 | +// in compliance with the License.You may obtain a copy of the License at |
| 5 | +// |
| 6 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +// |
| 8 | +// Unless required by applicable law or agreed to in writing, software distributed under the License |
| 9 | +// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 10 | +// or implied. See the License for the specific language governing permissions and limitations under |
| 11 | +// the License. |
| 12 | + |
| 13 | +//! Benchmarks for pecos-cuquantum GPU simulators. |
2 | 14 | //! |
3 | | -//! These benchmarks compare cuQuantum GPU simulation performance against |
4 | | -//! other backends (e.g., wgpu-based simulators). |
| 15 | +//! Benchmarks cuQuantum state vector and stabilizer simulation performance. |
5 | 16 | //! |
6 | | -//! Run with: `cargo bench -p pecos-cuquantum --features integration-tests` |
| 17 | +//! Run with: `cargo bench -p benchmarks --features cuquantum` |
7 | 18 | //! |
8 | 19 | //! **Requires cuQuantum to be installed.** |
9 | 20 |
|
10 | | -use criterion::{BenchmarkId, Criterion, Throughput, black_box, criterion_group, criterion_main}; |
| 21 | +use criterion::{BenchmarkId, Criterion, Throughput}; |
11 | 22 | use pecos_core::Angle64; |
12 | 23 | use pecos_cuquantum::{CuStabilizer, CuStateVec, QubitId, TryClone, is_cuquantum_available}; |
13 | 24 | use pecos_qsim::{ArbitraryRotationGateable, CliffordGateable, QuantumSimulator}; |
14 | 25 | use std::f64::consts::PI; |
| 26 | +use std::hint::black_box; |
15 | 27 |
|
16 | 28 | /// Benchmark state vector simulation for different qubit counts |
17 | 29 | fn bench_statevec_gates(c: &mut Criterion) { |
@@ -368,7 +380,7 @@ fn bench_sampling(c: &mut Criterion) { |
368 | 380 | group.finish(); |
369 | 381 | } |
370 | 382 |
|
371 | | -/// Benchmark Clone and TryClone operations |
| 383 | +/// Benchmark Clone and `TryClone` operations |
372 | 384 | fn bench_clone(c: &mut Criterion) { |
373 | 385 | if !is_cuquantum_available() { |
374 | 386 | eprintln!("Skipping clone benchmarks: cuQuantum not available"); |
@@ -424,15 +436,13 @@ fn bench_clone(c: &mut Criterion) { |
424 | 436 | group.finish(); |
425 | 437 | } |
426 | 438 |
|
427 | | -criterion_group!( |
428 | | - benches, |
429 | | - bench_statevec_gates, |
430 | | - bench_stabilizer_gates, |
431 | | - bench_bell_state, |
432 | | - bench_surface_code_syndrome, |
433 | | - bench_rotation_gates, |
434 | | - bench_two_qubit_rotation_gates, |
435 | | - bench_sampling, |
436 | | - bench_clone, |
437 | | -); |
438 | | -criterion_main!(benches); |
| 439 | +pub fn benchmarks(c: &mut Criterion) { |
| 440 | + bench_statevec_gates(c); |
| 441 | + bench_stabilizer_gates(c); |
| 442 | + bench_bell_state(c); |
| 443 | + bench_surface_code_syndrome(c); |
| 444 | + bench_rotation_gates(c); |
| 445 | + bench_two_qubit_rotation_gates(c); |
| 446 | + bench_sampling(c); |
| 447 | + bench_clone(c); |
| 448 | +} |
0 commit comments