Skip to content

Commit 089917c

Browse files
committed
sync c10
[ghstack-poisoned]
1 parent a212e81 commit 089917c

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,4 +508,14 @@ __host__ __device__
508508

509509
#endif
510510

511+
// This macro is used to find older C++ compilers
512+
// that don't support move optimization for return values.
513+
514+
#if (defined(__GNUC__) && __GNUC__ < 13) || \
515+
(defined(__clang_major__) && __clang_major__ < 13)
516+
#define C10_RETURN_MOVE_IF_OLD_COMPILER 1
517+
#else
518+
#define C10_RETURN_MOVE_IF_OLD_COMPILER 0
519+
#endif
520+
511521
#endif // C10_MACROS_MACROS_H_

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ inline C10_HOST_DEVICE float f32_from_bits(uint16_t src) {
3131
uint32_t tmp = src;
3232
tmp <<= 16;
3333

34-
#if defined(USE_ROCM)
34+
#if defined(USE_ROCM) && defined(__HIPCC__)
3535
float* tempRes;
3636

3737
// We should be using memcpy in order to respect the strict aliasing rule
@@ -48,7 +48,7 @@ inline C10_HOST_DEVICE float f32_from_bits(uint16_t src) {
4848
inline C10_HOST_DEVICE uint16_t bits_from_f32(float src) {
4949
uint32_t res = 0;
5050

51-
#if defined(USE_ROCM)
51+
#if defined(USE_ROCM) && defined(__HIPCC__)
5252
// We should be using memcpy in order to respect the strict aliasing rule
5353
// but it fails in the HIP environment.
5454
uint32_t* tempRes = reinterpret_cast<uint32_t*>(&src);
@@ -61,7 +61,7 @@ inline C10_HOST_DEVICE uint16_t bits_from_f32(float src) {
6161
}
6262

6363
inline C10_HOST_DEVICE uint16_t round_to_nearest_even(float src) {
64-
#if defined(USE_ROCM)
64+
#if defined(USE_ROCM) && defined(__HIPCC__)
6565
if (src != src) {
6666
#elif defined(_MSC_VER)
6767
if (isnan(src)) {
@@ -87,7 +87,7 @@ struct alignas(2) BFloat16 {
8787
uint16_t x;
8888

8989
// HIP wants __host__ __device__ tag, CUDA does not
90-
#if defined(USE_ROCM)
90+
#if defined(USE_ROCM) && defined(__HIPCC__)
9191
C10_HOST_DEVICE BFloat16() = default;
9292
#else
9393
BFloat16() = default;

0 commit comments

Comments
 (0)