docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
cuda_arch.h
Go to the documentation of this file.
1#pragma once
2
5#include "sdfg/types/array.h"
6
7namespace sdfg::codegen {
9}
10
11namespace sdfg::gpu::cuda {
12
18 uint32_t compute_cap;
21 std::vector<std::string> device_names;
22};
23
37std::vector<CudaComputeCapability> query_cuda_compute_capabilities();
38
40 const bool base_support;
41 const bool tf32_support;
42 const bool fp64_support;
43
47
48protected:
49 static constexpr MmaBlockSize DEFAULT_BLOCK_SIZE = {16, 16, 16};
50 static constexpr int THREADS_PER_WAVEFRONT = 32;
51
52public:
53 static constexpr const char* MMA_STORAGE_TYPE = "CUDA_MMA";
54
55 bool supported_types(types::PrimitiveType input_type, types::PrimitiveType output_type) const override;
57 types::PrimitiveType input_type, types::PrimitiveType output_type, types::PrimitiveType desired_acc_type
58 ) const override;
59
61
63 const MmaBlockSize& block_size, types::PrimitiveType input_type, types::PrimitiveType acc_type
64 ) const override;
65
66 std::optional<GpuMmaTiling> get_mma_tiling(
67 const symbolic::MultiExpression& res_shape,
68 types::PrimitiveType input_type,
69 types::PrimitiveType acc_type,
70 const MmaBlockSize* block_size_hint,
71 const BlockCounts* wave_tile_hint
72 ) const override;
73
75 types::StorageType& storage_type, const GpuMmaTiling& size, MmaFragmentType type, MmaFragmentLayout layout
76 ) const override;
77
78 std::vector<MmaBlockSize>
80
82 std::ostream& os,
84 const types::StorageType& storage_type,
85 types::PrimitiveType element_type
86 ) const;
87
89 std::ostream& os,
91 MmaFragmentType type,
92 const MmaBlockSize& dims,
93 MmaFragmentLayout layout,
94 types::PrimitiveType scalar_type,
95 std::optional<std::pair<int, int>> coop_dims
96 );
97
98 static bool is_mma_type(const types::StorageType& storage);
99};
100
101
102class CudaArch : public GpuArch {
103 int sm_version_;
104 CudaMmaSupport mma_support_;
105
106public:
107 CudaArch(int sm_version, bool mma_base_support, bool mma_tf32_support, bool mma_fp64_support)
108 : GpuArch(), sm_version_(sm_version), mma_support_(mma_base_support, mma_tf32_support, mma_fp64_support) {
109 }
110
111 std::string unique_id() const override;
112 std::string name() const override;
113
114 int per_cu_threads() const override {
115 return 32;
116 }
117
118 const CudaMmaSupport* mma_support() const override {
119 if (mma_support_.base_support) {
120 return &mma_support_;
121 } else {
122 return nullptr;
123 }
124 }
125
127};
128
141
147const CudaArch* cuda_arch_parse(const std::string& name);
148
149} // namespace sdfg::gpu::cuda
Array type representation for c-style arrays.
Definition language_extension.h:39
GpuArch()
Definition gpu_arch.h:18
Definition cuda_arch.h:102
int per_cu_threads() const override
Definition cuda_arch.h:114
std::string name() const override
CudaArch(int sm_version, bool mma_base_support, bool mma_tf32_support, bool mma_fp64_support)
Definition cuda_arch.h:107
structured_control_flow::ScheduleType create_schedule_type() const override
const CudaMmaSupport * mma_support() const override
Definition cuda_arch.h:118
std::string unique_id() const override
Represents a schedule type for Map nodes.
Definition structured_loop.h:31
Represents the storage location and management characteristics of data.
Definition type.h:64
std::vector< Expression > MultiExpression
Vector of symbolic expressions for multi-dimensional operations.
Definition symbolic.h:89
Definition argument_registry.h:10
StringEnum ImplementationType
Implementation type identifier for library nodes.
Definition library_node.h:75
Definition cuda_arch.h:11
CudaArch CUDA_ARCH_SM70
CudaArch CUDA_ARCH_SM90
const CudaArch * cuda_arch_from_env()
CudaArch CUDA_ARCH_SM75
std::vector< CudaComputeCapability > query_cuda_compute_capabilities()
Queries the CUDA compute capabilities of the GPUs available on this machine.
CudaArch CUDA_ARCH_SM86
CudaArch CUDA_ARCH_SM100
const CudaArch * cuda_arch_from_schedule_type(const structured_control_flow::ScheduleType &schedule)
Wrapper, that allows us to store this inside the ScheduleType in the future.
CudaArch CUDA_ARCH_SM120
CudaArch CUDA_ARCH_SM110
CudaArch CUDA_ARCH_SM80
const CudaArch * cuda_arch_parse(const std::string &name)
CudaArch CUDA_ARCH_SM103
CudaArch CUDA_ARCH_SM89
CudaArch CUDA_ARCH_SM87
const CudaArch * cuda_arch_from_available_hardware()
CudaArch CUDA_ARCH_SM107
MmaFragmentLayout
Definition gpu_mma_fragment.h:78
MmaFragmentType
Definition gpu_mma_fragment.h:14
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
Grouping of MMA blocks.
Definition gpu_mma_fragment.h:35
Definition gpu_mma_fragment.h:44
Definition gpu_mma_fragment.h:16
A CUDA compute capability together with the name(s) of the device(s) that report it.
Definition cuda_arch.h:15
uint32_t compute_cap
Compute capability in clang's integer convention (e.g.
Definition cuda_arch.h:18
std::vector< std::string > device_names
Distinct device names that share this compute capability, useful for logging.
Definition cuda_arch.h:21
Definition cuda_arch.h:39
types::PrimitiveType get_accumulator_type(types::PrimitiveType input_type, types::PrimitiveType output_type, types::PrimitiveType desired_acc_type) const override
const bool tf32_support
Definition cuda_arch.h:41
bool is_valid_block_size(const MmaBlockSize &block_size, types::PrimitiveType input_type, types::PrimitiveType acc_type) const override
void set_mma_fragment_storage_type(types::StorageType &storage_type, const GpuMmaTiling &size, MmaFragmentType type, MmaFragmentLayout layout) const override
static constexpr int THREADS_PER_WAVEFRONT
Definition cuda_arch.h:50
std::vector< MmaBlockSize > get_supported_block_sizes(types::PrimitiveType input_type, types::PrimitiveType acc_type) const override
std::optional< GpuMmaTiling > get_mma_tiling(const symbolic::MultiExpression &res_shape, types::PrimitiveType input_type, types::PrimitiveType acc_type, const MmaBlockSize *block_size_hint, const BlockCounts *wave_tile_hint) const override
static constexpr MmaBlockSize DEFAULT_BLOCK_SIZE
Definition cuda_arch.h:49
bool supported_types(types::PrimitiveType input_type, types::PrimitiveType output_type) const override
static constexpr const char * MMA_STORAGE_TYPE
Definition cuda_arch.h:53
static void emit_block_frag_type(std::ostream &os, codegen::LanguageExtension &lang_ext, MmaFragmentType type, const MmaBlockSize &dims, MmaFragmentLayout layout, types::PrimitiveType scalar_type, std::optional< std::pair< int, int > > coop_dims)
void emit_block_frag_type(std::ostream &os, codegen::LanguageExtension &lang_ext, const types::StorageType &storage_type, types::PrimitiveType element_type) const
static bool is_mma_type(const types::StorageType &storage)
const bool base_support
Definition cuda_arch.h:40
const bool fp64_support
Definition cuda_arch.h:42
data_flow::ImplementationType get_mma_impl_type(const GpuMmaTiling &tiling) const override
CudaMmaSupport(bool base_support, bool tf32_support, bool fp64_support)
Definition cuda_arch.h:44