Kernel Tuning Toolkit 2.3
 
Loading...
Searching...
No Matches
ktt Namespace Reference

Classes

class  BufferOutputDescriptor
 
class  ComputationResult
 
class  ComputeApiInitializer
 
class  ComputeInterface
 
class  ConfigurationCount
 
class  ConfigurationDuration
 
class  ConfigurationFraction
 
class  DeterministicSearcher
 
class  DeviceInfo
 
class  DimensionVector
 
struct  DurationMeasurementResult
 
struct  EnableBitfieldOperators< ValidationMode >
 
class  FailureCount
 
class  FailureFraction
 
struct  KernelCompilationData
 
class  KernelConfiguration
 
class  KernelProfilingCounter
 
class  KernelProfilingData
 
class  KernelResult
 
class  KttException
 
class  McmcSearcher
 
class  ParameterPair
 
class  PlatformInfo
 
struct  PreciseMeasurementParameters
 
class  RandomSearcher
 
class  Searcher
 
class  StopCondition
 
class  Tuner
 
class  TuningDuration
 
class  UnionCondition
 

Typedefs

using PlatformIndex = uint32_t
 
using DeviceIndex = uint32_t
 
using QueueId = uint32_t
 
using KernelDefinitionId = uint64_t
 
using KernelId = uint64_t
 
using ArgumentId = std::string
 
using ParameterValue = std::variant< int64_t, uint64_t, double, bool, std::string >
 
using KernelDimensions = std::map< KernelDefinitionId, std::pair< DimensionVector, DimensionVector > >
 
using ParameterInput = std::vector< std::pair< std::string, ParameterValue > >
 
using UserData = std::map< std::string, std::string >
 
using Nanoseconds = uint64_t
 
using KernelComputeId = std::string
 
using ComputeActionId = uint64_t
 
using TransferActionId = uint64_t
 
using ModifierFunction = std::function< uint64_t(const uint64_t, const std::vector< uint64_t > &)>
 
using ConstraintFunction = std::function< bool(const std::vector< uint64_t > &)>
 
using GenericConstraintFunction = std::function< bool(const std::vector< const ParameterValue * > &)>
 
using KernelLauncher = std::function< void(ComputeInterface &)>
 
using ReferenceComputation = std::function< void(void *)>
 
using ValueComparator = std::function< bool(const void *, const void *)>
 
using UnifiedBufferMemory = void *
 
using ComputeContext = void *
 
using ComputeQueue = void *
 
using ComputeBuffer = void *
 

Enumerations

enum class  ExceptionReason { General , CompilerError , DeviceLimitsExceeded }
 
enum class  DurationCalculationMethod { Minimum , Median , Average }
 
enum class  DeviceType { CPU , GPU , Custom }
 
enum class  ProfilingCounterType {
  Int , UnsignedInt , Double , Percent ,
  Throughput , UtilizationLevel
}
 
enum class  ResultStatus {
  Ok , ComputationFailed , ValidationFailed , CompilationFailed ,
  DeviceLimitsExceeded
}
 
enum class  ComputeApi { OpenCL , CUDA , Vulkan , Cpp }
 
enum class  GlobalSizeType { OpenCL , CUDA , Vulkan }
 
enum class  ModifierAction {
  Add , Subtract , Multiply , Divide ,
  DivideCeil
}
 
enum class  ModifierDimension { X , Y , Z }
 
enum class  ModifierType { Global , Local }
 
enum class  ArgumentAccessType { Undefined , ReadOnly , WriteOnly , ReadWrite }
 
enum class  ArgumentDataType {
  Char , UnsignedChar , Short , UnsignedShort ,
  Int , UnsignedInt , Long , UnsignedLong ,
  Half , Float , Double , Custom
}
 
enum class  ArgumentManagementType { Framework , User }
 
enum class  ArgumentMemoryLocation {
  Undefined , Device , Host , HostZeroCopy ,
  Unified
}
 
enum class  ArgumentMemoryType { Scalar , Vector , Local , Symbol }
 
enum class  KernelRunMode { Running , OfflineTuning , OnlineTuning , ResultValidation }
 
enum class  ValidationMethod { AbsoluteDifference , SideBySideComparison , SideBySideRelativeComparison }
 
enum class  ValidationMode {
  None = 0 , Running = (1 << 0) , OfflineTuning = (1 << 1) , OnlineTuning = (1 << 2) ,
  All = Running | OfflineTuning | OnlineTuning
}
 
enum class  TimeUnit { Nanoseconds , Microseconds , Milliseconds , Seconds }
 
enum class  OutputFormat { JSON , JSON_T4 , XML }
 
enum class  LoggingLevel {
  Off , Error , Warning , Info ,
  Debug
}
 
enum class  ParameterValueType {
  Int , UnsignedInt , Double , Float = Double ,
  Bool , String , CompilerParameter
}
 

