自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 Evolutional based RL algorithm

Evolutional based RL algorithm1. What is GA.2. What is ES, and the different between ES and GA.3. The difference between ES and PG, and the benefits of ES over PG.4. A simple introduction to gym test suit.5. Using ES based RL algorithm to solve some simple

2020-09-20 17:18:35 227

原创 8. reduction sumation

8. reduction sumationGPU版累加:相邻两个元素相加 (ruduction)pesedu code:for(int offset=1; offset < blockdim.x; offset *=2){ if(tid%(2 * offset) == 0) { input[tid] += input[tid + offset]; }}第一代中,offset为1,间隔为2:input[0] += input[0 + 1];input[2] += in

2020-09-19 21:39:34 150

原创 7. warp divergence

7. warp divergence因为CUDA是SIMD架构,所以当一个cuda核执行选择分支时,其他非该分支的核会强制进入等待状态。int tid = threadIdx.x;if (tid % 2 == 0){ //do something}else{ //do something else}tid为奇数的设备执行if时,tid为偶数的设备拥塞。反之亦然。可见如果同一个warp中的Thread有很多分支,会导致warp divergence,这会严重降低程序的运

2020-09-18 21:22:01 368

原创 6. cuda warp

7. cuda warp在cuda中,线程块在单流多处理器上运行。当设备内存足够时,多个block可以在同一个sm上运行。SIMT(Single instruction multiple threads):一个指令多个线程执行(cuda的本质)一个线程块不能再多个SM中执行。当一个SM中不能跑一个block的时候,(共享内存溢出时), 内核发射失败,函数将返回 cudaSucess以外的值。程序结构对应的硬件结构:为什么要有warp?理论上线程并行和实际上的并行

2020-09-18 19:33:53 442

原创 5. Device property查询

5. Device property查询在cuda编程中,要想编写出适合不同计算能力的并行程序,属性查询是必学的一部分。下表给出了cudaruntime.h中的动态查询属性:PropertyExplanationnamedescreptionMajor/minor计算能力 5.2 -> 5/2totalGlobalMem总全局内存的大小maxThreadsPerBlock每个block的最大线程数maxThreadsDim[3]block

2020-09-18 15:21:13 179

原创 4. 给CUDA程序计时

4. 给CUDA程序计时通过做差的方法来实现clock start = clock() Work loadclock end = clock()difference = end - starttime = (difference / clocks_per_sec)注意:要根据实际程序的运行时间除以合理的数字给cpu计时: //summation in CPU clock_t cpu_start, cpu_end; cpu_start = clock(); sum_array

2020-09-18 14:43:52 146

原创 3.cuda 异常捕获

3.cuda 异常捕获Error分类:Compile time errors:编译出错,在visual studio中代码一打错编译器就会提示这种错误。Run time Error:在一般的c++编程中,可以用 exception handling来抛出异常,并且用try 来捕获。Error handling in CUDAcudaError cuda_function(…)return value:cudaSuccess if the kennel was launched s

2020-09-18 14:43:40 756

原创 2. CUDA实例: 两个数组的相加

2. CUDA实例: 两个数组的相加#mermaid-svg-1LkSMkqK3VtEsCqd .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-1LkSMkqK3VtEsCqd .label text{fill:#333}#mermaid-svg-1LkSMkqK3VtEsCqd .node rect,#mer

2020-09-18 14:43:27 266

原创 1. CUDA内存传输

1. CUDA内存传输cudaMemCpy(destination ptr, sourse ptrsize in byte, direction);作用:把主机的数据传到设备端.cudaMalloc: ( (void**)destination ptr, size in byte);作用: 在主机端分配内存bite_size = size * sizeof(type):其中size为数组的大小,type为数组的类型,bite_size即size in byte;sourse

2020-09-18 14:42:48 202

原创 FPGA实验三: 编译码器

FPGA实验三: 编译码器decoder:3位转换为8位encoder: 8位转换为3位codertest: 实现测试脉冲编码器真值表:decoder:assign out = (en) ? (1 << din):8'b0;encoder:always@(en or x)begin if (en) begin case(x) 8'b00000001:y = 3'b000; 8'b00000010:y = 3'b001; 8'b00000100:y

2020-08-13 10:26:59 494

原创 FPGA实验二:计数器

FPGA实验二:计数器加计数器当reset为1的时候,count清零当enable为1的时候,count开始计数count的取值范围为0~16(4位)计数器代码always@(posedge clock) \\clock函数自从芯片一开始运行就一直在运作begin if(reset == 1) \\当reset函数为1的时候把count清零 begin count <= 0; end else if(enable == 1) begin

2020-08-12 19:34:12 1449

原创 FPGA实验一: 各种门的验证

FPGA各种门的验证创建andtest类:module andtest();reg p0;reg p1;wire p2;//----Code starts here: integrated by Robei-----initial beginp0 = 0;p1 = 0;#1p0 = 1;#1p1 = 1;#1p0 = 0;#1p1 = 0;#1$finish;endinitial begin $dumpfile ("D:/FPGA/FPGA_code

2020-08-12 18:40:45 574 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除