-
Notifications
You must be signed in to change notification settings - Fork 9
Fixed lookup buffer size calculation for Vulkan implementation. #99
base: develop
Are you sure you want to change the base?
Conversation
For me the behaviour is still the same on Linux at least.
There is, however recently found (it is working with and without that fix) ONE working Vulkan enabled GPU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the tests with build/test/gpu-setup-test --test --logs -N 8192
on llvmpipe and it fails:
Test LEAFS: Label size: 128, count 131072, buffer 2.0M
[2023-04-24 11:10:43] Vulkan library LOADED.
[2023-04-24 11:10:43] initCpu() finished.
CPU: 131072 hashes, 609 h/s, status: 0
WARNING: lavapipe is not a conformant vulkan implementation, testing use only.
[2023-04-24 11:14:19] 92% Max Allocation: 1971322880
[2023-04-24 11:14:19] GPU 0: selecting buffer_size of 1880
[2023-04-24 11:14:19] GPU 0: setting thread_concurrency to 7520 based on buffer size 1880 and lookup gap 4
[2023-04-24 11:14:19] 64:128 34362 -> 126892
[2023-04-24 11:14:19] SPIR-V program 64:128 126892 bytes
[2023-04-24 11:14:19] initVulkan() finished. Found llvmpipe (LLVM 12.0.0, 256 bits)
llvmpipe (LLVM 12.0.0, 256 bits): 131072 hashes, 14883 h/s
ZEROS result
WRONG result for label size 128 from provider 0 [llvmpipe (LLVM 12.0.0, 256 bits)]
cgpu->lookup_gap = 4; | ||
|
||
unsigned int bsize = 1024; | ||
size_t ipt = (bsize / cgpu->lookup_gap + (bsize % cgpu->lookup_gap > 0)); | ||
size_t ipt = scrypt_mem / cgpu->lookup_gap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please document and explain in comments the logic behind calculations of buffers/memory sizes in this function and what variables mean (for example, what "ipt" stands for)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrypt memory size in bytes scrypt_mem = 128 * r * N
Lookup gap reduces memory usage but increases computational complexity. With lookup gap memory usage is
ipt = scrypt_mem / lookup_gap
max concurrent threads = allocated_buffer_size / ipt
src/vulkan/driver-vulkan.cpp
Outdated
|
||
if (!cgpu->buffer_size) { | ||
unsigned int base_alloc = (int)(cgpu->gpu_max_alloc * 88 / 100 / 1024 / 1024 / 8) * 8 * 1024 * 1024; | ||
cgpu->thread_concurrency = (uint32_t)(base_alloc / scrypt_mem / ipt); | ||
unsigned int base_alloc = (int)(cgpu->gpu_max_alloc * 92 / 100 / 1024 / 1024 / 8) * 8 * 1024 * 1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use 92% of max memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A value of 88% is generally accepted, but this is a legacy of cards with 4G memory or less. 92% is performance improvement and is acceptable as long as there are no memory allocation errors. In fact, for cards with more than 4G memory, a value of 100% is acceptable.
That's from
|
Fixed lookup buffer size calculation for Vulkan implementation.