Functions

uint32_t GetKttVersion ()
 
std::string GetKttVersionString ()
 

Variables

const QueueId InvalidQueueId = std::numeric_limits<QueueId>::max()
 
const KernelDefinitionId InvalidKernelDefinitionId = std::numeric_limits<KernelDefinitionId>::max()
 
const KernelId InvalidKernelId = std::numeric_limits<KernelId>::max()
 
const ArgumentId InvalidArgumentId = ArgumentId()
 
const Nanoseconds InvalidDuration = std::numeric_limits<Nanoseconds>::max()
 

Detailed Description

All classes, methods and type aliases related to KTT framework are located inside ktt namespace.

Typedef Documentation

◆ ArgumentId

Data type for referencing kernel arguments in KTT.

◆ ComputeActionId

Data type for referencing kernel compute actions in KTT.

◆ ComputeBuffer

Data type for providing custom compute device buffers.

◆ ComputeContext

Data type for providing custom compute device context.

◆ ComputeQueue

Data type for providing custom compute device queues.

◆ ConstraintFunction

Definition of a kernel constraint function. This is an older version of constraint function which supports only unsigned integer parameters.

◆ DeviceIndex

Data type for referencing devices in KTT.

◆ GenericConstraintFunction

Definition of a kernel constraint function. This is a newer version of constraint function which supports parameters with different data types.

◆ KernelComputeId

Data type for referencing unique kernel configurations in compute engine.

◆ KernelDefinitionId

Data type for referencing kernel definitions in KTT.

◆ KernelDimensions

Global and local size for each kernel definition can be specified during kernel tuning and running.

◆ KernelId

Data type for referencing kernels in KTT.

◆ KernelLauncher

Definition of kernel launch function.

◆ ModifierFunction

Definition of kernel thread modifier function.

◆ Nanoseconds

Data type for storing elapsed times in KTT.

◆ ParameterInput

Data type used for creating and retrieving specific kernel configurations from KTT.

◆ ParameterValue

Data type for referencing parameter values in KTT.

◆ PlatformIndex

Data type for referencing platforms in KTT.

◆ QueueId

Data type for referencing compute API queues in KTT.

◆ ReferenceComputation

Function for computing reference kernel argument output. Used during validation.

◆ TransferActionId

Data type for referencing buffer transfer actions in KTT.

◆ UnifiedBufferMemory

Data type for accessing unified memory buffers in KTT.

◆ UserData

Custom user data which can be saved or loaded together with tuning results.

◆ ValueComparator

Custom comparison function for kernel argument values. Used during validation.

Enumeration Type Documentation

◆ ArgumentAccessType

enum class ktt::ArgumentAccessType
strong

Enum for access type of kernel arguments. Specifies whether argument is used for input or output by compute API kernel functions.

Enumerator
Undefined 

Kernel argument access is undefined.

ReadOnly 

Kernel argument is used for input.

WriteOnly 

Kernel argument is used for output.

ReadWrite 

Kernel argument is used for both input and output.

◆ ArgumentDataType

enum class ktt::ArgumentDataType
strong

Enum for data type of kernel arguments. Specifies the data type of elements inside single kernel argument.

Enumerator
Char 

8-bit signed integer type.

UnsignedChar 

8-bit unsigned integer type.

Short 

16-bit signed integer type.

UnsignedShort 

16-bit unsigned integer type.

Int 

32-bit signed integer type.

UnsignedInt 

32-bit unsigned integer type.

Long 

64-bit signed integer type.

UnsignedLong 

64-bit unsigned integer type.

Half 

16-bit floating-point type.

Float 

32-bit floating-point type.

Double 

64-bit floating-point type.

Custom 

Custom data type, usually defined by user. Custom data type has to be trivially copyable. It can be for example struct or class.

◆ ArgumentManagementType

enum class ktt::ArgumentManagementType
strong

Enum for management type of kernel arguments. Specifies who is responsible for managing vector kernel arguments.

Enumerator
Framework 

Vector kernel arguments are managed automatically by the framework.

User 

Vector kernel arguments are managed by user. This means that user is responsible for uploading and downloading argument data into compute API buffers at the right time. This can be achieved by utilizing ComputeInterface methods such as UploadBuffer() and DownloadBuffer().

◆ ArgumentMemoryLocation

enum class ktt::ArgumentMemoryLocation
strong

Enum for memory location of vector kernel arguments. Specifies the memory from which the argument data will be accessed by compute API functions and kernels.

Enumerator
Undefined 

Default memory location for non-vector kernel arguments.

Device 

Argument data will be accessed from device memory. This is recommended setting for devices with dedicated memory, e.g., discrete GPUs.

Host 

Argument data will be accessed from host memory. This is recommended setting for CPUs and devices without dedicated memory, e.g., integrated GPUs.

