unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.15k stars 130 forks source link

Bug: Compilation issue with a defined __AVX512__ without _Float16 support #202

Closed grubdragon closed 1 year ago

grubdragon commented 1 year ago

Describe the bug

While working on the lanterndb project, we discovered a bug that made compilation fail. Compilation failed for my machine since it had __AVX512F__ defined, but environment did not support _Float16. See code below: https://github.com/unum-cloud/usearch/blob/b7ec32c0bdd7ba496c6d7bbef209c889fb4bb1f6/include/usearch/index_plugins.hpp#L23-L35

There is another underlying issue in the else condition of the same code, since the code throws away the environment's choice, even if USEARCH_USE_NATIVE_F16 is pre-defined,

A better choice is to

We have filed the bug internally here: https://github.com/lanterndata/lanterndb/issues/59

Attempted to solve it here: https://github.com/Ngalstyan4/usearch/pull/6

Steps to reproduce

  1. Build the lanterndb project (which internally builds usearch) following QuickStart instructions.
  2. On the make install step, I hit the error message at 7%: error: _Float16 does not name a type

Expected behavior

Build should be successful and continue to 100%

USearch version

v0.22.1

Operating System

Ubuntu 22.04

Hardware architecture

x86

Which interface are you using?

C++ implementation

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

ashvardanian commented 1 year ago

Hey, @grubdragon! Thanks for reaching out!

We have encountered that issue internally as well and will try to patch it in the next two days.

ashvardanian commented 1 year ago

For compatibility purposes, you may want to disable the USEARCH_USE_NATIVE_F16 in generic builds, unless you know precisely, that the hardware supports it. This, however, will not necessarily compromise the performance.

If you keep SimSIMD enabled, on Linux targets, we will dispatch AVX-512 (for x86) and NEON/SVE (for Arm), when supported by the platforms. Those ISA extensions will bring the f16 support where it matters - in distance calculations. To ensure that the right implementation is always pre-compiled and needs no JIT-ing, we have added annotations for GCC, our default compiler on Linux. The patch will be merged into the main branch of SimSIMD, and then USearch as soon as it passes the CI. Sadly, some platforms, like MacOS, with their "Universal Builds", confuse my macros.

If you have any suggestions, feel free to contribute, @grubdragon 🤗

ashvardanian commented 1 year ago

@grubdragon, I'm curious if our last releases resolved the issue. Please let me know if it still requires addressing.