diff options
| author | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.001@gmail.com> | 2026-09-15 08:16:43 +0800 |
| commit | 4022e5c95210631e4aceb08eaf9d9071aa5aefc4 (patch) | |
| tree | a5922559836e45fb3459a3d070367912e1035b1a /tests/performance/13_stencil1.sy | |
| download | rcc-4022e5c95210631e4aceb08eaf9d9071aa5aefc4.tar.gz rcc-4022e5c95210631e4aceb08eaf9d9071aa5aefc4.tar.xz | |
Diffstat (limited to 'tests/performance/13_stencil1.sy')
| -rw-r--r-- | tests/performance/13_stencil1.sy | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/performance/13_stencil1.sy b/tests/performance/13_stencil1.sy new file mode 100644 index 0000000..4e7e16e --- /dev/null +++ b/tests/performance/13_stencil1.sy @@ -0,0 +1,63 @@ +const int width = 1024; +const int height = 1024; +int image_in[width * height]; +int image_out[width * height]; + +int cutout(int val){ + if(val < 0){ + val = 0; + } + else{ + if(val > 255){ + val = 255; + } + } + return val; +} + +int main(){ + int i; + int j; + int num = getarray(image_in); + + starttime(); + j = 1; + while(j < width - 1){ + i = 1; + while(i < height - 1){ + int im1jm1 =(i-1)*width + j-1; + int im1j =(i-1)*width + j; + int im1jp1 =(i-1)*width + j+1; + int ijm1 =(i )*width + j-1; + int ij =(i )*width + j; + int ijp1 =(i )*width + j+1; + int ip1jm1 =(i+1)*width + j-1; + int ip1j =(i+1)*width + j; + int ip1jp1 =(i+1)*width + j+1; + int val = 8*image_in[ij] - image_in[im1jm1] - image_in[im1j] - image_in[im1jp1] -image_in[ijm1] - image_in[ijp1] - image_in[ip1jm1] - image_in[ip1j] - image_in[ip1jp1]; + + image_out[i*width + j] = cutout(val); + i = i + 1; + } + j = j + 1; + } + + i = 0; + while(i < height){ + image_out[i * width] = image_in[i * width]; + image_out[i * width + width - 1] = image_in[i * width + width - 1]; + i = i + 1; + } + + j = 0; + while(j < width){ + image_out[j] = image_in[j]; + image_out[(height - 1) * width + j] = image_in[(height - 1) * width + j]; + j = j + 1; + } + + stoptime(); + + putarray(width * height, image_out); + return num; +}
\ No newline at end of file |
