OMPCollapse

collapse: how many nested loops to share as one iteration space.

Declaración

Sintaxis

OMPCollapse(expr count)

Argumentos

Argument

Descripción

count

how many loops to collapse.

Valores devueltos

None.

Descripción

With collapse(2) the two outermost loops of the nest are flattened into a single iteration space before the iterations are shared out, which gives the threads more work to divide when the outer loop is short.

Ejemplos

(OMPCollapse
  :count (IntegerConstant
    :n 1
    :type (Integer
      :kind 4
    )
    :intboz_type :Decimal
  )
)

It comes from this complete ASR text document:

(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
                :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 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 []
            )
            "n" (Variable
              :parent_symtab 1
              :name "n"
              :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 []
            )
            "run" (Variable
              :parent_symtab 1
              :name "run"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Logical
                :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 [
          (OMPRegion
            :region :Parallel
            :clauses [
              (OMPPrivate
                :vars [
                  (Var
                    :v (SymbolRef 1 "i")
                  )
                ]
              )
              (OMPShared
                :vars [
                  (Var
                    :v (SymbolRef 1 "a")
                  )
                ]
              )
              (OMPFirstPrivate
                :vars [
                  (Var
                    :v (SymbolRef 1 "n")
                  )
                ]
              )
              (OMPNumThreads
                :num_threads (IntegerConstant
                  :n 4
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
              )
              (OMPIf
                :condition (Var
                  :v (SymbolRef 1 "run")
                )
              )
            ]
            :body [
              (OMPRegion
                :region :Do
                :clauses [
                  (OMPSchedule
                    :kind :Static
                    :chunk_size (IntegerConstant
                      :n 1
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                  )
                  (OMPCollapse
                    :count (IntegerConstant
                      :n 1
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                  )
                  (OMPReduction
                    :operator :ReduceAdd
                    :vars [
                      (Var
                        :v (SymbolRef 1 "total")
                      )
                    ]
                  )
                  (OMPLastPrivate
                    :vars [
                      (Var
                        :v (SymbolRef 1 "i")
                      )
                    ]
                  )
                  (OMPNowait)
                ]
                :body [
                  (DoLoop
                    :name nil
                    :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
                      )
                    )
                    :body [
                      (Assignment
                        :target (Var
                          :v (SymbolRef 1 "total")
                        )
                        :value (IntegerBinOp
                          :left (Var
                            :v (SymbolRef 1 "total")
                          )
                          :op :Add
                          :right (Var
                            :v (SymbolRef 1 "i")
                          )
                          :type (Integer
                            :kind 4
                          )
                          :value nil
                        )
                        :overloaded nil
                        :realloc_lhs false
                        :move_allocation false
                      )
                    ]
                    :orelse []
                  )
                ]
                :exec_target :ExecAuto
              )
            ]
            :exec_target :ExecAuto
          )
          (OMPRegion
            :region :Target
            :clauses [
              (OMPMap
                :type :ToFrom
                :vars [
                  (Var
                    :v (SymbolRef 1 "a")
                  )
                ]
              )
              (OMPDevice
                :device (IntegerConstant
                  :n 0
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
              )
            ]
            :body [
              (OMPRegion
                :region :Teams
                :clauses [
                  (OMPNumTeams
                    :num_teams (IntegerConstant
                      :n 2
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                  )
                  (OMPThreadLimit
                    :thread_limit (IntegerConstant
                      :n 64
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                  )
                ]
                :body [
                  (Assignment
                    :target (Var
                      :v (SymbolRef 1 "total")
                    )
                    :value (IntegerConstant
                      :n 0
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                    :overloaded nil
                    :realloc_lhs false
                    :move_allocation false
                  )
                ]
                :exec_target :ExecAuto
              )
            ]
            :exec_target :ExecAuto
          )
        ]
      )
    }
  )
  :items []
)

Ver también

OMPSchedule, DoLoop, OMPRegion, omp_clause