symbol
}
+ def addPredicate(condition: Expression[BoolType]) {
+ predicates +:= new Predicate(condition)
+ }
+
def toConcrete : Statement = {
val contexts = ranges ++ predicates ++ expressions
val sortedContexts = Context.sort(contexts)
package ofc.generators.onetep
+import ofc.InvalidInputException
import ofc.codegen._
object SpatialRestriction {
def getSuffixFragment = new NullStatement
def getDataValue = op.getDataValue
def getReaderFragment = {
- //TODO: Implement me!
- new NullStatement
+ import OnetepTypes._
+ import SpatialRestriction._
+
+ val inputIndices = for(index <- op.getSpatialIndices) yield
+ index match {
+ case (f: FunctionSpatialIndex) => f
+ case _ => throw new InvalidInputException("Input to SpatialRestriction must be a function")
+ }
+
+ val ppdWidths = for(dim <- 0 to 2) yield CellInfo.public % CellInfo.ppdWidth(dim)
+ val cellWidthPPDs = for(dim <- 0 to 2) yield CellInfo.public % CellInfo.numPPDs(dim)
+ val cellWidthPts = for(dim <- 0 to 2) yield cellWidthPPDs(dim) * ppdWidths(dim)
+ val functionCentre = inputIndices.map(_.getFunctionCentre)
+
+ val producer = new ProducerStatement
+ val origin = for (dim <- 0 to 2)
+ yield producer.addExpression("fftbox_origin_pt"+(dim+1), functionCentre(dim) - pubFFTBoxWidth(dim)/2)
+
+ val offset = for (dim <- 0 to 2)
+ yield producer.addExpression("fftbox_offset_pt"+(dim+1),
+ (inputIndices(dim).getValue - origin(dim) + cellWidthPts(dim)) % cellWidthPts(dim))
+
+ for (dim <- 0 to 2)
+ producer.addPredicate(offset(dim) |<| pubFFTBoxWidth(dim))
+
+ producer
}
def getSpatialIndices = {