From: Francis Russell Date: Thu, 3 May 2012 15:40:26 +0000 (+0100) Subject: Handle origin of fields. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=370ae2d8dbd7b5c3b4123d437638554479b802c2;p=francis%2Fofc.git Handle origin of fields. --- diff --git a/src/ofc/generators/onetep/DensePsincToReciprocal.scala b/src/ofc/generators/onetep/DensePsincToReciprocal.scala index 640be99..35c77e1 100644 --- a/src/ofc/generators/onetep/DensePsincToReciprocal.scala +++ b/src/ofc/generators/onetep/DensePsincToReciprocal.scala @@ -25,6 +25,8 @@ class DensePsincToReciprocal(op: DensePsincFragment, indices: Map[NamedIndex, Ex def getSize = for (dim <- 0 to 2) yield OnetepTypes.FFTBoxInfo.public % OnetepTypes.FFTBoxInfo.totalPts(dim) + def getOrigin = op.getOrigin + def getBuffer = reciprocalBox def toPsinc = new ReciprocalToPsinc(this) diff --git a/src/ofc/generators/onetep/FieldFragment.scala b/src/ofc/generators/onetep/FieldFragment.scala index 0129b94..9dabd65 100644 --- a/src/ofc/generators/onetep/FieldFragment.scala +++ b/src/ofc/generators/onetep/FieldFragment.scala @@ -9,16 +9,18 @@ trait FieldFragment extends Fragment { trait PsincFragment extends FieldFragment { def toPsinc = this - def getSize : Seq[Expression[IntType]] } trait DensePsincFragment extends PsincFragment { def getBuffer : Expression[ArrayType[FloatType]] def toDensePsinc = this + def getSize : Seq[Expression[IntType]] + def getOrigin : Seq[Expression[IntType]] } trait ReciprocalFragment extends FieldFragment { def toReciprocal = this def getSize : Seq[Expression[IntType]] + def getOrigin : Seq[Expression[IntType]] def getBuffer : Expression[ArrayType[ComplexType]] } diff --git a/src/ofc/generators/onetep/InnerProduct.scala b/src/ofc/generators/onetep/InnerProduct.scala index bbbf3f3..c619b73 100644 --- a/src/ofc/generators/onetep/InnerProduct.scala +++ b/src/ofc/generators/onetep/InnerProduct.scala @@ -4,16 +4,20 @@ import ofc.codegen._ class InnerProduct(left: Field, right: Field) extends Scalar { class LocalFragment(left: FieldFragment, right: FieldFragment) extends ScalarFragment { + val leftDense = left.toDensePsinc + val rightDense = right.toDensePsinc + def setup(context: GenerationContext) { - left.setup(context) - right.setup(context) + leftDense.setup(context) + rightDense.setup(context) + + leftDense.teardown(context) + rightDense.teardown(context) } def getValue = throw new ofc.UnimplementedException("rargh!") def teardown(context: GenerationContext) { - left.teardown(context) - right.teardown(context) } } diff --git a/src/ofc/generators/onetep/Laplacian.scala b/src/ofc/generators/onetep/Laplacian.scala index 7d9766d..ae7ab15 100644 --- a/src/ofc/generators/onetep/Laplacian.scala +++ b/src/ofc/generators/onetep/Laplacian.scala @@ -62,6 +62,8 @@ class Laplacian(op: Field) extends Field { def getSize = opFragment.getSize + def getOrigin = opFragment.getOrigin + def getBuffer = transformed def toPsinc = new ReciprocalToPsinc(this) diff --git a/src/ofc/generators/onetep/PPDFunctionSet.scala b/src/ofc/generators/onetep/PPDFunctionSet.scala index 83c10e6..cb0c111 100644 --- a/src/ofc/generators/onetep/PPDFunctionSet.scala +++ b/src/ofc/generators/onetep/PPDFunctionSet.scala @@ -106,9 +106,6 @@ class PPDFunctionSet(basisName: String, dataName: String, indices: Seq[NamedInde def setup(context: GenerationContext) {} def teardown(context: GenerationContext) {} def toReciprocal : ReciprocalFragment = toDensePsinc.toReciprocal - - //FIXME: implement me! - def getSize = throw new UnimplementedException("Implement me!") def toDensePsinc = new LocalDense(parent, indices) } @@ -152,6 +149,21 @@ class PPDFunctionSet(basisName: String, dataName: String, indices: Seq[NamedInde def getSize = for (dim <- 0 to 2) yield OnetepTypes.FFTBoxInfo.public % OnetepTypes.FFTBoxInfo.totalPts(dim) + private def getTightBoxOrigin = for (dim <- 0 to 2) yield { + import OnetepTypes._ + val startPPD = tightbox % TightBox.startPPD(dim) - 1 + val startPPDPoint = startPPD * (CellInfo.public % CellInfo.ppdWidth(dim)) + val startPoint = startPPDPoint + tightbox % TightBox.startPts(dim) + startPoint + } + + def getOrigin = { + val tightBoxOrigin = getTightBoxOrigin + + for (dim <- 0 to 2) yield + tightBoxOrigin(dim) - fftboxOffset(dim) + } + def getBuffer = fftbox def toReciprocal = new DensePsincToReciprocal(this, indices) diff --git a/src/ofc/generators/onetep/ReciprocalToPsinc.scala b/src/ofc/generators/onetep/ReciprocalToPsinc.scala index e138404..f6b9263 100644 --- a/src/ofc/generators/onetep/ReciprocalToPsinc.scala +++ b/src/ofc/generators/onetep/ReciprocalToPsinc.scala @@ -25,5 +25,7 @@ class ReciprocalToPsinc(op: ReciprocalFragment) extends DensePsincFragment { def getSize = for (dim <- 0 to 2) yield OnetepTypes.FFTBoxInfo.public % OnetepTypes.FFTBoxInfo.totalPts(dim) + def getOrigin = op.getOrigin + def getBuffer = fftbox } diff --git a/src/ofc/generators/onetep/ScaledField.scala b/src/ofc/generators/onetep/ScaledField.scala index e90f004..d488327 100644 --- a/src/ofc/generators/onetep/ScaledField.scala +++ b/src/ofc/generators/onetep/ScaledField.scala @@ -48,6 +48,8 @@ class ScaledField(op: Field, factor: Scalar) extends Field { def getSize = opFragment.getSize + def getOrigin = opFragment.getOrigin + def getBuffer = transformed def toReciprocal = new DensePsincToReciprocal(this, indices)