Skip to content

Commit

Permalink
[98] Variable modifications
Browse files Browse the repository at this point in the history
Remove possibility to create variables using unicode caracters (greek
alphabet, sum, prod and sqrt).
Generated code and LaTeX view are unchanged or equivalent.

Bug: cea-hpc#98
Signed-off-by: Vincent BLAIN <vincent.blain@obeosoft.com>
  • Loading branch information
vblainobeo committed Oct 4, 2022
1 parent 903a0ad commit b972b0e
Show file tree
Hide file tree
Showing 259 changed files with 9,080 additions and 9,219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
package fr.cea.nabla.ide.contentassist

import com.google.inject.Inject
import fr.cea.nabla.ir.transformers.ReplaceUtf8Chars
import fr.cea.nabla.services.NablaGrammarAccess
import org.eclipse.xtext.RuleCall
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistContext
import org.eclipse.xtext.ide.editor.contentassist.ContentAssistEntry
import org.eclipse.xtext.ide.editor.contentassist.IIdeContentProposalAcceptor
import org.eclipse.xtext.ide.editor.contentassist.IdeContentProposalProvider

Expand All @@ -30,23 +28,10 @@ class NablaIdeContentProposalProvider extends IdeContentProposalProvider
case simpleVarRule,
case connectivityVarRule:
{
buildGrecLetterProposals(context, acceptor)
}
default:
super._createProposals(ruleCall, context, acceptor)
}
}

