pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
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 <gsl/gsl_blas.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 complexity is in terms of 1
31  * parameter
32  */
33 
34 int main(int argc, char **argv) {
35 
36 
37  /* declare variables */
38  gsl_matrix *A, *B, *C;
39  double arg;
40  size_t n;
41  long long int c;
42 
43 
44  /* parse arguments */
45  if(argc != NARGS+1) {
46  return PMM_EXIT_ARGFAIL;
47  }
48  if(sscanf(argv[1], "%lf", &arg) == 0) {
49  return PMM_EXIT_ARGPARSEFAIL;
50  }
51 
52  n = (size_t)arg;
53 
54  /* calculate complexity */
55  c = 2*n*n*(long long int)n;
56 
57  /* initialise data */
58  A = gsl_matrix_alloc(n, n);
59  B = gsl_matrix_alloc(n, n);
60  C = gsl_matrix_alloc(n, n);
61 
62 
63  gsl_matrix_set_all(A, 2.5);
64  gsl_matrix_set_all(B, 4.9);
65  gsl_matrix_set_zero(C);
66 
67  /* initialise timer */
68  pmm_timer_init(c);
69 
70  /* start timer */
72 
73  /* execute routine */
74  gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, A, B, 0.0, C);
75 
76  /* stop timer */
78 
79  /* get timing result */
81 
82  /* destroy timer */
84 
85  gsl_matrix_free(A);
86  gsl_matrix_free(B);
87  gsl_matrix_free(C);
88 
89  return PMM_EXIT_SUCCESS;
90 }