3 * Copyright (C) 2019 Samsung Electronics
4 * Copyright (C) 2019 MyungJoo Ham <myungjoo.ham@samsung.com>
5 * Copyright (C) 2019 Dongju Chae <dongju.chae@samsung.com>
10 * @brief Internal API to access global configuration of NPU Engine.
11 * @see https://code.sec.samsung.net/confluence/display/ODLC/2020+Overall+Software+Stack
12 * @author MyungJoo Ham <myungjoo.ham@samsung.com>
13 * @author Dongju Chae <dongju.chae@samsung.com>
14 * @bug No known bugs except for NYI items
21 #include <iniparser.h>
26 #define MAX_DIR_LEN 256
28 #define ENV_NUM_THREADS "NE_NUM_THREADS"
29 #define ENV_RESV_MEM_SIZE "NE_RESV_MEM_SIZE"
30 #define ENV_LOG_DIR "NE_LOG_DIR"
31 #define ENV_LOG_LEVEL "NE_LOG_LEVEL"
33 #define ENV_PREFIX_SHARE "NE_PREFIX_SHARE"
34 #define ENV_PREFIX_PROFILE "NE_PREFIX_PROFILE"
36 #define ENV_MUTE_STDOUT "NE_MUTE_STDOUT"
38 /** @brief Configuration for NPU-Engine components */
41 static Conf &getInstance (const char *inipath = nullptr);
43 uint32_t getNumThreads (bool is_default = false) const;
44 size_t getResvMemSize (bool is_default = false) const;
45 const char *getLogDir (bool is_default = false) const;
46 uint32_t getLogLevel (bool is_default = false) const;
47 const char *getPrefixShare (bool is_default = false) const;
48 const char *getPrefixProfile (bool is_default = false) const;
49 bool getMuteStdout (bool is_default = false) const;
54 static std::unique_ptr<Conf> instance_;
55 static std::once_flag once_flag_;
59 void loadConf (const char *inipath);
60 void loadConfIni (dictionary *ini);
61 void loadConfDefault ();
62 void loadConfEnvvar ();
64 void setNumThreads (const char *str);
65 void setResvMemSize (const char *str);
66 void setPrefixShare (const char *str);
67 void setPrefixProfile (const char *str);
68 void setLogDir (const char *str);
69 void setLogLevel (const char *str);
70 void setLayerDump (const char *str);
71 void setMuteStdout (bool mute_stdout) { mute_stdout_ = mute_stdout; }
73 uint32_t num_threads_;
74 /**< NE_NUM_THREADS, [main] num_threads, the number of threads in thread pool */
75 size_t reserved_mem_size_;
76 /**< NE_RESV_MEM_SIZE, [main] resv_mem_size, the size of memory reserved */
77 char prefix_share_[MAX_DIR_LEN];
78 /**< NE_PREFIX_SHARE, [main] prefix_share, the path where share directory is located */
79 char prefix_profile_[MAX_DIR_LEN];
80 /**< NE_PREFIX_PROFILE, [main] prefix_profile, the path where profile data is created */
81 char log_dir_[MAX_DIR_LEN];
82 /**< NE_LOG_DIR, [debug] log_dir, the path where log files are created */
84 /**< NE_LOG_LEVEL, [debug] log_level, maximum log level to print log messages to stderr */
86 /**< NE_MUTE_STDOUT, [sim] mute_stdout, ignore any stdout messages from simulator */
89 #endif /* __NE_CONF_H__ */