Kernel Tuning Toolkit 2.3
 
Loading...
Searching...
No Matches
ktt::ComputeInterface Class Referenceabstract

#include <ComputeInterface.h>

Public Member Functions

virtual ~ComputeInterface ()=default
 
virtual void RunKernel (const KernelDefinitionId id)=0
 
virtual void RunKernel (const KernelDefinitionId id, const DimensionVector &globalSize, const DimensionVector &localSize)=0
 
virtual ComputeActionId RunKernelAsync (const KernelDefinitionId id, const QueueId queue)=0
 
virtual ComputeActionId RunKernelAsync (const KernelDefinitionId id, const QueueId queue, const DimensionVector &globalSize, const DimensionVector &localSize)=0
 
virtual void WaitForComputeAction (const ComputeActionId id)=0
 
virtual void RunKernelWithProfiling (const KernelDefinitionId id)=0
 
virtual void RunKernelWithProfiling (const KernelDefinitionId id, const DimensionVector &globalSize, const DimensionVector &localSize)=0
 
virtual uint64_t GetRemainingProfilingRuns (const KernelDefinitionId id) const =0
 
virtual uint64_t GetRemainingProfilingRuns () const =0
 
virtual QueueId GetDefaultQueue () const =0
 
virtual std::vector< QueueIdGetAllQueues () const =0
 
virtual void SynchronizeQueue (const QueueId queue)=0
 
virtual void SynchronizeQueues ()=0
 
virtual void SynchronizeDevice ()=0
 
virtual const DimensionVectorGetCurrentGlobalSize (const KernelDefinitionId id) const =0
 
virtual const DimensionVectorGetCurrentLocalSize (const KernelDefinitionId id) const =0
 
virtual const KernelConfigurationGetCurrentConfiguration () const =0
 
virtual KernelRunMode GetRunMode () const =0
 
virtual void ChangeArguments (const KernelDefinitionId id, const std::vector< ArgumentId > &arguments)=0
 
virtual void SwapArguments (const KernelDefinitionId id, const ArgumentId &first, const ArgumentId &second)=0
 
virtual void UpdateScalarArgument (const ArgumentId &id, const void *data)=0
 
virtual void UpdateLocalArgument (const ArgumentId &id, const size_t dataSize)=0
 
virtual void UploadBuffer (const ArgumentId &id)=0
 
virtual TransferActionId UploadBufferAsync (const ArgumentId &id, const QueueId queue)=0
 
virtual void DownloadBuffer (const ArgumentId &id, void *destination, const size_t dataSize=0)=0
 
virtual TransferActionId DownloadBufferAsync (const ArgumentId &id, const QueueId queue, void *destination, const size_t dataSize=0)=0
 
virtual void UpdateBuffer (const ArgumentId &id, const void *data, const size_t dataSize=0)=0
 
virtual TransferActionId UpdateBufferAsync (const ArgumentId &id, const QueueId queue, const void *data, const size_t dataSize=0)=0
 
virtual void CopyBuffer (const ArgumentId &destination, const ArgumentId &source, const size_t dataSize=0)=0
 
virtual TransferActionId CopyBufferAsync (const ArgumentId &destination, const ArgumentId &source, const QueueId queue, const size_t dataSize=0)=0
 
virtual void WaitForTransferAction (const TransferActionId id)=0
 
virtual void ResizeBuffer (const ArgumentId &id, const size_t newDataSize, const bool preserveData)=0
 
virtual void ClearBuffer (const ArgumentId &id)=0
 
virtual bool HasBuffer (const ArgumentId &id)=0
 
virtual void GetUnifiedMemoryBufferHandle (const ArgumentId &id, UnifiedBufferMemory &memoryHandle)=0
 
virtual bool GetProfiling (const KernelId id)=0
 

Detailed Description

Interface for customizing kernel runs in order to run some part of computation on CPU, utilize iterative kernel launches, composite kernels and more. In order to use this functionality, custom kernel launcher function must be defined for the corresponding kernel.

Constructor & Destructor Documentation

