summaryrefslogtreecommitdiff
path: root/math.c
blob: d6fc7985708c367c76790a98d95898c21db84730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <math.h>
#include <stdint.h>

#define __rpcc __builtin_alpha_rpcc

#define CPML "cpml"
#define GLIBC "glibc"

#ifndef FUNCTION
#error Must define FUNCTION
#else
double FUNCTION(double);
#endif

#ifndef DOMAIN_START
#error Must define RANGE_START
#endif

#ifndef DOMAIN_END
#error Must define DOMAIN_END
#endif

#ifndef INCREMENT
#define INCREMENT 0.1
#endif

int main(int argc, char * argv[]) {
	double x;
	double results[100];
	int i;
	int iterations;

	uint64_t start, end;

	start = __rpcc();

	for (i = 0, x = DOMAIN_START; x < DOMAIN_END; i++, x += INCREMENT) {
		results[i] = FUNCTION(x);
	}

	end = __rpcc();

	iterations = i;

	if (argc != 1) {
		for (i = 0; i < iterations; i++) {
			printf("%f\n", results[i]);
		}
	}

/*	printf("%5s\t%5s\t%lu\n", LIB_NAME, FUNCTION_NAME, (end - start) / 30);*/
	printf("%lu,", (end - start) / iterations);

	return 0;
}