compute-acceleration
GEMM and sum reduction across serial, OpenMP and CUDA
Loading...
Searching...
No Matches
omp
omp_control.h
1
// Copyright (c) 2025 yanghuafang
2
// SPDX-License-Identifier: MIT
3
4
#ifndef ACCEL_OMP_OMP_CONTROL_H_
5
#define ACCEL_OMP_OMP_CONTROL_H_
6
7
namespace
accel {
8
9
// Lets drivers and tests pin and report the thread count without including
10
// <omp.h>, which would push the OpenMP compile flags onto every consumer.
11
//
12
// Call from the serial region only: these set a process-wide control variable,
13
// and changing it inside a parallel region is undefined.
14
15
// Threads the runtime would use next, honouring OMP_NUM_THREADS and any prior
16
// OpenmpSetThreads call.
17
int
OpenmpMaxThreads() noexcept;
18
19
// Pins subsequent regions to `count` threads; throws std::invalid_argument if
20
// it is not positive. Benchmarks must pin: an unpinned run is not
21
// reproducible, and on a hybrid CPU the default spans performance and
22
// efficiency cores.
23
void
OpenmpSetThreads(
int
count);
24
25
// Threads a region actually receives, measured by entering one. The runtime
26
// may supply fewer than OpenmpMaxThreads promises, and reporting the requested
27
// count is how a scaling table claims speedups on threads that never ran.
28
int
OpenmpThreadsUsed() noexcept;
29
30
}
// namespace accel
31
32
#endif
// ACCEL_OMP_OMP_CONTROL_H_
Generated by
1.9.8