Skip to content

Commit

Permalink
Update to latest libprimesieve
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jul 30, 2024
1 parent f62aa4a commit 84de797
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/primesieve/cmake/multiarch_avx512_vbmi2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ check_cxx_source_compiles("
class PrimeGenerator {
public:
__attribute__ ((target (\"avx512f,avx512vbmi,avx512vbmi2\")))
void fillNextPrimes_avx512_vbmi2(uint64_t* primes64);
void fillNextPrimes_avx512(uint64_t* primes64);
void fillNextPrimes_default(uint64_t* primes64);
void fillNextPrimes(uint64_t* primes64)
{
if (primesieve::has_cpuid_avx512_vbmi2())
fillNextPrimes_avx512_vbmi2(primes64);
fillNextPrimes_avx512(primes64);
else
fillNextPrimes_default(primes64);
}
Expand All @@ -44,7 +44,7 @@ check_cxx_source_compiles("
}
__attribute__ ((target (\"avx512f,avx512vbmi,avx512vbmi2\")))
void PrimeGenerator::fillNextPrimes_avx512_vbmi2(uint64_t* primes64)
void PrimeGenerator::fillNextPrimes_avx512(uint64_t* primes64)
{
__m512i bytes_0_to_7 = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7);
__m512i base = _mm512_set1_epi64(123);
Expand Down
6 changes: 3 additions & 3 deletions lib/primesieve/include/primesieve/PrimeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class PrimeGenerator : public Erat
ALWAYS_INLINE void fillNextPrimes(Vector<uint64_t>& primes, std::size_t* size)
{
#if defined(ENABLE_AVX512_VBMI2)
fillNextPrimes_avx512_vbmi2(primes, size);
fillNextPrimes_avx512(primes, size);
#elif defined(ENABLE_MULTIARCH_AVX512_VBMI2)
if (cpu_supports_avx512_vbmi2)
fillNextPrimes_avx512_vbmi2(primes, size);
fillNextPrimes_avx512(primes, size);
else
fillNextPrimes_default(primes, size);
#else
Expand All @@ -74,7 +74,7 @@ class PrimeGenerator : public Erat
#if defined(ENABLE_MULTIARCH_AVX512_VBMI2)
__attribute__ ((target ("avx512f,avx512vbmi,avx512vbmi2")))
#endif
void fillNextPrimes_avx512_vbmi2(Vector<uint64_t>& primes, std::size_t* size);
void fillNextPrimes_avx512(Vector<uint64_t>& primes, std::size_t* size);

#endif

Expand Down
2 changes: 1 addition & 1 deletion lib/primesieve/src/PrimeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void PrimeGenerator::fillNextPrimes_default(Vector<uint64_t>& primes, std::size_
#if defined(ENABLE_MULTIARCH_AVX512_VBMI2)
__attribute__ ((target ("avx512f,avx512vbmi,avx512vbmi2")))
#endif
void PrimeGenerator::fillNextPrimes_avx512_vbmi2(Vector<uint64_t>& primes, std::size_t* size)
void PrimeGenerator::fillNextPrimes_avx512(Vector<uint64_t>& primes, std::size_t* size)
{
*size = 0;

Expand Down
2 changes: 1 addition & 1 deletion lib/primesieve/src/x86/cpuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ bool has_cpuid_avx512_vbmi2()

run_cpuid(7, 0, abcd);

// PrimeGenerator::fillNextPrimes() requires AVX512F, AVX512VBMI & AVX512VBMI2
// PrimeGenerator::fillNextPrimes_avx512() requires AVX512F, AVX512VBMI & AVX512VBMI2
return ((abcd[1] & bit_AVX512F) == bit_AVX512F &&
(abcd[2] & (bit_AVX512VBMI | bit_AVX512VBMI2)) == (bit_AVX512VBMI | bit_AVX512VBMI2));
}
Expand Down

0 comments on commit 84de797

Please sign in to comment.