DoConcurrentLoop

A loop whose iterations may run in any order.

Declaration

Syntax

DoConcurrentLoop(do_loop_head* head, expr* shared, expr* local,
    reduction_expr* reduction, stmt* body)

Arguments

Argument

Description

head

one do_loop_head per index, giving the index variable and its range. Several heads mean a nest of concurrent indices.

shared

the variables shared by all iterations.

local

the variables each iteration has its own copy of.

reduction

the reductions, each a reduction_expr pairing an operator with the variable it accumulates into.

body

the statements of one iteration.

Return values

None.

Description

do concurrent asserts that the iterations do not depend on each other, so a backend may run them in any order or in parallel. ASR records the assertion and the data environment; it does not check it.

The locality lists say what each iteration sees. A variable in local is private to an iteration, a variable in shared is not, and a variable in reduction is combined across iterations with the named operator.

Examples

An ASR text document that uses it:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "a" (Variable
              :parent_symtab 1
              :name "a"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Array
                :type (Integer
                  :kind 4
                )
                :dims [
                  (dimension
                    :start (IntegerConstant
                      :n 1
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                    :length (IntegerConstant
                      :n 3
                      :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 1
              :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 []
            )
            "total" (Variable
              :parent_symtab 1
              :name "total"
              :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 "main"
        :dependencies []
        :body [
          (DoConcurrentLoop
            :head [
              (do_loop_head
                :v (Var
                  :v (SymbolRef 1 "i")
                )
                :start (IntegerConstant
                  :n 1
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :end (IntegerConstant
                  :n 3
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :increment (IntegerConstant
                  :n 1
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
              )
            ]
            :shared [
              (Var
                :v (SymbolRef 1 "a")
              )
            ]
            :local [
              (Var
                :v (SymbolRef 1 "i")
              )
            ]
            :reduction [
              (reduction_expr
                :op :ReduceAdd
                :arg (Var
                  :v (SymbolRef 1 "total")
                )
              )
            ]
            :body [
              (Assignment
                :target (ArrayItem
                  :v (Var
                    :v (SymbolRef 1 "a")
                  )
                  :args [
                    (array_index
                      :left nil
                      :right (Var
                        :v (SymbolRef 1 "i")
                      )
                      :step nil
                    )
                  ]
                  :type (Integer
                    :kind 4
                  )
                  :storage_format :ColMajor
                  :value nil
                )
                :value (Var
                  :v (SymbolRef 1 "i")
                )
                :overloaded nil
                :realloc_lhs false
                :move_allocation false
              )
            ]
          )
        ]
      )
    }
  )
  :items []
)

See Also

DoLoop, OMPRegion, do_loop_head, reduction_expr