spla
Loading...
Searching...
No Matches
library.hpp
Go to the documentation of this file.
1/**********************************************************************************/
2/* This file is part of spla project */
3/* https://github.com/SparseLinearAlgebra/spla */
4/**********************************************************************************/
5/* MIT License */
6/* */
7/* Copyright (c) 2023 SparseLinearAlgebra */
8/* */
9/* Permission is hereby granted, free of charge, to any person obtaining a copy */
10/* of this software and associated documentation files (the "Software"), to deal */
11/* in the Software without restriction, including without limitation the rights */
12/* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell */
13/* copies of the Software, and to permit persons to whom the Software is */
14/* furnished to do so, subject to the following conditions: */
15/* */
16/* The above copyright notice and this permission notice shall be included in all */
17/* copies or substantial portions of the Software. */
18/* */
19/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
20/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
21/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
22/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
23/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
24/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
25/* SOFTWARE. */
26/**********************************************************************************/
27
28#ifndef SPLA_LIBRARY_HPP
29#define SPLA_LIBRARY_HPP
30
31#include "config.hpp"
32
33#include <memory>
34#include <string>
35#include <unordered_map>
36
37namespace spla {
38
48 class Library final {
49 public:
52
53 Library(const Library&) = delete;
54 Library(Library&&) = delete;
55
66 SPLA_API void finalize();
67
80
88 SPLA_API Status set_platform(int index);
89
97 SPLA_API Status set_device(int index);
98
107
116
123
133
139 SPLA_API Status get_accelerator_info(std::string& info);
140
151
157
162 class Registry* get_registry();
163
168 class Dispatcher* get_dispatcher();
169
174 class Logger* get_logger();
175
181
192 SPLA_API static Library* get();
193
194 private:
195 std::unordered_map<std::string, std::string> m_env;
196 std::unique_ptr<class Accelerator> m_accelerator;
197 std::unique_ptr<class Registry> m_registry;
198 std::unique_ptr<class Dispatcher> m_dispatcher;
199 std::unique_ptr<class Logger> m_logger;
200 std::unique_ptr<class TimeProfiler> m_time_profiler;
201 bool m_force_no_acc = false;
202 };
203
208}// namespace spla
209
210#endif//SPLA_LIBRARY_HPP
Types of supported accelerators for computations.
Callback function called on library message event.
Status of library operation execution.
Interface for an computations acceleration backend.
Definition accelerator.hpp:58
Class responsible for dispatching of execution of a single task.
Definition dispatcher.hpp:58
Library global state automatically instantiated on lib init.
Definition library.hpp:48
Status set_queues_count(int count)
Set number of GPU queues for parallel ops execution.
Definition library.cpp:136
class Dispatcher * get_dispatcher()
Definition library.cpp:206
bool is_set_force_no_acceleration()
Definition library.cpp:171
Status set_platform(int index)
Selects platform for computations for current accelerator.
Definition library.cpp:128
Status set_device(int index)
Selects device for computations for current accelerator.
Definition library.cpp:132
Status time_profile_dump()
Dumps to default output current time profile.
Definition library.cpp:184
Status time_profile_reset()
Reset current time profile.
Definition library.cpp:191
class Logger * get_logger()
Definition library.cpp:210
Library(const Library &)=delete
Status set_default_callback()
Sets default library callback to log messages to console.
Definition library.cpp:146
class TimeProfiler * get_time_profiler()
Definition library.cpp:214
Status get_accelerator_info(std::string &info)
Get acc info in a form of a string.
Definition library.cpp:175
Status set_force_no_acceleration(bool value)
Sets option to force cpu only usage without acceleration.
Definition library.cpp:165
static Library * get()
Access global library instance.
Definition library.cpp:218
class Registry * get_registry()
Definition library.cpp:202
Status set_message_callback(MessageCallback callback)
Set callback function called on library message event.
Definition library.cpp:140
Library(Library &&)=delete
Library()
Definition library.cpp:70
class Accelerator * get_accelerator()
Definition library.cpp:198
Status set_accelerator(AcceleratorType accelerator)
Set accelerator to be used in library computations.
Definition library.cpp:106
void finalize()
Finalize library execution.
Definition library.cpp:97
Library logger.
Definition logger.hpp:48
Registry with key-algo mapping of stored algo implementations.
Definition registry.hpp:78
Scope-based time profiler to measure perf of schedule tasks execution.
Definition time_profiler.hpp:70
#define SPLA_API
Definition config.hpp:43
Definition algorithm.hpp:37