]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
More work on characterising producers.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Tue, 3 Apr 2012 18:16:01 +0000 (19:16 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Tue, 3 Apr 2012 18:16:01 +0000 (19:16 +0100)
src/ofc/codegen/Expression.scala
src/ofc/codegen/IterationTemplate.scala [deleted file]
src/ofc/codegen/ProducerStatement.scala [new file with mode: 0644]
src/ofc/codegen/ScopeStatement.scala
src/ofc/generators/onetep/IterationSpace.scala
src/ofc/generators/onetep/PPDFunctionSet.scala

index 303631832e8ae6924a5aae74f46904f99d2cfbe7..7f132bf429e80b49e3f940abf3efe62d44c18dc3 100644 (file)
@@ -4,8 +4,6 @@ class Expression {
   def %(field: FieldSymbol) : Expression = new FieldAccess(this, field)
   def readAt(index: List[Expression]) : Expression = new ArrayRead(this, index)
   def apply(index: Expression*) : Expression = this.readAt(index.toList)
-
-  implicit def fromInt(value: Int) : Expression = new IntegerLiteral(value)
 }
 
 // Variable references
diff --git a/src/ofc/codegen/IterationTemplate.scala b/src/ofc/codegen/IterationTemplate.scala
deleted file mode 100644 (file)
index c7ea71e..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-package ofc.codegen
-
-class IterationTemplate(statement: Statement) {
-}
diff --git a/src/ofc/codegen/ProducerStatement.scala b/src/ofc/codegen/ProducerStatement.scala
new file mode 100644 (file)
index 0000000..96c119a
--- /dev/null
@@ -0,0 +1,23 @@
+package ofc.codegen
+
+class ProducerStatement extends Statement {
+  class VariableRange(symbol: Symbol, count: Expression)
+  class Predicate
+
+  var statement = new NullStatement
+  var ranges : List[VariableRange] = List.empty
+  var predicates : List[Predicate] = List.empty
+  var expressions : Map[Symbol, Expression] = Map.empty
+
+  def addExpression(name: String, expression: Expression) : VarSymbol = {
+    val symbol = new DeclaredVarSymbol(name)
+    expressions += symbol -> expression
+    symbol
+  }
+
+  def addIteration(name: String, count: Expression) : VarSymbol = {
+    val symbol = new DeclaredVarSymbol(name)
+    ranges +:= new VariableRange(symbol, count)
+    symbol
+  }
+}
index 22cbf3285b2c5b8be927d8a6d7004e708d75591e..4606eadb098929d7ded6f63dedc4f30066b53544 100644 (file)
@@ -1,6 +1,12 @@
 package ofc.codegen
+import scala.collection.mutable.ArrayBuffer
+
+class ScopeStatement(initialStatements: List[Statement]) extends Statement {
+
+  val statements = initialStatements.toBuffer
 
-class ScopeStatement(var statements: List[Statement]) extends Statement {
   def this() = this(List.empty)
-  def +=(stat: Statement) = statements += stat
+  def +=(stat: Statement) {
+    statements += stat
+  }
 }
index 6b6ff2e5fd77ed50c2d68eac619b21b65e9dba9d..70f86a7031ddf7783baa38e3e5e50b5fb50f6c01 100644 (file)
@@ -1,5 +1,5 @@
 package ofc.generators.onetep
-import ofc.codegen.IterationTemplate
+import ofc.codegen.{Statement,NullStatement}
 
 /*
 object IterationSpace {
@@ -28,11 +28,13 @@ trait IterationSpace {
     val operands = getOperands
     operands.toSet ++ operands.flatMap(_.getDependencies)
   }
-  def getReader : IterationTemplate
+  def getReaderFragment : Statement
+  def getSuffixFragment : Statement
 }
 
 trait DataSpace extends IterationSpace {
   def getOperands = Nil
+  def getReaderFragment = new NullStatement
 }
 
 trait Matrix extends DataSpace
index 175bf8590633b435f49e097c16634318730d38ea..346e23971f5c302c06cb82fcd9d60cdf9358f7a0 100644 (file)
@@ -7,14 +7,22 @@ class PPDFunctionSet(val basisName: String, dataName: String) extends FunctionSe
   val pubCell = NamedUnboundVarSymbol("pub_cell")
 
   val numSpheres = basis % FieldSymbol("num");
-  val ppdWidths = for(dim <- 1 to 3) yield pubCell % FieldSymbol("n_ppds_a"+dim)
+  val ppdWidths = for(dim <- 1 to 3) yield pubCell % FieldSymbol("n_pt"+dim)
+  val cellWidthInPPDs = for(dim <- 1 to 3) yield pubCell % FieldSymbol("n_ppds_a"+dim)
 
-  def getReader = {
-    var sphereIndex = new IterationSymbol("sphere_index", numSpheres)
+  def getSuffixFragment = {
+    val producer = new ProducerStatement
+    val sphereIndex = producer.addIteration("sphere_index", numSpheres)
     val numPPDs = (basis % FieldSymbol("n_ppds_sphere"))(sphereIndex)
-    val ppdIndex = new IterationSymbol("ppd_index", numPPDs)
-    val ppdRanges = for(dim <- 1 to 3) yield new IterationSymbol("point"+dim, ppdWidths(dim)) 
-    new IterationTemplate(sphereLoop)
+    val ppdIndex = producer.addIteration("ppd_index", numPPDs)
+    val ppdGlobalCount = (basis % FieldSymbol("ppd_list"))(ppdIndex, new IntegerLiteral(1))
+
+    // We need to calculate the integer co-ordinates of the PPD
+
+    //val ppdRanges = for(dim <- 0 to 2) yield producer.addIteration("point"+(dim+1), ppdWidths(dim)) 
+    val tightbox = basis % FieldSymbol("tight_boxes")
+    
+    producer
   }
 
   def getDiscreteIndices = List.empty