From: Georgi Gerganov Date: Thu, 13 Apr 2023 12:40:33 +0000 (+0300) Subject: ggml : add GGML_DEFAULT_N_THREADS X-Git-Tag: upstream/0.0.1642~1552 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=216b172a2b2b04012f683b55f6d3a561970c3df2;p=pkg%2Fggml%2Fsources%2Fggml ggml : add GGML_DEFAULT_N_THREADS --- diff --git a/include/ggml/ggml.h b/include/ggml/ggml.h index a5245a8a..49024733 100644 --- a/include/ggml/ggml.h +++ b/include/ggml/ggml.h @@ -177,11 +177,12 @@ extern "C" { #include #include -#define GGML_MAX_DIMS 4 -#define GGML_MAX_NODES 4096 -#define GGML_MAX_PARAMS 16 -#define GGML_MAX_CONTEXTS 64 -#define GGML_MAX_OPT 4 +#define GGML_MAX_DIMS 4 +#define GGML_MAX_NODES 4096 +#define GGML_MAX_PARAMS 16 +#define GGML_MAX_CONTEXTS 64 +#define GGML_MAX_OPT 4 +#define GGML_DEFAULT_N_THREADS 4 #ifdef __ARM_NEON // we use the built-in 16-bit float type diff --git a/src/ggml.c b/src/ggml.c index ada3bbbd..b1b3dc60 100644 --- a/src/ggml.c +++ b/src/ggml.c @@ -9274,7 +9274,7 @@ struct ggml_cgraph ggml_build_forward(struct ggml_tensor * tensor) { struct ggml_cgraph result = { /*.n_nodes =*/ 0, /*.n_leafs =*/ 0, - /*.n_threads =*/ 0, + /*.n_threads =*/ GGML_DEFAULT_N_THREADS, /*.work_size =*/ 0, /*.work =*/ NULL, /*.nodes =*/ { NULL }, @@ -9894,8 +9894,8 @@ void ggml_graph_print(const struct ggml_cgraph * cgraph) { GGML_PRINT("=== GRAPH ===\n"); - GGML_PRINT_DEBUG("n_threads = %d\n", cgraph->n_threads); - GGML_PRINT_DEBUG("total work size = %zu bytes\n",cgraph->work_size); + GGML_PRINT_DEBUG("n_threads = %d\n", cgraph->n_threads); + GGML_PRINT_DEBUG("total work size = %zu bytes\n", cgraph->work_size); GGML_PRINT("n_nodes = %d\n", cgraph->n_nodes); for (int i = 0; i < cgraph->n_nodes; i++) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 69983a0f..4e7efccd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -190,7 +190,7 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT GGML_NO_ACCELERATE) add_executable(${TEST_TARGET} ${TEST_TARGET}.c) target_link_libraries(${TEST_TARGET} PRIVATE ggml ${GGML_EXTRA_LIBS}) target_compile_options(${TEST_TARGET} PRIVATE ${GGML_EXTRA_FLAGS}) - add_test(NAME ${TEST_TARGET} COMMAND $) + add_test(NAME ${TEST_TARGET} COMMAND $ 128 128 128) endif() #