在设备代码中使用函数 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. java反射机制的作用与优点

    java的反射机制就是增加程序的灵活性,避免将程序写死到代码里,例如: 实例化一个 person()对象, 不使用反射, new person(); 如果想变成 实例化 其他类, 那么必须修改源代码, ...

  2. hibernate连接oracle12c数据库报:java.sql.SQLException: ORA-01017: 用户名/口令无效; 登录被拒绝。(用户名/口令在oracle客户端以及cmd命令都能登入)

    报错信息: 2017-09-22 15:40:07,354 WARN [org.hibernate.cfg.SettingsFactory] - Could not obtain connection ...

  3. (精)AVL树旋转共8种情况(涵盖所有考研的范围)

  4. 通过torodb && hasura graphql 让mongodb 快速支持graphql api

    torodb 可以方便的将mongo 数据实时同步到pg,hasura graphql 可以方便的将pg 数据暴露为graphql api,集成在一起真的很方便 环境准备 docker-compose ...

  5. 环境搭建之JAVA项目部署步骤

    一.配置java环境 1.linux下安装jdk,在此处安装1.7_x64的jdk,解压缩  tar -zxvf xxxxxxx 2.将jdk移动到/usr下 mv java /user/ 3.配置环 ...

  6. 关于 Vue 方法前面的美元符号

    关于 Vue 方法前面的美元符号 学到这一段,不明白什么意思,然后手贱把 $ 删除了,出现未定义方法. vm.$watch('counter', function(nval, oval) { aler ...

  7. 【转】每天一个linux命令(43):killall命令

    原文网址:http://www.cnblogs.com/peida/archive/2012/12/21/2827366.html Linux系统中的killall命令用于杀死指定名字的进程(kill ...

  8. spark数据倾斜

    数据倾斜的主要问题在于,某个分区数量很巨大,在做map运算的时候,将会发生别的分区task很快计算完成,但是某几个分区task的计算成为了系统的瓶颈,明显超过其他分区时间:   1.方案:Kafka的 ...

  9. java 解析office文件 大全

    原文地址:http://ansjsun.iteye.com/blog/791142 读取OFFICE文件纯文本 package org.css.resource.businesssoft.search ...

  10. Linux内核深入研究之进程的线性地址空间-传统版

    引言: 了解Linux环境下,进程的地址空间划分,对于我们理解Linux应用程序有很大的帮助,否则会被New与Malloc之类的指针操作弄的晕头转向,本文基于Linux内核讲述了Linux/Unix线 ...