GpuBlockSize¶
The number of threads in a block.
Declaration¶
Syntax¶
GpuBlockSize(int dim, ttype type, expr? value)
Arguments¶
Argument |
Description |
|---|---|
|
which dimension to report, counting from zero. |
|
the type of the expression. |
|
the compile time value of the expression, when the frontend could fold it; |
Return values¶
The value of the expression.
Description¶
This is the block_size the kernel was launched with. It is read at run time
rather than baked in, so one kernel can be launched with different
configurations.
Examples¶
(GpuBlockSize
:dim 0
:type (Integer
:kind 4
)
:value nil
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"m" (Module
:symtab (SymbolTable
:id 1
:symbols {
"scale" (GpuKernelFunction
:symtab (SymbolTable
:id 2
:symbols {
"a" (Variable
:parent_symtab 2
:name "a"
:dependencies []
:intent :InOut
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Real
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 256
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"i" (Variable
:parent_symtab 2
:name "i"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Integer
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "scale"
:function_signature (FunctionType
:arg_types [
(Array
:type (Real
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 256
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
)
]
:return_var_type nil
:abi :Source
:deftype :Implementation
:bindc_name nil
:elemental false
:pure false
:module false
:inline false
:static false
:restrictions []
:is_restriction false
)
:dependencies []
:args [
(Var
:v (SymbolRef 2 "a")
)
]
:body [
(Assignment
:target (Var
:v (SymbolRef 2 "i")
)
:value (IntegerBinOp
:left (GpuThreadIndex
:dim 0
:type (Integer
:kind 4
)
:value nil
)
:op :Add
:right (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 2 "i")
)
:value (IntegerBinOp
:left (GpuBlockIndex
:dim 0
:type (Integer
:kind 4
)
:value nil
)
:op :Mul
:right (GpuBlockSize
:dim 0
:type (Integer
:kind 4
)
:value nil
)
:type (Integer
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (ArrayItem
:v (Var
:v (SymbolRef 2 "a")
)
:args [
(array_index
:left nil
:right (Var
:v (SymbolRef 2 "i")
)
:step nil
)
]
:type (Real
:kind 4
)
:storage_format :ColMajor
:value nil
)
:value (RealConstant
:r 0.0
:type (Real
:kind 4
)
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
:access :Public
)
}
)
:name "m"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
"main" (Program
:symtab (SymbolTable
:id 3
:symbols {}
)
:name "main"
:dependencies []
:body []
)
}
)
:items []
)
See Also¶
GpuKernelFunction, GpuKernelLaunch, GpuThreadIndex, GpuBlockIndex, GpuBlockSize