Merge branch 'add_rvv_support' of https://github.com/anthony-zy/snappy into add_rvv_support
This commit is contained in:
15
snappy.cc
15
snappy.cc
@@ -1288,11 +1288,12 @@ void MemCopy64(char* dst, const void* src, size_t size) {
|
|||||||
data = _mm256_lddqu_si256(static_cast<const __m256i *>(src) + 1);
|
data = _mm256_lddqu_si256(static_cast<const __m256i *>(src) + 1);
|
||||||
_mm256_storeu_si256(reinterpret_cast<__m256i *>(dst) + 1, data);
|
_mm256_storeu_si256(reinterpret_cast<__m256i *>(dst) + 1, data);
|
||||||
}
|
}
|
||||||
#else
|
// RVV acceleration available on RISC-V when compiled with -march=rv64gcv
|
||||||
#ifdef SNAPPY_HAVE_RVV
|
#elif defined(__riscv) & SNAPPY_HAVE_RVV
|
||||||
uint8_t* dst_u8 = (uint8_t*)dst;
|
uint8_t* dst_u8 = (uint8_t*)dst;
|
||||||
const uint8_t* src_u8 = (const uint8_t*)src;
|
const uint8_t* src_u8 = (const uint8_t*)src;
|
||||||
if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) { //overlap bwd copy
|
//overlap bwd copy
|
||||||
|
if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) {
|
||||||
size_t offset = size;
|
size_t offset = size;
|
||||||
while (offset > 0) {
|
while (offset > 0) {
|
||||||
size_t vl = VSETVL_E8M1(offset);
|
size_t vl = VSETVL_E8M1(offset);
|
||||||
@@ -1302,7 +1303,8 @@ if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) { //overlap bwd copy
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t vl = VSETVL_E8M1(size);
|
size_t vl = VSETVL_E8M1(size);
|
||||||
if (vl < size) { // if size >vl,use the max_vlen copy
|
// if size >vl,use the max_vlen copy
|
||||||
|
if (vl < size) {
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
while (offset < size) {
|
while (offset < size) {
|
||||||
vl = VSETVL_E8M1(size - offset);
|
vl = VSETVL_E8M1(size - offset);
|
||||||
@@ -1310,7 +1312,8 @@ if (src_u8 < dst_u8 && dst_u8 < src_u8 + size) { //overlap bwd copy
|
|||||||
VSE8_V_U8M1(dst_u8 + offset, vec, vl);
|
VSE8_V_U8M1(dst_u8 + offset, vec, vl);
|
||||||
offset += vl;
|
offset += vl;
|
||||||
}
|
}
|
||||||
} else { // copy the leaft
|
} else {
|
||||||
|
// Copy the rest
|
||||||
vuint8m1_t vec = VLE8_V_U8M1(src_u8, vl);
|
vuint8m1_t vec = VLE8_V_U8M1(src_u8, vl);
|
||||||
VSE8_V_U8M1(dst_u8, vec, vl);
|
VSE8_V_U8M1(dst_u8, vec, vl);
|
||||||
}
|
}
|
||||||
@@ -1322,8 +1325,6 @@ if (SNAPPY_PREDICT_FALSE(size > kShortMemCopy)) {
|
|||||||
std::memmove(dst + kShortMemCopy,
|
std::memmove(dst + kShortMemCopy,
|
||||||
static_cast<const uint8_t*>(src) + kShortMemCopy,
|
static_cast<const uint8_t*>(src) + kShortMemCopy,
|
||||||
64 - kShortMemCopy);}
|
64 - kShortMemCopy);}
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user