From 4e79cc94af47b0dba810b595a7a6d939c45d130b Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Tue, 1 May 2012 10:14:43 +0100 Subject: [PATCH] Work on converting to reciprocal space. --- src/ofc/codegen/Expression.scala | 5 +++++ src/ofc/generators/onetep/Laplacian.scala | 2 +- src/ofc/generators/onetep/PPDFunctionSet.scala | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ofc/codegen/Expression.scala b/src/ofc/codegen/Expression.scala index 474a4e2..1e3e9ff 100644 --- a/src/ofc/codegen/Expression.scala +++ b/src/ofc/codegen/Expression.scala @@ -76,6 +76,11 @@ class VarRef[T <: Type](symbol: VarSymbol[T]) extends Expression[T] with LeafExp def getType = symbol.getType } +class FieldRef[T <: Type](symbol: FieldSymbol[T]) extends Expression[T] with LeafExpression { + def getSymbol = symbol + def getType = symbol.getType +} + // Struct and array accesses class FieldAccess[T <: Type](expression: Expression[StructType], field: FieldSymbol[T]) extends Expression[T] { def foreach[U](f: Expression[_] => U) = f(expression) diff --git a/src/ofc/generators/onetep/Laplacian.scala b/src/ofc/generators/onetep/Laplacian.scala index 72a31b5..9588fad 100644 --- a/src/ofc/generators/onetep/Laplacian.scala +++ b/src/ofc/generators/onetep/Laplacian.scala @@ -2,5 +2,5 @@ package ofc.generators.onetep import ofc.codegen._ class Laplacian(op: Field) extends Field { - def getFragment(indices: Map[NamedIndex, Expression[IntType]]) = op.getFragment(indices) + def getFragment(indices: Map[NamedIndex, Expression[IntType]]) = op.getFragment(indices).toReciprocal } diff --git a/src/ofc/generators/onetep/PPDFunctionSet.scala b/src/ofc/generators/onetep/PPDFunctionSet.scala index 23b87ae..176e5bd 100644 --- a/src/ofc/generators/onetep/PPDFunctionSet.scala +++ b/src/ofc/generators/onetep/PPDFunctionSet.scala @@ -108,14 +108,17 @@ class PPDFunctionSet(basisName: String, dataName: String, indices: Seq[NamedInde val fftbox = new DeclaredVarSymbol[ArrayType[FloatType]]("fftbox", new ArrayType[FloatType](3)) def setup(context: GenerationContext) { + import OnetepTypes.FFTBoxInfo + context.addDeclaration(fftbox) + context += new AllocateStatement(fftbox, for (dim <- 0 to 2) yield FFTBoxInfo.public % FFTBoxInfo.totalPts(dim)) } def teardown(context: GenerationContext) { + context += new DeallocateStatement(fftbox) } } def getFragment(indices: Map[NamedIndex, Expression[IntType]]) : FieldFragment = new LocalFragment(this) - } -- 2.47.3