CUDA kernel MaxThreadsPerBlock not constant
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Martin Strambach
le 30 Jan 2020
Réponse apportée : Edric Ellis
le 3 Fév 2020
I create a CUDA kernel using KERN = parallel.gpu.CUDAKernel(PTXFILE,CUFILE,FUNC). Block size is computed from KERN.MaxThreadsPerBlock which may vary based on a function which is used to build the kernel. I presumed MaxThreadsPerBlock is only dependent on gpuDevice properties. So far, it seems there might be some connection to number of function parameters. Can someone explain how this is actually determined or am I missing something?
I'm using Matlab 2019b, GCC 8.3, CUDA Toolkit 10.1 with NVidia V100 (CC 7.0).
2 commentaires
Joss Knight
le 2 Fév 2020
I can't work out how you'd see this for the same device. Can you post some reproduction code?
Réponse acceptée
Edric Ellis
le 3 Fév 2020
In your comment you mention that you see different values of MaxThreadsPerBlock for different kernels. This is expected. The CUDAKernel object builds on the underlying CUDA Driver API. Different kernel functions have different requirements in terms of shared memory, registers, and other resources, and this affects how many threads per block can be launched. This is described (briefly) in the CUDA Driver reference documentation here: https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__EXEC.html#group__CUDA__EXEC_1g5e92a1b0d8d1b82cb00dcfb2de15961b (In case that link goes stale - it describes the function cuFuncGetAttribute which allows you to query the CUDA attribute CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK).
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur GPU Computing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!