博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CUDA Thread Indexing
阅读量:5238 次
发布时间:2019-06-14

本文共 2223 字,大约阅读时间需要 7 分钟。

1D grid of 1D blocks__device__ int getGlobalIdx_1D_1D(){return blockIdx.x *blockDim.x + threadIdx.x;}1D grid of 2D blocks__device__ int getGlobalIdx_1D_2D(){return blockIdx.x * blockDim.x * blockDim.y + threadIdx.y * blockDim.x + threadIdx.x;}1D grid of 3D blocks__device__ int getGlobalIdx_1D_3D(){return blockIdx.x * blockDim.x * blockDim.y * blockDim.z + threadIdx.z * blockDim.y * blockDim.x + threadIdx.y * blockDim.x + threadIdx.x;}{return blockIdx.x * blockDim.x * blockDim.y * blockDim.z + threadIdx.z * blockDim.y * blockDim.x + threadIdx.y * blockDim.x + threadIdx.x;}2D grid of 1D blocks __device__ int getGlobalIdx_2D_1D(){int blockId   = blockIdx.y * gridDim.x + blockIdx.x; int threadId = blockId * blockDim.x + threadIdx.x; return threadId;}{int blockId   = blockIdx.y * gridDim.x + blockIdx.x; int threadId = blockId * blockDim.x + threadIdx.x; return threadId;}2D grid of 2D blocks  __device__ int getGlobalIdx_2D_2D(){int blockId = blockIdx.x + blockIdx.y * gridDim.x; int threadId = blockId * (blockDim.x * blockDim.y) + (threadIdx.y * blockDim.x) + threadIdx.x;return threadId;}2D grid of 3D blocks__device__ int getGlobalIdx_2D_3D(){int blockId = blockIdx.x + blockIdx.y * gridDim.x; int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z)  + (threadIdx.z * (blockDim.x * blockDim.y))  + (threadIdx.y * blockDim.x)  + threadIdx.x;return threadId;}3D grid of 1D blocks__device__ int getGlobalIdx_3D_1D(){int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int threadId = blockId * blockDim.x + threadIdx.x;return threadId;}3D grid of 2D blocks__device__ int getGlobalIdx_3D_2D(){int blockId = blockIdx.x         + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int threadId = blockId * (blockDim.x * blockDim.y) + (threadIdx.y * blockDim.x) + threadIdx.x;return threadId;}3D grid of 3D blocks__device__ int getGlobalIdx_3D_3D(){int blockId = blockIdx.x + blockIdx.y * gridDim.x + gridDim.x * gridDim.y * blockIdx.z; int threadId = blockId * (blockDim.x * blockDim.y * blockDim.z) + (threadIdx.z * (blockDim.x * blockDim.y)) + (threadIdx.y * blockDim.x) + threadIdx.x;return threadId;}

  

转载于:https://www.cnblogs.com/tibetanmastiff/p/4639194.html

你可能感兴趣的文章
PS 滤镜— — sparkle 效果
查看>>
snmpwalk命令常用方法总结
查看>>
网站产品设计
查看>>
代理ARP
查看>>
go 学习笔记(4) ---项目结构
查看>>
java中静态代码块的用法 static用法详解
查看>>
Java线程面试题
查看>>
Paper Reading: Relation Networks for Object Detection
查看>>
Java IO流学习总结
查看>>
day22 01 初识面向对象----简单的人狗大战小游戏
查看>>
mybatis源代码分析:深入了解mybatis延迟加载机制
查看>>
Flask三剑客
查看>>
Hibernate-缓存
查看>>
【BZOJ4516】生成魔咒(后缀自动机)
查看>>
提高PHP性能的10条建议
查看>>
svn“Previous operation has not finished; run 'cleanup' if it was interrupted“报错的解决方法...
查看>>
熟用TableView
查看>>
Java大数——a^b + b^a
查看>>
poj 3164 最小树形图(朱刘算法)
查看>>
百度贴吧图片抓取工具
查看>>