xmrig / xmrig-cuda

NVIDIA CUDA plugin for XMRig miner
GNU General Public License v3.0
368 stars 155 forks source link

Automate handling of supported CUDA_ARCH by probing nvcc #143

Open Spudz76 opened 2 years ago

Spudz76 commented 2 years ago

This will follow naturally with the DEFAULT_CUDA_ARCH list being set to exactly everything the selected Toolkit nvcc supports (from nvcc --help output) and reduce need for manual updates to logic other than the MSG_CUDA_MAP and related support helper/crash messages.

When arch 90 comes out and CUDA Toolkit v12.x nvcc has support, the automatic builds should just work day one (when v12 is added to the build list).

Related to the issue #142 which was caused by never adding 86 and not working right with base 80 code. Should avoid similar issues in the future (like with 87 or 90) or when older things become deprecated (all 3X and 5X should all be gone suddenly in v12)

Also fixed a couple actual bugs and improved some message phrasing. Bumped minimal CMake version to 3.0 because execute_process() was not in 2.x ; Everyone either already has 3.0+ or it's super easy to get a more current version.

Sample output from testing against all major versions of Toolkit:

-- [/usr/local/cuda-8.0/bin/nvcc] Architecture support: 20;21;30;32;35;37;50;52;53;60;61;62
-- [/usr/local/cuda-9.0/bin/nvcc] Architecture support: 30;32;35;37;50;52;53;60;61;62;70
-- [/usr/local/cuda-9.1/bin/nvcc] Architecture support: 30;32;35;37;50;52;53;60;61;62;70;72
-- [/usr/local/cuda-9.2/bin/nvcc] Architecture support: 30;32;35;37;50;52;53;60;61;62;70;72
-- [/usr/local/cuda-10.0/bin/nvcc] Architecture support: 30;32;35;37;50;52;53;60;61;62;70;72;75
-- [/usr/local/cuda-10.1/bin/nvcc] Architecture support: 30;32;35;37;50;52;53;60;61;62;70;72;75
-- [/usr/local/cuda-10.2/bin/nvcc] Architecture support: 30;32;35;37;50;52;53;60;61;62;70;72;75
-- [/usr/local/cuda-11.0/bin/nvcc] Architecture support: 35;37;50;52;53;60;61;62;70;72;75;80
-- [/usr/local/cuda-11.1/bin/nvcc] Architecture support: 35;37;50;52;53;60;61;62;70;72;75;80;86
-- [/usr/local/cuda-11.2/bin/nvcc] Architecture support: 35;37;50;52;53;60;61;62;70;72;75;80;86
-- [/usr/local/cuda-11.3/bin/nvcc] Architecture support: 35;37;50;52;53;60;61;62;70;72;75;80;86
-- [/usr/local/cuda-11.4/bin/nvcc] Architecture support: 35;37;50;52;53;60;61;62;70;72;75;80;86;87
-- [/usr/local/cuda-11.5/bin/nvcc] Architecture support: 35;37;50;52;53;60;61;62;70;72;75;80;86;87
xmrig commented 2 years ago

Main reason why arch list is very limited was the resulting binary size and compile time. Large arch list dramatically increases size and compile time which is already huge. Overall changes are good but I don't like arch list becoming big. Thank you.

Spudz76 commented 2 years ago

Then someone should make a list of which ones actually need their sub-arch and which don't (60/61/62 all work on 60; obviously due to enduser report 86 does not work with 80)

Not sure if the release files being useless for anyone with an 86 is worth the savings of compile time nobody is waiting for because it's automated, or some more MB. :)

Spudz76 commented 2 years ago

Made that list I said someone should make, based on what the original code would have not-built (but adding the 86), and cleaned up some wording, and added some more architecture feedback.

Should build identically to current aside from the addition of 86 which should fix the actual reported issue.

Spudz76 commented 2 years ago

Updated sample output from every Toolkit version (confirming useless arch filtering):

