pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
dgemm3.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 3
27 
28 /*
29  * this version of the dgemm benchmark is for the multiplciation of two
30  * matrices where their sizes are uninhibited. As a result the
31  * complexity of the routine is dependent on 3 input paramateres
32  */
33 int main(int argc, char **argv) {
34 
35 
36  /* declare variables */
37  gsl_matrix *A, *B, *C;
38  double arg[NARGS];
39  size_t m, n, k;
40  long long c;
41  int i;
42 
43 
44  /* parse arguments */
45  if(argc != NARGS+1) {
46  return PMM_EXIT_ARGFAIL;
47  }
48  for(i=0; i<NARGS; i++) {
49  if(sscanf(argv[i+1], "%lf", &arg[i]) == 0) {
50  return PMM_EXIT_ARGPARSEFAIL;
51  }
52  }
53 
54  m = (size_t)arg[0];
55  n = (size_t)arg[1];
56  k = (size_t)arg[2];
57 
58  /* calculate complexity */
59  c = 2*m*n*(long long)k;
60 
61  /* initialise data */
62  A = gsl_matrix_alloc(m, n);
63  B = gsl_matrix_alloc(n, k);
64  C = gsl_matrix_alloc(m, k);
65 
66 
67  gsl_matrix_set_all(A, 2.5);
68  gsl_matrix_set_all(B, 4.9);
69  gsl_matrix_set_zero(C);
70 
71  /* initialise timer */
72  pmm_timer_init(c);
73 
74  /* start timer */
76 
77  /* execute routine */
78  gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0, A, B, 0.0, C);
79 
80  /* stop timer */
82 
83  /* get timing result */
85 
86  /* destroy timer */
88 
89  gsl_matrix_free(A);
90  gsl_matrix_free(B);
91  gsl_matrix_free(C);
92 
93  return PMM_EXIT_SUCCESS;
94 }