◆ ~ComputeInterface()

ktt::ComputeInterface::~ComputeInterface ( )
virtualdefault

Compute interface destructor.

Member Function Documentation

◆ ChangeArguments()

void ktt::ComputeInterface::ChangeArguments ( const KernelDefinitionId  id,
const std::vector< ArgumentId > &  arguments 
)
pure virtual

Changes kernel arguments for the specified kernel definitions under currently launched kernel.

Parameters
idId of kernel definition for which the arguments will be changed. The specified definition must be included in the currently launched kernel.
argumentsIds of arguments to be used by the specified kernel definition. The order of ids must match the order of arguments inside kernel function. The provided ids must be unique.

◆ ClearBuffer()

void ktt::ComputeInterface::ClearBuffer ( const ArgumentId id)
pure virtual

Removes compute buffer for the specified vector argument. This method should be used mainly with arguments with ArgumentManagementType set to User.

Parameters
idId of vector argument whose buffer will be removed.

◆ CopyBuffer()

void ktt::ComputeInterface::CopyBuffer ( const ArgumentId destination,
const ArgumentId source,
const size_t  dataSize = 0 
)
pure virtual

Copies part of the compute buffer of source vector argument to compute buffer of destination vector argument.

Parameters
destinationId of destination vector argument.
sourceId of source vector argument.
dataSizeSize in bytes of buffer portion which will be copied to destination buffer, starting with the first byte. If zero, the entire buffer will be copied.

◆ CopyBufferAsync()

TransferActionId ktt::ComputeInterface::CopyBufferAsync ( const ArgumentId destination,
const ArgumentId source,
const QueueId  queue,
const size_t  dataSize = 0 
)
pure virtual

Copies part of the compute buffer of source vector argument to compute buffer of destination vector argument. The data will be transferred asynchronously in the specified queue.

Parameters
destinationId of destination vector argument.
sourceId of source vector argument.
queueId of queue in which the command to copy argument will be submitted.
dataSizeSize in bytes of buffer portion which will be copied to destination buffer, starting with the first byte. If zero, the entire buffer will be copied.
Returns
Id of asynchronous action corresponding to the issued data transfer command. The action must be waited for with e.g., WaitForTransferAction(), SynchronizeQueue() methods. Otherwise, problems such as incorrectly recorded transfer durations may occur.

◆ DownloadBuffer()

void ktt::ComputeInterface::DownloadBuffer ( const ArgumentId id,
void *  destination,
const size_t  dataSize = 0 
)
pure virtual

Downloads the specified vector argument from compute buffer.

Parameters
idId of vector argument which will be downloaded.
destinationBuffer where the argument data will be downloaded. Its size must be equal or greater than the specified data size.
dataSizeSize in bytes of buffer portion which will be downloaded to specified destination, starting with the first byte. If zero, the entire buffer will be downloaded.

◆ DownloadBufferAsync()

TransferActionId ktt::ComputeInterface::DownloadBufferAsync ( const ArgumentId id,
const QueueId  queue,
void *  destination,
const size_t  dataSize = 0 
)
pure virtual

Downloads the specified vector argument from compute buffer. The data will be transferred asynchronously in the specified queue.

Parameters
idId of vector argument which will be downloaded.
queueId of queue in which the command to download argument will be submitted.
destinationBuffer where the argument data will be downloaded. Its size must be equal or greater than the specified data size.
dataSizeSize in bytes of buffer portion which will be downloaded to specified destination, starting with the first byte. If zero, the entire buffer will be downloaded.
Returns
Id of asynchronous action corresponding to the issued data transfer command. The action must be waited for with e.g., WaitForTransferAction(), SynchronizeQueue() methods. Otherwise, problems such as incorrectly recorded transfer durations may occur.

◆ GetAllQueues()

std::vector< QueueId > ktt::ComputeInterface::GetAllQueues ( ) const
pure virtual

Retrieves ids of all available device queues. Number of queues can be specified during tuner creation.

Returns
Ids of all available device queues.

