pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
dgemm2.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 2
27 
28 /*
29  * this version of the dgemm benchmark is for the multiplciation of two
30  * matrices where their sizes are transpositions of eachother. I.e. if
31  * Matrix A's size is MxN, then Matrix B's size is NxM and their product
32  * will give a matrix of size MxM
33  */
34 int main(int argc, char **argv) {
35 
36 
37  /* declare variables */
38  gsl_matrix *A, *B, *C;
39  double arg[NARGS];
40  size_t m, 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])) == 0 ||
49  sscanf(argv[2], "%lf", &(arg[1])) == 0) {
50  return PMM_EXIT_ARGPARSEFAIL;
51  }
52 
53  m = (size_t)arg[0];
54  n = (size_t)arg[1];
55 
56  /* calculate complexity */
57  c = 2*m*n*(long long int)m;
58 
59  /* initialise data */
60  A = gsl_matrix_alloc(m, n);
61  B = gsl_matrix_alloc(n, m);
62  C = gsl_matrix_alloc(m, m);
63 
64 
65  gsl_matrix_set_all(A, 2.5);
66  gsl_matrix_set_all(B, 4.9);
67  gsl_matrix_set_zero(C);
68 
69  /* initialise timer */
70  pmm_timer_init(c);
71 
72  /* start timer */
74 
75  /* execute routine */
76  gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, A, B, 0.0, C);
77 
78  /* stop timer */
80 
81  /* get timing result */
83 
84  /* destroy timer */
86 
87  gsl_matrix_free(A);
88  gsl_matrix_free(B);
89  gsl_matrix_free(C);
90 
91  return PMM_EXIT_SUCCESS;
92 }