Sha256: 5c443baec90629f43f7014712f48739f2c2773ca7b17f461f78e4846814c018c

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 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/example05.c
// Author.............Cedric Nugteren
// Last modified on...08-October-2013
//

#include <stdio.h>

// This is 'example05', like example02 but with constant values.
int main(void) {
	int i,j;
	
	// Declare input/output arrays
	int A[2048][1024];
	int B[2048][1024];
	int C[2048][1024];
	
	// Set the input data
	for(i=0;i<2048;i++) {
		for(j=0;j<1024;j++) {
			A[i][j] = i+j;
		}
	}
	
	// Perform the computation
	#pragma species kernel A[0:2047,0:1023]|element -> B[0:2047,0:1023]|element
	for(i=0;i<2048;i++) {
		for(j=0;j<1024;j++) {
			B[i][j] = A[i][j] + 3;
		}
	}
	#pragma species endkernel example05-part1
	#pragma species kernel A[0:2047,0:979]|element -> C[0:2047,0:979]|element
	for(i=0;i<2048;i++) {
		for(j=0;j<980;j++) {
			C[i][j] = 9*A[i][j];
		}
	}
	#pragma species endkernel example05-part2
	
	// Clean-up and exit the function
	fflush(stdout);
	C[8][9] = C[8][9];
	return 0;
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bones-compiler-1.3.1 examples/fusion/example05.c