HostZeroCopy 

Argument data will be accessed from host memory without explicitly creating additional compute API buffer. This flag cannot be used for writable arguments during regular kernel tuning. It can be used for any arguments during step kernel tuning and kernel running. Note that even when this flag is used, extra buffer copy is still sometimes created internally by compute API. This behaviour depends on particular API and device.

◆ ArgumentMemoryType

enum class ktt::ArgumentMemoryType
strong

Enum for memory type of kernel arguments. Specifies which compute API function should be used internally by KTT framework to make the argument accessible to kernel functions.

Enumerator
Scalar 

Argument is a scalar. Scalar arguments are made visible to kernels as a local copy.

Vector 

Argument is a vector. Vector arguments are made visible to kernels through compute API buffers. See ArgumentMemoryLocation for more information.

Local 

Argument will be located in local memory. Kernel arguments cannot be directly transferred into local memory from host memory. Assigning local memory argument to kernel from KTT API simply means that the compute API will allocate enough local memory to hold number of elements specified by the argument. The memory then needs to be filled with data on kernel side.

Symbol 

Argument corresponds to the CUDA symbol which resides in global or constant device memory and matches the argument's name. In Vulkan and OpenCL, symbol arguments are treated in the same way as scalars.

◆ ComputeApi

enum class ktt::ComputeApi
strong

Enum for compute API used by KTT framework. It is utilized during tuner creation.

Enumerator
OpenCL 

Tuner will use OpenCL as compute API.

CUDA 

Tuner will use CUDA as compute API.

Vulkan 

Tuner will use Vulkan as compute API.

Cpp 

Tuner will use C++ as compute API (CPU execution).

◆ DeviceType

enum class ktt::DeviceType
strong

Enum for type of compute device. Based on device types available in OpenCL API.

Enumerator
CPU 

Device is a CPU.

GPU 

Device is a GPU. All available devices in CUDA API and Vulkan will have this device type.

Custom 

Device has type other than CPU or GPU.

◆ DurationCalculationMethod

enum class ktt::DurationCalculationMethod
strong

Enum which specifies how to calculate kernel duration from multiple samples during precise measurement.

Enumerator
Minimum 

Use the minimum duration from all samples.

Median 

Use the median duration from all samples.

Average 

Use the average (mean) duration from all samples.

◆ ExceptionReason

enum class ktt::ExceptionReason
strong

Enum which describes reason why KTT exception was thrown.

Enumerator
General 

General issue with KTT API usage.

CompilerError 

Kernel source file compilation error.

DeviceLimitsExceeded 

Compute device limits were exceeded (e.g., local size was too large, shared memory usage was too high).

◆ GlobalSizeType

enum class ktt::GlobalSizeType
strong

Enum for format of global thread size. Specifies the format of global thread size specified by user during kernel addition.

Enumerator
OpenCL 

Global thread size uses OpenCL format for NDRange dimensions specification.

CUDA 

Global thread size uses CUDA format for grid dimensions specification.

Vulkan 

Global thread size uses Vulkan format. This format is the same as CUDA format.

◆ KernelRunMode

enum class ktt::KernelRunMode
strong

Enum for differentiating between different kernel running scenarios.

Enumerator
Running 

Regular kernel running.

OfflineTuning 

Offline kernel tuning.

OnlineTuning 

Online kernel tuning.

ResultValidation 

Computation of reference output for result validation.

◆ LoggingLevel

enum class ktt::LoggingLevel
strong

Enum for verbosity level of KTT logger. Higher logging levels also include logging of information from lower levels.

Enumerator
Off 

Logging is completely turned off.

Error 

Logs information about major problems which usually lead to application termination.

Warning 

Logs information about minor problems which possibly lead to incorrect application behaviour.

Info 

Logs general information about application status.

Debug 

Logs detailed information which is useful for debugging.

◆ ModifierAction

enum class ktt::ModifierAction
strong

Enum for modifier action for kernel parameters which modify thread size.

Enumerator
Add 

Kernel parameter value will be added to corresponding kernel thread size.

Subtract 

Kernel parameter value will be subtracted from corresponding kernel thread size.

Multiply 

Corresponding kernel thread size will be multiplied by kernel parameter value.

Divide 

Corresponding kernel thread size will be divided by kernel parameter value.

DivideCeil 

Corresponding kernel thread size will be divided by kernel parameter value and then rounded up to its multiple.

◆ ModifierDimension

enum class ktt::ModifierDimension
strong

Enum for modifier dimension for kernel parameters. Dimensions are utilized during specification of parameters which modify kernel thread sizes.

Enumerator

Kernel parameter will modify thread size in dimension X.

Kernel parameter will modify thread size in dimension Y.

Kernel parameter will modify thread size in dimension Z.

