当前位置: 首页 > news >正文

成都公司建网站北京网络职业技术学院官网

成都公司建网站,北京网络职业技术学院官网,wordpress 七牛云 cdn,泰安做网站的为了确保能够真正地了解线程块的分配#xff0c;接下来我们写一个简短的内核程序来输出线程块、线程、线程束和线程全局标号到屏幕上。现在#xff0c;除非你使用的是 3.2 版本以上的 SDK否则内核中是不支持 printf的。因此#xff0c;我们可以将数据传送回 CPU 端然后输出到…        为了确保能够真正地了解线程块的分配接下来我们写一个简短的内核程序来输出线程块、线程、线程束和线程全局标号到屏幕上。现在除非你使用的是 3.2 版本以上的 SDK否则内核中是不支持 printf的。因此我们可以将数据传送回 CPU 端然后输出到控制台窗口内核的代码如下: #include cuda_runtime.h #include device_launch_parameters.h#include stdio.h #include stdlib.h #include conio.h__global__ void what_is_my_id(unsigned int* const block,unsigned int* const thread,unsigned int* const warp,unsigned int* const calc_thread) {/* Thread id is block index * block size thread offset into the block */const unsigned int thread_idx (blockIdx.x * blockDim.x) threadIdx.x;block[thread_idx] blockIdx.x; thread[thread_idx] threadIdx.x;/* Calculate warp using buit in variable warpSize */warp[thread_idx] threadIdx.x / warpSize;calc_thread[thread_idx] thread_idx; }#define ARRAY_SIZE 128 #define ARRAY_SIZE_IN_BYTES (sizeof(unsigned int)* (ARRAY_SIZE))/* Declare statically four arrays of ARRAY_SIZE each */ unsigned int cpu_block[ARRAY_SIZE]; unsigned int cpu_thread[ARRAY_SIZE]; unsigned int cpu_warp[ARRAY_SIZE]; unsigned int cpu_calc_thread[ARRAY_SIZE];int main(void) {/* Total thread count 2*64128 */const unsigned int num_blocks 2;const unsigned int num_threads 64;char ch;/* Declare pointers for GPU based params */unsigned int* gpu_block;unsigned int* gpu_thread;unsigned int* gpu_warp;unsigned int* gpu_calc_thread;/* Declare loop counter for use later */unsigned int i;/* Allocate four arrays on the GPU */cudaMalloc((void**)gpu_block, ARRAY_SIZE_IN_BYTES);cudaMalloc((void**)gpu_thread, ARRAY_SIZE_IN_BYTES);cudaMalloc((void**)gpu_warp, ARRAY_SIZE_IN_BYTES);cudaMalloc((void**)gpu_calc_thread, ARRAY_SIZE_IN_BYTES);/* Execute our kerne] */what_is_my_id num_blocks, num_threads(gpu_block, gpu_thread, gpu_warp, gpu_calc_thread);/* Copy back the gpu results to the CPU */cudaMemcpy(cpu_block, gpu_block, ARRAY_SIZE_IN_BYTES, cudaMemcpyDeviceToHost);cudaMemcpy(cpu_thread, gpu_thread, ARRAY_SIZE_IN_BYTES, cudaMemcpyDeviceToHost);cudaMemcpy(cpu_warp, gpu_warp, ARRAY_SIZE_IN_BYTES, cudaMemcpyDeviceToHost);cudaMemcpy(cpu_calc_thread, gpu_calc_thread, ARRAY_SIZE_IN_BYTES, cudaMemcpyDeviceToHost);/* Free the arrays on the GPU as now were done with them */cudaFree(gpu_block);cudaFree(gpu_thread);cudaFree(gpu_warp);cudaFree(gpu_calc_thread);/* Iterate through the arrays and print */for (i 0; i ARRAY_SIZE; i) {printf(Calculated Thread: %3u - Block:%2u - Warp %2u - Thread %3u\n, cpu_calc_thread[i], cpu_block[i], cpu_warp[i], cpu_thread[i]);}ch getch(); } 在这个例子中我们可以看到线程块按照线程块的编号紧密相连。由于处理的是一维数组所以我们对线程块采用相同的布局便可简单解决问题。以下是此程序的输出结果: 正如我们计算的那样线程索引是0~ 127。一共有两个线块每个线程块包含 64个线程每个线程块内部线程的索引为0~63。一个线程块包含两个线束。
http://www.w-s-a.com/news/74968/

相关文章:

  • 眼科医院网站开发网络营销特点是什么
  • 提交网站给百度增加wordpress插件
  • 网站建设企业官网体验版是什么Wordpress哪个模板最快
  • 美丽说网站模板湖北可以做网站方案的公司
  • 北京西站进站最新规定建设网站的提成是多少
  • wordpress站点如何加速网站建设描述怎么写
  • 如何免费建造网站免费vi模板网站
  • 商丘做网站多少钱扬州大发网站建设
  • 网站建设哪家性价比高自己做项目的网站
  • 成立一个网站济宁营销型网站建设
  • 南通购物网站建设设计类平台网站
  • 专业网站建设咨询thinkphp网站源码下载
  • 怎么制作一个国外网站网站推广找哪家公司好
  • 免费做网站怎么做网站想在网上卖东西怎么注册
  • 淘宝网站建设的策划书网投怎么做网站
  • 如何免费做公司网站视频网站开发视频
  • 网站后台是怎么更新wordpress 大于2m的xm
  • 制作网页设计软件列表案例营销网站优化seo
  • 住房和建设建设局网站报告长官夫人在捉鬼
  • 用asp做网站需要什么软件天津建设工程信息网怎么注册
  • 一站式服务图片北京网站优化多少钱
  • 专业的论坛网站建设全网加速器
  • 成都品牌建设网站公司表单制作小程序
  • 手机端 网站 模板网页广告关不掉怎么办
  • 软装公司网站建设有没有做任务的网站
  • 加盟招商网站建设工业设计网站 知乎
  • 怎么做淘宝客网站优化免费windows7云主机
  • 有什么网站可以推广信息沈阳网站建设思路
  • 网站建设可研域名解析在线工具
  • 鲜花销售网站模板wordpress+模版+推荐