0_Simple__simplePrintf
在设备代码中使用函数 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的更多相关文章
随机推荐
- C# 使用GZip对字符串压缩和解压
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...
- 使用webpack搭建vue项目中遇到的问题
1:data数据文件经试验,需要放在生成的build文件夹中才能生效,但是应该把data文件夹先放在src中,然后如何定义config文件,让其复制过去? new CopyWebpackPlugin( ...
- MySQL中UNSIGNED和ZEROFILL的介绍
UNSIGNED: 将数字类型无符号化,这与C和C++这些程序语言的unsigned含义相同. INT的类型范围-2 147 483 648~2 147 483 647 INT UNSIGNED范围0 ...
- Spring MVC 向页面传值-Map、Model、ModelMap、ModelAndView
Spring MVC 向页面传值,有4种方式: ModelAndView Map Model ModelMap 使用后面3种方式,都是在方法参数中,指定一个该类型的参数. Model Model 是一 ...
- SQL 计算某月有多少天
今天用SQL Server 2005写查询语句,要求计算一个月平均每天发生的金额.以前往往喜欢查询相关的所有列,在代码中进行计算,还没有在SQL中写过. 第一印象就是:要考虑到润年还是平年,再判断是大 ...
- webmin安装简介
webmin安装简介 Webmin是目前功能最强大的基于Web的Unix系统管理工具.管理员通过浏览器访问Webmin的各种管理功能并完成相应的管理动作.目前Webmin支持绝大多数的Unix系统,这 ...
- 一、Python 模块EasyGui详细介绍
Python 模块EasyGui详细介绍 EasyGui 官网: -http://easygui.sourceforge.net 官方的教学文档: -easygui-docs-0.96\tutoria ...
- Linux下查看某个进程占用的CPU、内存
1.用top命令指定固定的PID top -p 10997 查询指定进程的PID ps -ef | grep zookeeper jim 10997 1959 0 12月14 pts/2 00:00: ...
- 如何将JQUERY对象转成Javascript对象
问: <div id="test"></div> $("#test") //由Javascript对象转为Jquery对象: 但是如何转 ...
- Linux 命令集合-错误
错误1 说明:在linux下,./xxx.sh执行shell脚本时会提示No such file or directory.但shell明明存在,为什么就是会提示这个呢? 这种其实是因为编码方式不对, ...