◆ ModifierType

enum class ktt::ModifierType
strong

Enum for modifier type for kernel parameters. Specifies whether kernel parameter value affects corresponding kernel thread size.

Enumerator
Global 

Parameter value affects global kernel thread size.

Local 

Parameter value affects local kernel thread size.

◆ OutputFormat

enum class ktt::OutputFormat
strong

Enum for format of tuner output.

Enumerator
JSON 

Tuner output has JSON format.

JSON_T4 

Tuner output in JSON format compatible with other autotuning tools.

XML 

Tuner output has XML format.

◆ ParameterValueType

enum class ktt::ParameterValueType
strong

Enum for value type for kernel parameters.

Enumerator
Int 

Parameter has 64-bit signed integer type.

UnsignedInt 

Parameter has 64-bit unsigned integer type.

Double 

Parameter has 64-bit floating-point type.

Float 

Parameter has 64-bit floating-point type.

Bool 

Parameter has boolean type.

String 

Parameter has string type.

CompilerParameter 

Parameter is a compiler parameter.

◆ ProfilingCounterType

enum class ktt::ProfilingCounterType
strong

Enum which specifies data type of a profiling counter.

Enumerator
Int 

Profiling counter is a signed 64-bit integer.

UnsignedInt 

Profiling counter is an unsigned 64-bit integer.

Double 

Profiling counter is a 64-bit float.

Percent 

Profiling counter is a 64-bit float with a range of values between 0.0 and 100.0 (corresponding to 0% - 100%).

Throughput 

Profiling counter is an unsigned 64-bit integer. The unit for throughput value is bytes/second.

UtilizationLevel 

Profiling counter is an unsigned 64-bit integer with a range of values between 0 and 10 (0 corresponds to minimum utilization level, 10 to maximum utilization level).

◆ ResultStatus

enum class ktt::ResultStatus
strong

Enum which describes status of a kernel result.

Enumerator
Ok 

Computation was completed successfully.

ComputationFailed 

Computation failed due to generic compute API error.

ValidationFailed 

Computation was completed successfully, but its output does not match the expected output.

CompilationFailed 

Kernel source file failed to compile.

DeviceLimitsExceeded 

Computation could not launch due to device limits being exceeded (e.g., local size was too large).

◆ TimeUnit

enum class ktt::TimeUnit
strong

Enum for time unit used during logging and output operations.

Enumerator
Nanoseconds 

Durations will be printed in nanoseconds.

Microseconds 

Durations will be printed in microseconds.

Milliseconds 

Durations will be printed in milliseconds.

Seconds 

Durations will be printed in seconds.

◆ ValidationMethod

enum class ktt::ValidationMethod
strong

Enum for validation method used during validation of floating-point output arguments.

Enumerator
AbsoluteDifference 

Calculates sum of differences between each pair of elements, then compares the sum to specified threshold.

SideBySideComparison 

Calculates difference for each pair of elements, then compares the difference to specified threshold.

SideBySideRelativeComparison 

Calculates difference for each pair of elements, then compares the difference divided by reference value to the specified threshold.

◆ ValidationMode

enum class ktt::ValidationMode
strong

Enum for enabling kernel output validation in different scenarios.

Enumerator
None 

Kernel output validation is completely disabled.

Running 

Kernel output is validated during kernel running.

OfflineTuning 

Kernel output is validated during offline kernel tuning.

OnlineTuning 

Kernel output is validated during online kernel tuning.

All 

Kernel output is always validated.

Function Documentation

◆ GetKttVersion()

uint32_t ktt::GetKttVersion ( )

Returns the current KTT framework version in integer format.

Returns
KTT framework version as integer xxxyyyzzz.

◆ GetKttVersionString()

std::string ktt::GetKttVersionString ( )

Returns the current KTT framework version in string format.

Returns
KTT framework version as string x.y.z.

Variable Documentation

◆ InvalidArgumentId

const ArgumentId ktt::InvalidArgumentId = ArgumentId()
inline

Argument id returned by argument addition methods in case of an error.

◆ InvalidDuration

const Nanoseconds ktt::InvalidDuration = std::numeric_limits<Nanoseconds>::max()
inline

Invalid duration used during initialization and in case of an error.

◆ InvalidKernelDefinitionId

const KernelDefinitionId ktt::InvalidKernelDefinitionId = std::numeric_limits<KernelDefinitionId>::max()
inline

Kernel definition id returned by kernel definition addition methods in case of an error.

◆ InvalidKernelId

const KernelId ktt::InvalidKernelId = std::numeric_limits<KernelId>::max()
inline

Kernel id returned by kernel addition methods in case of an error.

◆ InvalidQueueId

const QueueId ktt::InvalidQueueId = std::numeric_limits<QueueId>::max()
inline

Queue id returned by compute queue addition methods in case of an error.