Skip to content

Commit cf1305b

Browse files
committed
Fix c10 sync
1 parent 32068ad commit cf1305b

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

runtime/core/portable_type/c10/c10/util/llvmMathExtras.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ enum ZeroBehavior {
7070
namespace detail {
7171
template <typename T, std::size_t SizeOfT>
7272
struct TrailingZerosCounter {
73-
static std::size_t count(T Val, ZeroBehavior) {
73+
static std::size_t count(T Val, ZeroBehavior /*unused*/) {
7474
if (!Val)
7575
return std::numeric_limits<T>::digits;
7676
if (Val & 0x1)
@@ -147,7 +147,7 @@ std::size_t countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
147147
namespace detail {
148148
template <typename T, std::size_t SizeOfT>
149149
struct LeadingZerosCounter {
150-
static std::size_t count(T Val, ZeroBehavior) {
150+
static std::size_t count(T Val, ZeroBehavior /*unused*/) {
151151
if (!Val)
152152
return std::numeric_limits<T>::digits;
153153

runtime/core/portable_type/c10/torch/headeronly/macros/Macros.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ static inline int C10_WARP_SIZE_INTERNAL() {
359359
// Those platforms do not support assert()
360360
#define CUDA_KERNEL_ASSERT(cond)
361361
#define CUDA_KERNEL_ASSERT_MSG(cond, msg)
362+
#define CUDA_KERNEL_ASSERT_PRINTF(cond, msg, ...)
362363
#define SYCL_KERNEL_ASSERT(cond)
363364
#elif defined(_MSC_VER)
364365
#if defined(NDEBUG)
@@ -396,6 +397,26 @@ __host__ __device__
396397
static_cast<unsigned>(__LINE__)), \
397398
0); \
398399
}
400+
#define CUDA_KERNEL_ASSERT_PRINTF(cond, msg, ...) \
401+
if (C10_UNLIKELY(!(cond))) { \
402+
(void)(printf( \
403+
"[CUDA_KERNEL_ASSERT] " __FILE__ ":" C10_STRINGIZE( \
404+
__LINE__) ": %s: block: [%d,%d,%d], thread: [%d,%d,%d]: " \
405+
"Assertion failed: `" #cond "`: " msg "\n", \
406+
__func__, \
407+
blockIdx.x, \
408+
blockIdx.y, \
409+
blockIdx.z, \
410+
threadIdx.x, \
411+
threadIdx.y, \
412+
threadIdx.z, \
413+
##__VA_ARGS__)); \
414+
(void)(_wassert( \
415+
_CRT_WIDE(#cond), \
416+
_CRT_WIDE(__FILE__), \
417+
static_cast<unsigned>(__LINE__)), \
418+
0); \
419+
}
399420
#define SYCL_KERNEL_ASSERT(cond) \
400421
if (C10_UNLIKELY(!(cond))) { \
401422
(void)(_wassert( \
@@ -455,6 +476,10 @@ __host__ __device__
455476
if C10_UNLIKELY (!(cond)) { \
456477
abort(); \
457478
}
479+
#define CUDA_KERNEL_ASSERT_PRINTF(cond, msg, ...) \
480+
if C10_UNLIKELY (!(cond)) { \
481+
abort(); \
482+
}
458483
#define SYCL_KERNEL_ASSERT(cond) \
459484
if C10_UNLIKELY (!(cond)) { \
460485
abort(); \
@@ -470,6 +495,23 @@ __host__ __device__
470495
__assert_fail( \
471496
msg, __FILE__, static_cast<unsigned int>(__LINE__), __func__); \
472497
}
498+
#define CUDA_KERNEL_ASSERT_PRINTF(cond, msg, ...) \
499+
if (C10_UNLIKELY(!(cond))) { \
500+
printf( \
501+
"[CUDA_KERNEL_ASSERT] " __FILE__ ":" C10_STRINGIZE( \
502+
__LINE__) ": %s: block: [%d,%d,%d], thread: [%d,%d,%d]: " \
503+
"Assertion failed: `" #cond "`: " msg "\n", \
504+
__func__, \
505+
blockIdx.x, \
506+
blockIdx.y, \
507+
blockIdx.z, \
508+
threadIdx.x, \
509+
threadIdx.y, \
510+
threadIdx.z, \
511+
##__VA_ARGS__); \
512+
__assert_fail( \
513+
#cond, __FILE__, static_cast<unsigned int>(__LINE__), __func__); \
514+
}
473515
#define SYCL_KERNEL_ASSERT(cond) \
474516
if (C10_UNLIKELY(!(cond))) { \
475517
__assert_fail( \

runtime/core/portable_type/c10/torch/headeronly/util/BFloat16.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ struct alignas(2) BFloat16 {
3939
return from_bits_t();
4040
}
4141

42-
constexpr C10_HOST_DEVICE BFloat16(unsigned short bits, from_bits_t)
42+
constexpr C10_HOST_DEVICE BFloat16(
43+
unsigned short bits,
44+
from_bits_t /*unused*/)
4345
: x(bits) {}
4446
/* implicit */ inline C10_HOST_DEVICE BFloat16(float value);
4547
inline C10_HOST_DEVICE operator float() const;

runtime/core/portable_type/c10/torch/headeronly/util/Half.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ struct alignas(2) Half {
8080
Half() = default;
8181
#endif
8282

83-
constexpr C10_HOST_DEVICE Half(unsigned short bits, from_bits_t) : x(bits) {}
83+
constexpr C10_HOST_DEVICE Half(unsigned short bits, from_bits_t /*unused*/)
84+
: x(bits) {}
8485
#if defined(__aarch64__) && !defined(__CUDACC__)
8586
inline Half(float16_t value);
8687
inline operator float16_t() const;

0 commit comments

Comments
 (0)