Sha256: b7b5ef3dd08e5d74e6f80c97bcc569b90cd509f2ff67cc26b2986b0110cf1d9a

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 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/example6.c
// Author.............Cedric Nugteren
// Last modified on...16-April-2012
//

#include <stdio.h>
#include <stdlib.h>

// This is 'example6', demonstrating dynamically sized arrays, a dynamically sized kernel, and a classification including variables
int main(void) {
	int i;
	int N = 2048*2048;
	
	// Declare input/output arrays
	int *A = (int *)malloc(N*sizeof(int));
	int *B = (int *)malloc(N*sizeof(int));
	
	// Set the input data
	for(i=0;i<N;i++) {
		A[i] = i;
	}
	
	// Perform the computation
	#pragma scop
	{
		#pragma species kernel A[0:N-1]|element -> B[0:N-1]|element
		for (i = 0; i < N; i++) {
			B[i] = A[i] + 3;
		}
		#pragma species endkernel example06_k1
	}
	#pragma endscop
	
	// Clean-up and exit the function
	free(A);
	free(B);
	fflush(stdout);
	return 0;
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bones-compiler-1.3.1 test/examples/element/example06_species.c