Sha256: b6a34458b77f50a84cfc3dd692f078f7a01f8988e7215e2ad7bfe776a9cad9a1

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

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

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

// This is 'example9', demonstrating a for-loop that does not start at zero
int main(void) {
	int i;
	int result;
	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 species kernel 2:N-1|element -> 2:N-1|element
	for(i=2;i<N;i++) {
		result = A[i] + 3;
		B[i] = result * 3;
	}
	#pragma species endkernel example9
	
	// Clean-up and exit the function
	free(A);
	free(B);
	fflush(stdout);
	return 0;
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bones-compiler-1.3.1 examples/element/example09.c
bones-compiler-1.1.0 examples/element/example9.c