CH-Abhinav commented on code in PR #16723:
URL: https://github.com/apache/lucene/pull/16723#discussion_r4356683173
##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/codecs/faiss/FaissNativeWrapper.java:
##########
@@ -37,8 +39,63 @@
*/
@SuppressWarnings("restricted") // uses unsafe calls
final class FaissNativeWrapper {
- static {
- System.loadLibrary(FaissLibrary.NAME);
+
+ static final String LOADED_LIBRARY = loadLibrary();
+ private static final Logger LOG =
Logger.getLogger(FaissNativeWrapper.class.getName());
+
+ private static String loadLibrary() {
+ // Manual override via system property
+ String customLib = System.getProperty("lucene.faiss.libname");
+ if (customLib != null && customLib.isBlank() == false) {
+ System.loadLibrary(customLib);
+ return customLib;
+ }
+
+ // Try SIMD variants matching the CPU architecture
+ switch (Constants.OS_ARCH) {
+ case "amd64", "x86_64" -> {
+ if (Constants.HAS_AVX512) {
+ if (tryLoad("faiss_c_avx512")) {
+ return "faiss_c_avx512";
+ }
+ if (tryLoad("faiss_c_avx2")) {
+ LOG.warning(
+ "CPU supports AVX-512, but 'faiss_c_avx512' was not found;
falling back to 'faiss_c_avx2'.");
+ return "faiss_c_avx2";
+ }
+ LOG.warning(
+ "CPU supports AVX-512, but neither 'faiss_c_avx512' nor
'faiss_c_avx2' was found; falling back to generic 'faiss_c'.");
Review Comment:
This warning is intentional. It is just saying your CPU is avx512 but SIMD
faiss is not available so we will see if you have `faiss_c`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]