◆ GetCurrentConfiguration()

const KernelConfiguration & ktt::ComputeInterface::GetCurrentConfiguration ( ) const
pure virtual

Returns configuration of the currently launched kernel.

Returns
Configuration of the currently launched kernel. See KernelConfiguration for more information.

◆ GetCurrentGlobalSize()

const DimensionVector & ktt::ComputeInterface::GetCurrentGlobalSize ( const KernelDefinitionId  id) const
pure virtual

Returns global thread size for the specified kernel definition based on the current configuration.

Parameters
idId of kernel definition for which the global size will be retrieved. The specified definition must be included in the currently launched kernel.
Returns
Global thread size of the specified kernel definition.

◆ GetCurrentLocalSize()

const DimensionVector & ktt::ComputeInterface::GetCurrentLocalSize ( const KernelDefinitionId  id) const
pure virtual

Returns local thread size for the specified kernel definition based on the current configuration.

Parameters
idId of kernel definition for which the local size will be retrieved. The specified definition must be included in the currently launched kernel.
Returns
Local thread size of the specified kernel definition.

◆ GetDefaultQueue()

QueueId ktt::ComputeInterface::GetDefaultQueue ( ) const
pure virtual

Retrieves id of default device queue. All synchronous commands are submitted to this queue.

Returns
Id of default device queue.

◆ GetProfiling()

void ktt::ComputeInterface::GetProfiling ( const KernelId  id)
pure virtual

Signals whether profiling is activated in the kernel

Parameters
idId of queried kernel.

◆ GetRemainingProfilingRuns() [1/2]

uint64_t ktt::ComputeInterface::GetRemainingProfilingRuns ( ) const
pure virtual

Retrieves number of remaining profiling runs that are needed to collect all the profiling counters for the currently launched kernel. The number is derived from included kernel definitions which have kernel profiling functionality enabled.

Returns
Number of remaining profiling runs. Note that if no profiling runs were run so far, zero is returned.

◆ GetRemainingProfilingRuns() [2/2]

uint64_t ktt::ComputeInterface::GetRemainingProfilingRuns ( const KernelDefinitionId  id) const
pure virtual

Retrieves number of remaining profiling runs that are needed to collect all the profiling counters for the specified kernel definition.

Parameters
idId of kernel definition for which the number of remaining profiling runs will be retrieved. The specified definition must be included in the currently launched kernel.
Returns
Number of remaining profiling runs. Note that if no profiling runs were run so far for the specified definition, zero is returned.

◆ GetRunMode()

KernelRunMode ktt::ComputeInterface::GetRunMode ( ) const
pure virtual

Returns run mode of the currently launched kernel.

Returns
Run mode of the currently launched kernel. See KernelRunMode for more information.

◆ GetUnifiedMemoryBufferHandle()

void ktt::ComputeInterface::GetUnifiedMemoryBufferHandle ( const ArgumentId id,
UnifiedBufferMemory memoryHandle 
)
pure virtual

Retrieves memory handle for the specified unified memory argument. The handle can be used to manipulate argument memory on host side. Example usage: ktt::UnifiedBufferMemory memory; GetUnifiedMemoryBufferHandle(..., memory); float* floatArray = static_cast<float*>(memory);

Parameters
idId of vector argument whose memory handle will be retrieved.
memoryHandleLocation where the memory handle will be stored.

◆ HasBuffer()

bool ktt::ComputeInterface::HasBuffer ( const ArgumentId id)
pure virtual

Checks whether compute buffer for the specified vector argument exists.

Parameters
idId of vector argument to check.
Returns
True if the buffer for argument exists. False otherwise.

◆ ResizeBuffer()

void ktt::ComputeInterface::ResizeBuffer ( const ArgumentId id,
const size_t  newDataSize,
const bool  preserveData 
)
pure virtual

Resizes compute buffer for the specified vector argument.

Parameters
idId of vector argument whose buffer will be resized.
newDataSizeSize in bytes for the resized buffer.
preserveDataIf true, data from the old buffer will be copied into resized buffer. If false, the old data will be discarded.

