STORMM Source Documentation
Loading...
Searching...
No Matches
kernel_format.h
1// -*-c++-*-
2#ifndef STORMM_KERNEL_MANAGER_H
3#define STORMM_KERNEL_MANAGER_H
4
5#include <map>
6#include <string>
7#ifdef STORMM_USE_HPC
8# ifdef STORMM_USE_CUDA
9# include <cuda_runtime.h>
10# endif
11#endif
12#include "copyright.h"
13#include "DataTypes/stormm_vector_types.h"
14#include "gpu_details.h"
15
16namespace stormm {
17namespace card {
18
19#ifndef STORMM_USE_HPC
20using data_types::int2;
21#endif
22
24const char generic_kernel_manager_name[] = "KernelManager";
25
28public:
29
51
52 KernelFormat(int lb_max_threads_per_block, int lb_min_blocks_per_smp, int register_usage_in,
53 int shared_usage_in, int block_subdivision, const GpuDetails &gpu,
54 const std::string &kernel_name_in = std::string(""));
55
56 KernelFormat(int lb_max_threads_per_block, int lb_min_blocks_per_smp, int register_usage_in,
57 int shared_usage_in, const GpuDetails &gpu,
58 const std::string &kernel_name_in = std::string(""));
59
60#ifdef STORMM_USE_HPC
61# ifdef STORMM_USE_CUDA
62 KernelFormat(const cudaFuncAttributes &attr, int lb_min_blocks_per_smp, int block_subdivision,
63 const GpuDetails &gpu, const std::string &kernel_name_in = std::string(""));
64# endif
65#endif
67
70 KernelFormat(const KernelFormat &original) = default;
71 KernelFormat(KernelFormat &&original) = default;
72 KernelFormat& operator=(const KernelFormat &other) = default;
73 KernelFormat& operator=(KernelFormat &&other) = default;
75
78
80 int getRegisterUsage() const;
81
83 int getBlockSizeLimit() const;
84
87
89 const std::string& getKernelName() const;
90
91private:
92 int block_size_limit;
94 int shared_usage;
95 int block_dimension;
96 int grid_dimension;
97 int register_usage;
99 std::string kernel_name;
100};
101
105public:
106
108 const GpuDetails& getGpu() const;
109
115 void printLaunchParameters(const std::string &k_key = std::string(""),
116 const char* true_class_name = generic_kernel_manager_name) const;
117
118protected:
119
121 KernelManager(const GpuDetails &gpu_in = null_gpu);
122
125 virtual ~KernelManager();
126
129
132 std::map<std::string, KernelFormat> k_dictionary;
133};
134
135} // namespace card
136} // namespace stormm
137
138#endif
Pertinent aspects of one particular GPU. Condensing the data for each GPU in this manner helps to ens...
Definition gpu_details.h:27
KernelFormat(const KernelFormat &original)=default
Take the default copy and move constructors as well as assignment operators.
int getRegisterUsage() const
Get the register usage of the kernel.
Definition kernel_format.cpp:69
int getBlockSizeLimit() const
Get the maximum thread count for a single block in the kernel launch.
Definition kernel_format.cpp:74
KernelFormat()
The constructor takes launch bounds and other information that can be plucked from a cudaFuncAttribut...
Definition kernel_format.cpp:18
const std::string & getKernelName() const
Get the name of this kernel.
Definition kernel_format.cpp:84
int getSharedMemoryRequirement() const
Get the amount of shared memory needed by any one block.
Definition kernel_format.cpp:79
int2 getLaunchParameters() const
Get the optimal block and grid sizes for kernel launches with the present GPU.
Definition kernel_format.cpp:64
virtual ~KernelManager()
A virtual destructor ensures proper behavior in the destructors of derived classes for managing parti...
Definition kernel_format.cpp:94
const GpuDetails & getGpu() const
Get the GPU information for the active GPU.
Definition kernel_format.cpp:98
KernelManager(const GpuDetails &gpu_in=null_gpu)
The constructor for this base class takes the GPU specifications.
Definition kernel_format.cpp:89
void printLaunchParameters(const std::string &k_key=std::string(""), const char *true_class_name=generic_kernel_manager_name) const
Print out the kernel launch parameters found for this workload.
Definition kernel_format.cpp:103
GpuDetails gpu
The details of the GPU in use are simply copied into this object.
Definition kernel_format.h:128
std::map< std::string, KernelFormat > k_dictionary
Definition kernel_format.h:132
Definition stormm_vector_types.h:22