]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/ublas/benchmarks/mm_prod.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / numeric / ublas / benchmarks / mm_prod.cpp
1 //
2 // Copyright (c) 2018 Stefan Seefeld
3 // All rights reserved.
4 //
5 // This file is part of Boost.uBLAS. It is made available under the
6 // Boost Software License, Version 1.0.
7 // (Consult LICENSE or http://www.boost.org/LICENSE_1_0.txt)
8
9 #include <boost/numeric/ublas/matrix.hpp>
10 #include <boost/program_options.hpp>
11 #include "prod.hpp"
12 #include <complex>
13 #include <string>
14
15 namespace po = boost::program_options;
16 namespace ublas = boost::numeric::ublas;
17 namespace bm = boost::numeric::ublas::benchmark;
18
19 template <typename T>
20 void benchmark(std::string const &type)
21 {
22 using matrix = ublas::matrix<T, ublas::basic_row_major<>>;
23 bm::prod<matrix(matrix, matrix)> p("prod(matrix<" + type + ">)");
24 p.run(std::vector<long>({1, 2, 4, 8, 16, 32, 64, 128, 256, 512}));//, 1024}));
25 }
26
27 int main(int argc, char **argv)
28 {
29 po::variables_map vm;
30 try
31 {
32 po::options_description desc("Matrix product\n"
33 "Allowed options");
34 desc.add_options()("help,h", "produce help message");
35 desc.add_options()("type,t", po::value<std::string>(), "select value-type (float, double, fcomplex, dcomplex)");
36
37 po::store(po::parse_command_line(argc, argv, desc), vm);
38 po::notify(vm);
39
40 if (vm.count("help"))
41 {
42 std::cout << desc << std::endl;
43 return 0;
44 }
45 }
46 catch(std::exception &e)
47 {
48 std::cerr << "error: " << e.what() << std::endl;
49 return 1;
50 }
51 std::string type = vm.count("type") ? vm["type"].as<std::string>() : "float";
52 if (type == "float")
53 benchmark<float>("float");
54 else if (type == "double")
55 benchmark<double>("double");
56 else if (type == "fcomplex")
57 benchmark<std::complex<float>>("std::complex<float>");
58 else if (type == "dcomplex")
59 benchmark<std::complex<double>>("std::complex<double>");
60 else
61 std::cerr << "unsupported value-type \"" << vm["type"].as<std::string>() << '\"' << std::endl;
62 }