gpt4 book ai didi

memory - Cuda:如果我只使用 .x 的 block 和线程,它是否仍会使用 GPU 中的所有可用线程,还是必须使用 .y 和 .z 的线程和 block ?

转载 作者:行者123 更新时间:2023-12-01 02:13:46 26 4
gpt4 key购买 nike

我的程序需要最大限度地使用 GPU。

所以,blockDim.x * blockIdx.x + threadIdx.x;是否能够访问所有线程?或者也必须使用 .y 和 .z ?
这是强制性的吗?

最佳答案

CUDA 线程层次结构只是一种方便的抽象,不需要使用一维、二维或三维,如果只使用一维而不是所有三个维,也会损失性能。只要您指定了正确的网格维度,您就可以使用您通过一组索引启动的所有线程。

2.2. Thread Hierarchy

For convenience, threadIdx is a 3-component vector, so that threads can be identified using a one-dimensional, two-dimensional, or three-dimensional thread index, forming a one-dimensional, two-dimensional, or three-dimensional thread block. This provides a natural way to invoke computation across the elements in a domain such as a vector, matrix, or volume.


阅读更多: http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#thread-hierarchy

关于memory - Cuda:如果我只使用 .x 的 block 和线程,它是否仍会使用 GPU 中的所有可用线程,还是必须使用 .y 和 .z 的线程和 block ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26921682/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com