Skip to content

Commit 6e1c90f

Browse files
committed
Rename check_compatibility to check_avx512_compatibility
1 parent e25e916 commit 6e1c90f

5 files changed

Lines changed: 22 additions & 19 deletions

File tree

jvector-native/src/main/c/jvector_simd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ __m512i maskEighthBit;
2626

2727
__attribute__((constructor))
2828
void initialize_constants() {
29-
if (check_compatibility()) {
29+
if (check_avx512_compatibility()) {
3030
initialIndexRegister = _mm512_setr_epi32(-16, -15, -14, -13, -12, -11, -10, -9,
3131
-8, -7, -6, -5, -4, -3, -2, -1);
3232
indexIncrement = _mm512_set1_epi32(16);

jvector-native/src/main/c/jvector_simd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define VECTOR_SIMD_DOT_H
2121

2222
// check CPU support
23-
bool check_compatibility(void);
23+
bool check_avx512_compatibility(void);
2424

2525
//F32
2626
float dot_product_f32(int preferred_size, const float* a, int aoffset, const float* b, int boffset, int length);

jvector-native/src/main/c/jvector_simd_check.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
#include <cpuid.h>
1818
#include "jvector_simd.h"
1919

20-
bool check_compatibility(void) {
20+
bool check_avx512_compatibility(void) {
21+
/* __builtin_cpu_init required when this is used in ifunc
22+
resolver/__attribute__((constructor)) context, otherwise the CPU
23+
features may not be detected correctly. */
2124
__builtin_cpu_init();
2225
return (__builtin_cpu_supports("avx512f") &&
2326
__builtin_cpu_supports("avx512cd") &&

jvector-native/src/main/java/io/github/jbellis/jvector/vector/NativeVectorizationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public NativeVectorizationProvider() {
3535
if (!libraryLoaded) {
3636
throw new UnsupportedOperationException("Failed to load supporting native library.");
3737
}
38-
if (!NativeSimdOps.check_compatibility()) {
38+
if (!NativeSimdOps.check_avx512_compatibility()) {
3939
throw new UnsupportedOperationException("Native SIMD operations are not supported on this platform due to missing CPU support.");
4040
}
4141
this.vectorUtilSupport = new NativeVectorUtilSupport();

jvector-native/src/main/java/io/github/jbellis/jvector/vector/cnative/NativeSimdOps.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -96,55 +96,55 @@ public static int __bool_true_false_are_defined() {
9696
return __bool_true_false_are_defined;
9797
}
9898

99-
private static class check_compatibility {
99+
private static class check_avx512_compatibility {
100100
public static final FunctionDescriptor DESC = FunctionDescriptor.of(
101101
NativeSimdOps.C_BOOL );
102102

103-
public static final MemorySegment ADDR = NativeSimdOps.findOrThrow("check_compatibility");
103+
public static final MemorySegment ADDR = NativeSimdOps.findOrThrow("check_avx512_compatibility");
104104

105105
public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC, Linker.Option.critical(true));
106106
}
107107

108108
/**
109109
* Function descriptor for:
110110
* {@snippet lang=c :
111-
* _Bool check_compatibility()
111+
* _Bool check_avx512_compatibility()
112112
* }
113113
*/
114-
public static FunctionDescriptor check_compatibility$descriptor() {
115-
return check_compatibility.DESC;
114+
public static FunctionDescriptor check_avx512_compatibility$descriptor() {
115+
return check_avx512_compatibility.DESC;
116116
}
117117

118118
/**
119119
* Downcall method handle for:
120120
* {@snippet lang=c :
121-
* _Bool check_compatibility()
121+
* _Bool check_avx512_compatibility()
122122
* }
123123
*/
124-
public static MethodHandle check_compatibility$handle() {
125-
return check_compatibility.HANDLE;
124+
public static MethodHandle check_avx512_compatibility$handle() {
125+
return check_avx512_compatibility.HANDLE;
126126
}
127127

128128
/**
129129
* Address for:
130130
* {@snippet lang=c :
131-
* _Bool check_compatibility()
131+
* _Bool check_avx512_compatibility()
132132
* }
133133
*/
134-
public static MemorySegment check_compatibility$address() {
135-
return check_compatibility.ADDR;
134+
public static MemorySegment check_avx512_compatibility$address() {
135+
return check_avx512_compatibility.ADDR;
136136
}
137137

138138
/**
139139
* {@snippet lang=c :
140-
* _Bool check_compatibility()
140+
* _Bool check_avx512_compatibility()
141141
* }
142142
*/
143-
public static boolean check_compatibility() {
144-
var mh$ = check_compatibility.HANDLE;
143+
public static boolean check_avx512_compatibility() {
144+
var mh$ = check_avx512_compatibility.HANDLE;
145145
try {
146146
if (TRACE_DOWNCALLS) {
147-
traceDowncall("check_compatibility");
147+
traceDowncall("check_avx512_compatibility");
148148
}
149149
return (boolean)mh$.invokeExact();
150150
} catch (Throwable ex$) {

0 commit comments

Comments
 (0)