◆ RunKernel() [1/2]

void ktt::ComputeInterface::RunKernel ( const KernelDefinitionId  id)
pure virtual

Runs the specified kernel definition using thread sizes based on the current configuration.

Parameters
idId of kernel definition which will be run. The specified definition must be included in the currently launched kernel.

◆ RunKernel() [2/2]

void ktt::ComputeInterface::RunKernel ( const KernelDefinitionId  id,
const DimensionVector globalSize,
const DimensionVector localSize 
)
pure virtual

Runs the specified kernel definition using provided thread sizes.

Parameters
idId of kernel definition which will be run. The specified definition must be included in the currently launched kernel.
globalSizeDimensions for global size with which the kernel will be run.
localSizeDimensions for local size with which the kernel will be run.

◆ RunKernelAsync() [1/2]

ComputeActionId ktt::ComputeInterface::RunKernelAsync ( const KernelDefinitionId  id,
const QueueId  queue 
)
pure virtual

Runs the specified kernel definition using thread sizes based on the current configuration. The kernel will be launched asynchronously in the specified queue.

Parameters
idId of kernel definition which will be run. The specified definition must be included in the currently launched kernel.
queueId of queue in which the command to run kernel will be submitted.
Returns
Id of asynchronous action corresponding to the issued kernel run command. The action must be waited for with e.g., WaitForComputeAction(), SynchronizeQueue() methods. Otherwise, problems such as incorrectly recorded kernel durations may occur.

◆ RunKernelAsync() [2/2]

ComputeActionId ktt::ComputeInterface::RunKernelAsync ( const KernelDefinitionId  id,
const QueueId  queue,
const DimensionVector globalSize,
const DimensionVector localSize 
)
pure virtual

Runs the specified kernel definition using provided thread sizes. The kernel will be launched asynchronously in the specified queue.

Parameters
idId of kernel definition which will be run. The specified definition must be included in the currently launched kernel.
queueId of queue in which the command to run kernel will be submitted.
globalSizeDimensions for global size with which the kernel will be run.
localSizeDimensions for local size with which the kernel will be run.
Returns
Id of asynchronous action corresponding to the issued kernel run command. The action must be waited for with e.g., WaitForComputeAction(), SynchronizeQueue() methods. Otherwise, problems such as incorrectly recorded kernel durations may occur.

◆ RunKernelWithProfiling() [1/2]

void ktt::ComputeInterface::RunKernelWithProfiling ( const KernelDefinitionId  id)
pure virtual

Runs the specified kernel definition using thread sizes based on the current configuration. Collection of kernel profiling counters will be enabled for this run which means that performance will be decreased. Running kernels with profiling will always cause implicit device synchronization before and after the kernel run is finished.

Parameters
idId of kernel definition which will be run. The specified definition must be included in the currently launched kernel.

◆ RunKernelWithProfiling() [2/2]

void ktt::ComputeInterface::RunKernelWithProfiling ( const KernelDefinitionId  id,
const DimensionVector globalSize,
const DimensionVector localSize 
)
pure virtual

Runs the specified kernel definition using provided thread sizes. Collection of kernel profiling counters will be enabled for this run which means that performance will be decreased. Running kernels with profiling will always cause implicit device synchronization before and after the kernel run is finished.

Parameters
idId of kernel definition which will be run. The specified definition must be included in the currently launched kernel.
globalSizeDimensions for global size with which the kernel will be run.
localSizeDimensions for local size with which the kernel will be run.

◆ SwapArguments()

void ktt::ComputeInterface::SwapArguments ( const KernelDefinitionId  id,
const ArgumentId first,
const ArgumentId second 
)
pure virtual

Swaps positions of kernel arguments for the specified kernel definition under currently launched kernel.

Parameters
idId of kernel definition for which the arguments will be swapped. The specified definition must be included in the currently launched kernel.
firstId of the first argument which will be swapped.
secondId of the second argument which will be swapped.

◆ SynchronizeDevice()

