Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/04/18 11:05:31 (6 years ago)
Author:
bburlacu
Message:

#2958: Update dll files and C++ source code to the latest version.

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 
    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    if (remainingRows > 0)
     51    {
    5052        for (int rowIndex = total; rowIndex < totalRows; rowIndex += remainingRows)
    5153        {
     
    5456        }
    5557    }
     58    _aligned_free(buffer);
    5659}
    5760
Note: See TracChangeset for help on using the changeset viewer.