Skip to content
Open
5 changes: 3 additions & 2 deletions ggml/src/ggml-cuda/argsort.cu
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include "argsort.cuh"

#ifdef GGML_CUDA_USE_CUB
# include <cub/cub.cuh>
# include "cub-compat.cuh"
// CCCL_* are not defined for hipCUB, so these stay disabled on HIP
# if (CCCL_MAJOR_VERSION >= 3 && CCCL_MINOR_VERSION >= 1)
# define STRIDED_ITERATOR_AVAILABLE
# include <cuda/iterator>
# endif
# endif // CCCL_MAJOR_VERSION >= 3 && CCCL_MINOR_VERSION >= 1
using namespace cub;
#endif // GGML_CUDA_USE_CUB

Expand Down
4 changes: 2 additions & 2 deletions ggml/src/ggml-cuda/common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
#define GGML_CUDA_CC_IS_QY2(cc) (cc >= GGML_CUDA_CC_QY2 && cc < GGML_CUDA_CC_PH1)
#define GGML_CUDA_CC_IS_PH1(cc) (cc >= GGML_CUDA_CC_PH1)

#if !defined(GGML_USE_HIP) && !defined(GGML_USE_MUSA) && CUDART_VERSION >= 11070
#if !defined(GGML_USE_MUSA) && (defined(GGML_USE_HIP) || CUDART_VERSION >= 11070)
# define GGML_CUDA_USE_CUB
#endif // !defined(GGML_USE_HIP) && !defined(GGML_USE_MUSA) && CUDART_VERSION >= 11070
#endif// !defined(GGML_USE_MUSA) && (defined(GGML_USE_HIP) || CUDART_VERSION >= 11070)

// PDL host-side support (cudaLaunchKernelEx) requires CUDART >= 11.8.
// However, this has been bugged in CTK < 12.3 for MSVC builds, see
Expand Down
7 changes: 7 additions & 0 deletions ggml/src/ggml-cuda/cub-compat.cuh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#if defined(GGML_USE_HIP)
# include <hipcub/hipcub.hpp>
namespace cub = hipcub;
#else
# include <cub/cub.cuh>
#endif
Comment thread
Geramy marked this conversation as resolved.
Outdated
2 changes: 1 addition & 1 deletion ggml/src/ggml-cuda/cumsum.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "ggml.h"

#ifdef GGML_CUDA_USE_CUB
# include <cub/cub.cuh>
# include "cub-compat.cuh"
#endif // GGML_CUDA_USE_CUB

template<typename T, int BLOCK_SIZE>
Expand Down
2 changes: 1 addition & 1 deletion ggml/src/ggml-cuda/mean.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "reduce_rows.cuh"

#ifdef GGML_CUDA_USE_CUB
#include <cub/cub.cuh>
#include "cub-compat.cuh"
using namespace cub;
#endif // GGML_CUDA_USE_CUB

Expand Down
2 changes: 1 addition & 1 deletion ggml/src/ggml-cuda/ssm-scan.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#endif // !defined(GGML_USE_HIP) && !defined(GGML_USE_MUSA) && CUDART_VERSION >= 11070

#ifdef USE_CUB
#include <cub/cub.cuh>
#include "cub-compat.cuh"
using namespace cub;
#endif // USE_CUB
Comment thread
Geramy marked this conversation as resolved.
Outdated

Expand Down
2 changes: 1 addition & 1 deletion ggml/src/ggml-cuda/sum.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "sumrows.cuh"

#ifdef GGML_CUDA_USE_CUB
#include <cub/cub.cuh>
#include "cub-compat.cuh"
using namespace cub;
#endif // GGML_CUDA_USE_CUB

Expand Down
3 changes: 2 additions & 1 deletion ggml/src/ggml-cuda/top-k.cu
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include "top-k.cuh"

#ifdef GGML_CUDA_USE_CUB
# include <cub/cub.cuh>
# include "cub-compat.cuh"
// hipCUB has no DeviceTopK and does not define CCCL_*, so this stays disabled on HIP
# if (CCCL_MAJOR_VERSION >= 3 && CCCL_MINOR_VERSION >= 2)
# define CUB_TOP_K_AVAILABLE
# include <cuda/iterator>
Expand Down
3 changes: 3 additions & 0 deletions ggml/src/ggml-cuda/vendors/hip.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
#define cudaStreamPerThread hipStreamPerThread
#define cudaStreamSynchronize hipStreamSynchronize
#define cudaStreamWaitEvent hipStreamWaitEvent
#define cudaStreamIsCapturing hipStreamIsCapturing
#define cudaStreamCaptureStatus hipStreamCaptureStatus
#define cudaStreamCaptureStatusNone hipStreamCaptureStatusNone
Comment thread
Geramy marked this conversation as resolved.
Outdated
#define cudaGraphExec_t hipGraphExec_t
#define cudaGraphNode_t hipGraphNode_t
#define cudaKernelNodeParams hipKernelNodeParams
Expand Down
Loading