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/Interpreter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.