Speclib  0.1.2
The library for writing better CUDA libraries
sp::LUT< Spec > Class Template Referencefinal

Implement a lookup table. More...

#include <LUT.hpp>

Public Types

using InputType = uint32_t
 The type of the lookup table's input. More...
 
using OutputType = typename decltype(Spec::getOutput(0))::T
 The type of the lookup table's output. More...
 

Static Public Member Functions

static constexpr OutputType getOutput (InputType input)
 Get the output corresponding to the given input. More...
 
template<int Bit = 0, int VectorWidth>
static constexpr __uint< VectorWidth > get1BitOutputsFromTransposedInputs (sp::Vec< __uint< VectorWidth >, info.inputBitCount > inputs)
 Get a single bit of output from the LUT for each of a vector of inputs. More...
 
template<int Width = info.outputBitCount, int VectorWidth>
static constexpr sp::Vec< __uint< VectorWidth >, Width > getOutputsFromTransposedInputs (sp::Vec< __uint< VectorWidth >, info.inputBitCount > inputs)
 Return a vector of get1BitOutputsFromTransposedInputs(). More...
 

Detailed Description

template<typename Spec>
class sp::LUT< Spec >

Implement a lookup table.

Template Parameters
SpecThe specification for the lookup table. This must inherit from LUTSpec.

Member Typedef Documentation

◆ InputType

template<typename Spec >
using sp::LUT< Spec >::InputType = uint32_t

The type of the lookup table's input.

◆ OutputType

template<typename Spec >
using sp::LUT< Spec >::OutputType = typename decltype(Spec::getOutput(0))::T

The type of the lookup table's output.

Member Function Documentation

◆ get1BitOutputsFromTransposedInputs()

template<typename Spec >
template<int Bit = 0, int VectorWidth>
static constexpr __uint< VectorWidth > sp::LUT< Spec >::get1BitOutputsFromTransposedInputs ( sp::Vec< __uint< VectorWidth >, info.inputBitCount >  inputs)
staticconstexpr

Get a single bit of output from the LUT for each of a vector of inputs.

This method is intended to be used to generate a LUT that can be used in a highly vectorized fashion. In particular, it implements a bitwise LUT that returns one bit for each input indexing into the same LUT. The transposed nature of the inputs reflects this intended implementation.

Template Parameters
BitWhich output bit to get. If the LUT has output values other than just 0 and 1, then this parameter can be used to get an output bit other than the least significant bit.
Parameters
inputsThe inputs to get outputs for. Each element of the sp::Vec is a bit-vector (as a __uint<N>) containing one bit for each input. The number of elements should therefore be the same as the number of bits needed to uniquely represent every integer from 0 to Spec::getMaxInput() inclusive.
Returns
A bit-vector (as a __uint<N>) with one output bit per input.

◆ getOutput()

template<typename Spec >
static constexpr OutputType sp::LUT< Spec >::getOutput ( InputType  input)
staticconstexpr

Get the output corresponding to the given input.

◆ getOutputsFromTransposedInputs()

template<typename Spec >
template<int Width = info.outputBitCount, int VectorWidth>
static constexpr sp::Vec< __uint< VectorWidth >, Width > sp::LUT< Spec >::getOutputsFromTransposedInputs ( sp::Vec< __uint< VectorWidth >, info.inputBitCount >  inputs)
staticconstexpr

Return a vector of get1BitOutputsFromTransposedInputs().

Template Parameters
WidthThe number of bits to return. By default, this is set to the width of the LUT's output. If this is less, the output is truncated. If it is more, the output is zero-padded.