@Override public Object visitResetMv(GAPPResetMv gappResetMv, Object arg) { multivectors.add(gappResetMv.getDestination().getName()); return null; }
@Override public Object visitCalculateMv(GAPPCalculateMv gappCalculateMv, Object arg) { multivectors.add(gappCalculateMv.getDestination().getName()); return null; }
@Override public Object visitMultivector(GAPPMultivector gappMultivector, Object arg) { return new GAPPMultivector(gappMultivector.getName()); //Strings are immutable! }
@Override public Object visitAssignMv(GAPPAssignMv gappAssignMv, Object arg) { multivectors.add(gappAssignMv.getDestination().getName()); return null; }
@Override public Object visitDotVectors(GAPPDotVectors gappDotVectors, Object arg) { multivectors.add(gappDotVectors.getDestination().getName()); return null; }
@Override public Object visitResetMv(GAPPResetMv gappResetMv, Object arg) { final String destMv = GAPPOpenCLCodeGenerator.getVarName(gappResetMv.getDestination().getName()); if(gpcMetaInfo && !destMv.startsWith(GAPPOpenCLCodeGenerator.tempMv)) result.append("//#pragma gpc multivector ").append(destMv).append("\n"); printOpenCLVectorType(computeNearestOpenCLVectorSize(mvSizes.get(destMv))); result.append(" "); result.append(destMv).append(";\n"); mvBladeMap.put(destMv,new HashMap<Integer,String>()); return null; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { if (gappSetMv.getDestination().getName().equals(curDestination)) { String src = gappSetMv.getSource().getName(); if (!mapSetMv.containsKey(src)) { mapSetMv.put(src, new LinkedList<GAPPSetMv>()); } mapSetMv.get(src).add(gappSetMv); } return super.visitSetMv(gappSetMv, arg); } }
@Override public Object visitResetMv(GAPPResetMv gappResetMv, Object arg) { curLine++; liveStatistics.put(gappResetMv.getDestination().getName(), new LiveStatistics(curLine, gappResetMv.getSize())); return null; }
@Override public Object visitResetMv(GAPPResetMv gappResetMv, Object arg) { getMvSizes().put(GAPPOpenCLCodeGenerator.getVarName(gappResetMv.getDestination().getName()), 0); return null; }
@Override public Object visitAssignMv(GAPPAssignMv gappAssignMv, Object arg) { final String destMv = GAPPOpenCLCodeGenerator.getVarName(gappAssignMv.getDestination().getName()); Integer thisMvSetCount = mvBladeMap.get(destMv).size(); int selCount = 0; for(GAPPValueHolder val : gappAssignMv.getValues()) { final String bladeCoeff = getBladeCoeff(destMv,thisMvSetCount); result.append(bladeCoeff); result.append(" = "); result.append(val.toString()); result.append(";\n"); mvBladeMap.get(destMv).put(gappAssignMv.getSelectors().get(selCount++).getIndex(),bladeCoeff); ++thisMvSetCount; } return null; }
@Override public Object visitResetMv(GAPPResetMv gappResetMv, Object arg) { MultivectorWithValues mv = new MultivectorWithValues(gappResetMv.getSize(),true); values.put(gappResetMv.getDestination().getName(), mv); mv.clear(); return null; }
@Override public Object visitDotVectors(GAPPDotVectors gappDotVectors, Object arg) { incrementSize(GAPPOpenCLCodeGenerator.getVarName(gappDotVectors.getDestination().getName()),1); return null; }
@Override public Object visitCalculateMvCoeff(GAPPCalculateMvCoeff gappCalculateMvCoeff, Object arg) { final String destMv = GAPPOpenCLCodeGenerator.getVarName(gappCalculateMvCoeff.getDestination().getName()); final Integer thisMvSetCount = mvBladeMap.get(destMv).size(); final String bladeCoeff = getBladeCoeff(destMv,thisMvSetCount); result.append(bladeCoeff); result.append(" = "); visitCalculateOp(gappCalculateMvCoeff.getType(), GAPPOpenCLCodeGenerator.getVarName(gappCalculateMvCoeff.getOperand1().getName()), GAPPOpenCLCodeGenerator.getVarName(gappCalculateMvCoeff.getOperand2().getName())); result.append(";\n"); mvBladeMap.get(destMv).put(gappCalculateMvCoeff.getDestination().getBladeIndex(),bladeCoeff); return null; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { String name = gappSetMv.getSource().getName(); if (multivectors.contains(name)) { gappSetMv.setSource(new GAPPMultivector(name)); } else { if (vectors.contains(name)) { gappSetMv.setSource(new GAPPVector(name)); } else { System.err.println("Multivector/Vector "+name+" is not declared!"); } } multivectors.add(gappSetMv.getDestination().getName()); return null; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { final String destMv = GAPPOpenCLCodeGenerator.getVarName(gappSetMv.getDestination().getName()); Integer thisMvSetCount = mvBladeMap.get(destMv).size(); int selCount = 0; for(PosSelector sel : gappSetMv.getSelectorsDest()) { declareGPCMultivectorComponent(destMv, thisMvSetCount, sel); final String bladeCoeff = getBladeCoeff(destMv,thisMvSetCount); result.append(bladeCoeff); result.append(" = "); if(gappSetMv.getSelectorsSrc().get(0).getSign() < 0) result.append("-"); result.append(mvBladeMap.get(GAPPOpenCLCodeGenerator.getVarName(gappSetMv.getSource().getName())).get(gappSetMv.getSelectorsSrc().get(selCount++).getIndex())); result.append(";\n"); mvBladeMap.get(destMv).put(sel.getIndex(),bladeCoeff); ++thisMvSetCount; } return null; }
/** * Creates a temporary multivector with one entry and returns the according GAPPMultivectorComponent * @return The GAPPMultivectorComponent */ public GAPPMultivectorComponent createMvComp() { GAPPMultivector mv = new GAPPMultivector(createTMP(PREFIX_TMPMV)); gapp.addInstruction(new GAPPResetMv(mv, 1)); return new GAPPMultivectorComponent(mv.getName(), 0); }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { incrementSize(GAPPOpenCLCodeGenerator.getVarName(gappSetMv.getDestination().getName()), gappSetMv.getSelectorsDest().size()); return null; }
@Override public Object visitDotVectors(GAPPDotVectors gappDotVectors, Object arg) { MultivectorWithValues destination = getMultivector(gappDotVectors.getDestination().getName()); // calculate the dot product double sum = 0; int size = getMultivector(gappDotVectors.getParts().getFirst().getName()).getEntries().length; for (int slot = 0; slot < size; slot++) { double prod = 1; for (GAPPVector part : gappDotVectors.getParts()) { prod *= getMultivector(part.getName()).getEntry(slot); } sum += prod; } Selector sDest = gappDotVectors.getDestSelector(); destination.setEntry(sDest.getIndex(), sDest.getSign() * sum); return null; }
@Override public Object visitAssignMv(GAPPAssignMv gappAssignMv, Object arg) { MultivectorWithValues destination = getMultivector(gappAssignMv.getDestination().getName()); PosSelectorset selector = gappAssignMv.getSelectors(); int selCount = selector.size(); for (int sel = 0; sel < selCount; sel++) { GAPPValueHolder scalarVar = gappAssignMv.getValues().get(sel); double value = (scalarVar.isVariable()) ? getVariableValue(((GAPPVariable) scalarVar).getName()) : ((GAPPConstant) scalarVar).getValue(); destination.getEntries()[selector.get(sel).getIndex()] = value; } return null; }
@Override public Object visitSetMv(GAPPSetMv gappSetMv, Object arg) { MultivectorWithValues destination = getMultivector(gappSetMv.getDestination().getName()); MultivectorWithValues source = getMultivector(gappSetMv.getSource().getName()); Selectorset selSrc = gappSetMv.getSelectorsSrc(); PosSelectorset selDest = gappSetMv.getSelectorsDest(); int selCount = gappSetMv.getSelectorsSrc().size(); for (int sel = 0; sel < selCount; sel++) { PosSelector sDest = selDest.get(sel); Selector sSrc = selSrc.get(sel); destination.getEntries()[sDest.getIndex()] = sSrc.getSign() * source.getEntries()[sSrc.getIndex()]; } return null; }