From 3d816cd18d1f962c84c8988a316938530b57c1d3 Mon Sep 17 00:00:00 2001 From: claude Date: Fri, 14 Aug 2026 11:11:15 +0000 Subject: [PATCH] fix: add ceil_div + DEVICE_INLINE to device_utils.cuh ceil_div was in xllm utils.h (removed for glog). DEVICE_INLINE macro also moved to shared header. --- ex_engine/xllm_kernels/cuda/block_copy.cu | 4 ---- .../xllm_kernels/cuda/headers/device_utils.cuh | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ex_engine/xllm_kernels/cuda/block_copy.cu b/ex_engine/xllm_kernels/cuda/block_copy.cu index 23ef742b..d92e7b3e 100644 --- a/ex_engine/xllm_kernels/cuda/block_copy.cu +++ b/ex_engine/xllm_kernels/cuda/block_copy.cu @@ -25,10 +25,6 @@ limitations under the License. #include "device_utils.cuh" -#ifndef DEVICE_INLINE -#define DEVICE_INLINE __device__ __forceinline__ -#define HOST_DEVICE_INLINE __host__ __device__ __forceinline__ -#endif namespace xllm::kernel::cuda { diff --git a/ex_engine/xllm_kernels/cuda/headers/device_utils.cuh b/ex_engine/xllm_kernels/cuda/headers/device_utils.cuh index d14a6cb5..7115fcfc 100644 --- a/ex_engine/xllm_kernels/cuda/headers/device_utils.cuh +++ b/ex_engine/xllm_kernels/cuda/headers/device_utils.cuh @@ -115,6 +115,20 @@ struct TopkConstants { } // namespace xllm::kernel::cuda +// ============================================================================ +// Portable macros and utilities (from xllm/core/kernels/cuda/utils.h) +// ============================================================================ +#ifndef DEVICE_INLINE +#define DEVICE_INLINE __device__ __forceinline__ +#define HOST_DEVICE_INLINE __host__ __device__ __forceinline__ +#endif + +template +HOST_DEVICE_INLINE constexpr std::enable_if_t, T> +ceil_div(T a, T b) { + return (a + b - 1) / b; +} + // ============================================================================ // Dispatch macros (from xllm/core/kernels/cuda/utils.h) // These wrap AT_DISPATCH_SWITCH for float16/bfloat16/float32 dispatch.