Debian Codegraph @

src/atlas/library/Library.h

raw
1 /*
2 * (C) Copyright 2013 ECMWF.
3 *
4 * This software is licensed under the terms of the Apache Licence Version 2.0
5 * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6 * In applying this licence, ECMWF does not waive the privileges and immunities
7 * granted to it by virtue of its status as an intergovernmental organisation
8 * nor does it submit to any jurisdiction.
9 */
10
11 #pragma once
12
13 #include <iosfwd>
14 #include <memory>
15 #include <string>
16
17 #include "eckit/filesystem/PathName.h"
18 #include "eckit/system/Library.h"
19 #include "eckit/system/Plugin.h"
20
21 namespace eckit {
22 class Parametrisation;
23 class PathName;
24 } // namespace eckit
25
26 namespace atlas {
27
28 namespace mpi {
29 void finalise();
30 void finalize();
31 } // namespace mpi
32
33 void initialise(int argc, char** argv);
34 void initialize(int argc, char** argv);
35 void initialise();
36 void initialize();
37 void finalise();
38 void finalize();
39
40 //----------------------------------------------------------------------------------------------------------------------
41
42 class Library : public eckit::system::Library {
43 public:
44 static Library& instance();
45
46 virtual std::string version() const override;
47
48 virtual std::string gitsha1(unsigned int count) const override;
49 std::string gitsha1() const { return gitsha1(7); }
50
51 void initialise(int argc, char** argv);
52 void initialise(const eckit::Parametrisation&);
53 void initialise();
54 void finalise();
55
56 struct Information {
57 friend std::ostream& operator<<(std::ostream& s, const Information& i) {
58 i.print(s);
59 return s;
60 }
61 void print(std::ostream&) const;
62 };
63 Information information() const { return Information(); }
64
65 virtual eckit::Channel& infoChannel() const;
66 virtual eckit::Channel& warningChannel() const;
67 virtual eckit::Channel& traceChannel() const;
68 virtual eckit::Channel& debugChannel() const override;
69 bool trace() const { return trace_; }
70 virtual bool debug() const override { return debug_; }
71
72 bool traceBarriers() const { return trace_barriers_; }
73 bool traceMemory() const { return trace_memory_; }
74
75 Library();
76
77 void registerPlugin(eckit::system::Plugin&);
78 void deregisterPlugin(eckit::system::Plugin&);
79 const std::vector<eckit::system::Plugin*>& plugins() { return plugins_; }
80
81 std::string cachePath() const;
82 std::string dataPath() const;
83
84 std::string linalgDenseBackend() const;
85 std::string linalgSparseBackend() const;
86 std::string linalgFFTBackend() const;
87
88 void registerDataPath(const std::string&);
89
90 protected:
91 virtual const void* addr() const override;
92
93 bool initialized_{false};
94 bool debug_{false};
95 bool info_{true};
96 bool warning_{true};
97 bool trace_{false};
98 bool trace_memory_{false};
99 bool trace_barriers_{false};
100 bool trace_report_{false};
101 mutable std::unique_ptr<eckit::Channel> info_channel_;
102 mutable std::unique_ptr<eckit::Channel> warning_channel_;
103 mutable std::unique_ptr<eckit::Channel> trace_channel_;
104 mutable std::unique_ptr<eckit::Channel> debug_channel_;
105
106 private:
107 std::vector<eckit::system::Plugin*> plugins_;
108 mutable std::vector<std::string> data_paths_;
109 size_t atlas_io_trace_hook_;
110 };
111
112 using Atlas = Library;
113
114 //----------------------------------------------------------------------------------------------------------------------
115
116 } // namespace atlas