mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Uses the crc32q Intel instruction in x64 platforms.
This commit is contained in:
parent
28bdd0f7b7
commit
6a4879caad
2 changed files with 15 additions and 1 deletions
2
speed.c
2
speed.c
|
|
@ -177,7 +177,7 @@ void speed(void)
|
|||
}
|
||||
} SPEED_STOP
|
||||
|
||||
printf("CRC intel-crc32l %"PRIu64" [MB/s]\n", ds / dt);
|
||||
printf("CRC intel-crc32 %"PRIu64" [MB/s]\n", ds / dt);
|
||||
}
|
||||
#endif
|
||||
SPEED_START {
|
||||
|
|
|
|||
14
util.c
14
util.c
|
|
@ -1093,13 +1093,27 @@ uint32_t crc32c_gen(uint32_t crc, const unsigned char* ptr, unsigned size)
|
|||
|
||||
uint32_t crc32c_x86(uint32_t crc, const unsigned char* ptr, unsigned size)
|
||||
{
|
||||
#if defined(__x86_64__)
|
||||
uint64_t crc64;
|
||||
#endif
|
||||
|
||||
crc ^= CRC_IV;
|
||||
|
||||
#if defined(__x86_64__)
|
||||
crc64 = crc;
|
||||
while (size >= 8) {
|
||||
asm volatile ("crc32q %1, %0\n" : "+r" (crc64) : "rm" (*(uint64_t*)ptr));
|
||||
ptr += 8;
|
||||
size -= 8;
|
||||
}
|
||||
crc = crc64;
|
||||
#else
|
||||
while (size >= 4) {
|
||||
asm volatile ("crc32l %1, %0\n" : "+r" (crc) : "rm" (*(uint32_t*)ptr));
|
||||
ptr += 4;
|
||||
size -= 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (size) {
|
||||
asm volatile ("crc32b %1, %0\n" : "+r" (crc) : "rm" (*ptr));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue