diff --git a/examples/bench/bench.cpp b/examples/bench/bench.cpp index 60180c1..a9fdc81 100644 --- a/examples/bench/bench.cpp +++ b/examples/bench/bench.cpp @@ -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 314434b..3a36802 100644 --- 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 34f104b..f81fbc5 100644 --- 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 diff --git a/whisper.cpp b/whisper.cpp index 0634bc2..3bbf1c4 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -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(); +} diff --git a/whisper.h b/whisper.h index 53b0041..5414248 100644 --- 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