File: Bench.xs

package info (click to toggle)
pdl 1%3A2.025-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,768 kB
  • sloc: perl: 43,919; fortran: 13,113; ansic: 9,366; makefile: 37; sh: 32; sed: 6
file content (58 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download | duplicates (11)
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
57
58
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif

MODULE = PDL::Bench		PACKAGE = PDL::Bench

void
c_use_pp(sv)
	SV *sv;
	CODE:
	/* Let's hope the C compiler isn't smart enough to optimize
	 * away everything
	 */
	double *p = (double *) SvPV(sv,PL_na);
	int i = SvCUR(sv) / sizeof(double);
	while(i--) {
		(*p)++; p++;
	}

void
c_use_add(sv1,sv2,sv3)
	SV *sv1;
	SV *sv2;
	SV *sv3;
	CODE:
	double *p1 = (double *) SvPV(sv1,PL_na);
	int i = SvCUR(sv1) / sizeof(double);
	double *p2 = (double *) SvPV(sv2,PL_na);
	double *p3 = (double *) SvPV(sv3,PL_na);
	while(i--) {
		*p1 = *p2 + *p3;
		p1 ++; p2 ++; p3 ++;
	}

void
c_use_add_incr(sv1,sv2,sv3,i1,i2,i3)
	SV *sv1;
	SV *sv2;
	SV *sv3;
	int i1;
	int i2;
	int i3;
	CODE:
	double *p1 = (double *) SvPV(sv1,PL_na);
	int i = SvCUR(sv1) / sizeof(double);
	double *p2 = (double *) SvPV(sv2,PL_na);
	double *p3 = (double *) SvPV(sv3,PL_na);
	while(i--) {
		*p1 = *p2 + *p3;
		p1 += i1; p2 += i2; p3 += i3;
	}