GpuKernelLaunch¶
Launches a GPU kernel.
Declaration¶
Syntax¶
GpuKernelLaunch(symbol kernel, expr grid_size, expr block_size,
call_arg* args)
Arguments¶
Argument |
Description |
|---|---|
|
the GpuKernelFunction to run. |
|
the number of blocks to launch. |
|
the number of threads per block. |
|
the arguments passed to every thread. |
Return values¶
None.
Description¶
A launch is not a call: it starts grid_size * block_size threads and, unless
the backend says otherwise, returns without waiting for them.
GpuSync is what waits.
The execution configuration is part of the node rather than of the kernel, because the same kernel is normally launched with different sizes.
Examples¶
(GpuKernelLaunch
:kernel (SymbolRef 1 "zero")
:grid_size (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:block_size (IntegerConstant
:n 256
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:args [
(call_arg
:value (Var
:v (SymbolRef 2 "a")
)
)
]
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"m" (Module
:symtab (SymbolTable
:id 1
:symbols {
"launch" (Function
: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 []
)
}
)
:name "launch"
: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 [
(GpuKernelLaunch
:kernel (SymbolRef 1 "zero")
:grid_size (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:block_size (IntegerConstant
:n 256
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:args [
(call_arg
:value (Var
:v (SymbolRef 2 "a")
)
)
]
)
(GpuSync)
]
:return_var nil
:access :Public
:deterministic false
:side_effect_free false
:module_file nil
)
"zero" (GpuKernelFunction
:symtab (SymbolTable
:id 3
:symbols {
"a" (Variable
:parent_symtab 3
: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 []
)
}
)
:name "zero"
: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 3 "a")
)
]
:body []
:access :Public
)
}
)
:name "m"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
"main" (Program
:symtab (SymbolTable
:id 4
:symbols {}
)
:name "main"
:dependencies []
:body []
)
}
)
:items []
)