Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 16:03:48 (5 years ago)
Author:
mkommend
Message:

#2958: Merged 16266, 16269, 16274, 16276, 16277, 16285, 16286, 16287, 16289, 16293, 16296, 16297, 16298, 16333, 16334 into stable.

Location:
stable
Files:
3 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.ExtLibs

  • stable/HeuristicLab.ExtLibs/HeuristicLab.NativeInterpreter/0.1/NativeInterpreter-0.1/src/interpreter.cpp

    r16269 r17071  
    1 #include <memory>
    2 
    31#include "interpreter.h"
    42
     3#ifdef __cplusplus
    54extern "C" {
     5#endif
     6
     7constexpr size_t BUFSIZE = BATCHSIZE * sizeof(double);
    68
    79// slow (ish?)
     
    2224
    2325__declspec(dllexport)
    24 void __cdecl GetValuesVectorized(instruction* code, int codeLength, int* rows, int totalRows, double* result) noexcept
     26void __cdecl GetValuesVectorized(instruction* code, int codeLength, int* rows, int totalRows, double* __restrict result) noexcept
    2527{
    26     std::vector<double[BUFSIZE]> buffers(codeLength);
    27     // initialize instruction buffers
     28    double* buffer = static_cast<double*>(_aligned_malloc(codeLength * BUFSIZE, 16));
    2829    for (int i = 0; i < codeLength; ++i)
    2930    {
    3031        instruction& in = code[i];
    31         in.buf = buffers[i];
     32        in.buf = buffer + (i * BATCHSIZE);
    3233
    3334        if (in.opcode == OpCodes::Const)
     
    3738    }
    3839
    39     int remainingRows = totalRows % BUFSIZE;
     40    int remainingRows = totalRows % BATCHSIZE;
    4041    int total = totalRows - remainingRows;
    4142
    42     for (int rowIndex = 0; rowIndex < total; rowIndex += BUFSIZE)
     43    for (int rowIndex = 0; rowIndex < total; rowIndex += BATCHSIZE)
    4344    {
    44         evaluate(code, codeLength, rows, rowIndex, BUFSIZE);
    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);
    4647    }
    4748
    4849    // 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));
    5554    }
     55    _aligned_free(buffer);
    5656}
    5757
Note: See TracChangeset for help on using the changeset viewer.