Sha256: 04eb8a78979f323cfcbbc7bf85fb4743f75d9b065b39ec8ce6cc63fa251d4bbf

Contents?: true

Size: 1.17 KB

Versions: 2

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...........chunk/example4.c
// Author.............Cedric Nugteren
// Last modified on...16-April-2012
//

#include <stdio.h>
#define SIZE 1024

// This is 'example4', a basic element to chunk example with an if-statement in the body
int main(void) {
	int i;
	int threshold = 19;
	
	// Declare input/output arrays
	char A[SIZE];
	char B[SIZE*2];
	
	// Set the input data
	for(i=0;i<SIZE;i++) {
		A[i] = i%100;
	}
	
	// Set the output data to zero
	for(i=0;i<SIZE*2;i++) {
		B[i] = 0;
	}
	
	// Perform the computation
	#pragma species kernel 0:SIZE-1|element -> 0:SIZE*2-1|chunk(0:1)
	for(i=0;i<SIZE;i++) {
		B[i*2] = A[i];
		if (A[i] > threshold) {
			B[i*2+1] = A[i];
		}
		else {
			B[i*2+1] = 0;
		}
	}
	#pragma species endkernel example4
	
	// Clean-up and exit the function
	fflush(stdout);
	return 0;
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bones-compiler-1.3.1 examples/chunk/example04.c
bones-compiler-1.1.0 examples/chunk/example4.c