NCBI C++ ToolKit
ncbi_system.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef NCBI_SYSTEM__HPP
2 #define NCBI_SYSTEM__HPP
3 
4 /* $Id: ncbi_system.hpp 102548 2024-05-29 15:05:23Z ivanov $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author: Vladimir Ivanov
30  *
31  * File Description: System functions
32  *
33  */
34 
35 
36 #include <corelib/ncbitime.hpp>
37 #include <time.h>
38 #include <vector>
39 #include <bitset>
40 
41 #if defined(NCBI_OS_MSWIN)
42 # include <corelib/ncbi_os_mswin.hpp>
43 #endif
44 
46 
47 
48 
49 /////////////////////////////////////////////////////////////////////////////
50 ///
51 /// Process limits
52 ///
53 /// If, during the program execution, the process exceed any from limits
54 /// (see ELimitsExitCodeMemory) then:
55 /// 1) Dump info about current program's state to log-stream.
56 /// - if defined print handler "handler", then it will be used.
57 /// - if defined "parameter", it will be passed into print handler;
58 /// 2) Terminate the program.
59 /// One joint print handler for all limit types is used.
60 
61 
62 /// Code for program's exit handler.
64  eLEC_None, ///< Normal exit.
65  eLEC_Memory, ///< Memory limit.
66  eLEC_Cpu ///< CPU time usage limit.
67 };
68 
69 /// Type of parameter for print handler.
70 typedef void* TLimitsPrintParameter;
71 
72 /// Type of handler for printing a dump information after generating
73 /// any limitation event.
74 /// @attention
75 /// If you use handlers together with SetCpuLimit(), be aware!
76 /// See SetCpuLimit() for details.
77 /// @attention
78 /// The exit print handler can be registered only once at first call to
79 /// SetCpuTimeLimit() or SetMemoryLimit(), even if you don't specify handler
80 /// directly and passed it as NULL. Be aware. All subsequent attempts to set
81 /// new handler will be ignored, but limits will be changed anyway.
82 /// @sa
83 /// SetCpuTimeLimit, SetMemoryLimit
85 
86 
87 /// [UNIX only] Set memory limit.
88 ///
89 /// Set the limit for the size of used memory allocated by the process.
90 ///
91 /// @param max_size
92 /// The maximal amount of memory in bytes that can be allocated by
93 /// the process. Use the same limits for process's data segment
94 /// (including heap) and virtual memory (address space).
95 /// On 32-bit systems limit is at most 2 GiB, or this resource is unlimited.
96 /// The 0 value lift off the heap restrictions.
97 /// This value cannot exceed current hard limit set for the process.
98 /// @param handler
99 /// Pointer to a print handler used for dump output in the case of reaching
100 /// memory limit. Use default handler if passed as NULL.
101 /// @param parameter
102 /// Parameter carried into the print handler. Can be passed as NULL.
103 /// Useful if singular handler is used for setting some limits.
104 /// See also SetCpuTimeLimit().
105 /// @return
106 /// Completion status.
107 /// It returns TRUE if both, the memory limits for the data segment and
108 /// virtual memory, limitations were set. It can return FALSE if the limits
109 /// for the data segment has changed, but setting new values for
110 /// the virtual memory fails.
111 /// @note
112 /// By default it sets soft and hard memory limits to the same value.
113 /// @note
114 /// Setting a limits may not work on some systems, depends on OS, compilation
115 /// options and etc. Some systems enforce memory limits, other didn't.
116 /// Also, only privileged process can set hard memory limit.
117 /// @note
118 /// If the memory limit is reached, any subsequent memory allocations fails.
119 /// @attention
120 /// The exit print handler can be registered only once at first call to
121 /// SetCpuTimeLimit() or SetMemoryLimit(), even if you don't specify handler
122 /// directly and passed it as NULL. Be aware. All subsequent attempts to set
123 /// new handler will be ignored, but limits will be changed anyway.
124 /// @attention
125 /// if you use std::set_new_handler(), it should be called after SetMemoryLimit().
126 /// It override any memory related print handler set previously.
127 /// @sa
128 /// SetCpuTimeLimit, TLimitsPrintHandler, SetMemoryLimitSoft, SetMemoryLimitHard
130 extern bool SetMemoryLimit(size_t max_size,
132  TLimitsPrintParameter parameter = NULL);
133 
134 /// [UNIX only] Set soft memory limit.
135 /// @note
136 /// The soft limit is the value that the kernel enforces for the corresponding resource.
137 /// An unprivileged process may only set its soft limit to a value in the range
138 /// from 0 up to the hard limit, and (irreversibly) lower its hard limit.
139 /// A privileged process may make arbitrary changes to either limit value.
140 /// @sa SetMemoryLimit, SetMemoryLimitHard
142 extern bool SetMemoryLimitSoft(size_t max_size,
144  TLimitsPrintParameter parameter = NULL);
145 
146 /// [UNIX only] Set hard memory limit.
147 /// @note
148 /// The hard limit acts as a ceiling for the soft limit:
149 /// Current soft memory limit will be automatically decreased,
150 /// if it exceed new value for the hard memory limit.
151 /// @note
152 /// Only privileged process can increase current hard level limit.
153 /// @sa SetMemoryLimit, SetMemoryLimitSoft
155 extern bool SetMemoryLimitHard(size_t max_size,
157  TLimitsPrintParameter parameter = NULL);
158 
159 
160 /// [UNIX only] Get "soft" memory limit of the virtual memory (address space)
161 /// in bytes for a current process.
162 ///
163 /// @return
164 /// Returns "soft" value set by setrlimit(), SetMemoryLimit() or ulimit command
165 /// line utility for virtual memory address space.
166 /// 0 - if an error occurs and CNcbiError is set, or the memory limit is set to "unlimited".
167 /// @note
168 /// The implementation of malloc() can be different on many flavors of UNIX, and we
169 /// usually don't know how exactly it is implemented on the current system.
170 /// Some systems use sbrk()-based implementation (heap), other use mmap() system call
171 /// and virtual memory (address space) to allocate memory, some other use hybrid approach
172 /// and may allocate memory in two different ways depending on requested memory size
173 /// and certain parameters.
174 /// Almost all modern Unix versions uses mmap()-based approach for all memory allocations
175 /// or at least for big chunks of memory, so probably virtual memory limits is more
176 /// important nowadays.
177 /// @sa SetMemoryLimit, GetVirtualMemoryLimitHard
179 extern size_t GetVirtualMemoryLimitSoft(void);
180 
181 /// [UNIX only] Get "hard" memory limit of the virtual memory (address space)
182 /// in bytes for a current process.
183 ///
184 /// @return
185 /// Returns "hard" value set by setrlimit(), SetMemoryLimit() or ulimit command
186 /// line utility for virtual memory address space.
187 /// 0 - if an error occurs and CNcbiError is set, or the memory limit is set to "unlimited".
188 /// @note
189 /// The implementation of malloc() can be different on many flavors of UNIX, and we
190 /// usually don't know how exactly it is implemented on the current system.
191 /// Some systems use sbrk()-based implementation (heap), other use mmap() system call
192 /// and virtual memory (address space) to allocate memory, some other use hybrid approach
193 /// and may allocate memory in two different ways depending on requested memory size
194 /// and certain parameters.
195 /// Almost all modern Unix versions uses mmap()-based approach for all memory allocations
196 /// or at least for big chunks of memory, so probably virtual memory limits is more
197 /// important nowadays.
198 /// @sa SetMemoryLimit, GetVirtualMemoryLimitSoft
200 extern size_t GetVirtualMemoryLimitHard(void);
201 
202 
203 /// [UNIX only] Set CPU time usage limit.
204 ///
205 /// Set the limit for the CPU time that can be consumed by current process.
206 ///
207 /// @param max_cpu_time
208 /// The maximal amount of seconds of CPU time can be consumed by the process.
209 /// The 0 value lifts off the CPU time restrictions if allowed to do so.
210 /// For multi-threaded applications this can be a sum of time for all threads
211 /// (OS dependent).
212 /// @param terminate_delay_time
213 /// The time in seconds that the process will have to terminate itself after
214 /// receiving a signal about exceeding CPU usage limit. After that it can
215 /// be killed by OS.
216 /// @param handler
217 /// Pointer to a print handler used for dump output in the case of reaching
218 /// CPU usage limit. Use default handler if passed as NULL.
219 /// Note, that default handler is not async-safe (see attention below),
220 /// and can lead to coredump and application crash instead of program
221 /// termination, so use it on your own risk.
222 /// @param parameter
223 /// Parameter carried into the print handler. Can be passed as NULL.
224 /// @return
225 /// Completion status.
226 /// @note
227 /// Setting a low CPU time limit cannot be generally undone to a value
228 /// higher than "max_cpu_time + terminate_delay_time" at a later time.
229 /// @attention
230 /// The exit print handler can be registered only once at first call to
231 /// SetCpuTimeLimit() or SetMemoryLimit(), even if you don't specify handler
232 /// directly and passed it as NULL! Be aware. All subsequent attempts to set
233 /// new handler will be ignored, but limits will be changed anyway.
234 /// @attention
235 /// Only async-safe library functions and system calls can be used in
236 /// the print handler. For example, you cannot use C++ streams (cout/cerr)
237 /// and printf() calls here, but write() is allowed... You can find a list
238 /// of such functions in the C++ documentation (see man, Internet and etc).
239 /// Also, avoid to alter any shared (global) variables, except that are
240 /// declared to be of storage class and type "volatile sig_atomic_t".
241 /// @sa SetMemoryLimit, TLimitsPrintHandler
243 extern bool SetCpuTimeLimit(unsigned int max_cpu_time,
244  unsigned int terminate_delay_time,
246  TLimitsPrintParameter parameter = NULL);
247 
248 /// Verify that the CPU, where an application run, is compatible with flags it compiled for.
249 /// Right now it checks on SSE 4.2 only.
250 ///
251 /// @param message
252 /// Optional pointer to a string that will receive a description
253 /// of the problem if function returns FALSE.
254 /// @return
255 /// TRUE if CPU is compatible and application can run on it, FALSE otherwise.
257 bool VerifyCpuCompatibility(string* message = nullptr /* out */);
258 
259 
260 
261 /////////////////////////////////////////////////////////////////////////////
262 ///
263 /// CCpuFeatures --
264 ///
265 /// Uses the cpuid intrinsic to get information about CPU extended
266 /// instruction set support.
267 
269 {
270 public:
271  /// CPU vendor -- very limited list
272  enum EVendor {
275  eOther
276  };
277  static EVendor Vendor (void) { return IS().m_Vendor; }
278  static string VendorStr(void) { return IS().m_VendorStr; }
279  static string BrandStr (void) { return IS().m_BrandStr; }
280 
281  static bool SSE3 (void) { return IS().f01_ECX_[0]; }
282  static bool PCLMULQDQ (void) { return IS().f01_ECX_[1]; }
283  static bool MONITOR (void) { return IS().f01_ECX_[3]; }
284  static bool SSSE3 (void) { return IS().f01_ECX_[9]; }
285  static bool FMA (void) { return IS().f01_ECX_[12]; }
286  static bool CMPXCHG16B (void) { return IS().f01_ECX_[13]; }
287  static bool SSE41 (void) { return IS().f01_ECX_[19]; }
288  static bool SSE42 (void) { return IS().f01_ECX_[20]; }
289  static bool MOVBE (void) { return IS().f01_ECX_[22]; }
290  static bool POPCNT (void) { return IS().f01_ECX_[23]; }
291  static bool AES (void) { return IS().f01_ECX_[25]; }
292  static bool XSAVE (void) { return IS().f01_ECX_[26]; }
293  static bool OSXSAVE (void) { return IS().f01_ECX_[27]; }
294  static bool AVX (void) { return IS().f01_ECX_[28]; }
295  static bool F16C (void) { return IS().f01_ECX_[29]; }
296  static bool RDRAND (void) { return IS().f01_ECX_[30]; }
297 
298  static bool MSR (void) { return IS().f01_EDX_[5]; }
299  static bool CX8 (void) { return IS().f01_EDX_[8]; }
300  static bool SEP (void) { return IS().f01_EDX_[11]; }
301  static bool CMOV (void) { return IS().f01_EDX_[15]; }
302  static bool CLFSH (void) { return IS().f01_EDX_[19]; }
303  static bool MMX (void) { return IS().f01_EDX_[23]; }
304  static bool FXSR (void) { return IS().f01_EDX_[24]; }
305  static bool SSE (void) { return IS().f01_EDX_[25]; }
306  static bool SSE2 (void) { return IS().f01_EDX_[26]; }
307 
308  static bool FSGSBASE (void) { return IS().f07_EBX_[0]; }
309  static bool BMI1 (void) { return IS().f07_EBX_[3]; }
310  static bool HLE (void) { return IS().isIntel() && IS().f07_EBX_[4]; }
311  static bool AVX2 (void) { return IS().f07_EBX_[5]; }
312  static bool BMI2 (void) { return IS().f07_EBX_[8]; }
313  static bool ERMS (void) { return IS().f07_EBX_[9]; }
314  static bool INVPCID (void) { return IS().f07_EBX_[10]; }
315  static bool RTM (void) { return IS().isIntel() && IS().f07_EBX_[11]; }
316  static bool AVX512F (void) { return IS().f07_EBX_[16]; }
317  static bool RDSEED (void) { return IS().f07_EBX_[18]; }
318  static bool ADX (void) { return IS().f07_EBX_[19]; }
319  static bool AVX512PF (void) { return IS().f07_EBX_[26]; }
320  static bool AVX512ER (void) { return IS().f07_EBX_[27]; }
321  static bool AVX512CD (void) { return IS().f07_EBX_[28]; }
322  static bool SHA (void) { return IS().f07_EBX_[29]; }
323 
324  static bool PREFETCHWT1 (void) { return IS().f07_ECX_[0]; }
325 
326  static bool LAHF (void) { return IS().f81_ECX_[0]; }
327  static bool LZCNT (void) { return IS().isIntel() && IS().f81_ECX_[5]; }
328  static bool ABM (void) { return IS().isAMD() && IS().f81_ECX_[5]; }
329  static bool SSE4a (void) { return IS().isAMD() && IS().f81_ECX_[6]; }
330  static bool XOP (void) { return IS().isAMD() && IS().f81_ECX_[11]; }
331  static bool TBM (void) { return IS().isAMD() && IS().f81_ECX_[21]; }
332 
333  static bool SYSCALL (void) { return IS().isIntel() && IS().f81_EDX_[11]; }
334  static bool MMXEXT (void) { return IS().isAMD() && IS().f81_EDX_[22]; }
335  static bool RDTSCP (void) { return IS().isIntel() && IS().f81_EDX_[27]; }
336  static bool _3DNOWEXT (void) { return IS().isAMD() && IS().f81_EDX_[30]; }
337  static bool _3DNOW (void) { return IS().isAMD() && IS().f81_EDX_[31]; }
338 
339  /// Print human-readable list of supported and not supported CPU features.
340  /// Could be useful for debug purposes.
341  static void Print(void);
342 
343 private:
345  {
346  public:
347  InstructionSet(void);
348 
349  bool isAMD(void) const { return m_Vendor == eAMD; }
350  bool isIntel(void) const { return m_Vendor == eIntel; }
351 
353  string m_VendorStr;
354  string m_BrandStr;
355  bitset<32> f01_ECX_;
356  bitset<32> f01_EDX_;
357  bitset<32> f07_EBX_;
358  bitset<32> f07_ECX_;
359  bitset<32> f81_ECX_;
360  bitset<32> f81_EDX_;
361  };
362  // Get an instruction set on a first usage
363  static const InstructionSet& IS(void);
364 };
365 
366 
367 
368 /////////////////////////////////////////////////////////////////////////////
369 ///
370 /// CSystemInfo --
371 ///
372 /// Return various system information.
373 /// All methods work on UNIX and Windows, unless otherwise stated.
374 
376 {
377 public:
378  /// Get actual user name for the current process.
379  /// @note
380  /// Doesn't use environment as it can be changed.
381  /// @return
382  /// Process owner user name, or empty string if it cannot be determined.
383  static string GetUserName(void);
384 
385  /// Return number of active CPUs/cores (never less than 1).
386  static unsigned int GetCpuCount(void);
387 
388  /// Return number of allowed to use CPUs/cores for the current thread.
389  /// Returns 0 if unable to get this information on the current OS, or error occurs.
390  static unsigned int GetCpuCountAllowed(void);
391 
392  /// Get system uptime in seconds.
393  /// @return
394  /// Seconds since last boot, or negative number if cannot determine it
395  /// on current platform, or on error.
396  static double GetUptime(void);
397 
398  /// Return the amount of actual/total physical memory, in bytes.
399  /// On some platforms it can be less then installed physical memory,
400  /// and represent a total usable RAM (physical RAM minus reserved and the kernel).
401  /// @return
402  /// 0, if cannot determine it on current platform, or if an error occurs.
403  static Uint8 GetTotalPhysicalMemorySize(void);
404 
405  /// Return the amount of physical memory currently available on the system ("free"), in bytes.
406  /// @return
407  /// 0, if cannot determine it on current platform, or on error.
408  static Uint8 GetAvailPhysicalMemorySize(void);
409 
410  /// Return virtual memory page size.
411  /// @return
412  /// 0, if cannot determine it on current platform, or on error.
413  static unsigned long GetVirtualMemoryPageSize(void);
414 
415  /// Return size of an allocation unit (usually it is a multiple of page size).
416  /// @return
417  /// 0, if cannot determine it on current platform, or on error.
418  static unsigned long GetVirtualMemoryAllocationGranularity(void);
419 
420  /// Get number of (statistics) clock ticks per second.
421  /// Many OS system information values use it as a size unit.
422  /// @return
423  /// 0, if cannot determine it on current platform, or on error.
424  static clock_t GetClockTicksPerSecond(void);
425 };
426 
427 
428 
429 /////////////////////////////////////////////////////////////////////////////
430 ///
431 /// System/memory information (deprecated, please use CSystemInfo class)
432 ///
433 
434 /// Get process owner actual user name
435 /// @deprecated Please use CSystemInfo::GetUserName()
436 inline NCBI_DEPRECATED
437 string GetProcessUserName(void)
438 {
439  return CSystemInfo::GetUserName();
440 }
441 
442 /// Return number of active CPUs (never less than 1).
443 /// @deprecated Please use CSystemInfo::GetCpuCount()
444 inline NCBI_DEPRECATED
445 unsigned int GetCpuCount(void)
446 {
447  return CSystemInfo::GetCpuCount();
448 }
449 
450 /// Return virtual memory page size.
451 /// @deprecated Please use CSystemInfo::GetVirtualMemoryPageSize()
452 inline NCBI_DEPRECATED
453 unsigned long GetVirtualMemoryPageSize(void)
454 {
456 }
457 
458 /// Return size of an allocation unit (usually it is a multiple of page size).
459 /// @deprecated Please use CSystemInfo::GetVirtualMemoryAllocationGranularity()
460 inline NCBI_DEPRECATED
462 {
464 }
465 
466 /// Return the amount of physical memory available in the system.
467 /// @deprecated Please use CSystemInfo::GetTotalPhysicalMemorySize()
468 inline NCBI_DEPRECATED
470 {
472 }
473 
474 /// @deprecated Please use C[Current]Process::GetMemoryUsage()
477 extern bool GetMemoryUsage(size_t* total, size_t* resident, size_t* shared);
478 
479 
480 /// @deprecated Please use C[Current]Process::GetTimes()
483 extern bool GetCurrentProcessTimes(double* user_time, double* system_time);
484 
485 
486 /// @deprecated Please use C[Current]Process::GetFileDescriptorsCount
489 extern int GetProcessFDCount(int* soft_limit = NULL, int* hard_limit = NULL);
490 
491 
492 /// [Linux only] Provides the number of threads in the current process.
493 /// @deprecated Please use C[Current]Process::GetThreadCount
496 extern int GetProcessThreadCount(void);
497 
498 
499 
500 /////////////////////////////////////////////////////////////////////////////
501 ///
502 /// Memory advise
503 ///
504 
505 
506 /// What type of data access pattern will be used for specified memory region.
507 ///
508 /// Advises the VM system that the a certain region of memory will be
509 /// accessed following a type of pattern. The VM system uses this
510 /// information to optimize work with mapped memory.
511 ///
512 /// NOTE: Works on UNIX platform only.
513 typedef enum {
514  eMADV_Normal, ///< No further special treatment -- by default
515  eMADV_Random, ///< Expect random page references
516  eMADV_Sequential, ///< Expect sequential page references
517  eMADV_WillNeed, ///< Expect access in the near future
518  eMADV_DontNeed, ///< Do not expect access in the near future
519  // Available since Linux kernel 2.6.16
520  eMADV_DoFork, ///< Do inherit across fork() -- by default
521  eMADV_DontFork, ///< Don't inherit across fork()
522  // Available since Linux kernel 2.6.32
523  eMADV_Mergeable, ///< KSM may merge identical pages
524  eMADV_Unmergeable ///< KSM may not merge identical pages -- by default
526 
527 
528 /// [UNIX only] Advise on memory usage for specified memory region.
529 ///
530 /// @param addr
531 /// Address of memory region whose usage is being advised.
532 /// Some implementation requires that the address start be page-aligned.
533 /// @param len
534 /// Length of memory region whose usage is being advised.
535 /// @param advise
536 /// Advise on expected memory usage pattern.
537 /// @return
538 /// - TRUE, if memory advise operation successful.
539 /// - FALSE, if memory advise operation not successful, or is
540 /// not supported on current platform.
541 /// @sa
542 /// EMemoryAdvise
544 extern bool MemoryAdvise(void* addr, size_t len, EMemoryAdvise advise);
545 
546 
547 
548 /////////////////////////////////////////////////////////////////////////////
549 ///
550 /// Sleep
551 ///
552 /// Suspend execution for a time.
553 ///
554 /// Sleep for at least the specified number of microsec/millisec/seconds.
555 /// Time slice restrictions are imposed by platform/OS.
556 /// On UNIX the sleep can be interrupted by a signal.
557 /// Sleep*Sec(0) have no effect (but may cause context switches).
558 ///
559 /// [UNIX & Windows]
560 
562 extern void SleepSec(unsigned long sec,
564 
566 extern void SleepMilliSec(unsigned long ml_sec,
568 
570 extern void SleepMicroSec(unsigned long mc_sec,
572 
573 
574 
575 /////////////////////////////////////////////////////////////////////////////
576 ///
577 /// Suppress Diagnostic Popup Messages
578 ///
579 
580 /// Suppress modes
582  fSuppress_System = (1<<0), ///< System errors
583  fSuppress_Runtime = (1<<1), ///< Runtime library
584  fSuppress_Debug = (1<<2), ///< Debug library
585  fSuppress_Exception = (1<<3), ///< Unhandled exceptions
589 };
590 /// Binary OR of "ESuppressSystemMessageBox"
592 
593 /// Suppress popup messages on execution errors.
594 ///
595 /// NOTE: MS Windows-specific.
596 /// Suppresses all error message boxes in both runtime and in debug libraries,
597 /// as well as all General Protection Fault messages.
600 
601 /// Prevent run of SuppressSystemMessageBox().
602 ///
603 /// NOTE: MS Windows-specific.
604 /// If this function is called, all following calls of
605 /// SuppressSystemMessageBox() will be ignored. If SuppressSystemMessageBox()
606 /// was executed before, that this function print out a critical error message.
607 /// For example can be used in CGI applications where SuppressSystemMessageBox
608 /// always calls in the CCgiApplication constructor.
609 ///
611 extern void DisableSuppressSystemMessageBox();
612 
613 
614 /// Check if system message box has been suppressed for debug library.
615 ///
616 /// NOTE: MS Windows-specific.
619 
620 
622 
623 #endif /* NCBI_SYSTEM__HPP */
CCpuFeatures –.
static string VendorStr(void)
static bool AES(void)
static bool LZCNT(void)
static bool BMI2(void)
static bool AVX512PF(void)
static bool AVX(void)
static bool CMPXCHG16B(void)
static bool MOVBE(void)
static bool _3DNOW(void)
static bool AVX512F(void)
static bool ABM(void)
static bool SSE41(void)
static bool SSSE3(void)
static bool PCLMULQDQ(void)
static bool SSE42(void)
static bool MMXEXT(void)
static bool LAHF(void)
static bool CMOV(void)
static bool RDTSCP(void)
static bool RTM(void)
static bool CLFSH(void)
static bool SSE(void)
static bool SSE2(void)
EVendor
CPU vendor – very limited list.
static bool OSXSAVE(void)
static bool CX8(void)
static bool RDSEED(void)
static bool FXSR(void)
static bool MSR(void)
static EVendor Vendor(void)
static string BrandStr(void)
static bool BMI1(void)
static bool SHA(void)
static bool AVX512CD(void)
static bool HLE(void)
static bool XSAVE(void)
static bool PREFETCHWT1(void)
static bool FSGSBASE(void)
static bool MMX(void)
static bool F16C(void)
static bool ERMS(void)
static bool SYSCALL(void)
static bool POPCNT(void)
static bool SSE3(void)
static bool AVX512ER(void)
static bool AVX2(void)
static bool XOP(void)
static bool ADX(void)
static bool MONITOR(void)
static bool SSE4a(void)
static bool SEP(void)
static bool FMA(void)
static bool TBM(void)
static bool RDRAND(void)
static bool _3DNOWEXT(void)
static bool INVPCID(void)
CSystemInfo –.
static unsigned int GetCpuCount(void)
Return number of active CPUs/cores (never less than 1).
static unsigned long GetVirtualMemoryPageSize(void)
Return virtual memory page size.
static unsigned long GetVirtualMemoryAllocationGranularity(void)
Return size of an allocation unit (usually it is a multiple of page size).
static Uint8 GetTotalPhysicalMemorySize(void)
Return the amount of actual/total physical memory, in bytes.
static string GetUserName(void)
Get actual user name for the current process.
CTime –.
Definition: ncbitime.hpp:296
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
void Print(const CCompactSAMApplication::AlignInfo &ai)
EInterruptOnSignal
Interrupt on signal mode.
Definition: ncbimisc.hpp:160
@ eRestartOnSignal
Restart operation if interrupted by a signal.
Definition: ncbimisc.hpp:162
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_DEPRECATED
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XNCBI_EXPORT
Definition: ncbi_export.h:1283
int len
mdb_mode_t mode
Definition: lmdb++.h:38
Defines MS Windows specifics for our "C++" code.
bool SetCpuTimeLimit(unsigned int max_cpu_time, unsigned int terminate_delay_time, TLimitsPrintHandler handler=NULL, TLimitsPrintParameter parameter=NULL)
[UNIX only] Set CPU time usage limit.
int TSuppressSystemMessageBox
Binary OR of "ESuppressSystemMessageBox".
void SleepMilliSec(unsigned long ml_sec, EInterruptOnSignal onsignal=eRestartOnSignal)
void * TLimitsPrintParameter
Type of parameter for print handler.
Definition: ncbi_system.hpp:70
unsigned int GetCpuCount(void)
Return number of active CPUs (never less than 1).
bool MemoryAdvise(void *addr, size_t len, EMemoryAdvise advise)
[UNIX only] Advise on memory usage for specified memory region.
EMemoryAdvise
Memory advise.
@ eMADV_WillNeed
Expect access in the near future.
@ eMADV_Mergeable
KSM may merge identical pages.
@ eMADV_Normal
No further special treatment – by default.
@ eMADV_Random
Expect random page references.
@ eMADV_DontNeed
Do not expect access in the near future.
@ eMADV_Sequential
Expect sequential page references.
@ eMADV_DoFork
Do inherit across fork() – by default.
@ eMADV_DontFork
Don't inherit across fork()
@ eMADV_Unmergeable
KSM may not merge identical pages – by default.
ESuppressSystemMessageBox
Suppress Diagnostic Popup Messages.
@ fSuppress_Debug
Debug library.
@ fSuppress_All
@ fSuppress_System
System errors.
@ fSuppress_Runtime
Runtime library.
@ fSuppress_Exception
Unhandled exceptions.
@ fSuppress_Default
void(* TLimitsPrintHandler)(ELimitsExitCode, size_t, CTime &, TLimitsPrintParameter)
Type of handler for printing a dump information after generating any limitation event.
Definition: ncbi_system.hpp:84
void DisableSuppressSystemMessageBox()
Prevent run of SuppressSystemMessageBox().
int GetProcessFDCount(int *soft_limit=NULL, int *hard_limit=NULL)
Uint8 GetPhysicalMemorySize(void)
Return the amount of physical memory available in the system.
bool SetMemoryLimitSoft(size_t max_size, TLimitsPrintHandler handler=NULL, TLimitsPrintParameter parameter=NULL)
[UNIX only] Set soft memory limit.
bool SetMemoryLimitHard(size_t max_size, TLimitsPrintHandler handler=NULL, TLimitsPrintParameter parameter=NULL)
[UNIX only] Set hard memory limit.
bool IsSuppressedDebugSystemMessageBox()
Check if system message box has been suppressed for debug library.
ELimitsExitCode
Process limits.
Definition: ncbi_system.hpp:63
@ eLEC_None
Normal exit.
Definition: ncbi_system.hpp:64
@ eLEC_Cpu
CPU time usage limit.
Definition: ncbi_system.hpp:66
@ eLEC_Memory
Memory limit.
Definition: ncbi_system.hpp:65
size_t GetVirtualMemoryLimitHard(void)
[UNIX only] Get "hard" memory limit of the virtual memory (address space) in bytes for a current proc...
bool SetMemoryLimit(size_t max_size, TLimitsPrintHandler handler=NULL, TLimitsPrintParameter parameter=NULL)
[UNIX only] Set memory limit.
bool GetCurrentProcessTimes(double *user_time, double *system_time)
bool GetMemoryUsage(size_t *total, size_t *resident, size_t *shared)
bool VerifyCpuCompatibility(string *message=nullptr)
Verify that the CPU, where an application run, is compatible with flags it compiled for.
size_t GetVirtualMemoryLimitSoft(void)
[UNIX only] Get "soft" memory limit of the virtual memory (address space) in bytes for a current proc...
void SuppressSystemMessageBox(TSuppressSystemMessageBox mode=fSuppress_Default)
Suppress popup messages on execution errors.
void SleepMicroSec(unsigned long mc_sec, EInterruptOnSignal onsignal=eRestartOnSignal)
string GetProcessUserName(void)
System/memory information (deprecated, please use CSystemInfo class)
int GetProcessThreadCount(void)
[Linux only] Provides the number of threads in the current process.
unsigned long GetVirtualMemoryAllocationGranularity(void)
Return size of an allocation unit (usually it is a multiple of page size).
unsigned long GetVirtualMemoryPageSize(void)
Return virtual memory page size.
void SleepSec(unsigned long sec, EInterruptOnSignal onsignal=eRestartOnSignal)
Sleep.
Defines: CTimeFormat - storage class for time format.
Modified on Sun Jul 21 04:13:11 2024 by modify_doxy.py rev. 669887