Skip to content

Commit 86961ef

Browse files
authored
vulkan: fix 32-bit integer overflow in CEIL_DIV (ggml-org#25245)
1 parent d80e878 commit 86961ef

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ typedef struct VkPhysicalDeviceShaderMixedFloatDotProductFeaturesVALVE {
129129
#endif
130130

131131
#define ROUNDUP_POW2(M, N) (((M) + (N) - 1) & ~((N) - 1))
132-
#define CEIL_DIV(M, N) (((M) + (N)-1) / (N))
132+
#define CEIL_DIV(M, N) (((M) / (N)) + (((M) % (N)) != 0))
133133
static bool is_pow2(uint32_t x) { return x > 1 && (x & (x-1)) == 0; }
134134

135135
#define VK_VENDOR_ID_AMD 0x1002

0 commit comments

Comments
 (0)