Как насчет сторонних C-шных либ, собранных с поддержкой векторных инструкций процов (SSE, AVХ,..) ? Раз в 5..10 быстрее будет.
Пример таковой либы - правда на "плюсах" (в паскале без C-обертки не заюзаешь)
https://github.com/ermig1979/SimdThe Simd Library is a free open source image processing library, designed for C and C++ programmers. It provides many useful high performance algorithms for image processing such as: pixel format conversion, image scaling and filtration, extraction of statistic information from images, motion detection, object detection (HAAR and LBP classifier cascades) and classification, neural network.
The algorithms are optimized with using of different SIMD CPU extensions. In particular the library supports following CPU extensions: SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX-512 for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC (big-endian), NEON for ARM.
The Simd Library has C API and also contains useful C++ classes and functions to facilitate access to C API. The library supports dynamic and static linking, 32-bit and 64-bit Windows, Android and Linux, MSVS, G++ and Clang compilers, MSVS project and CMake build systems.
Добавлено спустя 8 часов 31 минуту 21 секунду:Даже Фэйсбук к этим делам приложил руку:
This month, we released Facebook AI Similarity Search (Faiss), a library that allows us to quickly search for multimedia documents that are similar to each other — a challenge where traditional query search engines fall short. We’ve built nearest-neighbor search implementations for billion-scale data sets that are some 8.5x faster than the previous reported state-of-the-art, along with the fastest k-selection algorithm on the GPU known in the literature. This lets us break some records, including the first k-nearest-neighbor graph constructed on 1 billion high-dimensional vectors.
https://code.fb.com/data-infrastructure ... ty-search/https://github.com/facebookresearch/faissЕсть даже реализация для видеокарт:
Billion-scale similarity search with GPUs
https://arxiv.org/pdf/1702.08734.pdf