第一个CUDA程序
来源:互联网 发布:数控车床椭圆编程实例 编辑:程序博客网 时间:2024/05/21 09:11
第一个CUDA程序
/*** addition: C = A + B.** This sample is a very basic sample that implements element by element* vector addition. It is the same as the sample illustrating Chapter 2* of the programming guide with some additions like error checking.*/#include <stdio.h>#include <iostream>// For the CUDA runtime routines (prefixed with "cuda_")#include <cuda_runtime.h>/*** CUDA Kernel Device code** Computes the vector addition of A and B into C. The 3 vectors have the same* number of elements numElements.*/__global__ void Add(int a, int b, int *c){ *c = a + b;}int main(){ int c; int *devc; cudaError_t err = cudaSuccess; err = cudaMalloc((void **)&devc, sizeof(int)); if (err != cudaSuccess) { fprintf(stderr, "Failed to allocate device vector A (error code %s)!\n", cudaGetErrorString(err)); exit(EXIT_FAILURE); } Add << <1, 1 >> >(2, 7, devc); err = cudaMemcpy(&c, devc, sizeof(int), cudaMemcpyDeviceToHost); if (err != cudaSuccess) { fprintf(stderr, "Failed to allocate device vector A (error code %s)!\n", cudaGetErrorString(err)); exit(EXIT_FAILURE); } printf("2+7=%d\n", c); cudaFree(devc); system("pause"); return 0;}
0 0
- 第一个cuda程序
- cuda第一个程序
- 第一个CUDA程序
- 第一个CUDA程序
- 【CUDA】第一个CUDA程序-addVector
- cuda编程---第一个cuda程序
- 第一个CUDA程序-addVector
- 详解第一个CUDA程序kernel.cu
- VS2013 CUDA8.0 第一个CUDA程序
- 深入浅出谈CUDA-[第三章][第一个CUDA程序]
- 深入浅出谈CUDA-[第四章][改良第一个CUDA程序]
- CUDA下的GPU编程入门--第一个CUDA程序
- CUDA编程(一)第一个CUDA程序
- CUDA小记(2)运行第一个CUDA程序
- CUDA编程(一)第一个CUDA程序
- CUDA学习笔记(2) 第一个CUDA程序
- CUDA第一个程序优化(若干个线程)
- CUDA入门(二)cuda编程的基本知识与第一个cuda程序
- SQL优化思路
- Docker系列~将镜像推送到DockerHub(七)
- synchronization()
- 论文笔记 《Fast R-CNN》
- kmp算法原理分析
- 第一个CUDA程序
- (一)loadrunneran12.53安装与汉化
- Angualrjs——定义全局变量的方法
- 【文智背后的奥秘】系列篇——自动文本分类
- 图像处理学习方法及资源搜索
- android 动画的使用(小总结)
- find_first_of()和 find_last_of()
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">作用
- 小规模纳税人季度申报流程指导