Skip to content
GitLab
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
3888e3fd
Commit
3888e3fd
authored
Feb 24, 2022
by
Richard Angersbach
Browse files
Add handling for I/O of layout-transformed fields via copies.
parent
38d7acbf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Compiler/src/exastencils/io/ir/IR_FileAccess.scala
View file @
3888e3fd
...
...
@@ -9,6 +9,7 @@ import exastencils.baseExt.ir._
import
exastencils.config.Knowledge
import
exastencils.config.Platform
import
exastencils.config.Settings
import
exastencils.core.Duplicate
import
exastencils.datastructures.Transformation.Output
import
exastencils.datastructures.ir.StatementList
import
exastencils.logger.Logger
...
...
@@ -48,6 +49,38 @@ abstract class IR_FileAccess(interfaceName : String) extends IR_Statement with I
}
def
mpiDatatypeBuffer
(
buf
:
IR_DataBuffer
)
=
IR_VariableAccess
(
buf
.
datatype
.
resolveBaseDatatype
.
prettyprint_mpi
,
IR_UnknownDatatype
)
// handling for field layout transformations
var
allocateCopiesLayoutTrafos
:
ListBuffer
[
IR_Statement
]
=
ListBuffer
[
IR_Statement
]()
var
handleLayoutTrafos
:
ListBuffer
[
IR_Statement
]
=
ListBuffer
[
IR_Statement
]()
dataBuffers
.
zipWithIndex
.
foreach
{
case
(
dataBuffer
,
bufIdx
)
=>
// create copy for layout trafos if not stream-based IO
if
(!
isInstanceOf
[
IR_Iostream
]
&&
dataBuffer
.
layoutTransformationTarget
.
isDefined
)
{
// replace databuffer in array with copy
val
buf
=
Duplicate
(
dataBuffer
)
val
copy
=
IR_IV_TemporaryBuffer
(
buf
.
datatype
.
resolveBaseDatatype
,
buf
.
localization
,
buf
.
name
+
"_copy_layout_trafo"
,
buf
.
domainIdx
,
buf
.
accessBlockwise
,
buf
.
innerDimsLocal
)
val
pattern
=
buf
.
accessPattern
match
{
case
_
:
IR_RegularAccessPattern
=>
IR_RegularAccessPattern
(
IR_AccessTempBufferFunction
(
copy
))
case
swe
:
IR_SWEAccessPattern
=>
IR_SWEAccessPattern
(
IR_AccessTempBufferFunction
(
copy
),
swe
.
accessIndices
)
}
val
copyBuf
=
IR_DataBuffer
(
copy
,
buf
.
slot
,
Some
(
pattern
),
Some
(
buf
.
datasetName
),
buf
.
canonicalOrder
)
// fill copy with values from original buffer
val
indices
=
copyBuf
.
getIndicesMultiDimDatatypes
allocateCopiesLayoutTrafos
+=
copy
.
allocateMemory
handleLayoutTrafos
+=
IR_LoopOverFragments
(
copyBuf
.
loopOverDims
(
true
,
indices
.
map
(
idx
=>
if
(
writeAccess
)
IR_Assignment
(
copyBuf
.
getAccess
(
idx
),
buf
.
getAccess
(
idx
))
else
IR_Assignment
(
buf
.
getAccess
(
idx
),
copyBuf
.
getAccess
(
idx
))
)
:
_
*
))
dataBuffers
(
bufIdx
)
=
copyBuf
// replace buffer
}
}
// to be implemented by all subclasses
def
dataBuffers
:
ListBuffer
[
IR_DataBuffer
]
def
filename
:
IR_Expression
...
...
@@ -203,6 +236,13 @@ abstract class IR_FileAccess(interfaceName : String) extends IR_Statement with I
stmts
++=
closeFile
()
}
// handling for fields with transformed layout
if
(
writeAccess
)
// copy-in/out
stmts
.
prepend
(
handleLayoutTrafos
:
_
*
)
else
stmts
.
append
(
handleLayoutTrafos
:
_
*
)
stmts
.
prepend
(
allocateCopiesLayoutTrafos
:
_
*
)
// alloc copies
// reset lookup tables
IR_DataBuffer
.
resetDimensionalityMap
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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