static void create_clobj(size_t kpc, struct fmt_main *self) { cl_ulong max_alloc_size_bytes = 0; cl_ulong cache_size_bytes = 0; HANDLE_CLERROR(clGetDeviceInfo(devices[gpu_id], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_alloc_size_bytes, 0), "failed to get CL_DEVICE_MAX_MEM_ALLOC_SIZE."); HANDLE_CLERROR(clGetDeviceInfo(devices[gpu_id], CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, sizeof(cl_ulong), &cache_size_bytes, 0), "failed to get CL_DEVICE_GLOBAL_MEM_CACHE_SIZE."); if (max_alloc_size_bytes & (max_alloc_size_bytes - 1)) { get_power_of_two(max_alloc_size_bytes); max_alloc_size_bytes >>= 1; }
int get_power_of_two_uint(const uint64_t *operand, int uint64_count) { #ifdef _DEBUG if (operand == nullptr && uint64_count > 0) { throw invalid_argument("operand"); } if (uint64_count < 0) { throw invalid_argument("uint64_count"); } #endif operand += uint64_count; for (int long_index = uint64_count - 1; long_index >= 0; --long_index) { uint64_t value = *--operand; if (value != 0) { // First non-zero value, verify that it is a power of 2. int power = get_power_of_two(value); if (power == -1) { return -1; } power += long_index * bits_per_uint64; // Verify remaining values are 0. long_index--; for (; long_index >= 0; --long_index) { value = *--operand; if (value != 0) { return -1; } } return power; } } return -1; }
void QSettingsDialog::on_dialBufferlength_valueChanged(int value) { ui->lineEditBufferlength->setText(QString::number(get_power_of_two(value))); }
quint32 QSettingsDialog::get_bufferlength() const { return get_power_of_two(ui->dialBufferlength->value()); }
quint32 QSettingsDialog::get_datalength() const { return get_power_of_two(ui->dialDatalength->value()); }