Sha256: b84462dde3ee344578092f6103544773aa809ea98f33f2fa133da285f7c1fe8b
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
// // This file is part of the Bones source-to-source compiler examples. This C-code // example is meant to illustrate the use of Bones. For more information on Bones // use the contact information below. // // == More information on Bones // Contact............Cedric Nugteren <c.nugteren@tue.nl> // Web address........http://parse.ele.tue.nl/bones/ // // == File information // Filename...........fusion/example04.c // Author.............Cedric Nugteren // Last modified on...02-Oct-2013 // #include <stdio.h> // This is 'example04', with code similar to PolyBench's "atax" benchmark int main(void) { int i,j; // Declare arrays on the stack float A[4096][4096]; float x[4096]; float y[4096]; float tmp[4096]; // Set the input data for (i=0; i<4096; i++) { x[i] = i*3.14159; } for (i=0; i<4096; i++) { for (j=0; j<4096; j++) { A[i][j] = ((float) i*(j+1)) / 4096; } } // Perform the computation (y := A'Ax) #pragma species kernel 0:4095,0:4095|chunk(0:0,0:4095) ^ 0:4095|full -> 0:4095|element for (i=0; i<4096; i++) { tmp[i] = 0; for (j=0; j<4096; j++) { tmp[i] = tmp[i] + A[i][j] * x[j]; } } #pragma species endkernel atax-part1 #pragma species kernel 0:4095,0:4095|chunk(0:4095,0:0) ^ 0:4095|full -> 0:4095|element for (j=0; j<4096; j++) { y[j] = 0; for (i=0; i<4096; i++) { y[j] = y[j] + A[i][j] * tmp[i]; } } #pragma species endkernel atax-part2 // Clean-up and exit the function fflush(stdout); y[9] = y[9]; return 0; }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bones-compiler-1.3.1 | examples/fusion/example04.c |