private def void buildGrecLetterProposals(ContentAssistContext context, IIdeContentProposalAcceptor acceptor)
{
for (p : ReplaceUtf8Chars.UTF8Chars.keySet)
{
val trueEntry = new ContentAssistEntry => [
prefix = context.prefix
proposal = p
]
acceptor.accept(trueEntry, proposalPriorities.getDefaultPriority(trueEntry))
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ class InstructionContentProvider
else if (f.name.startsWith("sum")) "Sum"
else throw new RuntimeException("Reduction type not implemented in Arcane accelerator API: " + f.name)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class IrModuleContentProvider
«IF ts.constExpr || ts.option»

// constant time step
m_global_deltat = «ts.codeName»;
m_global_delta_t = «ts.codeName»;
«ENDIF»
«FOR p : externalProviders»
«val optionName = StringExtensions.separateWithUpperCase(p.extensionName)»
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@ import static extension fr.cea.nabla.ir.generator.Utils.*
import static extension fr.cea.nabla.ir.generator.java.ExpressionContentProvider.*
import static extension fr.cea.nabla.ir.generator.java.InstructionContentProvider.*

class JobContentProvider
{
static def getContent(Job it)
class JobContentProvider
{
static def getContent(Job it)
'''
«comment»
protected void «codeName»()
{
«innerContent»
}
'''
private static def dispatch CharSequence getInnerContent(Job it)
«comment»
protected void «codeName»()
{
«innerContent»
}
'''
private static def dispatch CharSequence getInnerContent(Job it)
'''
«instruction.innerContent»
'''
«instruction.innerContent»
'''
private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it)
'''
«val itVar = iterationCounter.codeName»
«val irRoot = IrUtils.getContainerOfType(it, IrRoot
«val tn = irRoot.currentTimeVariable.codeName»
«val deltat = irRoot.timeStepVariable.codeName»
«val delta_t = irRoot.timeStepVariable.codeName»
«val ppInfo = irRoot.postProcessing»
«itVar» = 0;
boolean continueLoop = true;
do
{
«itVar»++;
«IF caller.main»
System.out.printf("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - deltat: %5.5f\n", «itVar», «tn», «deltat»);
System.out.printf("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - delta_t: %5.5f\n", «itVar», «tn», «delta_t»);
«IF ppInfo !== null»
if («ppInfo.periodReference.codeName» >= «ppInfo.lastDumpVariable.codeName» + «ppInfo.periodValue.codeName»)
dumpVariables(«itVar»);
Expand All @@ -68,7 +68,7 @@ class JobContentProvider
} while (continueLoop);
«IF caller.main»

System.out.printf("FINAL TIME: %5.5f - deltat: %5.5f\n", «tn», «deltat»);
System.out.printf("FINAL TIME: %5.5f - delta_t: %5.5f\n", «tn», «delta_t»);
«IF ppInfo !== null»dumpVariables(«itVar»+1);«ENDIF»
«ENDIF»
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,39 @@ import static extension fr.cea.nabla.ir.JobCallerExtensions.*
import static extension fr.cea.nabla.ir.generator.python.ExpressionContentProvider.*
import static extension fr.cea.nabla.ir.generator.python.InstructionContentProvider.*

class JobContentProvider
{
static def getContent(Job it)
class JobContentProvider
{
static def getContent(Job it)
'''
"""
Job «Utils.getCodeName(it)» called @«at» in «Utils.getCodeName(caller)» method.
In variables: «FOR v : inVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR»
Out variables: «FOR v : outVars.sortBy[name] SEPARATOR ', '»«v.getName»«ENDFOR»
"""
def _«Utils.getCodeName(it)»(self):
«innerContent»
'''

private static def dispatch CharSequence getInnerContent(Job it)
def _«Utils.getCodeName(it)»(self):
«innerContent»
'''

private static def dispatch CharSequence getInnerContent(Job it)
'''
«instruction.innerContent»
'''
«instruction.innerContent»
'''

private static def dispatch CharSequence getInnerContent(ExecuteTimeLoopJob it)
'''
«val itVar = Utils.getCodeName(iterationCounter
«val irRoot = IrUtils.getContainerOfType(it, IrRoot
«val tn = Utils.getCodeName(irRoot.currentTimeVariable
«val deltat = Utils.getCodeName(irRoot.timeStepVariable
«val delta_t = Utils.getCodeName(irRoot.timeStepVariable
«val ppInfo = irRoot.postProcessing»
self.«itVar» = 0
«IF irRoot.currentTimeVariable.needDefinition»self.«tn» = 0.0«ENDIF»
«IF irRoot.timeStepVariable.needDefinition»self.«deltat» = 0.0«ENDIF»
«IF irRoot.timeStepVariable.needDefinition»self.«delta_t» = 0.0«ENDIF»
continueLoop = True
while continueLoop:
self.«itVar» += 1
«IF caller.main»
print("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - deltat: %5.5f\n" % (selfitVar», selftn», selfdeltat»))
print("START ITERATION «iterationCounter.name»: %5d - t: %5.5f - delta_t: %5.5f\n" % (selfitVar», selftn», selfdelta_t»))
«IF ppInfo !== null»
if (selfUtils.getCodeName(ppInfo.periodReference)» >= self.«Utils.getCodeName(ppInfo.lastDumpVariable)» + self.«Utils.getCodeName(ppInfo.periodValue)»):
self.__dumpVariables(selfitVar»)
Expand All @@ -71,7 +71,7 @@ class JobContentProvider
«instruction.innerContent»
«IF caller.main»

print("FINAL TIME: %5.5f - deltat: %5.5f\n" % (selftn», selfdeltat»))
print("FINAL TIME: %5.5f - delta_t: %5.5f\n" % (selftn», selfdelta_t»))
«IF ppInfo !== null»self.__dumpVariables(selfitVar»+1);«ENDIF»
«ENDIF»
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class JobInterpreter

if (caller.main)
{
val log = String.format(Locale::ENGLISH, "START ITERATION %1$s: %2$5d - t: %3$.5f - deltat: %4$.5f",
val log = String.format(Locale::ENGLISH, "START ITERATION %1$s: %2$5d - t: %3$.5f - delta_t: %4$.5f",
iterationCounter.name,
iteration,
context.getReal(context.ir.currentTimeVariable),
Expand Down Expand Up @@ -96,7 +96,7 @@ class JobInterpreter
if (caller.main)
{
// force a last trace and output at the end
val log = String.format(Locale::ENGLISH, "FINAL TIME: %1$.5f - deltat: %2$.5f",
val log = String.format(Locale::ENGLISH, "FINAL TIME: %1$.5f - delta_t: %2$.5f",
context.getReal(context.ir.currentTimeVariable),
context.getReal(context.ir.timeStepVariable))
context.logFine(log)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class IrTransformationUtils
static def getCommonTransformation(boolean replaceAllReductions)
{
#[
new ReplaceUtf8Chars,
new ReplaceReductions(replaceAllReductions),
new ReplaceAffectations,
new CreateArrayOperators,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void ExplicitHeatEquationModule::init()
// initialization of other attributes
m_lastDump = numeric_limits<int>::min();
m_n = 0;
m_deltat = 0.001;
m_delta_t = 0.001;
m_alpha.resize(nbCell());

// calling jobs
Expand Down Expand Up @@ -144,12 +144,12 @@ void ExplicitHeatEquationModule::computeFaceLength()

/**
* Job computeTn called @1.0 in executeTimeLoopN method.
* In variables: deltat, t_n
* In variables: delta_t, t_n
* Out variables: t_nplus1
*/
void ExplicitHeatEquationModule::computeTn()
{
m_t_nplus1 = m_t_n + m_deltat;
m_t_nplus1 = m_t_n + m_delta_t;
}

/**
Expand Down Expand Up @@ -267,7 +267,7 @@ void ExplicitHeatEquationModule::updateU()
/**
* Job computeDeltaTn called @2.0 in simulate method.
* In variables: D, V
* Out variables: deltat
* Out variables: delta_t
*/
void ExplicitHeatEquationModule::computeDeltaTn()
{
Expand All @@ -283,8 +283,8 @@ void ExplicitHeatEquationModule::computeDeltaTn()
};
reduction0 = reducer.reduce();
}
m_deltat = reduction0 * 0.24;
m_global_deltat = m_deltat;
m_delta_t = reduction0 * 0.24;
m_global_delta_t = m_delta_t;
}

/**
Expand Down Expand Up @@ -359,13 +359,13 @@ void ExplicitHeatEquationModule::setUpTimeLoopN()

/**
* Job computeAlphaCoeff called @3.0 in simulate method.
* In variables: V, Xc, deltat, faceConductivity, faceLength
* In variables: V, Xc, delta_t, faceConductivity, faceLength
* Out variables: alpha
*/
void ExplicitHeatEquationModule::computeAlphaCoeff()
{
auto command = makeCommand(m_default_queue);
auto in_deltat = m_deltat;
auto in_delta_t = m_delta_t;
auto in_V = ax::viewIn(command, m_V);
auto in_faceLength = ax::viewIn(command, m_faceLength);
auto in_faceConductivity = ax::viewIn(command, m_faceConductivity);
Expand All @@ -374,7 +374,7 @@ void ExplicitHeatEquationModule::computeAlphaCoeff()
command << RUNCOMMAND_ENUMERATE(Cell, cCells, allCells())
{
const auto cId(cCells);
Real alphaDiag(0.0);
Real alpha_Diag(0.0);
{
const auto neighbourCellsC(m_mesh->getNeighbourCells(cId));
const Int32 nbNeighbourCellsC(neighbourCellsC.size());
Expand All @@ -384,12 +384,12 @@ void ExplicitHeatEquationModule::computeAlphaCoeff()
const auto dCells(dId);
const auto fId(m_mesh->getCommonFace(cId, dId));
const auto fFaces(fId);
const Real alphaExtraDiag(in_deltat / in_V[cCells] * (in_faceLength[fFaces] * in_faceConductivity[fFaces]) / explicitheatequationfreefuncs::norm(explicitheatequationfreefuncs::operatorSub(in_Xc[cCells], in_Xc[dCells])));
out_alpha[cCells][dCells] = alphaExtraDiag;
alphaDiag = alphaDiag + alphaExtraDiag;
const Real alpha_ExtraDiag(in_delta_t / in_V[cCells] * (in_faceLength[fFaces] * in_faceConductivity[fFaces]) / explicitheatequationfreefuncs::norm(explicitheatequationfreefuncs::operatorSub(in_Xc[cCells], in_Xc[dCells])));
out_alpha[cCells][dCells] = alpha_ExtraDiag;
alpha_Diag = alpha_Diag + alpha_ExtraDiag;
}
}
out_alpha[cCells][cCells] = 1 - alphaDiag;
out_alpha[cCells][cCells] = 1 - alpha_Diag;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ExplicitHeatEquationModule
Int32 m_n;
static constexpr Real m_u0 = 1.0;
static constexpr Real2 m_vectOne = {1.0, 1.0};
Real m_deltat;
Real m_delta_t;
Real m_t_n;
Real m_t_nplus1;
Real m_t_n0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@
need-sync="true"/>

<variable
field-name="deltatj"
name="deltatj"
field-name="delta_tj"
name="delta_tj"
data-type="real"
item-kind="cell"
dim="0"
Expand Down
Loading

0 comments on commit b972b0e

Please sign in to comment.