Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clang compilation error with Lib ATen for ppc64le #106446

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions aten/src/ATen/cpu/vec/vec256/vsx/vec256_complex_float_vsx.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class Vectorized<ComplexFlt> {
auto mask_complex = Vectorized<ComplexFlt>(
vec_mergeh(mask._vec0, mask._vec0), vec_mergeh(mask._vec1, mask._vec1));
return {
vec_sel(a._vec0, b._vec0, mask_complex._vec0),
vec_sel(a._vec1, b._vec1, mask_complex._vec1),
vec_sel(a._vec0, b._vec0, reinterpret_cast<vbool32>(mask_complex._vec0)),
vec_sel(a._vec1, b._vec1, reinterpret_cast<vbool32>(mask_complex._vec1)),
};
}

Expand All @@ -156,8 +156,8 @@ class Vectorized<ComplexFlt> {
const Vectorized<ComplexFlt>& b,
const Vectorized<ComplexFlt>& mask) {
return {
vec_sel(a._vec0, b._vec0, mask._vec0),
vec_sel(a._vec1, b._vec1, mask._vec1),
vec_sel(a._vec0, b._vec0, reinterpret_cast<vbool32>(mask._vec0)),
vec_sel(a._vec1, b._vec1, reinterpret_cast<vbool32>(mask._vec1)),
};
}

Expand Down
1 change: 1 addition & 0 deletions aten/src/ATen/cpu/vec/vec256/vsx/vec256_int64_vsx.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Vectorized<int64_t> {
using vec_internal_type = vint64;
using vec_internal_mask_type = vbool64;
using size_type = int;
using ElementType = signed long long;
static constexpr size_type size() {
return 4;
}
Expand Down
26 changes: 23 additions & 3 deletions aten/src/ATen/cpu/vec/vec256/vsx/vsx_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
#include <c10/macros/Macros.h>
#include <ATen/cpu/vec/intrinsics.h>

#if defined(__clang__)
typedef __vector __bool char vbool8;
typedef __vector __bool short vbool16;
typedef __vector __bool int vbool32;
typedef __vector __bool long long vbool64;
using vint8 = __attribute__((vector_size(16))) signed char;
using vint16 = __attribute__((vector_size(16))) signed short;
using vint32 = __attribute__((vector_size(16))) signed int;
using vint64 = __attribute__((vector_size(16))) signed long long;
using vuint8 = __attribute__((vector_size(16))) unsigned char;
using vuint16 = __attribute__((vector_size(16))) unsigned short;
using vuint32 = __attribute__((vector_size(16))) unsigned int;
using vuint64 = __attribute__((vector_size(16))) unsigned long long;
using vfloat32 = __attribute__((vector_size(16))) float;
using vfloat64 = __attribute__((vector_size(16))) double;
#else
using vbool8 = __attribute__((altivec(vector__))) __attribute__((altivec(bool__))) char;
using vbool16 = __attribute__((altivec(vector__))) __attribute__((altivec(bool__))) short;
using vbool32 = __attribute__((altivec(vector__))) __attribute__((altivec(bool__))) int;
Expand All @@ -17,6 +33,7 @@ using vuint32 = __attribute__((altivec(vector__))) unsigned int;
using vuint64 = __attribute__((altivec(vector__))) unsigned long long;
using vfloat32 = __attribute__((altivec(vector__))) float;
using vfloat64 = __attribute__((altivec(vector__))) double;
#endif

#if !defined(vec_float)
C10_ALWAYS_INLINE vfloat32 vec_float(const vint32& vec_in) {
Expand Down Expand Up @@ -64,8 +81,7 @@ C10_ALWAYS_INLINE vint32 vec_neg(const vint32& vec_in) {
}

C10_ALWAYS_INLINE vint64 vec_neg(const vint64& vec_in) {
vint64 vint0 = {0, 0};
return vec_vsubudm(vint0, vec_in);
return -vec_in;
}
#endif

Expand All @@ -84,7 +100,11 @@ vec_sldw_aux(const vfloat32& vec_in0, const vfloat32& vec_in1) {
#endif

#define vec_not(a) vec_nor(a, a)

#if defined(__clang__) && !defined(vec_splats)
C10_ALWAYS_INLINE vint64 vec_splats(const int64_t& a) {
return vec_splats(a);
}
#endif
// Vectorized min/max which return a if any operand is nan
template <class T>
C10_ALWAYS_INLINE T vec_min_nan(const T& a, const T& b) {
Expand Down
Loading