void ktt::ComputeInterface::SynchronizeDevice ( )
pure virtual

Blocks until all commands submitted to device are completed.

◆ SynchronizeQueue()

void ktt::ComputeInterface::SynchronizeQueue ( const QueueId  queue)
pure virtual

Blocks until all commands submitted to the specified device queue are completed.

Parameters
queueId of queue which will be synchronized.

◆ SynchronizeQueues()

void ktt::ComputeInterface::SynchronizeQueues ( )
pure virtual

Blocks until all commands submitted to all device queues are completed.

◆ UpdateBuffer()

void ktt::ComputeInterface::UpdateBuffer ( const ArgumentId id,
const void *  data,
const size_t  dataSize = 0 
)
pure virtual

Updates data in compute buffer of the specified vector argument.

Parameters
idId of vector argument which will be updated.
dataPointer to new data for vector argument. Its size must be equal or greater than the specified data size. The data must have matching kernel argument data type.
dataSizeSize in bytes of buffer portion which will be updated, starting with the first byte. If zero, the entire buffer will be updated.

◆ UpdateBufferAsync()

TransferActionId ktt::ComputeInterface::UpdateBufferAsync ( const ArgumentId id,
const QueueId  queue,
const void *  data,
const size_t  dataSize = 0 
)
pure virtual

Updates data in compute buffer of the specified vector argument. The data will be transferred asynchronously in the specified queue.

Parameters
idId of vector argument which will be updated.
queueId of queue in which the command to update argument will be submitted.
dataPointer to new data for vector argument. Its size must be equal or greater than the specified data size. The data must have matching kernel argument data type.
dataSizeSize in bytes of buffer portion which will be updated, starting with the first byte. If zero, the entire buffer will be updated.
Returns
Id of asynchronous action corresponding to the issued data transfer command. The action must be waited for with e.g., WaitForTransferAction(), SynchronizeQueue() methods. Otherwise, problems such as incorrectly recorded transfer durations may occur.

◆ UpdateLocalArgument()

void ktt::ComputeInterface::UpdateLocalArgument ( const ArgumentId id,
const size_t  dataSize 
)
pure virtual

Updates the specified local memory argument under currently launched kernel.

Parameters
idId of local memory argument which will be updated.
dataSizeNew size in bytes for the argument.

◆ UpdateScalarArgument()

void ktt::ComputeInterface::UpdateScalarArgument ( const ArgumentId id,
const void *  data 
)
pure virtual

Updates the specified scalar argument under currently launched kernel.

Parameters
idId of scalar argument which will be updated.
dataPointer to new data for scalar argument. The data must have matching kernel argument data type.

◆ UploadBuffer()

void ktt::ComputeInterface::UploadBuffer ( const ArgumentId id)
pure virtual

Uploads the specified vector argument into compute buffer. This method should be used mainly with arguments with ArgumentManagementType set to User.

Parameters
idId of vector argument which will be uploaded.

◆ UploadBufferAsync()

TransferActionId ktt::ComputeInterface::UploadBufferAsync ( const ArgumentId id,
const QueueId  queue 
)
pure virtual

Uploads the specified vector argument into compute buffer. The data will be transferred asynchronously in the specified queue.

Parameters
idId of vector argument which will be uploaded.
queueId of queue in which the command to upload argument will be submitted.
Returns
Id of asynchronous action corresponding to the issued data transfer command. The action must be waited for with e.g., WaitForTransferAction(), SynchronizeQueue() methods. Otherwise, problems such as incorrectly recorded transfer durations may occur.

◆ WaitForComputeAction()

void ktt::ComputeInterface::WaitForComputeAction ( const ComputeActionId  id)
pure virtual

Blocks until the specified compute action is finished.

Parameters
idId of compute action to wait for.

◆ WaitForTransferAction()

void ktt::ComputeInterface::WaitForTransferAction ( const TransferActionId  id)
pure virtual

Blocks until the specified buffer transfer action is finished.

Parameters
idId of transfer action to wait for.

The documentation for this class was generated from the following file: