IKernelDescriptor

struct IKernelDescriptor

This interface is used to implement an abstract representation for a kernel. For example, one may implement a MatrixMultiplyDescriptor that represents a kernel for matrix multiplication. The build method should return the KernelBuilder that be used to build the specific kernel.

The interface is used in combination with KernelRegistry to look up if this kernel has already been compiled. The registry is essentially a hash table that maps IKernelDescriptor objects to KernelInstance objects. This is why this descriptor class must implement equals and hash.

Subclassed by kernel_launcher::PragmaKernel

Public Functions

virtual KernelBuilder build() const = 0

Should return the KernelBuilder that can be used to build the kernel associated with this descriptor.

virtual bool equals(const IKernelDescriptor &that) const = 0

Check if this descriptor is equal to another descriptor.

inline virtual hash_t hash() const

Return a hash of this descriptor. This is used to test for equality of two descriptors:

  • Two descriptors that return the same hash MAY be identical.

  • Two descriptors that return different hashes MUST be different.

This method is optional; its default implementation just returns 0.