pmm
1.0.0
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
routines
example
example.c
Go to the documentation of this file.
1
/*
2
Copyright (C) 2008-2010 Robert Higgins
3
Author: Robert Higgins <robert.higgins@ucd.ie>
4
5
This file is part of PMM.
6
7
PMM is free software: you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
PMM is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with PMM. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
22
23
/*
24
* This file serves as a template to illustrate how a routine is to be called
25
* inside a compiled program for use with the Performance Model Manager
26
*
27
* Program accepts one integer 'problem_size' as a parameter, no more no less.
28
* This integer must be used to assign data and ultimately computations of a
29
* proportional volume.
30
*
31
* In terms of Smart/Grid/Net-Solve, the integer relates to the complexity
32
* of the routine. This program should determine the parameters with which
33
* to call the routine using this integer.
34
*/
35
36
37
#include <math.h>
38
#include <stdlib.h>
39
#include <stdio.h>
40
#include "
pmm_util.h
"
41
42
#define NARGS 1
43
44
int
main
(
int
argc,
char
**argv) {
45
long
long
complexity;
46
47
/* declare variables */
48
double
a;
49
double
b;
50
double
c;
51
double
i;
52
53
/* parse arguments */
54
if
(argc !=
NARGS
+1) {
55
return
PMM_EXIT_ARGFAIL
;
56
}
57
if
(sscanf(argv[1],
"%lf"
, &i) == 0) {
58
return
PMM_EXIT_ARGPARSEFAIL
;
59
}
60
61
/* calculate complexity */
62
complexity = 2*(
long
long)i;
63
64
/* initialise data */
65
a = M_PI;
66
b = M_E;
67
68
/* initialise timer */
69
pmm_timer_init
(complexity);
70
71
/* start timer */
72
pmm_timer_start
();
73
74
/* execute routine */
75
while
(i>0.0) {
76
c = a * b;
77
i = i - 1.0;
78
}
79
80
/* stop timer */
81
pmm_timer_stop
();
82
83
/* get timing result */
84
pmm_timer_result
();
85
86
/* destroy timer */
87
pmm_timer_destroy
();
88
89
return
PMM_EXIT_SUCCESS
;
90
}
Generated on Fri Apr 5 2013 18:25:32 for pmm by
1.8.1.2