Make round size power of 2

This commit is contained in:
SChernykh 2020-10-15 14:29:15 +02:00
parent f3ea3c5227
commit c4db1435b2
2 changed files with 25 additions and 3 deletions

View file

@ -62,7 +62,19 @@ std::atomic<bool> CudaWorker::ready;
static inline bool isReady() { return !Nonce::isPaused() && CudaWorker::ready; } static inline bool isReady() { return !Nonce::isPaused() && CudaWorker::ready; }
static inline uint32_t roundSize(uint32_t intensity) { return kReserveCount / intensity + 1; }
static inline uint32_t roundSize(uint32_t intensity)
{
#ifdef _MSC_VER
unsigned long index;
_BitScanReverse(&index, intensity - 1);
const uint32_t n = 31 - index;
#else
const uint32_t n = __builtin_clz(intensity - 1);
#endif
return 1U << (32 - n);
}
} // namespace xmrig } // namespace xmrig

View file

@ -56,12 +56,22 @@
namespace xmrig { namespace xmrig {
static constexpr uint32_t kReserveCount = 32768;
std::atomic<bool> OclWorker::ready; std::atomic<bool> OclWorker::ready;
static inline bool isReady() { return !Nonce::isPaused() && OclWorker::ready; } static inline bool isReady() { return !Nonce::isPaused() && OclWorker::ready; }
static inline uint32_t roundSize(uint32_t intensity) { return kReserveCount / intensity + 1; }
static inline uint32_t roundSize(uint32_t intensity)
{
#ifdef _MSC_VER
unsigned long index;
_BitScanReverse(&index, intensity - 1);
const uint32_t n = 31 - index;
#else
const uint32_t n = __builtin_clz(intensity - 1);
#endif
return 1U << (32 - n);
}
static inline void printError(size_t id, const char *error) static inline void printError(size_t id, const char *error)