在设备代码中使用函数 printf(),没有新的认识。

▶ 源代码

 #include <stdio.h>
#include <cuda_runtime.h>
#include "device_launch_parameters.h"
#include <helper_functions.h>
#include <helper_cuda.h> __global__ void testKernel(int val)
{
printf("[%d, %d]:\t\tValue is:%d\n", blockIdx.y*gridDim.x + blockIdx.x, threadIdx.z*blockDim.x*blockDim.y + threadIdx.y*blockDim.x + threadIdx.x, val);
} int main(int argc, char **argv)
{
int devID;
cudaDeviceProp props;
devID = findCudaDevice(argc, (const char **)argv);
cudaGetDevice(&devID);
cudaGetDeviceProperties(&props, devID);
printf("Device %d: \"%s\" with Compute %d.%d capability\n",devID, props.name, props.major, props.minor); dim3 dimGrid(, );
dim3 dimBlock(, , );
testKernel<<<dimGrid, dimBlock>>>();
cudaDeviceSynchronize(); getchar();
return ;
}

▶ 输出结果

GPU Device : "GeForce GTX 1070" with compute capability 6.1

Device  : "GeForce GTX 1070" with Compute 6.1 capability
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :
[, ] : Value is :

0_Simple__simplePrintf的更多相关文章

随机推荐

  1. NSObject之一

    Objective-C中有两个NSObject,一个是NSObject类,另一个是NSObject协议.而其中NSObject类采用了NSObject协议.在本文中,我们主要整理一下NSObject类 ...

  2. WinFrom调试时,弹出你正在调试发布的版本

    把下图这里改成DEBUG就好 还有项目属性里面也要改一下 问题解决!

  3. python学习之-软件开发的目录规范

    通常软件目录下有几个标准文件夹 软件主文件夹命名,通常都是大写(ATM_SHOPPING) ------------------------------------------------------ ...

  4. hdu2069-2071

    hdu2069 选取硬币组成定值,暴力 #include<stdio.h> ]={,,,,,}; int main(){ int n; while(scanf("%d" ...

  5. C# NPOI导出Excel和EPPlus导出Excel

    转自:http://www.cnblogs.com/tanpeng/p/6155749.html 系统中经常会使用导出Excel的功能.之前使用的是NPOI,但是导出数据行数多就报内存溢出. 最近看到 ...

  6. MySQL--修改普通表为自增表

    =========================================================== 修改普通表为自增表 将普通表修改为自增表,可分为两种类型: 1.将现有列修改为自 ...

  7. adnanh webhook 框架request values 说明

      request values 在adnanh webhook 是比较重要的,规则触发以及命令参数传递都是通过它 支持的request values 类似 http header 查询参数 play ...

  8. jquery选择器之属性过滤选择器详解

    代码如下: <style type="text/css">  /*高亮显示*/  .highlight{       } </style> 复制代码代码如下 ...

  9. 设置zedgraph鼠标拖拽和局部放大属性(转帖)

    说一下几个属性的意义和具体应用: (1)鼠标拖拽显示区域 PanModifierKeys ->> Gets or sets a value that determines which mo ...

  10. 关于android setTextSize() 以及 px dip/dp sp的说明。。。。

    Paint.setTextSize()单位为px,Android系统中,默认的单位是像素(px).也就是说,在没有明确说明的情况下,所有的大小设置都是以像素为单位.Paint.setTextSize传 ...