Sha256: f1b82f16941731c207a46b4c54ba8abf881645af710921da4f1a49b93ff8b966

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

//
// This file is part of the Bones source-to-source compiler examples. For more
// information on Bones please 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...........benchmark/saxpy.c
// Author.............Cedric Nugteren
// Last modified on...09-Aug-2012
//

#include <stdio.h>
#include <stdlib.h>
#define N 2048*2048

// This is 'saxpy', a scalar multiplication and vector addition kernel
int main(void) {
	int i;
	
	// Declare arrays on the stack
	float x[N];
	float y[N];
	
	// Set the input data
	for (i=0; i<N; i++) {
		x[i] = i*1.4;
		y[i] = i/0.9;
	}
	
	// Set the constants
	float a = 411.3;
	
	// Perform the computation (y := ax+y)
	#pragma scop
	#pragma species kernel 0:N-1|element ^ 0:N-1|element -> 0:N-1|element
	for (i=0; i<N; i++) {
		y[i] = a*x[i] + y[i];
	}
	#pragma species endkernel saxpy
	#pragma endscop
	
	// 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.6.0 examples/benchmarks/other/saxpy.c
bones-compiler-1.3.1 examples/benchmarks/other/saxpy.c