Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ExaStencils
exastencils-release
Commits
5f8a701a
Commit
5f8a701a
authored
Mar 17, 2022
by
Richard Angersbach
Browse files
Refactor temp buffer IV
parent
f3b0a367
Changes
8
Hide whitespace changes
Inline
Side-by-side
Compiler/src/exastencils/applications/ns/ir/IR_PrintVisualizationNS.scala
View file @
5f8a701a
...
@@ -76,7 +76,7 @@ trait IR_PrintVisualizationNS extends IR_PrintVisualizationQuads {
...
@@ -76,7 +76,7 @@ trait IR_PrintVisualizationNS extends IR_PrintVisualizationQuads {
IR_IfCondition
(
IR_IV_IsValidForDomain
(
p
.
domain
.
index
),
IR_IfCondition
(
IR_IV_IsValidForDomain
(
p
.
domain
.
index
),
IR_LoopOverDimensions
(
numDimsGrid
,
idxRange
,
IR_LoopOverDimensions
(
numDimsGrid
,
idxRange
,
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
vel
,
IR_LoopOverFragments
.
defIt
*
numCellsPerFrag
+
linearizedIdx
),
IR_
ArrayAccess
(
vel
,
IR_LoopOverFragments
.
defIt
*
numCellsPerFrag
+
linearizedIdx
),
velAsVec
(
dir
)))))
velAsVec
(
dir
)))))
}
}
...
@@ -99,7 +99,7 @@ trait IR_PrintVisualizationNS extends IR_PrintVisualizationQuads {
...
@@ -99,7 +99,7 @@ trait IR_PrintVisualizationNS extends IR_PrintVisualizationQuads {
val
initBuffer
:
ListBuffer
[
IR_Statement
]
=
(
0
until
numDimsGrid
).
map
(
d
=>
{
val
initBuffer
:
ListBuffer
[
IR_Statement
]
=
(
0
until
numDimsGrid
).
map
(
d
=>
{
val
linearizedIdx
=
idxRange
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
val
linearizedIdx
=
idxRange
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
velocityBuf
,
IR_LoopOverFragments
.
defIt
*
numCellsPerFrag
*
numDimsGrid
+
numDimsGrid
*
linearizedIdx
+
d
),
IR_
ArrayAccess
(
velocityBuf
,
IR_LoopOverFragments
.
defIt
*
numCellsPerFrag
*
numDimsGrid
+
numDimsGrid
*
linearizedIdx
+
d
),
velAsVec
(
d
))
:
IR_Statement
velAsVec
(
d
))
:
IR_Statement
}).
to
[
ListBuffer
]
}).
to
[
ListBuffer
]
...
...
Compiler/src/exastencils/applications/swe/ir/IR_PrintVisualizationSWE.scala
View file @
5f8a701a
...
@@ -91,7 +91,7 @@ trait IR_PrintVisualizationSWE extends IR_PrintVisualizationTriangles {
...
@@ -91,7 +91,7 @@ trait IR_PrintVisualizationSWE extends IR_PrintVisualizationTriangles {
IR_LoopOverDimensions
(
numDimsGrid
,
indexRangeCells
,
IR_LoopOverDimensions
(
numDimsGrid
,
indexRangeCells
,
(
0
until
numAccessesPerCell
).
to
[
ListBuffer
].
map
(
idx
=>
{
(
0
until
numAccessesPerCell
).
to
[
ListBuffer
].
map
(
idx
=>
{
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
tmpBuf
,
offset
+
idx
),
IR_
ArrayAccess
(
tmpBuf
,
offset
+
idx
),
IR_FieldAccess
(
discFields
(
tmpBuf
.
name
)(
idx
),
IR_IV_ActiveSlot
(
someCellField
),
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)))
:
IR_Statement
IR_FieldAccess
(
discFields
(
tmpBuf
.
name
)(
idx
),
IR_IV_ActiveSlot
(
someCellField
),
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)))
:
IR_Statement
}))))
}))))
}
}
...
...
Compiler/src/exastencils/applications/swe/ir/IR_PrintXdmfSWE.scala
View file @
5f8a701a
...
@@ -117,7 +117,7 @@ case class IR_PrintXdmfSWE(
...
@@ -117,7 +117,7 @@ case class IR_PrintXdmfSWE(
IR_LoopOverDimensions
(
numDimsGrid
,
indexRangeCells
,
IR_LoopOverDimensions
(
numDimsGrid
,
indexRangeCells
,
(
0
until
numAccessesPerCell
).
to
[
ListBuffer
].
map
(
idx
=>
{
(
0
until
numAccessesPerCell
).
to
[
ListBuffer
].
map
(
idx
=>
{
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
tmpBuf
,
offset
+
idx
),
IR_
ArrayAccess
(
tmpBuf
,
offset
+
idx
),
IR_FieldAccess
(
nodalFields
(
name
),
IR_IV_ActiveSlot
(
nodalFields
(
name
)),
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)
+
nodeOffsets
(
idx
)))
:
IR_Statement
IR_FieldAccess
(
nodalFields
(
name
),
IR_IV_ActiveSlot
(
nodalFields
(
name
)),
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)
+
nodeOffsets
(
idx
)))
:
IR_Statement
})))))
})))))
}
}
...
...
Compiler/src/exastencils/io/ir/IR_AccessPattern.scala
View file @
5f8a701a
...
@@ -26,7 +26,7 @@ case class IR_AccessFieldFunction(var field : IR_Field, var slot : IR_Expression
...
@@ -26,7 +26,7 @@ case class IR_AccessFieldFunction(var field : IR_Field, var slot : IR_Expression
}
}
case
class
IR_AccessTempBufferFunction
(
var
tempBuffer
:
IR_IV_TemporaryBuffer
)
extends
IR_AccessFunction
{
case
class
IR_AccessTempBufferFunction
(
var
tempBuffer
:
IR_IV_TemporaryBuffer
)
extends
IR_AccessFunction
{
override
def
get
(
idx
:
IR_Index
)
=
IR_
IV_TemporaryBuffer
.
accessArray
(
tempBuffer
,
idx
)
override
def
get
(
idx
:
IR_Index
)
=
IR_
ArrayAccess
(
tempBuffer
,
tempBuffer
.
linearizedIndex
(
idx
)
)
}
}
/// IR_AccessPattern
/// IR_AccessPattern
...
...
Compiler/src/exastencils/io/ir/IR_IV_TemporaryBuffer.scala
View file @
5f8a701a
...
@@ -8,6 +8,7 @@ import exastencils.baseExt.ir.IR_ExpressionIndexRange
...
@@ -8,6 +8,7 @@ import exastencils.baseExt.ir.IR_ExpressionIndexRange
import
exastencils.baseExt.ir.IR_InternalVariable
import
exastencils.baseExt.ir.IR_InternalVariable
import
exastencils.baseExt.ir.IR_LoopOverFragments
import
exastencils.baseExt.ir.IR_LoopOverFragments
import
exastencils.grid.ir.IR_Localization
import
exastencils.grid.ir.IR_Localization
import
exastencils.prettyprinting.PpStream
/// IR_IV_TemporaryBuffer
/// IR_IV_TemporaryBuffer
// represents a temporary buffer where data is stored (fragment-wise) before writing it to file
// represents a temporary buffer where data is stored (fragment-wise) before writing it to file
...
@@ -16,17 +17,6 @@ import exastencils.grid.ir.IR_Localization
...
@@ -16,17 +17,6 @@ import exastencils.grid.ir.IR_Localization
// - only contains data of interest
// - only contains data of interest
// - does not have layers to be excluded (e.g. pad/ghost/...)
// - does not have layers to be excluded (e.g. pad/ghost/...)
object
IR_IV_TemporaryBuffer
{
def
accessArray
(
tempBuf
:
IR_IV_TemporaryBuffer
,
idx
:
IR_Expression
)
=
{
// TODO: should be done automatically
var
base
:
IR_Expression
=
tempBuf
if
(!
tempBuf
.
blockwise
)
base
=
IR_ArrayAccess
(
tempBuf
,
IR_LoopOverFragments
.
defIt
)
IR_ArrayAccess
(
base
,
tempBuf
.
linearizedIndex
(
idx
))
}
}
case
class
IR_IV_TemporaryBuffer
(
case
class
IR_IV_TemporaryBuffer
(
var
baseDatatype
:
IR_Datatype
,
var
baseDatatype
:
IR_Datatype
,
var
localization
:
IR_Localization
,
var
localization
:
IR_Localization
,
...
@@ -34,7 +24,9 @@ case class IR_IV_TemporaryBuffer(
...
@@ -34,7 +24,9 @@ case class IR_IV_TemporaryBuffer(
var
domainIdx
:
Int
,
var
domainIdx
:
Int
,
var
blockwise
:
Boolean
,
var
blockwise
:
Boolean
,
dimsPerFrag
:
ListBuffer
[
IR_Expression
],
dimsPerFrag
:
ListBuffer
[
IR_Expression
],
)
extends
IR_InternalVariable
(!
blockwise
,
true
,
false
,
false
,
false
)
with
IR_Access
{
)
extends
IR_InternalVariable
(!
blockwise
,
true
,
false
,
false
,
false
)
{
override
def
prettyprint
(
out
:
PpStream
)
:
Unit
=
out
<<
this
.
resolveAccess
()
override
def
resolveName
()
:
String
=
name
+
resolvePostfix
(
""
,
domainIdx
.
prettyprint
,
""
,
""
,
""
)
override
def
resolveName
()
:
String
=
name
+
resolvePostfix
(
""
,
domainIdx
.
prettyprint
,
""
,
""
,
""
)
override
def
resolveDatatype
()
:
IR_Datatype
=
IR_PointerDatatype
(
baseDatatype
)
override
def
resolveDatatype
()
:
IR_Datatype
=
IR_PointerDatatype
(
baseDatatype
)
...
...
Compiler/src/exastencils/visualization/ir/postprocessing/IR_PrintVisualization.scala
View file @
5f8a701a
...
@@ -193,7 +193,7 @@ trait IR_PrintVisualization {
...
@@ -193,7 +193,7 @@ trait IR_PrintVisualization {
val
initBuffer
:
ListBuffer
[
IR_Statement
]
=
connectivityForCell
().
indices
.
map
(
d
=>
{
val
initBuffer
:
ListBuffer
[
IR_Statement
]
=
connectivityForCell
().
indices
.
map
(
d
=>
{
val
linearizedLoopIdx
=
loopOverCells
().
indices
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
val
linearizedLoopIdx
=
loopOverCells
().
indices
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
connectivityBuf
,
IR_LoopOverFragments
.
defIt
*
sizeConnectionFrag
+
connectivityForCell
().
length
*
linearizedLoopIdx
+
d
),
IR_
ArrayAccess
(
connectivityBuf
,
IR_LoopOverFragments
.
defIt
*
sizeConnectionFrag
+
connectivityForCell
().
length
*
linearizedLoopIdx
+
d
),
connectivityForCell
(
global
)(
d
))
:
IR_Statement
connectivityForCell
(
global
)(
d
))
:
IR_Statement
}).
to
[
ListBuffer
]
}).
to
[
ListBuffer
]
...
@@ -220,7 +220,7 @@ trait IR_PrintVisualization {
...
@@ -220,7 +220,7 @@ trait IR_PrintVisualization {
val
dims
=
(
indexRange
.
end
-
indexRange
.
begin
).
indices
.
to
[
ListBuffer
]
val
dims
=
(
indexRange
.
end
-
indexRange
.
begin
).
indices
.
to
[
ListBuffer
]
val
linearizedLoopIdx
=
indexRange
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
val
linearizedLoopIdx
=
indexRange
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
val
init
=
IR_Assignment
(
val
init
=
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
cellCentersBuf
(
dim
),
IR_LoopOverFragments
.
defIt
*
dims
.
reduce
(
_
*
_
)
+
linearizedLoopIdx
),
IR_
ArrayAccess
(
cellCentersBuf
(
dim
),
IR_LoopOverFragments
.
defIt
*
dims
.
reduce
(
_
*
_
)
+
linearizedLoopIdx
),
getPos
(
IR_AtCellCenter
,
level
,
dim
))
getPos
(
IR_AtCellCenter
,
level
,
dim
))
// declare, allocate and init temp. buffer with cell centers
// declare, allocate and init temp. buffer with cell centers
...
@@ -264,7 +264,7 @@ trait IR_PrintVisualization {
...
@@ -264,7 +264,7 @@ trait IR_PrintVisualization {
IR_LoopOverDimensions
(
numDimsGrid
,
IR_LoopOverDimensions
(
numDimsGrid
,
indexRange
,
indexRange
,
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
facePositionsBuf
(
faceDir
)(
dim
),
IR_LoopOverFragments
.
defIt
*
dims
.
reduce
(
_
*
_
)
+
linearizedLoopIdx
),
IR_
ArrayAccess
(
facePositionsBuf
(
faceDir
)(
dim
),
IR_LoopOverFragments
.
defIt
*
dims
.
reduce
(
_
*
_
)
+
linearizedLoopIdx
),
getPos
(
IR_AtFaceCenter
(
faceDir
),
level
,
dim
)))))))
getPos
(
IR_AtFaceCenter
(
faceDir
),
level
,
dim
)))))))
}
}
...
@@ -285,7 +285,7 @@ trait IR_PrintVisualization {
...
@@ -285,7 +285,7 @@ trait IR_PrintVisualization {
val
initBuffer
:
ListBuffer
[
IR_Statement
]
=
(
0
until
numAccPerCell
).
map
(
n
=>
{
val
initBuffer
:
ListBuffer
[
IR_Statement
]
=
(
0
until
numAccPerCell
).
map
(
n
=>
{
val
linearizedLoopIdx
=
loopOverDims
(
isNodalLoop
).
indices
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
val
linearizedLoopIdx
=
loopOverDims
(
isNodalLoop
).
indices
.
linearizeIndex
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
))
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
nodePositionsBuf
(
dim
),
IR_LoopOverFragments
.
defIt
*
numPointsPerFrag
+
numAccPerCell
*
linearizedLoopIdx
+
n
),
IR_
ArrayAccess
(
nodePositionsBuf
(
dim
),
IR_LoopOverFragments
.
defIt
*
numPointsPerFrag
+
numAccPerCell
*
linearizedLoopIdx
+
n
),
getPos
(
IR_AtNode
,
level
,
dim
,
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)
+
nodeOffsets
(
n
)))
:
IR_Statement
getPos
(
IR_AtNode
,
level
,
dim
,
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)
+
nodeOffsets
(
n
)))
:
IR_Statement
}).
to
[
ListBuffer
]
}).
to
[
ListBuffer
]
...
...
Compiler/src/exastencils/visualization/ir/postprocessing/netCDF/IR_PrintExodus.scala
View file @
5f8a701a
...
@@ -266,11 +266,11 @@ abstract class IR_PrintExodus() extends IR_Statement with IR_Expandable with IR_
...
@@ -266,11 +266,11 @@ abstract class IR_PrintExodus() extends IR_Statement with IR_Expandable with IR_
IR_LoopOverDimensions
(
numDimsGrid
,
indexRangeTransformed
,
IR_LoopOverDimensions
(
numDimsGrid
,
indexRangeTransformed
,
(
0
until
numAccesses
).
to
[
ListBuffer
].
map
(
idx
=>
{
(
0
until
numAccesses
).
to
[
ListBuffer
].
map
(
idx
=>
{
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
tmp
,
offset
+
idx
),
IR_
ArrayAccess
(
tmp
,
offset
+
idx
),
buf
.
getAccess
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)
+
accesses
(
idx
)))
:
IR_Statement
buf
.
getAccess
(
IR_LoopOverDimensions
.
defIt
(
numDimsGrid
)
+
accesses
(
idx
)))
:
IR_Statement
}))))
}))))
IR_AddressOf
(
IR_
IV_TemporaryBuffer
.
accessArray
(
tmp
,
0
))
IR_AddressOf
(
IR_
ArrayAccess
(
tmp
,
0
))
}
else
{
}
else
{
buf
.
getBaseAddress
buf
.
getBaseAddress
}
}
...
...
Compiler/src/exastencils/visualization/ir/postprocessing/xdmf/IR_PrintXdmfStructured.scala
View file @
5f8a701a
...
@@ -129,7 +129,7 @@ abstract class IR_PrintXdmfStructured(ioMethod : IR_Expression) extends IR_Print
...
@@ -129,7 +129,7 @@ abstract class IR_PrintXdmfStructured(ioMethod : IR_Expression) extends IR_Print
IR_IfCondition
(
IR_IV_IsValidForDomain
(
dataBuffer
.
domainIdx
),
IR_IfCondition
(
IR_IV_IsValidForDomain
(
dataBuffer
.
domainIdx
),
IR_LoopOverDimensions
(
numDimsGrid
,
idxRange
,
IR_LoopOverDimensions
(
numDimsGrid
,
idxRange
,
IR_Assignment
(
IR_Assignment
(
IR_
IV_TemporaryBuffer
.
accessArray
(
tmpBufDest
,
fragOff
+
linearizedIdx
),
IR_
ArrayAccess
(
tmpBufDest
,
fragOff
+
linearizedIdx
),
mean
))))
mean
))))
stmts
stmts
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment