- Timestamp:
- 11/08/18 16:55:30 (6 years ago)
- 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 1 1 using System; 2 using System.Numerics;3 2 4 3 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 5 4 public static class BatchOperations { 6 5 public const int BATCHSIZE = 64; 7 private static readonly int STRIDE = Vector<double>.Count;8 6 9 7 public static void Load(double[] a, double[] b) { … … 12 10 13 11 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]; 18 14 } 19 15 } 20 16 21 17 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]; 26 20 } 27 21 } 28 22 29 23 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]; 34 26 } 35 27 } 36 28 37 29 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]; 42 32 } 43 33 } 44 34 45 35 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]; 49 38 } 50 39 } 51 40 52 41 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]; 56 44 } 57 45 } -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r16285 r16287 161 161 } 162 162 163 code[i].buf = new double[BATCHSIZE]; 164 163 165 if (node is VariableTreeNode variable) { 164 166 code[i].weight = variable.Weight; 165 167 code[i].data = dataset.GetReadOnlyDoubleValues(variable.VariableName).ToArray(); 166 code[i].buf = new double[BATCHSIZE];167 168 } else if (node is ConstantTreeNode constant) { 168 169 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; 172 172 } 173 173
Note: See TracChangeset
for help on using the changeset viewer.