GpuBlockIndex

The index of the running block within the grid.

Declaración

Sintaxis

GpuBlockIndex(int dim, ttype type, expr? value)

Argumentos

Argument

Descripción

dim

which dimension to report, counting from zero.

type

the type of the expression.

value

the compile time value of the expression, when the frontend could fold it; nil otherwise.

Valores devueltos

The value of the expression.

Descripción

The block index counts from zero, up to the grid_size the kernel was launched with.

Ejemplos

(GpuBlockIndex
  :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" (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
                      :memory_space :Global
                    )
                    :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
                    :memory_space :Global
                  )
                ]
                :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
                :exec_space :Kernel
              )
              :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
                )
              ]
              :return_var nil
              :access :Public
              :deterministic false
              :side_effect_free false
              :module_file nil
            )
          }
        )
        :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 []
)

Ver también

exec_space, GpuKernelLaunch, GpuThreadIndex, GpuBlockIndex, GpuBlockSize