1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-13 20:57:06 +01:00

Optional support for faster CRC32C checksum through Intel IPP

This commit is contained in:
2018-11-19 17:21:53 +00:00
parent 494b3c9e57
commit d77bc88170
3 changed files with 45 additions and 3 deletions

View File

@ -28,17 +28,31 @@
extern "C" {
#include <openssl/sha.h>
}
#ifdef USE_IPP
#include "ipp.h"
#endif
#pragma once
class GridChecksum
{
public:
static inline uint32_t crc32(const void *data,size_t bytes)
static inline uint32_t crc32(const void *data, size_t bytes)
{
return ::crc32(0L,(unsigned char *)data,bytes);
}
#ifdef USE_IPP
static inline uint32_t crc32c(const void* data, size_t bytes)
{
uint32_t crc32c = ~(uint32_t)0;
ippsCRC32C_8u(reinterpret_cast<const unsigned char *>(data), bytes, &crc32c);
ippsSwapBytes_32u_I(&crc32c, 1);
return ~crc32c;
}
#endif
template <typename T>
static inline std::string sha256_string(const std::vector<T> &hash)
{