Skip to content

Commit 86df2c9

Browse files
authored
vulkan: use a more appropriate amount of threads when generating shaders (#16418)
* use a more flexible amount of threads * fix windows compile and 0 thread case * nominmax
1 parent f392839 commit 86df2c9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
#include <iostream>
42
#include <fstream>
53
#include <sstream>
@@ -22,6 +20,7 @@
2220
#include <sys/types.h>
2321

2422
#ifdef _WIN32
23+
#define NOMINMAX
2524
#include <windows.h>
2625
#include <direct.h> // For _mkdir on Windows
2726
#else
@@ -306,7 +305,7 @@ using compile_count_guard = std::unique_ptr<uint32_t, decltype(&decrement_compil
306305
compile_count_guard acquire_compile_slot() {
307306
// wait until fewer than N compiles are in progress.
308307
// 16 is an arbitrary limit, the goal is to avoid "failed to create pipe" errors.
309-
uint32_t N = 16;
308+
uint32_t N = std::max(1u, std::min(16u, std::thread::hardware_concurrency()));
310309
std::unique_lock<std::mutex> guard(compile_count_mutex);
311310
compile_count_cond.wait(guard, [N] { return compile_count < N; });
312311
compile_count++;

0 commit comments

Comments
 (0)