aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Graf <markus.graf@markusgraf.net>2026-02-27 20:48:41 +0000
committerGleb Popov <arrowd@FreeBSD.org>2026-03-01 16:24:01 +0000
commit0289e12ec3a7b736793e435454bbeeda59faedb6 (patch)
tree1593d946b8e3182fc420493a5b4aa7787bc3f4fe
parent52e37a08ce1c6b5bdba9f03948386109b9b39052 (diff)
math/usearch: Search & Clustering engine library (C, C++ and Java JNI)
PR: 293490 Co-authored-by: Gleb Popov <arrowd@FreeBSD.org>
-rw-r--r--math/Makefile1
-rw-r--r--math/usearch/Makefile69
-rw-r--r--math/usearch/distinfo9
-rw-r--r--math/usearch/files/patch-simsimd_c_lib.c47
-rw-r--r--math/usearch/pkg-descr2
-rw-r--r--math/usearch/pkg-plist8
6 files changed, 136 insertions, 0 deletions
diff --git a/math/Makefile b/math/Makefile
index fb5a95ecaf5e..e225fecb37f7 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -1288,6 +1288,7 @@
SUBDIR += units
SUBDIR += universal
SUBDIR += unuran
+ SUBDIR += usearch
SUBDIR += vampire
SUBDIR += vdt
SUBDIR += verdict
diff --git a/math/usearch/Makefile b/math/usearch/Makefile
new file mode 100644
index 000000000000..bff800a1139a
--- /dev/null
+++ b/math/usearch/Makefile
@@ -0,0 +1,69 @@
+PORTNAME= USearch
+DISTVERSIONPREFIX= v
+DISTVERSION= 2.24.0
+CATEGORIES= math java
+
+MAINTAINER= markus.graf@markusgraf.net
+COMMENT= Search & Clustering engine library (C, C++ and Java JNI)
+WWW= https://unum.cloud/usearch
+
+LICENSE= APACHE20
+LICENSE_FILE= ${WRKSRC}/LICENSE
+
+NOT_FOR_ARCHS= i386
+NOT_FOR_ARCHS_REASON= Tests crash on i386
+
+USES= cmake java
+
+USE_GITHUB= yes
+GH_ACCOUNT= unum-cloud
+
+CMAKE_ON= USEARCH_USE_FP16LIB \
+ USEARCH_USE_SIMSIMD \
+ USEARCH_BUILD_TEST_C \
+ USEARCH_BUILD_TEST_CPP \
+ USEARCH_BUILD_LIB_C \
+ USEARCH_USE_OPENMP \
+ USEARCH_BUILD_JNI
+
+CMAKE_OFF= USEARCH_BUILD_BENCH_CPP
+
+CMAKE_ARGS= -DJAVA_INCLUDE_PATH=${JAVA_HOME}/include \
+ -DJAVA_HOME=${JAVA_HOME}
+
+JAVA_VERSION= 21
+
+USE_LDCONFIG= yes
+
+GH_TUPLE= maratyszcza:FP16:0a92994d729ff76a58f692d3028ca1b64b145d91:fp16/fp16 \
+ ashvardanian:StringZilla:v3.12.6:sz/stringzilla \
+ ashvardanian:SimSIMD:v6.5.13:sim/simsimd
+
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} == amd64 # for simsimd
+CXXFLAGS= -march=x86-64
+.endif
+
+post-build:
+ cd ${WRKSRC} && ${JAVAC} -classpath java -encoding UTF-8 -h java/cloud/unum/usearch -d bin java/cloud/unum/usearch/Index.java
+ ${MKDIR} ${WRKSRC}/bin/usearch-native
+ ${INSTALL_LIB} ${BUILD_WRKSRC}/libusearch_jni.so ${WRKSRC}/bin/usearch-native/
+ cd ${WRKSRC} && ${JAR} cvf usearch.jar -C bin .
+
+do-install:
+ ${MKDIR} ${STAGEDIR}${PREFIX}/include/usearch
+ ${INSTALL_DATA} ${WRKSRC}/include/usearch/*.hpp ${STAGEDIR}${PREFIX}/include/usearch/
+ ${INSTALL_DATA} ${WRKSRC}/c/usearch.h ${STAGEDIR}${PREFIX}/include/usearch/
+ ${INSTALL_LIB} ${BUILD_WRKSRC}/libusearch_c.so ${STAGEDIR}${PREFIX}/lib/
+ ${INSTALL_DATA} ${BUILD_WRKSRC}/libusearch_static_c.a ${STAGEDIR}${PREFIX}/lib/
+ ${INSTALL_DATA} ${WRKSRC}/usearch.jar ${STAGEDIR}${JAVAJARDIR}/usearch-${DISTVERSION}.jar
+ ${RLN} usearch-${DISTVERSION}.jar ${STAGEDIR}${JAVAJARDIR}/usearch.jar
+
+do-test:
+ cd ${BUILD_WRKSRC} && ./test_c
+ cd ${BUILD_WRKSRC} && ./test_cpp
+ cd ${WRKSRC} && ${JAVA} -classpath bin cloud.unum.usearch.Index
+ cd ${WRKSRC} && ${JAVA} -classpath usearch.jar cloud.unum.usearch.Index
+
+.include <bsd.port.post.mk>
diff --git a/math/usearch/distinfo b/math/usearch/distinfo
new file mode 100644
index 000000000000..abf94883adc0
--- /dev/null
+++ b/math/usearch/distinfo
@@ -0,0 +1,9 @@
+TIMESTAMP = 1771522888
+SHA256 (unum-cloud-USearch-v2.24.0_GH0.tar.gz) = 44606e88f4d49c252daea222ef0b26054e09086e43208c8d5e4914a92c838a44
+SIZE (unum-cloud-USearch-v2.24.0_GH0.tar.gz) = 473715
+SHA256 (maratyszcza-FP16-0a92994d729ff76a58f692d3028ca1b64b145d91_GH0.tar.gz) = a91f4770ff9c39f4d72e339c379f566b3bbb359fa66122d85fc0bae3dde7abc7
+SIZE (maratyszcza-FP16-0a92994d729ff76a58f692d3028ca1b64b145d91_GH0.tar.gz) = 71228
+SHA256 (ashvardanian-StringZilla-v3.12.6_GH0.tar.gz) = 1255cac3aced48b4b73e045829a80e3122c54eca5621274073839c9036f48fe8
+SIZE (ashvardanian-StringZilla-v3.12.6_GH0.tar.gz) = 264360
+SHA256 (ashvardanian-SimSIMD-v6.5.13_GH0.tar.gz) = 64316486fe09f3df9b3f36fef5c7f5cf8741d3c7c9d5413602388322d89def8e
+SIZE (ashvardanian-SimSIMD-v6.5.13_GH0.tar.gz) = 227713
diff --git a/math/usearch/files/patch-simsimd_c_lib.c b/math/usearch/files/patch-simsimd_c_lib.c
new file mode 100644
index 000000000000..38205b405e74
--- /dev/null
+++ b/math/usearch/files/patch-simsimd_c_lib.c
@@ -0,0 +1,47 @@
+--- simsimd/c/lib.c.orig 2026-02-27 20:37:49 UTC
++++ simsimd/c/lib.c
+@@ -20,34 +20,34 @@
+ * - Windows - MSVC: everything except Sapphire Rapids and ARM SVE.
+ * - macOS - Apple Clang: only Arm NEON and x86 AVX2 Haswell extensions are available.
+ */
+-#if !defined(SIMSIMD_TARGET_NEON) && (defined(__APPLE__) || defined(__linux__))
++#if !defined(SIMSIMD_TARGET_NEON) && (defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_NEON 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_SVE) && (defined(__linux__))
++#if !defined(SIMSIMD_TARGET_SVE) && (defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_SVE 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_SVE2) && (defined(__linux__))
++#if !defined(SIMSIMD_TARGET_SVE2) && (defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_SVE2 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_HASWELL) && (defined(_MSC_VER) || defined(__APPLE__) || defined(__linux__))
++#if !defined(SIMSIMD_TARGET_HASWELL) && (defined(_MSC_VER) || defined(__APPLE__) || defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_HASWELL 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_SKYLAKE) && (defined(_MSC_VER) || defined(__linux__))
++#if !defined(SIMSIMD_TARGET_SKYLAKE) && (defined(_MSC_VER) || defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_SKYLAKE 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_ICE) && (defined(_MSC_VER) || defined(__linux__))
++#if !defined(SIMSIMD_TARGET_ICE) && (defined(_MSC_VER) || defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_ICE 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_GENOA) && (defined(__linux__))
++#if !defined(SIMSIMD_TARGET_GENOA) && (defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_GENOA 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_SAPPHIRE) && (defined(__linux__))
++#if !defined(SIMSIMD_TARGET_SAPPHIRE) && (defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_SAPPHIRE 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_TURIN) && (defined(__linux__))
++#if !defined(SIMSIMD_TARGET_TURIN) && (defined(__linux__) || defined(__FreeBSD__))
+ #define SIMSIMD_TARGET_TURIN 1
+ #endif
+-#if !defined(SIMSIMD_TARGET_SIERRA) && (defined(__linux__)) && 0 // TODO: Add target spec to GCC & Clang
++#if !defined(SIMSIMD_TARGET_SIERRA) && (defined(__linux__) || defined(__FreeBSD__)) && 0 // TODO: Add target spec to GCC & Clang
+ #define SIMSIMD_TARGET_SIERRA 1
+ #endif
+
diff --git a/math/usearch/pkg-descr b/math/usearch/pkg-descr
new file mode 100644
index 000000000000..1e6fd9f95e06
--- /dev/null
+++ b/math/usearch/pkg-descr
@@ -0,0 +1,2 @@
+USearch is a fast search and cluster engine, and the industry-standard search
+backend replacing Meta's FAISS and Apache Lucene in the modern data stack.
diff --git a/math/usearch/pkg-plist b/math/usearch/pkg-plist
new file mode 100644
index 000000000000..ae3abd6d8c6a
--- /dev/null
+++ b/math/usearch/pkg-plist
@@ -0,0 +1,8 @@
+include/usearch/index.hpp
+include/usearch/index_dense.hpp
+include/usearch/index_plugins.hpp
+include/usearch/usearch.h
+lib/libusearch_c.so
+lib/libusearch_static_c.a
+%%JAVAJARDIR%%/usearch-2.24.0.jar
+%%JAVAJARDIR%%/usearch.jar