Skip to content

Commit

Permalink
Build: Compilation fixes, WASM build succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
mgevor committed Jul 11, 2023
1 parent cf695b4 commit c50d10f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
17 changes: 11 additions & 6 deletions cpp/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
using namespace unum::usearch;
using namespace unum;

using label_t = std::int64_t;
using vector_id_t = std::uint32_t;
using vector_view_t = span_gt<float const>;

Expand Down Expand Up @@ -534,24 +535,24 @@ void run_big_or_small(dataset_at& dataset, args_t const& args, index_config_t co
if (args.native) {
if (args.metric_cos) {
std::printf("-- Metric: Angular\n");
run_typed<index_gt<cos_gt<float>, std::size_t, neighbor_id_at>>(dataset, args, config, limits);
run_typed<index_gt<cos_gt<float>, label_t, neighbor_id_at>>(dataset, args, config, limits);
} else if (args.metric_l2) {
std::printf("-- Metric: Euclidean\n");
run_typed<index_gt<l2sq_gt<float>, std::size_t, neighbor_id_at>>(dataset, args, config, limits);
run_typed<index_gt<l2sq_gt<float>, label_t, neighbor_id_at>>(dataset, args, config, limits);
} else if (args.metric_haversine) {
std::printf("-- Metric: Haversine\n");
run_typed<index_gt<haversine_gt<float>, std::size_t, neighbor_id_at>>(dataset, args, config, limits);
run_typed<index_gt<haversine_gt<float>, label_t, neighbor_id_at>>(dataset, args, config, limits);
} else {
std::printf("-- Metric: Inner Product\n");
run_typed<index_gt<ip_gt<float>, std::size_t, neighbor_id_at>>(dataset, args, config, limits);
run_typed<index_gt<ip_gt<float>, label_t, neighbor_id_at>>(dataset, args, config, limits);
}
} else
run_punned<index_punned_dense_gt<std::size_t, neighbor_id_at>>(dataset, args, config, limits);
run_punned<index_punned_dense_gt<label_t, neighbor_id_at>>(dataset, args, config, limits);
}

void report_alternative_setups() {
using set_member_t = std::uint32_t;
using sets_index_t = index_gt<jaccard_gt<set_member_t>, std::size_t, std::uint32_t>;
using sets_index_t = index_gt<jaccard_gt<set_member_t>, label_t, std::uint32_t>;
set_member_t set_a[] = {10, 12, 15};
set_member_t set_b[] = {11, 12, 15, 16};
sets_index_t index;
Expand Down Expand Up @@ -684,7 +685,11 @@ int main(int argc, char** argv) {
// std::printf("-- Expansion @ Search: %zu\n", config.expansion_search);

if (args.big)
#ifdef USEARCH_64BIT_ENV
run_big_or_small<uint40_t>(dataset, args, config, limits);
#else
std::printf("Error: Don't use 40 bit identifiers in 32bit environment\n");
#endif
else
run_big_or_small<std::uint32_t>(dataset, args, config, limits);

Expand Down
17 changes: 13 additions & 4 deletions include/usearch/index.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
#define USEARCH_DEFINED_ARM
#endif

// Inferring hardware bitness: 32 vs 64
#if __WORDSIZE == 64
#define USEARCH_64BIT_ENV
#else
#define USEARCH_32BIT_ENV
#endif

#if !defined(USEARCH_USE_OPENMP)
#define USEARCH_USE_OPENMP 0
#endif
Expand Down Expand Up @@ -169,9 +176,9 @@ inline std::size_t ceil2(std::size_t v) noexcept {
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
// For 64 bit systems
if constexpr (sizeof(void*) == 8)
v |= v >> 32;
#ifdef USEARCH_64BIT_ENV
v |= v >> 32;
#endif
v++;
return v;
}
Expand Down Expand Up @@ -971,6 +978,8 @@ class sorted_buffer_gt {

/**
* @brief Five-byte integer type to address node clouds with over 4B entries.
*
* @note Avoid usage in 32bit environment
*/
class usearch_pack_m uint40_t {
unsigned char octets[5];
Expand Down Expand Up @@ -1299,7 +1308,7 @@ struct viewed_file_t {
*
*/
template <typename metric_at = ip_gt<float>, //
typename label_at = std::size_t, //
typename label_at = std::int64_t, //
typename id_at = std::uint32_t, //
typename allocator_at = std::allocator<char>, //
typename point_allocator_at = allocator_at> //
Expand Down

0 comments on commit c50d10f

Please sign in to comment.