Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/08/18 16:55:30 (6 years ago)
Author:
bburlacu
Message:

#2958: Keep the SymbolicDataAnalysisExpressionTreeBatchInterpreter, but remove vectorization.

Location:
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r16286 r16287  
    117117    </Reference>
    118118    <Reference Include="System.Drawing" />
    119     <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
    120       <HintPath>..\..\packages\System.Numerics.Vectors.4.5.0\lib\portable-net45+win8+wp8+wpa81\System.Numerics.Vectors.dll</HintPath>
    121     </Reference>
    122119    <Reference Include="System.Xml.Linq">
    123120      <RequiredTargetFramework>3.5</RequiredTargetFramework>
     
    165162    <Compile Include="Interfaces\IVariableSymbol.cs" />
    166163    <Compile Include="Interpreter\BatchInstruction.cs" />
    167     <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs" />
    168164    <Compile Include="Interpreter\BatchOperations.cs" />
    169165    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs" />
     166    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs" />
    170167    <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs" />
    171168    <Compile Include="SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs" />
     
    283280    <Compile Include="TreeMatching\SymbolicExpressionTreePhenotypicSimilarityCalculator.cs" />
    284281    <None Include="HeuristicLab.snk" />
    285     <None Include="packages.config" />
    286282    <None Include="Plugin.cs.frame" />
    287283    <None Include="Properties\AssemblyInfo.cs.frame" />
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs

    r16285 r16287  
    11using System;
    2 using System.Numerics;
    32
    43namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    54  public static class BatchOperations {
    65    public const int BATCHSIZE = 64;
    7     private static readonly int STRIDE = Vector<double>.Count;
    86
    97    public static void Load(double[] a, double[] b) {
     
    1210
    1311    public static void Add(double[] a, double[] b) {
    14       for (int i = 0; i < BATCHSIZE; i += STRIDE) {
    15         var va = new Vector<double>(a, i);
    16         var vb = new Vector<double>(b, i);
    17         (va + vb).CopyTo(a, i);
     12      for (int i = 0; i < BATCHSIZE; ++i) {
     13        a[i] += b[i];
    1814      }
    1915    }
    2016
    2117    public static void Sub(double[] a, double[] b) {
    22       for (int i = 0; i < BATCHSIZE; i += STRIDE) {
    23         var va = new Vector<double>(a, i);
    24         var vb = new Vector<double>(b, i);
    25         (va - vb).CopyTo(a, i);
     18      for (int i = 0; i < BATCHSIZE; ++i) {
     19        a[i] -= b[i];
    2620      }
    2721    }
    2822
    2923    public static void Div(double[] a, double[] b) {
    30       for (int i = 0; i < BATCHSIZE; i += STRIDE) {
    31         var va = new Vector<double>(a, i);
    32         var vb = new Vector<double>(b, i);
    33         (va / vb).CopyTo(a, i);
     24      for (int i = 0; i < BATCHSIZE; ++i) {
     25        a[i] /= b[i];
    3426      }
    3527    }
    3628
    3729    public static void Mul(double[] a, double[] b) {
    38       for (int i = 0; i < BATCHSIZE; i += STRIDE) {
    39         var va = new Vector<double>(a, i);
    40         var vb = new Vector<double>(b, i);
    41         (va * vb).CopyTo(a, i);
     30      for (int i = 0; i < BATCHSIZE; ++i) {
     31        a[i] *= b[i];
    4232      }
    4333    }
    4434
    4535    public static void Neg(double[] a, double[] b) {
    46       for (int i = 0; i < BATCHSIZE; i += STRIDE) {
    47         var vb = new Vector<double>(b, i);
    48         Vector.Negate(vb).CopyTo(a, i);
     36      for (int i = 0; i < BATCHSIZE; ++i) {
     37        a[i] = -b[i];
    4938      }
    5039    }
    5140
    5241    public static void Inv(double[] a, double[] b) {
    53       for (int i = 0; i < BATCHSIZE; i += STRIDE) {
    54         var vb = new Vector<double>(b, i);
    55         (Vector<double>.One / vb).CopyTo(a, i);
     42      for (int i = 0; i < BATCHSIZE; ++i) {
     43        a[i] = 1 / b[i];
    5644      }
    5745    }
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs

    r16285 r16287  
    161161        }
    162162
     163        code[i].buf = new double[BATCHSIZE];
     164
    163165        if (node is VariableTreeNode variable) {
    164166          code[i].weight = variable.Weight;
    165167          code[i].data = dataset.GetReadOnlyDoubleValues(variable.VariableName).ToArray();
    166           code[i].buf = new double[BATCHSIZE];
    167168        } else if (node is ConstantTreeNode constant) {
    168169          code[i].value = constant.Value;
    169           code[i].buf = Enumerable.Repeat(code[i].value, BATCHSIZE).ToArray();
    170         } else if (node.SubtreeCount > 0) {
    171           code[i].buf = new double[BATCHSIZE];
     170          for (int j = 0; j < BATCHSIZE; ++j)
     171            code[i].buf[j] = code[i].value;
    172172        }
    173173
Note: See TracChangeset for help on using the changeset viewer.