File: test_BLAS.cpp

package info (click to toggle)
cgal 3.6.1-2
  • links: PTS
  • area: non-free
  • in suites: squeeze
  • size: 62,184 kB
  • ctags: 95,782
  • sloc: cpp: 453,758; ansic: 96,821; sh: 226; makefile: 120; xml: 2
file content (85 lines) | stat: -rw-r--r-- 2,443 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2007  INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Installation/config/support/test_BLAS.cpp $
//
// Author(s)     : Laurent Saboret

// Test if BLAS is available

// blaswrap.h maps CBLAS function names to BLAS standard Fortran interface.
#ifdef CGAL_USE_CBLASWRAP
  #ifndef CGAL_USE_F2C
    #define CGAL_USE_F2C
  #endif
  #include <blaswrap.h>
#endif

#include <iostream>
#include <cassert>

extern "C" {
  // Fortran interface (taken from www.netlib.org/clapack)...
  void dgemm_(char* transa, char* transb, int* m,
              int* n, int* k,
              double* alpha,
              double* a, int* lda, double* b, int* ldb,
              double* beta,
              double* c, int* ldc);
  // ... or C interface (taken from AMD Core Math Library)
  void dgemm (char transa, char transb, int m,
              int n, int k,
              double alpha,
              double* a, int lda, double* b, int ldb,
              double beta,
              double* c, int ldc);
}

namespace CGAL { namespace BLAS {

inline
void dgemm (char* transa, char* transb, int* m,
            int* n, int* k,
            double* alpha,
            double* a, int* lda, double* b, int* ldb,
            double* beta,
            double* c, int* ldc)
{
#ifdef CGAL_USE_F2C
  ::dgemm_(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc);
#else
  ::dgemm (*transa, *transb, *m, *n, *k, *alpha, a, *lda, b, *ldb, *beta, c, *ldc);
#endif
}

} }

int main()
{
  char S[2] = "N";
  double A = 2.0;
  double B = 3.0;
  double C = 5.0;
  double alpha = 7.0;
  double beta  = 11.0;
  int n = 1;
  int ld = 1;

  CGAL::BLAS::dgemm(S,S, &n,&n,&n, &alpha, &A,&ld, &B,&ld, &beta, &C,&ld);
  assert(C == 97.0);

  std::cout << "ok for BLAS" << std::endl;

  return 0;
}