Changeset 16274 for trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.cpp
- Timestamp:
- 11/04/18 11:05:31 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.cpp
r16269 r16274 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 if (remainingRows > 0) 51 { 50 52 for (int rowIndex = total; rowIndex < totalRows; rowIndex += remainingRows) 51 53 { … … 54 56 } 55 57 } 58 _aligned_free(buffer); 56 59 } 57 60
Note: See TracChangeset
for help on using the changeset viewer.