📄 accumulate.br
字号:
// accumulate.br//// This test repeatedly computes b += a for two different streams. The// goal is to validate that read-modify-write works with kernels (i.e. the// same stream can be passed as an input and an output).#include <stdio.h>static void callKernel(float a<>, float b<>);kernel voidsum(float a<>, float b<>, out float c<>){ c = a + b;}static voidcallKernel(float a<>, float b<>){ sum(a, b, b);}intmain(int argc, char *argv[]){ float input_a1[100], input_b1[100], output_b1[100]; float output_b2[10][10]; float a1<100>, b1<100>; float a2<10,10>, b2<10,10>; int i, j; for (i = 0; i < 10; i++ ) { for (j = 0; j < 10; j++ ) { input_a1[10*i+j] = 0.125f*(float)(10*i+j); input_b1[10*i+j] = (float)0; } } streamRead(a1, input_a1); streamRead(a2, input_a1); streamRead(b1, input_b1); streamRead(b2, input_b1); for (i = 0; i < 12; i++ ) { callKernel(a1, b1); callKernel(a2, b2); } streamWrite(b1, output_b1); streamWrite(b2, output_b2); for (i = 0; i < 10; i++) { for (j = 0; j < 10; j++) printf( "%6.2f ", output_b1[10*i+j] ); printf("\n"); } for( i = 0; i < 10; i++ ) { for( j = 0; j < 10; j++ ) printf( "%6.2f ", output_b2[i][j] ); printf("\n"); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -