From 75ee6b46546777e837c3bc84d438c4bda2fddcb6 Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Mon, 9 Apr 2012 21:59:50 +0100 Subject: [PATCH] Move public fields into OnetepTypes. --- src/ofc/generators/onetep/OnetepTypes.scala | 2 ++ src/ofc/generators/onetep/PPDFunctionSet.scala | 12 +++++------- src/ofc/generators/onetep/SpatialRestriction.scala | 5 ++++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/ofc/generators/onetep/OnetepTypes.scala b/src/ofc/generators/onetep/OnetepTypes.scala index 6e5907c..fd8eabd 100644 --- a/src/ofc/generators/onetep/OnetepTypes.scala +++ b/src/ofc/generators/onetep/OnetepTypes.scala @@ -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)") } diff --git a/src/ofc/generators/onetep/PPDFunctionSet.scala b/src/ofc/generators/onetep/PPDFunctionSet.scala index 5469db5..de4094e 100644 --- a/src/ofc/generators/onetep/PPDFunctionSet.scala +++ b/src/ofc/generators/onetep/PPDFunctionSet.scala @@ -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)) diff --git a/src/ofc/generators/onetep/SpatialRestriction.scala b/src/ofc/generators/onetep/SpatialRestriction.scala index fb469c9..bb54d40 100644 --- a/src/ofc/generators/onetep/SpatialRestriction.scala +++ b/src/ofc/generators/onetep/SpatialRestriction.scala @@ -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 { -- 2.47.3