mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-10-31 08:51:55 +00:00 
			
		
		
		
	llama : update logic for number of threads when using BLAS
This commit is contained in:
		| @@ -2942,7 +2942,12 @@ static bool llama_eval_internal( | |||||||
|  |  | ||||||
|     // for big prompts, if BLAS is enabled, it is better to use only one thread |     // for big prompts, if BLAS is enabled, it is better to use only one thread | ||||||
|     // otherwise, the threads are spin-lock waiting for the BLAS calls and are degrading the performance |     // otherwise, the threads are spin-lock waiting for the BLAS calls and are degrading the performance | ||||||
|     n_threads = N >= 32 && ggml_cpu_has_blas() && !ggml_cpu_has_gpublas() ? 1 : n_threads; |     // TODO: this is mostly important for Apple Silicon where CBLAS is still performing very well | ||||||
|  |     //       we still need some threads to process all non-mul_mat ops, but not too much to avoid interfering | ||||||
|  |     //       with the BLAS calls. need a better solution | ||||||
|  |     if (N >= 32 && ggml_cpu_has_blas() && !ggml_cpu_has_gpublas()) { | ||||||
|  |         n_threads = std::min(4, n_threads); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     struct ggml_tensor * res        = gf->nodes[gf->n_nodes - 1]; |     struct ggml_tensor * res        = gf->nodes[gf->n_nodes - 1]; | ||||||
|     struct ggml_tensor * embeddings = gf->nodes[gf->n_nodes - 2]; |     struct ggml_tensor * embeddings = gf->nodes[gf->n_nodes - 2]; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Georgi Gerganov
					Georgi Gerganov