《CUDA C 编程》

2020-04-30  本文已影响0人  Incredibles

第一章

GPU 版的 HelloWorld

#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <cstdio>

__global__ void helloFromGPU(void)
{
    printf("Hello World from GPU!  Thread Id: %d\n", threadIdx.x);
}

int main(void)
{
    // hello from cpu
    printf("Hello world from CPU! \n\n");
    helloFromGPU << <1, 10 >> > ();
    cudaDeviceReset();
    getchar();
    return 0;
}

问题1:原来GPU中也可以输出,我之前一直以为不能的,也许直接走的总线输出?
问题2:为什么GPU输出只能用printf,不能用cout呢?

API

笔记

上一篇 下一篇

猜你喜欢

热点阅读