Sha256: 8c1ed347c597477d5f1c11c7204264b4c30db30aecc4f7d49569c1f49640611f
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 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...........element/example7.c // Author.............Cedric Nugteren // Last modified on...16-April-2012 #include <stdio.h> #include <stdlib.h> // This is 'example7', demonstrating variable length arrays (C99 VLAs) int main(void) { int a,b,c; int dim_1A = 50; int dim_1B = 40; // Declare input/output arrays int in1[dim_1A][dim_1B][30]; int in2[dim_1A][dim_1B][30]; int out[dim_1A][dim_1B][30]; // Set the input data for(a=0;a<dim_1A;a++) { for(b=0;b<dim_1B;b++) { for(c=0;c<30;c++) { in1[a][b][c] = a*b+c; in2[a][b][c] = -(c/4)+6; } } } // Perform the computation #pragma scop { #pragma species kernel in1[0:dim_1A-1,0:dim_1B-1,0:29]|element ^ in2[0:dim_1A-1,0:dim_1B-1,0:29]|element -> out[0:dim_1A-1,0:dim_1B-1,0:29]|element for (a = 0; a < dim_1A; a++) { for (b = 0; b < dim_1B; b++) { for (c = 0; c < 30; c++) { out[a][b][c] = in1[a][b][c] + in2[a][b][c]; } } } #pragma species endkernel example07_k1 } #pragma endscop // Clean-up and exit the function fflush(stdout); return 0; }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bones-compiler-1.3.1 | test/examples/element/example07_species.c |