Changeset 17071
- Timestamp:
- 07/04/19 16:03:48 (5 years ago)
- Location:
- stable
- Files:
-
- 17 edited
- 7 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk merged: 16266,16269,16274,16276-16277,16285-16287,16289,16293,16296-16298,16333-16334
- Property svn:mergeinfo changed
-
stable/HeuristicLab.ExtLibs
- Property svn:mergeinfo changed
/trunk/HeuristicLab.ExtLibs merged: 16266,16269,16274,16333-16334
- Property svn:mergeinfo changed
-
stable/HeuristicLab.ExtLibs.sln
r17053 r17071 1 1 2 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 # Visual Studio 20134 VisualStudioVersion = 1 2.0.40629.03 # Visual Studio 15 4 VisualStudioVersion = 15.0.28010.2048 5 5 MinimumVisualStudioVersion = 10.0.40219.1 6 6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.DayView-1.0", "HeuristicLab.ExtLibs\HeuristicLab.DayView\1.0\HeuristicLab.DayView-1.0.csproj", "{02766ECC-D0F5-4115-9ECA-47409167B638}" … … 72 72 EndProject 73 73 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.IGraph-0.8.0-pre", "HeuristicLab.ExtLibs\HeuristicLab.Igraph\0.8.0-pre\HeuristicLab.Igraph-0.8.0-pre\HeuristicLab.IGraph-0.8.0-pre.csproj", "{088D34F2-32EA-43FF-BAA8-22428D5B66BE}" 74 EndProject 75 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.NativeInterpreter-0.1", "HeuristicLab.ExtLibs\HeuristicLab.NativeInterpreter\0.1\HeuristicLab.NativeInterpreter-0.1\HeuristicLab.NativeInterpreter-0.1.csproj", "{E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}" 74 76 EndProject 75 77 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.MathJax-2.7.5", "HeuristicLab.ExtLibs\HeuristicLab.MathJax\2.7.5\HeuristicLab.MathJax-2.7.5\HeuristicLab.MathJax-2.7.5.csproj", "{31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}" … … 477 479 {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|x86.ActiveCfg = Release|x86 478 480 {31C09AD0-9610-4AFB-AE57-0F10AAC82BE5}.Release|x86.Build.0 = Release|x86 481 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 482 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|Any CPU.Build.0 = Debug|Any CPU 483 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x64.ActiveCfg = Debug|Any CPU 484 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x64.Build.0 = Debug|Any CPU 485 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x86.ActiveCfg = Debug|Any CPU 486 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Debug|x86.Build.0 = Debug|Any CPU 487 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|Any CPU.ActiveCfg = Release|Any CPU 488 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|Any CPU.Build.0 = Release|Any CPU 489 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x64.ActiveCfg = Release|Any CPU 490 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x64.Build.0 = Release|Any CPU 491 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x86.ActiveCfg = Release|Any CPU 492 {E05AC63F-6924-4C83-BD0A-EDF3C103C1D8}.Release|x86.Build.0 = Release|Any CPU 479 493 EndGlobalSection 480 494 GlobalSection(SolutionProperties) = preSolution 481 495 HideSolutionNode = FALSE 482 496 EndGlobalSection 497 GlobalSection(ExtensibilityGlobals) = postSolution 498 SolutionGuid = {7851D6F6-9C5F-4A36-8159-8F1C316DFAE0} 499 EndGlobalSection 483 500 EndGlobal -
stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/HeuristicLab.NativeInterpreter-0.1/DllImporter.cs
r16266 r17071 15 15 } 16 16 17 public class NativeWrapper {17 public static class NativeWrapper { 18 18 private const string x86dll = "hl-native-interpreter-msvc-x86.dll"; 19 19 private const string x64dll = "hl-native-interpreter-msvc-x64.dll"; … … 43 43 } 44 44 45 // x86 45 46 [DllImport(x86dll, EntryPoint = "GetValue", CallingConvention = CallingConvention.Cdecl)] 46 47 internal static extern double GetValue32(NativeInstruction[] code, int len, int row); … … 52 53 internal static extern void GetValuesVectorized32(NativeInstruction[] code, int len, int[] rows, int nRows, double[] result); 53 54 55 // x64 54 56 [DllImport(x64dll, EntryPoint = "GetValue", CallingConvention = CallingConvention.Cdecl)] 55 57 internal static extern double GetValue64(NativeInstruction[] code, int len, int row); -
stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/CMakeLists.txt
r16269 r17071 17 17 18 18 if(MSVC) 19 target_compile_options(hl-native-interpreter PRIVATE "/W4" "/Qvec-report:2" "$<$<CONFIG:Release>:/O2>") 20 target_compile_options(hl-native-interpreter-vdt PRIVATE "/W4" "/Qvec-report:2" "$<$<CONFIG:Release>:/O2>") 19 target_compile_options(hl-native-interpreter PRIVATE "/W4" "/Qvec-report:2" "/MT" "$<$<CONFIG:Release>:/O2>") 20 target_compile_options(hl-native-interpreter-vdt PRIVATE "/W4" "/Qvec-report:2" "/MT" "$<$<CONFIG:Release>:/O2>") 21 target_compile_definitions(hl-native-interpreter-vdt PRIVATE "USE_VDT") 21 22 else() 22 target_compile_options(hl-native-interpreter PRIVATE "-Wall" "-Wextra" "-Werror" "-fopt-info-vec-optimized" "$<$<CONFIG:Release>:-O fast>")23 target_compile_options(hl-native-interpreter-vdt PRIVATE "-Wall" "-Wextra" "-Werror" "-fopt-info-vec-optimized" "$<$<CONFIG:Release>:-O fast>")23 target_compile_options(hl-native-interpreter PRIVATE "-Wall" "-Wextra" "-Werror" "-fopt-info-vec-optimized" "$<$<CONFIG:Release>:-O3;-march=x86-64>") 24 target_compile_options(hl-native-interpreter-vdt PRIVATE "-Wall" "-Wextra" "-Werror" "-fopt-info-vec-optimized" "$<$<CONFIG:Release>:-O3;-march=x86-64>") 24 25 target_compile_definitions(hl-native-interpreter-vdt PRIVATE "USE_VDT") 26 set_target_properties(hl-native-interpreter PROPERTIES PREFIX "") 27 set_target_properties(hl-native-interpreter-vdt PROPERTIES PREFIX "") 25 28 endif() -
stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/README.md
r16269 r17071 43 43 ## TypeCoherent Grammar 44 44 45 | Rows | StandardInterpreter | LinerInterpreter | ILEmittingInterpreter | CompiledTreeInterpreter | Native-MSVC-Std | Native-MSVC-Vdt | Native-MinGW-Std | Native-MinGW-Vdt | Native-MSVC-Std[BatchSize=64] | Native-MSVC-Vdt[BatchSize=64] | Native-MinGW-Std[BatchSize=64] | Native-MinGW-Vdt[BatchSize=64] | 46 |-------|---------------------|------------------|-----------------------|-------------------------|-----------------|-----------------|------------------|------------------|-------------------------------|-------------------------------|--------------------------------|--------------------------------| 47 | 1000 | 0.0435 | 0.1522 | 0.0813 | 0.0732 | 0.3049 | 0.3074 | 0.2419 | 0.3098 | 0.7542 | 0.7928 | 0.3049 | 1.1368 | 48 | 2000 | 0.0441 | 0.1569 | 0.1254 | 0.1165 | 0.3066 | 0.3138 | 0.2407 | 0.3170 | 0.7932 | 0.8429 | 0.3199 | 1.2424 | 49 | 3000 | 0.0441 | 0.1536 | 0.1521 | 0.1476 | 0.3115 | 0.3088 | 0.2397 | 0.3136 | 0.8595 | 0.8675 | 0.3268 | 1.3074 | 50 | 4000 | 0.0440 | 0.1559 | 0.1708 | 0.1692 | 0.3122 | 0.3166 | 0.2420 | 0.3172 | 0.8443 | 0.8918 | 0.3247 | 1.3084 | 51 | 5000 | 0.0436 | 0.1543 | 0.1829 | 0.1852 | 0.3119 | 0.3138 | 0.2355 | 0.3175 | 0.8634 | 0.8872 | 0.3165 | 1.3024 | 52 | 6000 | 0.0439 | 0.1539 | 0.1950 | 0.1939 | 0.3091 | 0.3060 | 0.2389 | 0.3127 | 0.8758 | 0.9049 | 0.3284 | 1.3058 | 53 | 7000 | 0.0437 | 0.1553 | 0.2013 | 0.2055 | 0.3131 | 0.2835 | 0.2403 | 0.3141 | 0.8542 | 0.8989 | 0.3292 | 1.2941 | 54 | 8000 | 0.0442 | 0.1530 | 0.2084 | 0.2095 | 0.3109 | 0.3096 | 0.2381 | 0.3132 | 0.8804 | 0.9049 | 0.3286 | 1.3383 | 55 | 9000 | 0.0440 | 0.1552 | 0.2127 | 0.2222 | 0.3107 | 0.2944 | 0.2385 | 0.3035 | 0.8359 | 0.9049 | 0.3171 | 1.2707 | 56 | 10000 | 0.0439 | 0.1554 | 0.2133 | 0.2274 | 0.3118 | 0.2870 | 0.2385 | 0.3089 | 0.8424 | 0.9023 | 0.3187 | 1.3271 | 45 | Rows | StandardInterpreter | LinerInterpreter | ILEmittingInterpreter | CompiledTreeInterpreter | Native-MSVC-Std | Native-MSVC-Vdt | Native-MinGW-Std | Native-MinGW-Vdt | Native-MSVC-Std[BatchSize=64] | Native-MSVC-Vdt[BatchSize=64] | Native-MinGW-Std[BatchSize=64] | Native-MinGW-Vdt[BatchSize=64] | 46 |:-----:|:-------------------:|:----------------:|:---------------------:|:-----------------------:|:---------------:|:---------------:|:----------------:|:----------------:|:-----------------------------:|:-----------------------------:|:------------------------------:|:------------------------------:| 47 | 1000 | 0.0435 | 0.1522 | 0.0813 | 0.0732 | 0.3049 | 0.3074 | 0.2419 | 0.3098 | 0.7542 | 0.7928 | 0.3049 | 1.1368 | 48 | 2000 | 0.0441 | 0.1569 | 0.1254 | 0.1165 | 0.3066 | 0.3138 | 0.2407 | 0.3170 | 0.7932 | 0.8429 | 0.3199 | 1.2424 | 49 | 3000 | 0.0441 | 0.1536 | 0.1521 | 0.1476 | 0.3115 | 0.3088 | 0.2397 | 0.3136 | 0.8595 | 0.8675 | 0.3268 | 1.3074 | 50 | 4000 | 0.0440 | 0.1559 | 0.1708 | 0.1692 | 0.3122 | 0.3166 | 0.2420 | 0.3172 | 0.8443 | 0.8918 | 0.3247 | 1.3084 | 51 | 5000 | 0.0436 | 0.1543 | 0.1829 | 0.1852 | 0.3119 | 0.3138 | 0.2355 | 0.3175 | 0.8634 | 0.8872 | 0.3165 | 1.3024 | 52 | 6000 | 0.0439 | 0.1539 | 0.1950 | 0.1939 | 0.3091 | 0.3060 | 0.2389 | 0.3127 | 0.8758 | 0.9049 | 0.3284 | 1.3058 | 53 | 7000 | 0.0437 | 0.1553 | 0.2013 | 0.2055 | 0.3131 | 0.2835 | 0.2403 | 0.3141 | 0.8542 | 0.8989 | 0.3292 | 1.2941 | 54 | 8000 | 0.0442 | 0.1530 | 0.2084 | 0.2095 | 0.3109 | 0.3096 | 0.2381 | 0.3132 | 0.8804 | 0.9049 | 0.3286 | 1.3383 | 55 | 9000 | 0.0440 | 0.1552 | 0.2127 | 0.2222 | 0.3107 | 0.2944 | 0.2385 | 0.3035 | 0.8359 | 0.9049 | 0.3171 | 1.2707 | 56 | 10000 | 0.0439 | 0.1554 | 0.2133 | 0.2274 | 0.3118 | 0.2870 | 0.2385 | 0.3089 | 0.8424 | 0.9023 | 0.3187 | 1.3271 | 57 58 59 60 61 62 63 64 65 66 -
stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/lib/vdt/exp.h
r16269 r17071 153 153 //------------------------------------------------------------------------------ 154 154 155 void expv(const uint32_t size, double const * __restrict iarray, double* __restrict oarray);156 void fast_expv(const uint32_t size, double const * __restrict iarray, double* __restrict oarray);157 void expfv(const uint32_t size, float const * __restrict iarray, float* __restrict oarray);158 void fast_expfv(const uint32_t size, float const * __restrict iarray, float* __restrict oarray);159 160 155 } // end namespace vdt 161 156 -
stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.cpp
r16269 r17071 1 #include <memory>2 3 1 #include "interpreter.h" 4 2 3 #ifdef __cplusplus 5 4 extern "C" { 5 #endif 6 7 constexpr size_t BUFSIZE = BATCHSIZE * sizeof(double); 6 8 7 9 // slow (ish?) … … 22 24 23 25 __declspec(dllexport) 24 void __cdecl GetValuesVectorized(instruction* code, int codeLength, int* rows, int totalRows, double* result) noexcept26 void __cdecl GetValuesVectorized(instruction* code, int codeLength, int* rows, int totalRows, double* __restrict result) noexcept 25 27 { 26 std::vector<double[BUFSIZE]> buffers(codeLength); 27 // initialize instruction buffers 28 double* buffer = static_cast<double*>(_aligned_malloc(codeLength * BUFSIZE, 16)); 28 29 for (int i = 0; i < codeLength; ++i) 29 30 { 30 31 instruction& in = code[i]; 31 in.buf = buffer s[i];32 in.buf = buffer + (i * BATCHSIZE); 32 33 33 34 if (in.opcode == OpCodes::Const) … … 37 38 } 38 39 39 int remainingRows = totalRows % B UFSIZE;40 int remainingRows = totalRows % BATCHSIZE; 40 41 int total = totalRows - remainingRows; 41 42 42 for (int rowIndex = 0; rowIndex < total; rowIndex += B UFSIZE)43 for (int rowIndex = 0; rowIndex < total; rowIndex += BATCHSIZE) 43 44 { 44 evaluate(code, codeLength, rows, rowIndex, B UFSIZE);45 std::memcpy(result + rowIndex, code[0].buf, BUFSIZE * sizeof(double));45 evaluate(code, codeLength, rows, rowIndex, BATCHSIZE); 46 std::memcpy(result + rowIndex, code[0].buf, BUFSIZE); 46 47 } 47 48 48 49 // are there any rows left? 49 if (remainingRows > 0) { 50 for (int rowIndex = total; rowIndex < totalRows; rowIndex += remainingRows) 51 { 52 evaluate(code, codeLength, rows, rowIndex, remainingRows); 53 std::memcpy(result + rowIndex, code[0].buf, remainingRows * sizeof(double)); 54 } 50 if (remainingRows > 0) 51 { 52 evaluate(code, codeLength, rows, total, remainingRows); 53 std::memcpy(result + total, code[0].buf, remainingRows * sizeof(double)); 55 54 } 55 _aligned_free(buffer); 56 56 } 57 57 -
stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.h
r16269 r17071 2 2 #define NATIVE_TREE_INTERPRETER_CLANG_H 3 3 4 #include <cstring> 5 #include <vector> 6 #include <algorithm> 7 4 #include "vector_operations.h" 8 5 #include "instruction.h" 9 #include "vector_operations.h"10 6 11 7 inline double evaluate(instruction *code, int len, int row) noexcept … … 104 100 break; 105 101 } 102 case OpCodes::Square: 103 { 104 in.value = std::pow(code[in.childIndex].value, 2.); 105 break; 106 } 106 107 case OpCodes::Sqrt: 107 108 { … … 146 147 case OpCodes::Sub: 147 148 { 148 load(in.buf, code[in.childIndex].buf); 149 for (int j = 1; j < in.narg; ++j) 150 { 151 sub(in.buf, code[in.childIndex + j].buf); 152 } 153 if (in.narg == 1) 154 { 155 neg(in.buf); 149 if (in.narg == 1) 150 { 151 neg(in.buf, code[in.childIndex].buf); 152 break; 153 } 154 else 155 { 156 load(in.buf, code[in.childIndex].buf); 157 for (int j = 1; j < in.narg; ++j) 158 { 159 sub(in.buf, code[in.childIndex + j].buf); 160 } 156 161 } 157 162 break; … … 168 173 case OpCodes::Div: 169 174 { 170 load(in.buf, code[in.childIndex].buf); 171 for (int j = 1; j < in.narg; ++j) 172 { 173 div(in.buf, code[in.childIndex + j].buf); 174 } 175 if (in.narg == 1) 176 { 177 inv(in.buf); 175 if (in.narg == 1) 176 { 177 inv(in.buf, code[in.childIndex].buf); 178 break; 179 } 180 else 181 { 182 load(in.buf, code[in.childIndex].buf); 183 for (int j = 1; j < in.narg; ++j) 184 { 185 div(in.buf, code[in.childIndex + j].buf); 186 } 178 187 } 179 188 break; … … 219 228 { 220 229 square(in.buf, code[in.childIndex].buf); 230 break; 231 } 232 case OpCodes::Sqrt: 233 { 234 sqrt(in.buf, code[in.childIndex].buf); 221 235 break; 222 236 } -
stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/vector_operations.h
r16269 r17071 2 2 #define VECTOR_OPERATIONS_H 3 3 4 #define _USE_MATH_DEFINES 5 #include <cmath> 4 6 #include <cstring> 5 #include <cmath>6 7 7 8 #ifdef USE_VDT … … 27 28 #endif 28 29 29 constexpr int B UFSIZE = 64;30 constexpr int BATCHSIZE = 64; 30 31 31 #define FOR(i) for(int i = 0; i < B UFSIZE; ++i)32 #define FOR(i) for(int i = 0; i < BATCHSIZE; ++i) 32 33 33 34 // When auto-vectorizing without __restrict, … … 36 37 37 38 // vector - vector operations 38 inline void load(double* __restrict a, double* __restrict b) noexcept { std::memcpy(a, b, BUFSIZE * sizeof(double)); } 39 inline void add(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] += b[i]; } 40 inline void sub(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] -= b[i]; } 41 inline void mul(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] *= b[i]; } 42 inline void div(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] /= b[i]; } 43 inline void exp(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_exp(b[i]); } 44 inline void log(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_log(b[i]); } 45 inline void sin(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_sin(b[i]); } 46 inline void cos(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_cos(b[i]); } 47 inline void tan(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_tan(b[i]); } 48 inline void sqrt(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_sqrt(b[i]); } 49 inline void pow(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_pow(a[i], hl_round(b[i])); }; 50 inline void root(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = hl_pow(a[i], 1 / hl_round(b[i])); }; 51 inline void square(double* __restrict a, double* __restrict b) noexcept { FOR(i) a[i] = b[i] * b[i]; }; 39 inline void load(double* __restrict a, double const * __restrict b) noexcept { std::memcpy(a, b, BATCHSIZE * sizeof(double)); } 40 inline void add(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] += b[i]; } 41 inline void sub(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] -= b[i]; } 42 inline void mul(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] *= b[i]; } 43 inline void div(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] /= b[i]; } 44 inline void exp(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_exp(b[i]); } 45 inline void log(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_log(b[i]); } 46 inline void sin(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_sin(b[i]); } 47 inline void cos(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_cos(b[i]); } 48 inline void tan(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_tan(b[i]); } 49 inline void sqrt(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_sqrt(b[i]); } 50 inline void pow(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_pow(a[i], hl_round(b[i])); }; 51 inline void root(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_pow(a[i], 1. / hl_round(b[i])); }; 52 inline void square(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = hl_pow(b[i], 2.); }; 53 inline void inv(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = 1. / b[i]; } 54 inline void neg(double* __restrict a, double const * __restrict b) noexcept { FOR(i) a[i] = -b[i]; } 52 55 53 56 // vector - scalar operations … … 60 63 // vector operations 61 64 inline void neg(double* __restrict a) noexcept { FOR(i) a[i] = -a[i]; } 62 inline void inv(double* __restrict a) noexcept { FOR(i) a[i] = 1 / a[i]; }65 inline void inv(double* __restrict a) noexcept { FOR(i) a[i] = 1. / a[i]; } 63 66 inline void exp(double* __restrict a) noexcept { FOR(i) a[i] = hl_exp(a[i]); } 64 67 inline void log(double* __restrict a) noexcept { FOR(i) a[i] = hl_log(a[i]); } … … 67 70 inline void sqrt(double* __restrict a) noexcept { FOR(i) a[i] = hl_sqrt(a[i]); } 68 71 inline void round(double* __restrict a) noexcept { FOR(i) a[i] = hl_round(a[i]); } 69 inline void square(double* __restrict a) noexcept { FOR(i) a[i] = a[i] * a[i];; }72 inline void square(double* __restrict a) noexcept { FOR(i) a[i] = hl_pow(a[i], 2.); } 70 73 71 74 #undef FOR -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 16276-16277,16285-16287,16289,16293,16296-16297
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17066 r17071 107 107 <Private>False</Private> 108 108 </Reference> 109 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1, Version=0.0.0.1, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 110 <SpecificVersion>False</SpecificVersion> 111 <HintPath>..\..\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.NativeInterpreter-0.1.dll</HintPath> 112 <Private>False</Private> 113 </Reference> 109 114 <Reference Include="System" /> 110 115 <Reference Include="System.Core"> … … 152 157 <Compile Include="Interfaces\IVariableSymbol.cs" /> 153 158 <Compile Include="Interpreter\IntervalInterpreter.cs" /> 159 <Compile Include="Interpreter\BatchInstruction.cs" /> 160 <Compile Include="Interpreter\BatchOperations.cs" /> 154 161 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionCompiledTreeInterpreter.cs" /> 162 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs" /> 163 <Compile Include="Interpreter\SymbolicDataAnalysisExpressionTreeNativeInterpreter.cs" /> 155 164 <Compile Include="SymbolicDataAnalysisExpressionTreeSimplificationOperator.cs" /> 156 165 <Compile Include="SymbolicDataAnalysisModelComplexityCalculator.cs" /> -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/BatchOperations.cs
r16287 r17071 64 64 a[i] = Math.Cos(b[i]); 65 65 } 66 67 public static void Tan(double[] a, double[] b) { 68 for (int i = 0; i < BATCHSIZE; ++i) 69 a[i] = Math.Tan(b[i]); 70 } 71 72 public static void Pow(double[] a, double[] b) { 73 for (int i = 0; i < BATCHSIZE; ++i) 74 a[i] = Math.Pow(a[i], Math.Round(b[i])); 75 } 76 77 public static void Root(double[] a, double[] b) { 78 for (int i = 0; i < BATCHSIZE; ++i) 79 a[i] = Math.Pow(a[i], 1 / Math.Round(b[i])); 80 } 81 82 public static void Square(double[] a, double[] b) { 83 for (int i = 0; i < BATCHSIZE; ++i) 84 a[i] = Math.Pow(b[i], 2d); 85 } 86 87 public static void Sqrt(double[] a, double[] b) { 88 for (int i = 0; i < BATCHSIZE; ++i) 89 a[i] = Math.Sqrt(b[i]); 90 } 66 91 } 67 92 } -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeBatchInterpreter.cs
r16287 r17071 11 11 12 12 using static HeuristicLab.Problems.DataAnalysis.Symbolic.BatchOperations; 13 //using static HeuristicLab.Problems.DataAnalysis.Symbolic.BatchOperationsVector;14 13 15 14 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { … … 65 64 break; 66 65 } 66 67 67 case OpCodes.Add: { 68 68 Load(instr.buf, code[c].buf); … … 76 76 if (n == 1) { 77 77 Neg(instr.buf, code[c].buf); 78 break;79 78 } else { 80 79 Load(instr.buf, code[c].buf); … … 82 81 Sub(instr.buf, code[c + j].buf); 83 82 } 84 break;85 }83 } 84 break; 86 85 } 87 86 … … 97 96 if (n == 1) { 98 97 Inv(instr.buf, code[c].buf); 99 break;100 98 } else { 101 99 Load(instr.buf, code[c].buf); … … 103 101 Div(instr.buf, code[c + j].buf); 104 102 } 105 break; 106 } 103 } 104 break; 105 } 106 107 case OpCodes.Square: { 108 Square(instr.buf, code[c].buf); 109 break; 110 } 111 112 case OpCodes.Root: { 113 Root(instr.buf, code[c].buf); 114 break; 115 } 116 117 case OpCodes.SquareRoot: { 118 Sqrt(instr.buf, code[c].buf); 119 break; 120 } 121 122 case OpCodes.Power: { 123 Pow(instr.buf, code[c].buf); 124 break; 107 125 } 108 126 … … 116 134 break; 117 135 } 136 137 case OpCodes.Sin: { 138 Sin(instr.buf, code[c].buf); 139 break; 140 } 141 142 case OpCodes.Cos: { 143 Cos(instr.buf, code[c].buf); 144 break; 145 } 146 147 case OpCodes.Tan: { 148 Tan(instr.buf, code[c].buf); 149 break; 150 } 118 151 } 119 152 } 153 } 154 155 [ThreadStatic] 156 private Dictionary<string, double[]> cachedData; 157 158 private void InitCache(IDataset dataset) { 159 cachedData = new Dictionary<string, double[]>(); 160 foreach (var v in dataset.DoubleVariables) { 161 var values = dataset.GetDoubleValues(v).ToArray(); 162 } 163 } 164 165 public void InitializeState() { 166 cachedData = null; 167 EvaluatedSolutions = 0; 120 168 } 121 169 122 170 private double[] GetValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) { 123 171 var code = Compile(tree, dataset, OpCodes.MapSymbolToOpCode); 124 125 172 var remainingRows = rows.Length % BATCHSIZE; 126 173 var roundedTotal = rows.Length - remainingRows; … … 141 188 } 142 189 190 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, int[] rows) { 191 if (cachedData == null) { 192 InitCache(dataset); 193 } 194 return GetValues(tree, dataset, rows); 195 } 196 143 197 public IEnumerable<double> GetSymbolicExpressionTreeValues(ISymbolicExpressionTree tree, IDataset dataset, IEnumerable<int> rows) { 144 return GetValues(tree, dataset, rows.ToArray()); 145 } 146 147 public void InitializeState() { 198 return GetSymbolicExpressionTreeValues(tree, dataset, rows.ToArray()); 148 199 } 149 200 … … 152 203 var code = new BatchInstruction[root.GetLength()]; 153 204 if (root.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)"); 154 code[0] = new BatchInstruction { narg = (ushort)root.SubtreeCount, opcode = opCodeMapper(root) };155 205 int c = 1, i = 0; 156 206 foreach (var node in root.IterateNodesBreadth()) { 157 for (int j = 0; j < node.SubtreeCount; ++j) { 158 var s = node.GetSubtree(j); 159 if (s.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)"); 160 code[c + j] = new BatchInstruction { narg = (ushort)s.SubtreeCount, opcode = opCodeMapper(s) }; 161 } 162 163 code[i].buf = new double[BATCHSIZE]; 164 207 if (node.SubtreeCount > ushort.MaxValue) throw new ArgumentException("Number of subtrees is too big (>65.535)"); 208 code[i] = new BatchInstruction { 209 opcode = opCodeMapper(node), 210 narg = (ushort)node.SubtreeCount, 211 buf = new double[BATCHSIZE], 212 childIndex = c 213 }; 165 214 if (node is VariableTreeNode variable) { 166 215 code[i].weight = variable.Weight; 167 code[i].data = dataset.GetReadOnlyDoubleValues(variable.VariableName).ToArray(); 216 if (cachedData.ContainsKey(variable.VariableName)) { 217 code[i].data = cachedData[variable.VariableName]; 218 } else { 219 code[i].data = dataset.GetReadOnlyDoubleValues(variable.VariableName).ToArray(); 220 cachedData[variable.VariableName] = code[i].data; 221 } 168 222 } else if (node is ConstantTreeNode constant) { 169 223 code[i].value = constant.Value; … … 171 225 code[i].buf[j] = code[i].value; 172 226 } 173 174 code[i].childIndex = c;175 227 c += node.SubtreeCount; 176 228 ++i; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r15587 r17071 37 37 [PluginDependency("HeuristicLab.Data", "3.3")] 38 38 [PluginDependency("HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "3.4")] 39 [PluginDependency("HeuristicLab.NativeInterpreter", "0.1")] 39 40 [PluginDependency("HeuristicLab.Operators", "3.3")] 40 41 [PluginDependency("HeuristicLab.Optimization", "3.3")] -
stable/HeuristicLab.Tests
- Property svn:mergeinfo changed
/trunk/HeuristicLab.Tests merged: 16298
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs
r15584 r17071 119 119 public void LinearInterpreterTestArithmeticGrammarPerformance() { 120 120 TestArithmeticGrammarPerformance(new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), 12.5e6); 121 } 122 123 [TestMethod] 124 [TestCategory("Problems.DataAnalysis.Symbolic")] 125 [TestProperty("Time", "long")] 126 public void BatchInterpreterTestTypeCoherentGrammarPerformance() { 127 TestTypeCoherentGrammarPerformance(new SymbolicDataAnalysisExpressionTreeBatchInterpreter(), 12.5e6); 128 } 129 [TestMethod] 130 [TestCategory("Problems.DataAnalysis.Symbolic")] 131 [TestProperty("Time", "long")] 132 public void BatchInterpreterTestArithmeticGrammarPerformance() { 133 TestArithmeticGrammarPerformance(new SymbolicDataAnalysisExpressionTreeBatchInterpreter(), 12.5e6); 121 134 } 122 135
Note: See TracChangeset
for help on using the changeset viewer.