]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
riscv : modify Makefile and add a RISCV_VECT to print log info (#9442)
authorAhmad Tameem <redacted>
Thu, 12 Sep 2024 11:24:31 +0000 (16:24 +0500)
committerGitHub <redacted>
Thu, 12 Sep 2024 11:24:31 +0000 (14:24 +0300)
- Added ggml_cpu_has_riscv_v() in GGML to print system info in log
- Modified Makefile to only use flag when cross compiling for RISC-V

Makefile
common/common.cpp
ggml/include/ggml.h
ggml/src/ggml.c
src/llama.cpp

index c12bc61f4a095f2cd4bc351720ebe1eaaf1a90bc..8d3fd3ee83f61b2a95a376fc6650d6cd586dd6ba 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -434,7 +434,7 @@ endif
 # TODO: probably these flags need to be tweaked on some architectures
 #       feel free to update the Makefile for your architecture and send a pull request or issue
 
-ifndef RISCV
+ifndef RISCV_CROSS_COMPILE
 
 ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686 amd64))
        # Use all CPU extensions that are available:
@@ -514,7 +514,12 @@ ifneq ($(filter loongarch64%,$(UNAME_M)),)
        MK_CXXFLAGS += -mlasx
 endif
 
-else
+ifneq ($(filter riscv64%,$(UNAME_M)),)
+       MK_CFLAGS   += -march=rv64gcv -mabi=lp64d
+       MK_CXXFLAGS += -march=rv64gcv -mabi=lp64d
+endif
+
+else # RISC-V CROSS COMPILATION
        MK_CFLAGS   += -march=rv64gcv -mabi=lp64d
        MK_CXXFLAGS += -march=rv64gcv -mabi=lp64d
 endif
index 30c6e84c795f71d7b2e8bcd11c14c2773bffd018..c492ae0cc66d0e516205701cb33f51bea50ed5ad 100644 (file)
@@ -1828,6 +1828,7 @@ void yaml_dump_non_result_info(FILE * stream, const gpt_params & params, const l
     fprintf(stream, "cpu_has_sve: %s\n",         ggml_cpu_has_sve()         ? "true" : "false");
     fprintf(stream, "cpu_has_f16c: %s\n",        ggml_cpu_has_f16c()        ? "true" : "false");
     fprintf(stream, "cpu_has_fp16_va: %s\n",     ggml_cpu_has_fp16_va()     ? "true" : "false");
+    fprintf(stream, "cpu_has_riscv_v: %s\n",     ggml_cpu_has_riscv_v()     ? "true" : "false");
     fprintf(stream, "cpu_has_wasm_simd: %s\n",   ggml_cpu_has_wasm_simd()   ? "true" : "false");
     fprintf(stream, "cpu_has_blas: %s\n",        ggml_cpu_has_blas()        ? "true" : "false");
     fprintf(stream, "cpu_has_sse3: %s\n",        ggml_cpu_has_sse3()        ? "true" : "false");
index 86ad6fb6224d5113b8e9a38ddf50fdefcaf86617..13026ab32e663d7ba5a9c5ebe503768a164874d3 100644 (file)
@@ -2470,6 +2470,7 @@ extern "C" {
     GGML_API int ggml_cpu_has_gpublas    (void);
     GGML_API int ggml_cpu_has_sse3       (void);
     GGML_API int ggml_cpu_has_ssse3      (void);
+    GGML_API int ggml_cpu_has_riscv_v    (void);
     GGML_API int ggml_cpu_has_sycl       (void);
     GGML_API int ggml_cpu_has_rpc        (void);
     GGML_API int ggml_cpu_has_vsx        (void);
index 47417c02413dba5c2a78cc7842c9be788553dbea..493ff7fc072db60c83a0e5b7cd243d918df77287 100644 (file)
@@ -23288,6 +23288,14 @@ int ggml_cpu_has_arm_fma(void) {
 #endif
 }
 
+int ggml_cpu_has_riscv_v(void) {
+#if defined(__riscv_v_intrinsic)
+    return 1;
+#else
+    return 0;
+#endif
+}
+
 int ggml_cpu_has_metal(void) {
 #if defined(GGML_USE_METAL)
     return 1;
index 0f80b2402728e1898e10a04ae34e1b3c671b46ac..acda9e235c04050e41286a8150ba11171c5f5a6c 100644 (file)
@@ -20672,6 +20672,7 @@ const char * llama_print_system_info(void) {
     s += "ARM_FMA = "     + std::to_string(ggml_cpu_has_arm_fma())     + " | ";
     s += "F16C = "        + std::to_string(ggml_cpu_has_f16c())        + " | ";
     s += "FP16_VA = "     + std::to_string(ggml_cpu_has_fp16_va())     + " | ";
+    s += "RISCV_VECT = "  + std::to_string(ggml_cpu_has_riscv_v())     + " | ";
     s += "WASM_SIMD = "   + std::to_string(ggml_cpu_has_wasm_simd())   + " | ";
     s += "BLAS = "        + std::to_string(ggml_cpu_has_blas())        + " | ";
     s += "SSE3 = "        + std::to_string(ggml_cpu_has_sse3())        + " | ";