Description Traits#
Description traits can be retrieved from a function descriptor using the helper functions provided below.
Trait |
Description |
---|---|
Direction of the operation |
|
Selected algorithm for (de)compression |
|
The unit in which the (de)compressor interprets the data. |
|
The maximum uncompressed chunk size in bytes. |
|
Target architecture for the underlying computation. |
|
|
|
|
For example, one can use the description traits conveniently in user code to query various description parameters:
#include <nvcompdx.hpp>
using namespace nvcompdx;
using COMP = decltype(Algorithm<algorithm::ans>() +
DataType<datatype::uint8>() +
Direction<direction::compress>() +
MaxUncompChunkSize<32768>() +
SM<800>());
if constexpr (is_complete_comp<COMP>::value) {
std::cout << "Compressor (maximum uncompressed chunk size, SM): "
<< max_uncomp_chunk_size_of<COMP>::value << ", "
<< sm_of<COMP>::value << std::endl;
}
Direction Trait#
// nvcompdx::direction
nvcompdx::direction_of<Description>::value
nvcompdx::direction_of_v<Description>
The direction_of
trait retrieves the direction of the (de)compression problem we want to solve, as set by the Direction Operator.
If the descriptor was not created using a Direction Operator, compilation will fail with an error message.
Algorithm Trait#
// nvcompdx::algorithm
nvcompdx::algorithm_of<Description>::value
nvcompdx::algorithm_of_v<Description>
The algorithm_of
trait retrieves the algorithm of the (de)compression problem we want to solve, as set by the Algorithm Operator.
If the descriptor was not created using a Algorithm Operator, compilation will fail with an error message.
Data Type Trait#
// nvcompdx::datatype
nvcompdx::datatype_of<Description>::value
nvcompdx::datatype_of_v<Description>::value
The datatype_of
trait retrieves the data type of the (de)compression problem we want to solve, as set by the Data Type Operator.
If the descriptor was not created using a Data Type Operator, compilation will fail with an error message.
Maximum Uncompressed Chunk Size Trait#
// size_t
nvcompdx::max_uncomp_chunk_size_of<Description>::value
nvcompdx::max_uncomp_chunk_size_of_v<Description>
The max_uncomp_chunk_size_of
trait retrieves the maximum expected uncompressed chunk size of the compression problem we want to solve, as set by the Maximum Uncompressed Chunk Size Operator.
If the descriptor was not created using a Maximum Uncompressed Chunk Size Operator, compilation will fail with an error message.
SM Trait#
// unsigned int
nvcompdx::sm_of<Description>::value
nvcompdx::sm_of_v<Description>
The GPU architecture used to run the function, as set by the SM Operator. Generally, it is 100 * CC major + 10 * CC minor
, where CC
stands for Compute Capability.
More information can be found on the official NVIDIA website regarding compute capabilities.
For example, when the problem is set up for Volta cards (sm_70), one would use the SM<700>()
description operator, and in return, sm_of<Description>
would return 700u
.
Is it a description? Trait#
// bool
nvcompdx::is_comp<Description>::value
nvcompdx::is_comp_v<Description>
The trait evaluates to true
if the descriptor is an nvCOMPDx function description, formed with description operators.
Is it a complete description? Trait#
// bool
nvcompdx::is_complete_comp<Description>::value
nvcompdx::is_complete_comp_v<Description>
The trait evaluates to true
if the descriptor is a complete nvCOMPDx function description, formed with description operators. The requirements for a complete function descriptor for a compressor are described here, while for a decompressor they are described here.
Note
Complete in this context means that the descriptor has been formed with all the necessary description operators and only requires execution operators to be able to run.