Skip to content

Commit 50c1e6e

Browse files
committed
ggml : add SSE2 detection for x86 backends
1 parent 7831b42 commit 50c1e6e

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

ggml/include/ggml-cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ extern "C" {
7575
//
7676

7777
// x86
78+
GGML_BACKEND_API int ggml_cpu_has_sse2 (void);
7879
GGML_BACKEND_API int ggml_cpu_has_sse3 (void);
7980
GGML_BACKEND_API int ggml_cpu_has_ssse3 (void);
8081
GGML_BACKEND_API int ggml_cpu_has_avx (void);

ggml/src/ggml-cpu/ggml-cpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,6 +3442,14 @@ int ggml_cpu_has_llamafile(void) {
34423442
#endif
34433443
}
34443444

3445+
int ggml_cpu_has_sse2(void) {
3446+
#if defined(__SSE2__)
3447+
return 1;
3448+
#else
3449+
return 0;
3450+
#endif
3451+
}
3452+
34453453
int ggml_cpu_has_sse3(void) {
34463454
#if defined(__SSE3__)
34473455
return 1;

ggml/src/ggml-cpu/ggml-cpu.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ static ggml_backend_feature * ggml_backend_cpu_get_features(ggml_backend_reg_t r
516516
ggml_cpu_init();
517517

518518
std::vector<ggml_backend_feature> features;
519+
if (ggml_cpu_has_sse2()) {
520+
features.push_back({ "SSE2", "1" });
521+
}
519522
if (ggml_cpu_has_sse3()) {
520523
features.push_back({ "SSE3", "1" });
521524
}

0 commit comments

Comments
 (0)