]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Move public fields into OnetepTypes.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 9 Apr 2012 20:59:50 +0000 (21:59 +0100)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 9 Apr 2012 20:59:50 +0000 (21:59 +0100)
src/ofc/generators/onetep/OnetepTypes.scala
src/ofc/generators/onetep/PPDFunctionSet.scala
src/ofc/generators/onetep/SpatialRestriction.scala

index 6e5907c7775c2e09473cd487e1aa447c03f127fd..fd8eabdc117b0b77ef0b4cead65fb0eac3cdbd57 100644 (file)
@@ -35,6 +35,7 @@ object OnetepTypes {
   }
 
   object CellInfo extends StructType {
+    val public = new NamedUnboundVarSymbol[StructType]("pub_cell", OnetepTypes.CellInfo)
     val ppdWidth = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("n_pt"+dim)}.toSeq
     val numPPDs = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("n_ppds_a"+dim)}.toSeq
     val pointsInPPD = new FieldSymbol[IntType]("n_pts")
@@ -50,6 +51,7 @@ object OnetepTypes {
   }
 
   object FFTBoxInfo extends StructType {
+    val public = new NamedUnboundVarSymbol[StructType]("pub_fftbox", FFTBoxInfo)
     val totalPts = {for (dim <- 1 to 3) yield new FieldSymbol[IntType]("total_pt"+dim)}.toSeq
     def getFortranAttributes = Set("type(FFTBOX_INFO)")
   }
index 5469db5f060e5502390e10fb2cf72279e1ee813a..de4094e38f847472213398f32822d3c2dd42f3a9 100644 (file)
@@ -2,8 +2,6 @@ package ofc.generators.onetep
 import ofc.codegen._
 
 object PPDFunctionSet {
-  private val pubCell = new NamedUnboundVarSymbol[StructType]("pub_cell", OnetepTypes.CellInfo)
-
   private class SphereIndex(name: String, value: Expression[IntType]) extends DiscreteIndex {
     def getName = name
     def getValue = value
@@ -21,8 +19,8 @@ object PPDFunctionSet {
     val data =  new NamedUnboundVarSymbol[ArrayType[FloatType]](dataName, new ArrayType[FloatType](1))
 
     val numSpheres = basis % FunctionBasis.num
-    val ppdWidths = for(dim <- 0 to 2) yield pubCell % CellInfo.ppdWidth(dim)
-    val cellWidthInPPDs = for(dim <- 0 to 2) yield pubCell % CellInfo.numPPDs(dim)
+    val ppdWidths = for(dim <- 0 to 2) yield CellInfo.public % CellInfo.ppdWidth(dim)
+    val cellWidthInPPDs = for(dim <- 0 to 2) yield CellInfo.public % CellInfo.numPPDs(dim)
 
     val producer = new ProducerStatement
     val sphereIndex = producer.addIteration("sphere_index", 1, numSpheres)
@@ -65,11 +63,11 @@ object PPDFunctionSet {
 
     // TODO: We explicitly convert to Expression[IntType] here since we don't promote both sides of the addition for ppdDataIndex.
     val ppdDataStart : Expression[IntType] = 
-      producer.addExpression("ppd_data_start", (sphere % Sphere.offset) + (ppdIndex-1) * (pubCell % CellInfo.pointsInPPD))
+      producer.addExpression("ppd_data_start", (sphere % Sphere.offset) + (ppdIndex-1) * (CellInfo.public % CellInfo.pointsInPPD))
 
     val ppdDataIndex = producer.addExpression("ppd_data_index", ppdDataStart 
-      + (ppdIndices(2)-1) * (pubCell % CellInfo.ppdWidth(1)) * (pubCell % CellInfo.ppdWidth(0))
-      + (ppdIndices(1)-1) * (pubCell % CellInfo.ppdWidth(0))
+      + (ppdIndices(2)-1) * (CellInfo.public % CellInfo.ppdWidth(1)) * (CellInfo.public % CellInfo.ppdWidth(0))
+      + (ppdIndices(1)-1) * (CellInfo.public % CellInfo.ppdWidth(0))
       + (ppdIndices(0)-1))
 
     val dataValue = producer.addExpression("data", data.readAt(ppdDataIndex))
index fb469c9d2a09c2259b843b76031be686b7c6302a..bb54d40d9e9856603de047ff74111d7320ec4c60 100644 (file)
@@ -2,7 +2,10 @@ package ofc.generators.onetep
 import ofc.codegen._
 
 object SpatialRestriction {
-  private val pubFFTBox = new NamedUnboundVarSymbol[StructType]("pub_fftbox", OnetepTypes.FFTBoxInfo)
+  import OnetepTypes._
+
+  private val pubFFTBoxWidth = for (dim <- 0 to 2) yield FFTBoxInfo.public % FFTBoxInfo.totalPts(dim)
+  private val ppdWidth = for(dim <- 0 to 2) yield CellInfo.public % CellInfo.ppdWidth(dim)
 }
 
 class SpatialRestriction(op: IterationSpace, function: BindingIndex) extends IterationSpace {