pmm
1.0.0
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
routines
cblas
cblas_dgemm.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
#include <stdlib.h>
21
#include <stdio.h>
22
#include "
pmm_util.h
"
23
//#include <gsl/gsl_matrix.h>
24
#include <cblas.h>
25
26
#define NARGS 1
27
28
/*
29
* this version of the dgemm benchmark is for the multiplciation of two square
30
* matrices of the same exact size, i.e. the complexit is in terms of 1
31
* parameter
32
*/
33
34
int
main
(
int
argc,
char
**argv) {
35
36
37
/* declare variables */
38
double
*a, *b, *c;
39
double
arg;
40
size_t
n;
41
unsigned
int
i;
42
long
long
complexity;
43
44
45
/* parse arguments */
46
if
(argc !=
NARGS
+1) {
47
return
PMM_EXIT_ARGFAIL
;
48
}
49
if
(sscanf(argv[1],
"%lf"
, &arg) == 0) {
50
return
PMM_EXIT_ARGPARSEFAIL
;
51
}
52
53
n = (size_t)arg;
54
55
/* calculate complexity */
56
complexity = 2*n*n*(
long
long)n;
57
58
/* initialise data */
59
a = malloc(n*n *
sizeof
*a);
60
b = malloc(n*n *
sizeof
*b);
61
c = malloc(n*n *
sizeof
*c);
62
63
64
for
(i=0; i<n*n; i++) {
65
a[i] = 2.0;
66
b[i] = 1.0;
67
c[i] = 0.0;
68
}
69
70
/* initialise timer */
71
pmm_timer_init
(complexity);
72
73
/* start timer */
74
pmm_timer_start
();
75
76
/* execute routine */
77
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, n, n, n, 1.0,
78
a, n, b, n, 0.0, c, n);
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
free(a);
90
free(b);
91
free(c);
92
93
return
PMM_EXIT_SUCCESS
;
94
}
Generated on Fri Apr 5 2013 18:25:32 for pmm by
1.8.1.2