
gpu计算
JennyBi
这个作者很懒,什么都没留下…
展开
-
第一章 起步——串行程序
dist_v1/main.cpp#include <math.h>#include "stdlib.h"#define N 64float scale(int i, int n){ return ((float)i / (n - 1));}float distance(float x1, float x2){ return sqrt((x2 - x1)*(x...原创 2018-07-29 22:35:30 · 615 阅读 · 0 评论 -
第二章 CUDA基础知识
2.1 CUDA并行模式从串行到CUDA并行同时涉及硬件和软件两方面。硬件的转换涉及包含了多个运算单元以及运算规划和数据传输机制的芯片。软件的转换涉及API以及对编程语言的扩展。主机:CPU和内存设备:GPU和显存CUDA芯片结构:CUDA引用了单指令多线程(SIMT)的并行模式。CUDA GPU包含了大量的基础计算单元,这些单元被称为核(core),每一个核包...原创 2018-07-29 23:36:46 · 876 阅读 · 0 评论 -
第三章 从循环到网络
3.1 并行化dist_v1#include <stdio.h>#include "stdlib.h"#define N 64#define TPB 32//每个线程块包含32个线程__device__ float scale(int i, int n){ return ((float)i / (n - 1));}__device__ float dis...原创 2018-07-30 14:50:01 · 251 阅读 · 0 评论 -
4.3 stability应用程序
在4.2 flashlight基础上的改进kernel.h#pragma once#ifndef KERNEL_H#define KERNEL_Hstruct uchar4;struct int2;void kernelLauncher(uchar4 *d_out, int w, int h, float p, int s);#endif // !KERNEL_Hk...原创 2018-08-27 12:26:13 · 334 阅读 · 0 评论 -
5.2 一维网格上的导数计算
kernel.h#pragma once#ifndef KERNEL_H#define KERNEL_Hvoid ddParallel(float *out, const float *in, int n, float h);#endif // !KERNEL_Hkernel.cu#include "kernel.h"#define TPB 64__global...原创 2018-08-28 10:54:21 · 651 阅读 · 0 评论 -
第四章 二维网格与交互式图形-4.2通过图形交互实时显示——flashlight
main.cpp #include <stdio.h>//加载合适的头文件#include <stdlib.h>#include "kernel.h"#ifdef _WIN32#define WINDOWS_LEAN_AND_MEAN#define NOMINMAX#include <windows.h>#endif // _WIN32#i...原创 2018-08-24 14:24:01 · 812 阅读 · 0 评论 -
5.3 解决二维拉普拉斯方程:heat_2d
main.cpp#include "interactions.h"#include <stdio.h>//加载合适的头文件#include <stdlib.h>#include "kernel.h"#ifdef _WIN32#define WINDOWS_LEAN_AND_MEAN#define NOMINMAX#include <windows....原创 2018-09-05 23:15:33 · 2239 阅读 · 0 评论