Template Class OperationKernelMap

Class Documentation

template<class Operation, size_t cache_size = 16>
class OperationKernelMap

This class manages all data related to kernel map statevector uses.

For a given number of qubit, threading, and memory model, this class returns the best kernels for each gate/generator/matrix operation.

Public Types

using EnumDispatchKernalMap = std::unordered_map<std::pair<Operation, uint32_t>, PriorityDispatchSet, PairHash>
using EnumKernelMap = std::unordered_map<Operation, KernelType>

Public Functions

inline void assignKernelForOp(Operation op, Threading threading, CPUMemoryModel memory_model, uint32_t priority, const Util::IntegerInterval<size_t> &interval, KernelType kernel)

Assign a kernel for a given operation, threading, and memory model.

Variable priority set the priority of the given kernel when multiple choices are available. The given interval must be disjoint with all existing intervals with a given priority.

Parameters
  • op – Operation to use as a dispatch key

  • threading – Threading option to use as a dispatch key

  • memory_model – Memory model to use as a dispatch key

  • priority – Priority of this assignment

  • interval – Range of the number of qubits to use this kernel

  • kernel – Kernel to assign

inline void assignKernelForOp(Operation op, [[maybe_unused]] AllThreading dummy, CPUMemoryModel memory_model, const Util::IntegerInterval<size_t> &interval, KernelType kernel)

Assign kernel for given operation and memory model for all threading options. The priority of this assignment is 1.

inline void assignKernelForOp(Operation op, Threading threading, [[maybe_unused]] AllMemoryModel dummy, const Util::IntegerInterval<size_t> &interval, KernelType kernel)

Assign kernel for given operation and threading option for all memory models. The priority of this assignment is 2.

inline void assignKernelForOp(Operation op, [[maybe_unused]] AllThreading dummy1, [[maybe_unused]] AllMemoryModel dummy2, const Util::IntegerInterval<size_t> &interval, KernelType kernel)

Assign kernel for a given operation for all memory model and all threading options. The priority of this assignment is 0.

inline void removeKernelForOp(Operation op, Threading threading, CPUMemoryModel memory_model, uint32_t priority)

Remove an assigned kernel for the given operation, threading, and memory model.

Parameters
  • op – Operation

  • threading – Threading option

  • memory_model – Memory model

  • priority – Priority to remove

inline auto getKernelMap(size_t num_qubits, Threading threading, CPUMemoryModel memory_model) const -> EnumKernelMap

Create map contains default kernels for operation.

Parameters
  • num_qubits – Number of qubits

  • threading – Threading context

  • memory_model – Memory model of the underlying data

Returns

A kernel map for given keys

Public Static Functions

static inline auto getInstance() -> OperationKernelMap&

Get a singleton instance.

Returns

A singleton instance.