Skip to content
Snippets Groups Projects
Select Git revision
  • 0d098851383717edfa7340d596fa0e4bbf40104c
  • master default protected
  • github/fork/hrani/master
  • github/fork/dilawar/master
  • chamcham
  • chhennapoda
  • wheel
  • 3.2.0-pre0
  • v3.1.3
  • 3.1.2
  • 3.1.1
  • chamcham-3.1.1
  • 3.1.0
  • ghevar_3.0.2_pre2
  • ghevar_3.0.2
15 results

Msg.cpp

Blame
  • config.cpp 1.44 KiB
    #include <iomanip>
    #include <ios>
    #include <sstream>
    
    #include <pybind11/pybind11.h>
    #include <pybind11/stl.h>
    
    #include <arbor/version.hpp>
    
    namespace pyarb {
    
    // Returns a python dictionary that python users can use to look up
    // which options the Arbor library was configured with at compile time.
    
    pybind11::dict config() {
        pybind11::dict dict;
    #ifdef ARB_MPI_ENABLED
        dict[pybind11::str("mpi")]     = pybind11::bool_(true);
    #else
        dict[pybind11::str("mpi")]     = pybind11::bool_(false);
    #endif
    #ifdef ARB_WITH_MPI4PY
        dict[pybind11::str("mpi4py")]  = pybind11::bool_(true);
    #else
        dict[pybind11::str("mpi4py")]  = pybind11::bool_(false);
    #endif
    #ifdef ARB_WITH_GPU
        dict[pybind11::str("gpu")]     = pybind11::bool_(true);
    #else
        dict[pybind11::str("gpu")]     = pybind11::bool_(false);
    #endif
        dict[pybind11::str("version")] = pybind11::str(ARB_VERSION);
        return dict;
    }
    
    void print_config(const pybind11::dict &d) {
        std::stringstream s;
        s << "Arbor's configuration:\n";
    
        for (auto x: d) {
            s << "     "
            << std::left << std::setw(7) << x.first << ": "
            << std::right << std::setw(10) << x.second << "\n";
        }
    
        pybind11::print(s.str());
    }
    
    // Register configuration
    void register_config(pybind11::module &m) {
    
        m.def("config", &config, "Get Arbor's configuration.")
         .def("print_config", [](const pybind11::dict& d){return print_config(d);}, "Print Arbor's configuration.");
    }
    } // namespace pyarb