-- Found CUDA: /usr/local/cuda-8.0 (found suitable version "8.0", minimum required is "8.0")
-- CUDA 8.0: RandomX, AstroBWT, and KawPow disabled, they do not work with CUDA < 9.0
-- CUDA Architectures supported by [/usr/local/cuda-8.0/bin/nvcc]: 20;21;30;32;35;37;50;52;53;60;61;62
-- CUDA Architectures filtered defaults: 20;21;30;35;50;60
-- CUDA Architectures being built: 20;21;30;35;50;60
-- Found CUDA: /usr/local/cuda-9.0 (found suitable version "9.0", minimum required is "8.0")
-- CUDA Architectures supported by [/usr/local/cuda-9.0/bin/nvcc]: 30;32;35;37;50;52;53;60;61;62;70
-- CUDA Architectures filtered defaults: 30;35;50;60;70
-- CUDA Architectures being built: 30;35;50;60;70
-- Found CUDA: /usr/local/cuda-9.1 (found suitable version "9.1", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-9.1/bin/nvcc]: 30;32;35;37;50;52;53;60;61;62;70;72
-- CUDA Architectures filtered defaults: 30;35;50;60;70
-- CUDA Architectures being built: 30;35;50;60;70
-- Found CUDA: /usr/local/cuda-9.2 (found suitable version "9.2", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-9.2/bin/nvcc]: 30;32;35;37;50;52;53;60;61;62;70;72
-- CUDA Architectures filtered defaults: 30;35;50;60;70
-- CUDA Architectures being built: 30;35;50;60;70
-- Found CUDA: /usr/local/cuda-10.0 (found suitable version "10.0", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-10.0/bin/nvcc]: 30;32;35;37;50;52;53;60;61;62;70;72;75
-- CUDA Architectures filtered defaults: 30;35;50;60;70;75
-- CUDA Architectures being built: 30;35;50;60;70;75
-- Found CUDA: /usr/local/cuda-10.1 (found suitable version "10.1", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-10.1/bin/nvcc]: 30;32;35;37;50;52;53;60;61;62;70;72;75
-- CUDA Architectures filtered defaults: 30;35;50;60;70;75
-- CUDA Architectures being built: 30;35;50;60;70;75
-- Found CUDA: /usr/local/cuda-10.2 (found suitable version "10.2", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-10.2/bin/nvcc]: 30;32;35;37;50;52;53;60;61;62;70;72;75
-- CUDA Architectures filtered defaults: 30;35;50;60;70;75
-- CUDA Architectures being built: 30;35;50;60;70;75
-- Found CUDA: /usr/local/cuda-11.0 (found suitable version "11.0", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-11.0/bin/nvcc]: 35;37;50;52;53;60;61;62;70;72;75;80
-- CUDA Architectures filtered defaults: 35;50;60;70;75;80
-- CUDA Architectures being built: 35;50;60;70;75;80
-- Found CUDA: /usr/local/cuda-11.1 (found suitable version "11.1", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-11.1/bin/nvcc]: 35;37;50;52;53;60;61;62;70;72;75;80;86
-- CUDA Architectures filtered defaults: 35;50;60;70;75;80;86
-- CUDA Architectures being built: 35;50;60;70;75;80;86
-- Found CUDA: /usr/local/cuda-11.2 (found suitable version "11.2", minimum required is "8.0") 
-- CUDA Architectures supported by [/usr/local/cuda-11.2/bin/nvcc]: 35;37;50;52;53;60;61;62;70;72;75;80;86
-- CUDA Architectures filtered defaults: 35;50;60;70;75;80;86
-- CUDA Architectures being built: 35;50;60;70;75;80;86
-- Found CUDA: /usr/local/cuda-11.3 (found suitable version "11.3", minimum required is "8.0")
-- CUDA Architectures supported by [/usr/local/cuda-11.3/bin/nvcc]: 35;37;50;52;53;60;61;62;70;72;75;80;86
-- CUDA Architectures filtered defaults: 35;50;60;70;75;80;86
-- CUDA Architectures being built: 35;50;60;70;75;80;86
-- Found CUDA: /usr/local/cuda-11.4 (found suitable version "11.4", minimum required is "8.0")
-- CUDA Architectures supported by [/usr/local/cuda-11.4/bin/nvcc]: 35;37;50;52;53;60;61;62;70;72;75;80;86;87
-- CUDA Architectures filtered defaults: 35;50;60;70;75;80;86
-- CUDA Architectures being built: 35;50;60;70;75;80;86
-- Found CUDA: /usr/local/cuda-11.5 (found suitable version "11.5", minimum required is "8.0")
-- CUDA Architectures supported by [/usr/local/cuda-11.5/bin/nvcc]: 35;37;50;52;53;60;61;62;70;72;75;80;86;87
-- CUDA Architectures filtered defaults: 35;50;60;70;75;80;86
-- CUDA Architectures being built: 35;50;60;70;75;80;86
Spudz76 commented 2 years ago

Here is one where I am building on purpose for some other specified arch:

-- CUDA Architectures supported by [/usr/local/cuda-11.5/bin/nvcc]: 35;37;50;52;53;60;61;62;70;72;75;80;86;87
-- CUDA Architectures filtered defaults: 35;50;60;70;75;80;86
-- CUDA Architectures being built: 61