Skip to content

Commit f4a9303

Browse files
committed
MUSA adds support for __vsubss4
Signed-off-by: Xiaodong Ye <[email protected]>
1 parent 27396ea commit f4a9303

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

ggml/src/ggml-cuda/common.cuh

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@
259259
#define cublasComputeType_t cudaDataType_t
260260

261261
// XXX: Clang builtins mapping
262-
#define __vsubss4 __vsubss4_musa
263262
#define __vsub4 __vsub4_musa
264263
#define __vcmpeq4 __vcmpeq4_musa
265264
#define __vcmpne4 __vcmpne4_musa
@@ -372,30 +371,10 @@ typedef float2 dfloat2;
372371
#define __has_builtin(x) 0
373372
#endif
374373

375-
typedef int8_t int8x4_t __attribute__((ext_vector_type(4)));
376374
typedef uint8_t uint8x4_t __attribute__((ext_vector_type(4)));
377-
static __device__ __forceinline__ int __vsubss4_musa(const int a, const int b) {
378-
const int8x4_t va = reinterpret_cast<const int8x4_t&>(a);
379-
const int8x4_t vb = reinterpret_cast<const int8x4_t&>(b);
380-
#if __has_builtin(__builtin_elementwise_sub_sat)
381-
const int8x4_t c = __builtin_elementwise_sub_sat(va, vb);
382-
return reinterpret_cast<const int &>(c);
383-
#else
384-
int8x4_t c;
385-
int16_t tmp;
386-
#pragma unroll
387-
for (int i = 0; i < 4; i++) {
388-
tmp = va[i] - vb[i];
389-
if(tmp > std::numeric_limits<int8_t>::max()) tmp = std::numeric_limits<int8_t>::max();
390-
if(tmp < std::numeric_limits<int8_t>::min()) tmp = std::numeric_limits<int8_t>::min();
391-
c[i] = tmp;
392-
}
393-
return reinterpret_cast<int &>(c);
394-
#endif // __has_builtin(__builtin_elementwise_sub_sat)
395-
}
396375

397376
static __device__ __forceinline__ int __vsub4_musa(const int a, const int b) {
398-
return __vsubss4_musa(a, b);
377+
return __vsubss4(a, b);
399378
}
400379

401380
static __device__ __forceinline__ unsigned int __vcmpeq4_musa(unsigned int a, unsigned int b) {

0 commit comments

Comments
 (0)