Commit 2501aaa9 authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Merge branch 'master' into devel/adapt_alloc

# Conflicts:
#	Compiler/src/exastencils/app/ir/IR_LayerHandler.scala
#	Compiler/src/exastencils/config/Knowledge.scala
parents 26a768cf d243c6d7
......@@ -12,9 +12,9 @@ stages:
#######################################
.test_template:
image: i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11
dependencies:
- build:generator
image: i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11
tags:
- docker
artifacts:
......@@ -60,6 +60,26 @@ stages:
- ln -s /usr/local/cuda-11.4/targets/x86_64-linux/lib/libcudart.so /usr/lib
- cd Testing
.test_template_IO:
extends: .test_template
image: i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11-par-io
artifacts:
when: on_failure
paths:
- Testing/output/Debug/*
- Testing/output/generated/*
- Testing/data/*
expire_in: 1 weeks
before_script:
- java -version
- python3 --version
- mpirun --version
- sionversion
- h5pcc -showconfig
- pnetcdf-config --all
- cd Testing
.benchmark_template:
dependencies:
- build:generator
......@@ -84,7 +104,7 @@ stages:
## ##
#######################################
generate-docker-image:
generate-docker-image-base:
stage: .pre
when: manual
image: docker:latest
......@@ -96,6 +116,18 @@ generate-docker-image:
- docker build --pull . -f dockerfiles/ubuntu-20.04-openjdk-11.Dockerfile -t i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11
- docker push i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11
generate-docker-image-pario:
stage: .pre
when: manual
image: docker:latest
tags:
- docker-docker
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11-par-io || true
- docker build --pull . -f dockerfiles/ubuntu-20.04-openjdk-11-par-io.Dockerfile -t i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11-par-io
- docker push i10git.cs.fau.de:5005/exastencils/exastencils/ubuntu-20.04-openjdk-11-par-io
#######################################
## ##
## Generator ##
......@@ -254,6 +286,46 @@ test:Appl_OptFlow3D:
script:
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib Appl_OptFlow3D Application/OpticalFlow3D.knowledge "Application/OpticalFlow3D.exa4" Application/OpticalFlow3D.results 1 10 Platform/random.platform output
###############################################
# (PARALLEL) I/O TESTS #
###############################################
test:ParIO_CheckEquality_2D:
extends: .test_template_IO
tags:
- docker
- AVX2
script:
# 2D_Scalar_CheckEquality_ReadAfterWrite
- mkdir -p data/2D_Scalar_CheckEquality_ReadAfterWrite
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib 2D_Scalar_CheckEquality_ReadAfterWrite IOTest/2D_Scalar_CheckEquality_ReadAfterWrite.knowledge "IOTest/2D_Scalar_CheckEquality_ReadAfterWrite.exa4" "" 2 1 Platform/anyavx2.platform output
# 2D_LayoutTrafo_CheckEquality_ReadAfterWrite
- mkdir -p data/2D_LayoutTrafo_CheckEquality_ReadAfterWrite
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib 2D_LayoutTrafo_CheckEquality_ReadAfterWrite IOTest/2D_LayoutTrafo_CheckEquality_ReadAfterWrite.knowledge "IOTest/2D_LayoutTrafo_CheckEquality_ReadAfterWrite.exa4" "" 2 1 Platform/anyavx2.platform output
# 2D_Vector_CheckEquality_ReadAfterWrite
- mkdir -p data/2D_Vector_CheckEquality_ReadAfterWrite
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib 2D_Vector_CheckEquality_ReadAfterWrite IOTest/2D_Vector_CheckEquality_ReadAfterWrite.knowledge "IOTest/2D_Vector_CheckEquality_ReadAfterWrite.exa4" "" 4 1 Platform/anyavx2.platform output
test:ParIO_CheckEquality_3D:
extends: .test_template_IO
tags:
- docker
- AVX2
script:
# 3D_Matrix_CheckEquality_ReadAfterWrite
- mkdir -p data/3D_Matrix_CheckEquality_ReadAfterWrite
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib 3D_Matrix_CheckEquality_ReadAfterWrite IOTest/3D_Matrix_CheckEquality_ReadAfterWrite.knowledge "IOTest/3D_Matrix_CheckEquality_ReadAfterWrite.exa4" "" 4 1 Platform/anyavx2.platform output
# 3D_Scalar_CheckEquality_ReadAfterWrite
- mkdir -p data/3D_Scalar_CheckEquality_ReadAfterWrite
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib 3D_Scalar_CheckEquality_ReadAfterWrite IOTest/3D_Scalar_CheckEquality_ReadAfterWrite.knowledge "IOTest/3D_Scalar_CheckEquality_ReadAfterWrite.exa4" "" 8 1 Platform/anyavx2.platform output
# 3D_Vector_CheckEquality_ReadAfterWrite
- mkdir -p data/3D_Vector_CheckEquality_ReadAfterWrite
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib 3D_Vector_CheckEquality_ReadAfterWrite IOTest/3D_Vector_CheckEquality_ReadAfterWrite.knowledge "IOTest/3D_Vector_CheckEquality_ReadAfterWrite.exa4" "" 4 1 Platform/anyavx2.platform output
# CheckEquality_ReadAfterWrite
- mkdir -p data/CheckEquality_ReadAfterWrite
- python3 run_test.py ../Compiler/Compiler.jar:../Compiler/lib CheckEquality_ReadAfterWrite IOTest/CheckEquality_ReadAfterWrite.knowledge "IOTest/CheckEquality_ReadAfterWrite.exa4" "" 8 1 Platform/anyavx2.platform output
###############################################
# BASIC COMMUNICATION TESTS #
###############################################
......
......@@ -52,9 +52,9 @@ import exastencils.stencil.ir._
import exastencils.timing.ir._
import exastencils.util._
import exastencils.util.ir._
import exastencils.visualization.ir.cimg.IR_ResolveCImgFunctions
import exastencils.visualization.ir.visit.IR_SetupVisit
import exastencils.visualization.ir.vtk.IR_ResolveVtkPrinters
import exastencils.visualization.ir.interactive.cimg.IR_ResolveCImgFunctions
import exastencils.visualization.ir.interactive.visit.IR_SetupVisit
import exastencils.visualization.ir.postprocessing.IR_ResolveVisualizationPrinters
/// IR_LayerHandler
......@@ -135,7 +135,7 @@ object IR_DefaultLayerHandler extends IR_LayerHandler {
IR_ResolveCharacteristicsFunctions.apply()
IR_ResolveBenchmarkFunctions.apply()
IR_ResolveGismoFunctions.apply()
IR_ResolveVtkPrinters.apply()
IR_ResolveVisualizationPrinters.apply()
IR_ResolvePrintWithReducedPrec.apply()
IR_AdaptTimerFunctions.apply()
......
......@@ -221,6 +221,7 @@ object L4_DefaultLayerHandler extends L4_LayerHandler {
// after L4_ResolveFieldAccesses
L4_ResolveReadFieldFunctions.apply()
L4_ResolvePrintFieldFunctions.apply()
L4_ResolveWriteFieldFunctions.apply()
L4_ResolveBoundaryHandlingFunctions.apply()
......
package exastencils.applications.ns.ir
import scala.collection.mutable.ListBuffer
import exastencils.base.ir._
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.field.ir.IR_IV_ActiveSlot
import exastencils.io.ir.IR_DataBuffer
import exastencils.io.ir.IR_IV_FragmentInfo
import exastencils.visualization.ir.postprocessing.netCDF.IR_PrintExodus
/// IR_PrintExodusNNF
// 2D or 3D
// for a fixed number of fragments per block
@deprecated
case class IR_PrintExodusNNF(
var filename : IR_Expression,
level : Int,
var resolveId : Int
) extends IR_PrintExodus with IR_PrintVisualizationNS {
override def variableEntityType : IR_VariableAccess = EX_ELEM_BLOCK
override def elementName : String = if (numDimsGrid > 2) "hex" else "quad"
override def nodesPerElement : Int = connectivityForCell().length
override def fieldnames : ListBuffer[String] = (0 until numDimsGrid).map(d => "vel" + ('X' + d).toChar.toString).to[ListBuffer] ++ ListBuffer("p", "rho", "mue", "gamma", "phi")
override def statementsForPreparation : ListBuffer[IR_Statement] = {
IR_IV_FragmentInfo.init(domainIndex) ++
setupNodePositions() ++
setupConnectivity(global = true) ++
setupVelocityComponents
}
override def dataBuffersNodePos : ListBuffer[IR_DataBuffer] = nodePositionsBuf.zipWithIndex.map { case (buf, idx) =>
IR_DataBuffer(buf, IR_IV_ActiveSlot(p), None, Some(datasetCoords(idx)))
}
override def dataBufferConnectivity : IR_DataBuffer = IR_DataBuffer(connectivityBuf, IR_IV_ActiveSlot(p), None, Some(datasetConnectivity))
override def dataBuffers(constsIncluded : Boolean) : ListBuffer[IR_DataBuffer] = {
var fields = velocityComponentsAsVec.zipWithIndex.map { case (tmpBuf, d) =>
IR_DataBuffer(tmpBuf, IR_IV_ActiveSlot(u), None, Some(datasetFields(d)))
}.to[ListBuffer]
fields += IR_DataBuffer(p, IR_IV_ActiveSlot(p), includeGhosts = false, None, Some(datasetFields(numDimsGrid)), canonicalOrder = false)
fields += IR_DataBuffer(rho, IR_IV_ActiveSlot(rho), includeGhosts = false, None, Some(datasetFields(numDimsGrid + 1)), canonicalOrder = false)
fields += IR_DataBuffer(mue, IR_IV_ActiveSlot(mue), includeGhosts = false, None, Some(datasetFields(numDimsGrid + 2)), canonicalOrder = false)
fields += IR_DataBuffer(gamma, IR_IV_ActiveSlot(gamma), includeGhosts = false, None, Some(datasetFields(numDimsGrid + 3)), canonicalOrder = false)
fields += IR_DataBuffer(phi, IR_IV_ActiveSlot(phi), includeGhosts = false, None, Some(datasetFields(numDimsGrid + 4)), canonicalOrder = false)
if (constsIncluded) dataBuffersConstant ++ fields else fields
}
override def statementsForCleanup : ListBuffer[IR_Statement] = ListBuffer()
}
package exastencils.applications.ns.ir
import scala.collection.mutable.ListBuffer
import exastencils.base.ir._
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.field.ir.IR_IV_ActiveSlot
import exastencils.io.ir.IR_DataBuffer
import exastencils.io.ir.IR_IV_FragmentInfo
import exastencils.visualization.ir.postprocessing.netCDF.IR_PrintExodus
/// IR_PrintExodusNS
// 2D or 3D
// for a fixed number of fragments per block
@deprecated
case class IR_PrintExodusNS(
var filename : IR_Expression,
level : Int,
var resolveId : Int,
) extends IR_PrintExodus with IR_PrintVisualizationNS {
override def variableEntityType : IR_VariableAccess = EX_ELEM_BLOCK
override def elementName : String = if (numDimsGrid > 2) "hex" else "quad"
override def nodesPerElement : Int = connectivityForCell().length
override def fieldnames : ListBuffer[String] = (0 until numDimsGrid).map(d => "vel" + ('X' + d).toChar.toString).to[ListBuffer] :+ "p"
override def statementsForPreparation : ListBuffer[IR_Statement] = {
IR_IV_FragmentInfo.init(domainIndex) ++
setupNodePositions() ++
setupConnectivity(global = true) ++
setupVelocityComponents
}
override def dataBuffersNodePos : ListBuffer[IR_DataBuffer] = nodePositionsBuf.zipWithIndex.map { case (buf, idx) =>
IR_DataBuffer(buf, IR_IV_ActiveSlot(p), None, Some(datasetCoords(idx)))
}
override def dataBufferConnectivity : IR_DataBuffer = IR_DataBuffer(connectivityBuf, IR_IV_ActiveSlot(p), None, Some(datasetConnectivity))
override def dataBuffers(constsIncluded : Boolean) : ListBuffer[IR_DataBuffer] = {
var fields = velocityComponentsAsVec.zipWithIndex.map { case (tmpBuf, d) =>
IR_DataBuffer(tmpBuf, IR_IV_ActiveSlot(u), None, Some(datasetFields(d)))
}.to[ListBuffer]
fields += IR_DataBuffer(p, IR_IV_ActiveSlot(p), includeGhosts = false, None, Some(datasetFields(numDimsGrid)), canonicalOrder = false)
if (constsIncluded) dataBuffersConstant ++ fields else fields
}
override def statementsForCleanup : ListBuffer[IR_Statement] = ListBuffer()
}
package exastencils.applications.ns.ir
import scala.collection.mutable.ListBuffer
import exastencils.base.ir._
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.baseExt.ir._
import exastencils.core.Duplicate
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.field.ir.IR_FieldAccess
import exastencils.field.ir.IR_IV_ActiveSlot
import exastencils.util.ir.IR_Print
/// IR_PrintFieldAsciiNS
// provides functions to write geometry and field data in ascii format
// encapsulated in trait to minimize duplicate code in ascii writers
trait IR_PrintFieldAsciiNS extends IR_PrintVisualizationNS {
def printField(name : String, stream : IR_VariableAccess, loopBody : ListBuffer[IR_Statement], numComponents : Int = 1) : ListBuffer[IR_Statement] = ListBuffer(
IR_Print(stream, "std::scientific"),
IR_LoopOverFragments(
IR_IfCondition(IR_IV_IsValidForDomain(p.domain.index),
loopBody
),
IR_Print(stream, IR_Print.flush))
)
def addCellPrint(name : String, cellPrint : ListBuffer[IR_Expression], numComponents : Int = 1, optStream : Option[IR_VariableAccess] = None) : ListBuffer[IR_Statement] = {
val stream = optStream getOrElse newStream
val print = IR_Print(stream, cellPrint)
val loopBody = IR_LoopOverDimensions(numDimsGrid, IR_ExpressionIndexRange(
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DLB", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression)),
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DRE", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression))),
print)
printField(name, stream, ListBuffer(loopBody), numComponents)
}
def printVel(stream : Option[IR_VariableAccess] = None, indentation : Option[IR_StringConstant] = None) : ListBuffer[IR_Statement] = addCellPrint("vel", {
var cellPrint = ListBuffer[IR_Expression]()
if (indentation.isDefined)
cellPrint += indentation.get
cellPrint += meanU
cellPrint += IR_StringConstant(" ")
cellPrint += meanV
if (numDimsGrid > 2) {
cellPrint += IR_StringConstant(" ")
cellPrint += meanW
}
cellPrint += IR_Print.newline
}, numDimsGrid, stream)
def printP(stream : Option[IR_VariableAccess] = None, indentation : Option[IR_StringConstant] = None) : ListBuffer[IR_Statement] = addCellPrint("p", {
var cellPrint = ListBuffer[IR_Expression]()
if (indentation.isDefined)
cellPrint += indentation.get
cellPrint += IR_FieldAccess(p, IR_IV_ActiveSlot(p), IR_LoopOverDimensions.defIt(numDimsGrid))
cellPrint += IR_Print.newline
}, optStream = stream)
def printRho(stream : Option[IR_VariableAccess] = None, indentation : Option[IR_StringConstant] = None) : ListBuffer[IR_Statement] = addCellPrint("rho", {
var cellPrint = ListBuffer[IR_Expression]()
if (indentation.isDefined)
cellPrint += indentation.get
cellPrint += IR_FieldAccess(rho, IR_IV_ActiveSlot(rho), IR_LoopOverDimensions.defIt(numDimsGrid))
cellPrint += IR_Print.newline
}, optStream = stream)
def printMue(stream : Option[IR_VariableAccess] = None, indentation : Option[IR_StringConstant] = None) : ListBuffer[IR_Statement] = addCellPrint("mue", {
var cellPrint = ListBuffer[IR_Expression]()
if (indentation.isDefined)
cellPrint += indentation.get
cellPrint += IR_FieldAccess(mue, IR_IV_ActiveSlot(mue), IR_LoopOverDimensions.defIt(numDimsGrid))
cellPrint += IR_Print.newline
}, optStream = stream)
def printGamma(stream : Option[IR_VariableAccess] = None, indentation : Option[IR_StringConstant] = None) : ListBuffer[IR_Statement] = addCellPrint("gamma", {
var cellPrint = ListBuffer[IR_Expression]()
if (indentation.isDefined)
cellPrint += indentation.get
cellPrint += IR_FieldAccess(gamma, IR_IV_ActiveSlot(gamma), IR_LoopOverDimensions.defIt(numDimsGrid))
cellPrint += IR_Print.newline
}, optStream = stream)
def printPhi(stream : Option[IR_VariableAccess] = None, indentation : Option[IR_StringConstant] = None) : ListBuffer[IR_Statement] = addCellPrint("phi", {
var cellPrint = ListBuffer[IR_Expression]()
if (indentation.isDefined)
cellPrint += indentation.get
cellPrint += IR_FieldAccess(phi, IR_IV_ActiveSlot(phi), IR_LoopOverDimensions.defIt(numDimsGrid))
cellPrint += IR_Print.newline
}, optStream = stream)
}
package exastencils.applications.ns.ir
import scala.collection.mutable.ListBuffer
import exastencils.base.ir._
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.baseExt.ir._
import exastencils.core.Duplicate
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.field.ir._
import exastencils.grid.ir.IR_AtCellCenter
import exastencils.io.ir.IR_IV_TemporaryBuffer
import exastencils.visualization.ir.postprocessing.IR_PrintVisualizationQuads
trait IR_PrintVisualizationNS extends IR_PrintVisualizationQuads {
def numDimsGrid : Int = p.numDimsGrid
def numCells_x : Int = p.layout.layoutsPerDim(0).numInnerLayers
def numCells_y : Int = p.layout.layoutsPerDim(1).numInnerLayers
def numCells_z : Int = if (numDimsGrid > 2) p.layout.layoutsPerDim(2).numInnerLayers else 1
def numCellsPerFrag : IR_Expression = numCells_x * numCells_y * numCells_z
override def dimsPositionsFrag : ListBuffer[IR_Expression] = ListBuffer(numCells_x + 1, numCells_y + 1, if (numDimsGrid > 2) numCells_z + 1 else 1).map(a => IR_IntegerConstant(a))
def fieldnames : ListBuffer[String]
def numFields : Int = fieldnames.length
def u : IR_Field = IR_FieldCollection.getByIdentifier("u", level).get
def v : IR_Field = IR_FieldCollection.getByIdentifier("v", level).get
def w : IR_Field = IR_FieldCollection.getByIdentifier("w", level).get
def p : IR_Field = IR_FieldCollection.getByIdentifier("p", level).get
def rho : IR_Field = IR_FieldCollection.getByIdentifier("rho", level).get
def mue : IR_Field = IR_FieldCollection.getByIdentifier("mue", level).get
def gamma : IR_Field = IR_FieldCollection.getByIdentifier("gamma", level).get
def phi : IR_Field = IR_FieldCollection.getByIdentifier("phi", level).get
def someCellField : IR_Field = p
def velAsVec : Array[IR_Expression] = Array[IR_Expression](meanU, meanV) ++ (if (numDimsGrid > 2) Some(meanW) else None)
def meanU : IR_Multiplication = 0.5 * (IR_FieldAccess(u, IR_IV_ActiveSlot(u), IR_LoopOverDimensions.defIt(numDimsGrid))
+ IR_FieldAccess(u, IR_IV_ActiveSlot(u), IR_LoopOverDimensions.defIt(numDimsGrid) + IR_ConstIndex(1, 0, 0)))
def meanV : IR_Multiplication = 0.5 * (IR_FieldAccess(v, IR_IV_ActiveSlot(v), IR_LoopOverDimensions.defIt(numDimsGrid))
+ IR_FieldAccess(v, IR_IV_ActiveSlot(v), IR_LoopOverDimensions.defIt(numDimsGrid) + IR_ConstIndex(0, 1, 0)))
def meanW : IR_Multiplication = 0.5 * (IR_FieldAccess(w, IR_IV_ActiveSlot(w), IR_LoopOverDimensions.defIt(numDimsGrid))
+ IR_FieldAccess(w, IR_IV_ActiveSlot(w), IR_LoopOverDimensions.defIt(numDimsGrid) + IR_ConstIndex(0, 0, 1)))
// for exodusII: velocity vector must be provided as separate components
def velocityComponentX = IR_IV_TemporaryBuffer(u.resolveBaseDatatype, IR_AtCellCenter, "velX", domainIndex,
blockwise = true, ListBuffer(numCells_x, numCells_y, numCells_z))
def velocityComponentY = IR_IV_TemporaryBuffer(v.resolveBaseDatatype, IR_AtCellCenter, "velY", domainIndex,
blockwise = true, ListBuffer(numCells_x, numCells_y, numCells_z))
def velocityComponentZ : Option[IR_IV_TemporaryBuffer] = if (numDimsGrid > 2)
Some(IR_IV_TemporaryBuffer(w.resolveBaseDatatype, IR_AtCellCenter, "velZ", domainIndex,
blockwise = true, ListBuffer(numCells_x, numCells_y, numCells_z)))
else
None
def velocityComponentsAsVec : Array[IR_IV_TemporaryBuffer] = Array(velocityComponentX, velocityComponentY) ++ velocityComponentZ
def setupVelocityComponents : ListBuffer[IR_Statement] = {
// init buffer with components of the vector field
var stmts : ListBuffer[IR_Statement] = ListBuffer()
velocityComponentsAsVec.zipWithIndex.foreach { case (vel, dir) =>
stmts += vel.allocateMemory
def idxRange = IR_ExpressionIndexRange(
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DLB", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression)),
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DRE", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression)))
val linearizedIdx = idxRange.linearizeIndex(IR_LoopOverDimensions.defIt(numDimsGrid))
stmts += IR_LoopOverFragments(
IR_IfCondition(IR_IV_IsValidForDomain(p.domain.index),
IR_LoopOverDimensions(numDimsGrid, idxRange,
IR_Assignment(
IR_ArrayAccess(vel, IR_LoopOverFragments.defIt * numCellsPerFrag + linearizedIdx),
velAsVec(dir)))))
}
stmts
}
def velocityBuf = IR_IV_TemporaryBuffer(u.resolveBaseDatatype, IR_AtCellCenter, "vel", domainIndex,
blockwise = true, ListBuffer(IR_IntegerConstant(numDimsGrid), numCells_x, numCells_y, numCells_z))
def setupVelocityBuf : ListBuffer[IR_Statement] = {
// init buffer with values of vector field
var stmts : ListBuffer[IR_Statement] = ListBuffer()
stmts += velocityBuf.allocateMemory
def idxRange = IR_ExpressionIndexRange(
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DLB", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression)),
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DRE", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression)))
val initBuffer : ListBuffer[IR_Statement] = (0 until numDimsGrid).map(d => {
val linearizedIdx = idxRange.linearizeIndex(IR_LoopOverDimensions.defIt(numDimsGrid))
IR_Assignment(
IR_ArrayAccess(velocityBuf, IR_LoopOverFragments.defIt * numCellsPerFrag * numDimsGrid + numDimsGrid * linearizedIdx + d),
velAsVec(d)) : IR_Statement
}).to[ListBuffer]
stmts += IR_LoopOverFragments(
IR_IfCondition(IR_IV_IsValidForDomain(p.domain.index),
IR_LoopOverDimensions(numDimsGrid, idxRange,
initBuffer)))
stmts
}
}
......@@ -22,38 +22,24 @@ import scala.collection.mutable.ListBuffer
import exastencils.base.ir.IR_ImplicitConversion._
import exastencils.base.ir._
import exastencils.baseExt.ir._
import exastencils.config._
import exastencils.core.Duplicate
import exastencils.domain.ir.IR_IV_IsValidForDomain
import exastencils.field.ir._
import exastencils.parallelization.api.mpi._
import exastencils.util.ir.IR_Print
import exastencils.visualization.ir.vtk.IR_PrintVtkQuads
import exastencils.visualization.ir.postprocessing.vtk.IR_PrintVtkQuads
/// IR_PrintVtkNNF
case class IR_PrintVtkNNF(var filename : IR_Expression, level : Int) extends IR_PrintVtkQuads {
def numDimsGrid = p.numDimsGrid
def numCells_x = p.layout.layoutsPerDim(0).numInnerLayers
def numCells_y = p.layout.layoutsPerDim(1).numInnerLayers
def numCells_z = if (numDimsGrid > 2) p.layout.layoutsPerDim(2).numInnerLayers else 1
def numPointsPerFrag = (numCells_x + 1) * (numCells_y + 1) * (if (numDimsGrid > 2) numCells_z + 1 else 1)
def numFrags = Knowledge.domain_numFragmentsTotal
def u = IR_FieldCollection.getByIdentifier("u", level).get
def v = IR_FieldCollection.getByIdentifier("v", level).get
def w = IR_FieldCollection.getByIdentifier("w", level).get
def p = IR_FieldCollection.getByIdentifier("p", level).get
def rho = IR_FieldCollection.getByIdentifier("rho", level).get
def mue = IR_FieldCollection.getByIdentifier("mue", level).get
def gamma = IR_FieldCollection.getByIdentifier("gamma", level).get
def phi = IR_FieldCollection.getByIdentifier("phi", level).get
case class IR_PrintVtkNNF(var filename : IR_Expression, level : Int, var resolveId : Int) extends IR_PrintVtkQuads with IR_PrintVisualizationNS with IR_PrintFieldAsciiNS {
override def stmtsForNodeData : ListBuffer[IR_Statement] = ListBuffer()
def someCellField = p
def fieldnames : ListBuffer[String] = ListBuffer("vel", "p", "rho", "mue", "gamma", "phi")
override def stmtsForNodeData : ListBuffer[IR_Statement] = ListBuffer()
override def printField(name : String, stream : IR_VariableAccess, loopBody : ListBuffer[IR_Statement], numComponents : Int = 1) : ListBuffer[IR_Statement] = ListBuffer(
IR_ObjectInstantiation(stream, Duplicate(filename), IR_VariableAccess("std::ios::app", IR_UnknownDatatype)),
IR_IfCondition(MPI_IsRootProc(),
IR_Print(stream, IR_StringConstant(name), separator, numComponents, separator, numCells, separator, IR_StringConstant("double"), IR_Print.endl))) ++
super.printField(name, stream, loopBody) :+
IR_ExpressionStatement(IR_MemberFunctionCall(stream, "close"))
override def stmtsForCellData : ListBuffer[IR_Statement] = {
val stmts = ListBuffer[IR_Statement]()
......@@ -64,86 +50,17 @@ case class IR_PrintVtkNNF(var filename : IR_Expression, level : Int) extends IR_
IR_IfCondition(MPI_IsRootProc(), ListBuffer[IR_Statement](
IR_ObjectInstantiation(stream, Duplicate(filename), IR_VariableAccess("std::ios::app", IR_UnknownDatatype)),
IR_Print(stream, IR_StringConstant("CELL_DATA"), separator, numCells, IR_Print.endl),
IR_Print(stream, IR_StringConstant("FIELD"), separator, IR_StringConstant("FieldData"), separator, 6, IR_Print.endl),
IR_Print(stream, IR_StringConstant("FIELD"), separator, IR_StringConstant("FieldData"), separator, numFields, IR_Print.endl),
IR_MemberFunctionCall(stream, "close")))))
def addCellPrint(name : String, cellPrint : ListBuffer[IR_Expression], numComponents : Int = 1) = {
val stream = newStream
val print = IR_Print(stream, cellPrint)
val initCells = ListBuffer[IR_Statement](
IR_ObjectInstantiation(stream, Duplicate(filename), IR_VariableAccess("std::ios::app", IR_UnknownDatatype)),
IR_IfCondition(MPI_IsRootProc(),
IR_Print(stream, IR_StringConstant(name), separator, numComponents, separator, numCells, separator, IR_StringConstant("double"), IR_Print.endl)),
IR_Print(stream, "std::scientific"),
IR_LoopOverFragments(
IR_IfCondition(IR_IV_IsValidForDomain(p.domain.index),
IR_LoopOverDimensions(numDimsGrid, IR_ExpressionIndexRange(
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DLB", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression)),
IR_ExpressionIndex((0 until numDimsGrid).toArray.map(dim => p.layout.idxById("DRE", dim) - Duplicate(p.referenceOffset(dim)) : IR_Expression))),
print))),
IR_MemberFunctionCall(stream, "close"))
stmts ++= genStmtBlock(initCells)
}
def meanU = 0.5 * (IR_FieldAccess(u, IR_IV_ActiveSlot(u), IR_LoopOverDimensions.defIt(numDimsGrid))
+ IR_FieldAccess(u, IR_IV_ActiveSlot(u), IR_LoopOverDimensions.defIt(numDimsGrid) + IR_ConstIndex(1, 0, 0)))
def meanV = 0.5 * (IR_FieldAccess(v, IR_IV_ActiveSlot(v), IR_LoopOverDimensions.defIt(numDimsGrid))
+ IR_FieldAccess(v, IR_IV_ActiveSlot(v), IR_LoopOverDimensions.defIt(numDimsGrid) + IR_ConstIndex(0, 1, 0)))
def meanW = 0.5 * (IR_FieldAccess(w, IR_IV_ActiveSlot(w), IR_LoopOverDimensions.defIt(numDimsGrid))
+ IR_FieldAccess(w, IR_IV_ActiveSlot(w), IR_LoopOverDimensions.defIt(numDimsGrid) + IR_ConstIndex(0, 0, 1)))
// add vel
addCellPrint("vel", {
var cellPrint = ListBuffer[IR_Expression]()
cellPrint += meanU
cellPrint += separator
cellPrint += meanV
if (numDimsGrid > 2) {
cellPrint += separator
cellPrint += meanW
}
cellPrint += IR_Print.endl
}, numDimsGrid)
// add p