Skip to content
Snippets Groups Projects
Commit 3b282b83 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'ifunc.CxxUtils-20180611' into 'master'

CxxUtils: A few cleanups for multiversioned functions.

See merge request atlas/athena!12047
parents 611de6c0 62cb2ef6
No related branches found
No related tags found
No related merge requests found
......@@ -124,35 +124,6 @@ namespace CxxUtils {
}
// We want to use the popcnt instruction for this if it's available.
// However, we're still compiling for a Model-T x86_64 by default.
// Use the target attribute and function multiversioning to use
// this instruction if it is in fact available.
#if defined(__x86_64__) && HAVE_BITCOUNT_INTRINSICS && HAVE_FUNCTION_MULTIVERSIONING
/**
* Count number of set bits.
*
* @param x Number to check
* @return Number of bits set in x.
*/
__attribute__ ((target ("popcnt")))
inline unsigned count_ones(unsigned x) {
return __builtin_popcount(x);
}
__attribute__ ((target ("popcnt")))
inline unsigned count_ones(unsigned long x) {
return __builtin_popcountl(x);
}
__attribute__ ((target ("popcnt")))
inline unsigned count_ones(unsigned long long x) {
return __builtin_popcountll(x);
}
#endif // defined(__x86_64__) && HAVE_BITCOUNT_INTRINSICS && HAVE_FUNCTION_MULTIVERSIONING
/**
* Count number of set bits.
*
......@@ -160,7 +131,11 @@ namespace CxxUtils {
* @return Number of bits set in x.
*/
#if defined(__x86_64__) && HAVE_BITCOUNT_INTRINSICS && HAVE_FUNCTION_MULTIVERSIONING
__attribute__ ((target ("default")))
// We want to use the popcnt instruction for this if it's available.
// However, we're still compiling for a Model-T x86_64 by default.
// Use the target attribute and function multiversioning to use
// this instruction if it is in fact available.
__attribute__ ((target_clones ("popcnt,default")))
#endif
inline unsigned count_ones(unsigned x) {
#if HAVE_BITCOUNT_INTRINSICS
......@@ -171,7 +146,7 @@ namespace CxxUtils {
}
#if defined(__x86_64__) && HAVE_BITCOUNT_INTRINSICS && HAVE_FUNCTION_MULTIVERSIONING
__attribute__ ((target ("default")))
__attribute__ ((target_clones ("popcnt,default")))
#endif
inline unsigned count_ones(unsigned long x) {
#if HAVE_BITCOUNT_INTRINSICS
......@@ -183,7 +158,7 @@ namespace CxxUtils {
#if defined(__x86_64__) && HAVE_BITCOUNT_INTRINSICS && HAVE_FUNCTION_MULTIVERSIONING
__attribute__ ((target ("default")))
__attribute__ ((target_clones ("popcnt,default")))
#endif
inline unsigned count_ones(unsigned long long x) {
#if HAVE_BITCOUNT_INTRINSICS
......
......@@ -110,29 +110,6 @@ __attribute__ ((target ("pclmul")))
uint64_t crc64 (const CRCTable& table,
const char* data,
size_t data_len);
/**
* @brief Find the CRC-64 of a string, with the default CRC.
* @param table Precomputed CRC tables and constants.
* @param data Pointer to the string to hash.
* @param data_len Length of the string to hash, in bytes.
*
* This is the vectorized implementation, used on platforms with pclmul.
*/
__attribute__ ((target ("pclmul")))
uint64_t crc64 (const char* data,
size_t data_len);
/**
* @brief Find the CRC-64 of a string, using the default polynomial.
* @param str The string to hash.
*
* This is the vectorized implementation, used on platforms with pclmul.
*/
__attribute__ ((target ("pclmul")))
uint64_t crc64 (const std::string& s);
#endif // ATH_CRC64_VEC
......@@ -156,12 +133,7 @@ uint64_t crc64 (const CRCTable& table,
* @brief Find the CRC-64 of a string, with the default CRC.
* @param data Pointer to the string to hash.
* @param data_len Length of the string to hash, in bytes.
*
* This is the default implementation, used on platforms without pclmul.
*/
#if ATH_CRC64_VEC
__attribute__ ((target ("default")))
#endif
uint64_t crc64 (const char* data,
size_t data_len);
......@@ -169,12 +141,7 @@ uint64_t crc64 (const char* data,
/**
* @brief Find the CRC-64 of a string, using the default polynomial.
* @param str The string to hash.
*
* This is the default implementation, used on platforms without pclmul.
*/
#if ATH_CRC64_VEC
__attribute__ ((target ("default")))
#endif
uint64_t crc64 (const std::string& s);
......
......@@ -15,7 +15,7 @@
/// Do we have function multiversioning?
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC)
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__COVERITY__)
# define HAVE_FUNCTION_MULTIVERSIONING 1
#else
# define HAVE_FUNCTION_MULTIVERSIONING 0
......
......@@ -674,34 +674,6 @@ uint64_t crc64 (const CRCTable& table,
}
/**
* @brief Find the CRC-64 of a string, using a vectorized algorithm,
* with the default CRC.
* @param table Precomputed CRC tables and constants.
* @param data Pointer to the string to hash.
* @param data_len Length of the string to hash, in bytes.
*/
__attribute__ ((target ("pclmul")))
uint64_t crc64 (const char* data,
size_t data_len)
{
return crc64 (defaultCRCTable, data, data_len);
}
/**
* @brief Find the CRC-64 of a string, using the default polynomial.
* @param str The string to hash.
*
* This is the vectorized implementation, used on platforms with pclmul.
*/
__attribute__ ((target ("pclmul")))
uint64_t crc64 (const std::string& s)
{
return crc64 (defaultCRCTable, s.data(), s.size());
}
#endif // ATH_CRC64_VEC
......@@ -728,12 +700,7 @@ uint64_t crc64 (const CRCTable& table,
* @brief Find the CRC-64 of a string, with the default CRC.
* @param data Pointer to the string to hash.
* @param data_len Length of the string to hash, in bytes.
*
* This is the default implementation, used on platforms without pclmul.
*/
#if ATH_CRC64_VEC
__attribute__ ((target ("default")))
#endif
uint64_t crc64 (const char* data,
size_t data_len)
{
......@@ -744,12 +711,7 @@ uint64_t crc64 (const char* data,
/**
* @brief Find the CRC-64 of a string, using the default polynomial.
* @param str The string to hash.
*
* This is the default implementation, used on platforms without pclmul.
*/
#if ATH_CRC64_VEC
__attribute__ ((target ("default")))
#endif
uint64_t crc64 (const std::string& s)
{
return crc64 (defaultCRCTable, s.data(), s.size());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment