GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
lo-sysinfo.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2018 Markus Mützel
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 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 Octave is distributed in the hope that it will be useful, but
13 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 Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <sstream>
28 #include <string>
29 
30 #include "f77-fcn.h"
31 #include "lo-sysinfo.h"
32 #include "oct-shlib.h"
33 
34 // Hack to stringize macro results.
35 #define xSTRINGIZE(x) #x
36 #define STRINGIZE(x) xSTRINGIZE(x)
37 
38 namespace octave
39 {
40  namespace sys
41  {
43  {
44  dynamic_library dyn_libs ("");
45 
46  if (! dyn_libs)
47  return "unknown BLAS";
48 
50 
51  // Check for functions that are specific to certain BLAS implementations.
52 
53  // FlexiBLAS
54  typedef void (*flexi_f_type) (int*, int*, int*);
55  flexi_f_type flexi_f_ptr = reinterpret_cast<flexi_f_type>
56  (dyn_libs.search ("flexiblas_get_version"));
57 
58  if (flexi_f_ptr)
59  {
60  int v_major = 0;
61  int v_minor = 0;
62  int v_patch = 0;
63  flexi_f_ptr (&v_major, &v_minor, &v_patch);
64 
65  std::ostringstream s;
66  s << "FlexiBLAS Version "
67  << v_major << "." << v_minor << "." << v_patch;
68 
69  if (! retval.empty ())
70  retval += "\n";
71 
72  retval += s.str ();
73  }
74 
75  // OpenBLAS
76  typedef char * (*open_fcn_type) (void);
77  open_fcn_type open_f_ptr = reinterpret_cast<open_fcn_type>
78  (dyn_libs.search ("openblas_get_config"));
79 
80  if (open_f_ptr)
81  {
82  if (! retval.empty ())
83  retval += "\n";
84 
85  retval += "OpenBLAS (config: " + std::string (open_f_ptr ()) + ")";
86  }
87 
88  // GotoBLAS(2)
89  if (dyn_libs.search ("gotoblas_profile_init"))
90  {
91  if (! retval.empty ())
92  retval += "\n";
93 
94  retval += "GotoBLAS(2)";
95  }
96 
97  // ATLAS
98  // FIXME: If we are really interested, we could use a pipe to
99  // redirect the output of "ATL_buildinfo".
100  if (dyn_libs.search ("ATL_buildinfo"))
101  {
102  if (! retval.empty ())
103  retval += "\n";
104 
105  retval += "ATLAS";
106  }
107 
108  // ACML
109  typedef void (*acml_f_type) (int*, int*, int*);
110  acml_f_type acml_f_ptr = reinterpret_cast<acml_f_type>
111  (dyn_libs.search ("acmlversion"));
112 
113  if (acml_f_ptr)
114  {
115  int v_major = 0;
116  int v_minor = 0;
117  int v_patch = 0;
118  acml_f_ptr (&v_major, &v_minor, &v_patch);
119 
120  std::ostringstream s;
121  s << "ACML BLAS Version "
122  << v_major << "." << v_minor << "." << v_patch;
123 
124  if (! retval.empty ())
125  retval += "\n";
126 
127  retval += s.str ();
128  }
129 
130  // Intel MKL
131  typedef void (*mkl_f_type) (char*, int);
132  mkl_f_type mkl_f_ptr = reinterpret_cast<mkl_f_type>
133  (dyn_libs.search ("mkl_get_version_string"));
134 
135  if (mkl_f_ptr)
136  {
137  char buf[198];
138  int len = 198;
139  mkl_f_ptr (buf, len);
140 
141  if (! retval.empty ())
142  retval += "\n";
143 
144  retval += std::string (buf);
145  }
146 
147  // Otherwise
148  if (retval.empty ())
149  retval = "unknown or reference BLAS";
150 
151  return retval;
152  }
153 
155  {
156  std::string retval = "unknown LAPACK";
157 
158  dynamic_library dyn_libs ("");
159 
160  if (! dyn_libs)
161  return retval;
162 
163  // query LAPACK version
164  typedef F77_RET_T
165  (*ilaver_fcn_type) (const F77_INT&, const F77_INT&, const F77_INT&);
166  ilaver_fcn_type f_ptr = reinterpret_cast<ilaver_fcn_type>
167  (dyn_libs.search (STRINGIZE (F77_FUNC (ilaver, ILAVER))));
168 
169  if (f_ptr)
170  {
171  int v_major = 0;
172  int v_minor = 0;
173  int v_patch = 0;
174  f_ptr (v_major, v_minor, v_patch);
175 
176  std::ostringstream s;
177  s << "Linear Algebra PACKage Version "
178  << v_major << "." << v_minor << "." << v_patch;
179 
180  retval = s.str ();
181  }
182 
183  return retval;
184  }
185  }
186 }
s
Definition: file-io.cc:2729
F77_RET_T(F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, F77_CONST_CHAR_ARG_DECL, const F77_INT &, const F77_INT &, const F77_INT &, F77_INT &, F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_DBLE *, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, const F77_INT &, F77_DBLE *, F77_INT *, F77_INT &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL)
#define STRINGIZE(x)
Definition: lo-sysinfo.cc:36
octave_value retval
Definition: data.cc:6246
F77_RET_T F77_FUNC(xerbla, XERBLA)
Definition: xerbla.c:57
std::string lapack_version(void)
Definition: lo-sysinfo.cc:154
octave_f77_int_type F77_INT
Definition: f77-fcn.h:305
std::string blas_version(void)
Definition: lo-sysinfo.cc:42
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
void * search(const std::string &nm, name_mangler mangler=nullptr) const
Definition: oct-shlib.h:172