Skip to content

Commit f4fefe4

Browse files
authored
Fix building for CUDA 11.6 (#917)
* Fix building for CUDA 11.6 * Minor fixes.
1 parent 43ed450 commit f4fefe4

File tree

2 files changed

+5
-42
lines changed

2 files changed

+5
-42
lines changed

k2/csrc/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ add_library(context ${context_srcs})
9292
target_compile_definitions(context PUBLIC K2_TORCH_VERSION_MAJOR=${K2_TORCH_VERSION_MAJOR})
9393
target_compile_definitions(context PUBLIC K2_TORCH_VERSION_MINOR=${K2_TORCH_VERSION_MINOR})
9494

95+
# see https://github.com/NVIDIA/thrust/issues/1401
96+
# and https://github.com/k2-fsa/k2/pull/917
97+
target_compile_definitions(context PUBLIC CUB_WRAPPED_NAMESPACE=k2)
98+
target_compile_definitions(context PUBLIC THRUST_NS_QUALIFIER=thrust)
99+
95100
set_target_properties(context PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
96101
set_target_properties(context PROPERTIES OUTPUT_NAME "k2context")
97102

k2/csrc/cub.h

-42
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,8 @@
2020
#ifndef K2_CSRC_CUB_H_
2121
#define K2_CSRC_CUB_H_
2222

23-
// See
24-
// https://github.com/k2-fsa/k2/issues/698
25-
// and
26-
// https://github.com/pytorch/pytorch/issues/54245#issuecomment-805707551
27-
// for why we need the following two macros
28-
//
29-
// NOTE: We define the following two macros so
30-
// that k2 and PyTorch use a different copy
31-
// of CUB.
32-
33-
#ifdef CUB_NS_PREFIX
34-
#undef CUB_NS_PREFIX
35-
#endif
36-
37-
#ifdef CUB_NS_POSTFIX
38-
#undef CUB_NS_POSTFIX
39-
#endif
40-
41-
#ifdef CUB_NS_QUALIFIER
42-
#undef CUB_NS_QUALIFIER
43-
#endif
44-
45-
// see
46-
// https://github.com/NVIDIA/cub/commit/6631c72630f10e370d93814a59146b12f7620d85
47-
// The above commit replaced "thrust" with "THRUST_NS_QUALIFIER"
48-
#ifndef THRUST_NS_QUALIFIER
49-
#define THRUST_NS_QUALIFIER thrust
50-
#endif
51-
52-
#define CUB_NS_PREFIX namespace k2 {
53-
#define CUB_NS_POSTFIX }
54-
55-
// See
56-
// https://github.com/NVIDIA/cub/commit/6631c72630f10e370d93814a59146b12f7620d85
57-
// and
58-
// https://github.com/NVIDIA/cub/pull/350
59-
#define CUB_NS_QUALIFIER ::k2::cub
60-
6123
#ifdef K2_WITH_CUDA
6224
#include "cub/cub.cuh" // NOLINT
6325
#endif
6426

65-
#undef CUB_NS_PREFIX
66-
#undef CUB_NS_POSTFIX
67-
#undef CUB_NS_QUALIFIER
68-
6927
#endif // K2_CSRC_CUB_H_

0 commit comments

Comments
 (0)