Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
int_chains.hpp File Reference

Integer ALU throughput benchmark (multiply chains vs add chains). More...

#include "shambase/time.hpp"
#include "shambackends/DeviceBuffer.hpp"
#include "shambackends/DeviceScheduler.hpp"
#include <type_traits>
Include dependency graph for int_chains.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sham::benchmarks::int_chains_result
 Structure containing the results of an int_chains benchmark. More...

Namespaces

namespace  sham
 namespace for backends this one is named only sham since shambackends is too long to write

Macros

#define IMAD_4(x, y)
#define IMAD_16(x, y)
#define IADD_4(x, y)
#define IADD_16(x, y)

Enumerations

enum class  sham::benchmarks::IntChainOp { Mul , Add }
 Which integer operation a chain is built from. More...

Functions

template<class T, IntChainOp op>
void sham::benchmarks::int_chains (u32 i, int nrotation, T y0, T *__restrict in, T *__restrict out)
 Kernel for the int_chains benchmark.
template<class T, IntChainOp op>
int_chains_result sham::benchmarks::int_chains_bench (DeviceScheduler_ptr sched, int N, f64 time_threshold)
 Run the int_chains benchmark.

Detailed Description

Integer ALU throughput benchmark (multiply chains vs add chains).

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Mirrors the structure of fma_chains.hpp, but on unsigned integers. Running the multiply and the add variants gives the multiply/add throughput ratio, which differs strongly across vendors: GCN-derived architectures issue a 32 bit integer multiply at a fraction of the rate of an add, while architectures with a dedicated integer pipe do not.

Definition in file int_chains.hpp.

Macro Definition Documentation

◆ IADD_16

#define IADD_16 ( x,
y )
Value:
IADD_4(x, y); \
IADD_4(x, y); \
IADD_4(x, y); \
IADD_4(x, y);

Definition at line 55 of file int_chains.hpp.

◆ IADD_4

#define IADD_4 ( x,
y )
Value:
x = y + x + y; \
y = x + y + x; \
x = y + x + y; \
y = x + y + x;

Definition at line 50 of file int_chains.hpp.

◆ IMAD_16

#define IMAD_16 ( x,
y )
Value:
IMAD_4(x, y); \
IMAD_4(x, y); \
IMAD_4(x, y); \
IMAD_4(x, y);

Definition at line 44 of file int_chains.hpp.

◆ IMAD_4

#define IMAD_4 ( x,
y )
Value:
x = y * x + y; \
y = x * y + x; \
x = y * x + y; \
y = x * y + x;

Definition at line 39 of file int_chains.hpp.

Enumeration Type Documentation

◆ IntChainOp

enum class sham::benchmarks::IntChainOp
strong

Which integer operation a chain is built from.

Enumerator
Mul 

multiply-add chains, 16 multiplies + 16 adds per rotation

Add 

add-only chains, 32 adds per rotation

Definition at line 32 of file int_chains.hpp.

Function Documentation

◆ int_chains()

template<class T, IntChainOp op>
void sham::benchmarks::int_chains ( u32 i,
int nrotation,
T y0,
T *__restrict in,
T *__restrict out )
inline

Kernel for the int_chains benchmark.

Dependent integer chains, long enough to hide memory latency and expose the integer issue rate. T must be unsigned so that the wraparound the chains rely on is defined behaviour.

Template Parameters
Tvalue type of the input and output vectors
opoperation the chain is built from
Parameters
iindex of the element to process
nrotationnumber of chain rotations to apply
y0initial value of the second chain register
ininput vector
outoutput vector

Definition at line 77 of file int_chains.hpp.

◆ int_chains_bench()

template<class T, IntChainOp op>
int_chains_result sham::benchmarks::int_chains_bench ( DeviceScheduler_ptr sched,
int N,
f64 time_threshold )
inline

Run the int_chains benchmark.

Template Parameters
Tunsigned value type used in the benchmark
opoperation the chains are built from
Parameters
schedscheduler for the target device
Nnumber of elements (independent chains) to process
time_thresholdminimum wall-clock time to run the benchmark in seconds
Returns
benchmark results as an int_chains_result

Definition at line 116 of file int_chains.hpp.

Here is the call graph for this function: