]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
ggml : add system info functions
authorGeorgi Gerganov <redacted>
Tue, 25 Oct 2022 17:18:26 +0000 (20:18 +0300)
committerGeorgi Gerganov <redacted>
Tue, 25 Oct 2022 17:53:48 +0000 (20:53 +0300)
examples/bench/bench.cpp
ggml.c
ggml.h
whisper.cpp
whisper.h

index 60180c19f85a5c78ef8fa817f2932b31054982a1..a9fdc819148af96ba24ce442703a5dd304b128eb 100644 (file)
@@ -74,5 +74,20 @@ int main(int argc, char ** argv) {
     whisper_print_timings(ctx);
     whisper_free(ctx);
 
+    fprintf(stderr, "\n");
+    fprintf(stderr, "system_info: n_threads = %d | %s\n", params.n_threads, whisper_print_system_info());
+
+    fprintf(stderr, "\n");
+    fprintf(stderr, "If you wish, you can submit these results here:\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, "  https://github.com/ggerganov/whisper.cpp/issues/89\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, "Please include the following information:\n");
+    fprintf(stderr, "\n");
+    fprintf(stderr, "  - CPU model\n");
+    fprintf(stderr, "  - Operating system\n");
+    fprintf(stderr, "  - Compiler\n");
+    fprintf(stderr, "\n");
+
     return 0;
 }
diff --git a/ggml.c b/ggml.c
index 314434b77994c8df5991beaa6641c43f7ae0d0ed..3a368021752fb0223680bfaa174fc81f7e67254e 100644 (file)
--- a/ggml.c
+++ b/ggml.c
@@ -8032,3 +8032,53 @@ enum ggml_opt_result ggml_opt(
 }
 
 ////////////////////////////////////////////////////////////////////////////////
+
+int ggml_cpu_has_avx2(void) {
+#if defined(__AVX2__)
+    return 1;
+#else
+    return 0;
+#endif
+}
+
+int ggml_cpu_has_avx512(void) {
+#if defined(__AVX512F__)
+    return 1;
+#else
+    return 0;
+#endif
+}
+
+int ggml_cpu_has_neon(void) {
+#if defined(__ARM_NEON__)
+    return 1;
+#else
+    return 0;
+#endif
+}
+
+int ggml_cpu_has_fp16_va(void) {
+#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
+    return 1;
+#else
+    return 0;
+#endif
+}
+
+int ggml_cpu_has_wasm_simd(void) {
+#if defined(__wasm_simd128__)
+    return 1;
+#else
+    return 0;
+#endif
+}
+
+int ggml_cpu_has_blas(void) {
+#if defined(GGML_USE_BLAS) || defined(GGML_USE_ACCELERATE)
+    return 1;
+#else
+    return 0;
+#endif
+}
+
+////////////////////////////////////////////////////////////////////////////////
diff --git a/ggml.h b/ggml.h
index 34f104b70c26daffd9b7f6988d6d1f5929d27712..f81fbc5ee8eea1ad18fc851570e431479e4117ee 100644 (file)
--- a/ggml.h
+++ b/ggml.h
@@ -548,6 +548,17 @@ enum ggml_opt_result ggml_opt(
         struct ggml_opt_params params,
         struct ggml_tensor * f);
 
+//
+// system info
+//
+
+int ggml_cpu_has_avx2(void);
+int ggml_cpu_has_avx512(void);
+int ggml_cpu_has_neon(void);
+int ggml_cpu_has_fp16_va(void);
+int ggml_cpu_has_wasm_simd(void);
+int ggml_cpu_has_blas(void);
+
 #ifdef  __cplusplus
 }
 #endif
index 0634bc254645510a06d5a2bc46c5c9abfa73be97..3bbf1c465b818efa02bb1e47fcb70fa56ea7d097 100644 (file)
@@ -2628,3 +2628,17 @@ whisper_token whisper_full_get_token_id(struct whisper_context * ctx, int i_segm
 float whisper_full_get_token_p(struct whisper_context * ctx, int i_segment, int i_token) {
     return ctx->result_all[i_segment].tokens[i_token].p;
 }
+
+const char * whisper_print_system_info() {
+    static std::string s;
+
+    s  = "";
+    s += "AVX2 = "      + std::to_string(ggml_cpu_has_avx2())      + " | ";
+    s += "AVX512 = "    + std::to_string(ggml_cpu_has_avx512())    + " | ";
+    s += "NEON = "      + std::to_string(ggml_cpu_has_neon())      + " | ";
+    s += "FP16_VA = "   + std::to_string(ggml_cpu_has_fp16_va())   + " | ";
+    s += "WASM_SIMD = " + std::to_string(ggml_cpu_has_wasm_simd()) + " | ";
+    s += "BLAS = "      + std::to_string(ggml_cpu_has_blas())      + " | ";
+
+    return s.c_str();
+}
index 53b0041055a3013bf6ed8939dcfa8cd63ba107c1..541424881888cfb9df53ea4a4d8f0205afe80690 100644 (file)
--- a/whisper.h
+++ b/whisper.h
@@ -225,6 +225,9 @@ extern "C" {
     // Get the probability of the specified token in the specified segment.
     WHISPER_API float whisper_full_get_token_p(struct whisper_context * ctx, int i_segment, int i_token);
 
+    // Print system information
+    WHISPER_API const char * whisper_print_system_info();
+
 #ifdef __cplusplus
 }
 #endif