Sha256: bb9484b0e9653fd682819bcc3da679db53487c5d474c85f43dcd8ecce2a8e12e

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 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...........shared/example5.c
// Author.............Cedric Nugteren
// Last modified on...07-May-2012
//

#include <stdio.h>

// This is 'example5', demonstrating an inner-loop only classification of a reduction to scalar
int main(void) {
	int a,b,c;
	
	// Declare input/output arrays
	float in[16][16];
	float out[1];
	
	// Set the input data
	out[0] = -1;
	for(a=0;a<16;a++) {
		for(b=0;b<16;b++) {
			in[a][b] = 1.001;
		}
	}
	
	// Perform the computation
	for(a=0;a<16;a++) {
	#pragma scop
	{
		#pragma species kernel out[0:0]|full ^ in[a:a,0:a]|element -> out[0:0]|shared
		for (b = 0; b <= a; b++) {
			out[0] = out[0] - in[a][b] * in[a][b];
		}
		#pragma species endkernel example05_k1
	}
	#pragma endscop
		out[0] = 1.002;
	}
	
	// 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/shared/example05_species.c