Changeset 17071 for stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.cpp
- Timestamp:
- 07/04/19 16:03:48 (5 years ago)
- Location:
- stable
- Files:
-
- 3 edited
- 2 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/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
Note: See TracChangeset
for help on using the changeset viewer.