AllianceDB  0.0.1
AllianceDB is an open-source suite, including benchmarks and libs for evaluating and improving stream operation algorithms on modern hardwares.
UtilityFunctions.hpp
Go to the documentation of this file.
1 
2 // Copyright (C) 2021 by the INTELLI team (https://github.com/intellistream)
3 
4 #ifndef IntelliStream_SRC_UTILS_UTILITYFUNCTIONS_HPP_
5 #define IntelliStream_SRC_UTILS_UTILITYFUNCTIONS_HPP_
6 
7 #include <string>
8 #include <experimental/filesystem>
9 #include <barrier>
10 #include <functional>
11 #include <Common/Types.h>
12 
13 
14 /* Period parameters */
15 #define N 624
16 #define M 397
17 #define MATRIX_A 0x9908b0dfUL /* constant vector a */
18 #define UPPER_MASK 0x80000000UL /* most significant w-r bits */
19 #define LOWER_MASK 0x7fffffffUL /* least significant r bits */
20 #define TRUE 1
21 #define FALSE 0
22 #include <sys/time.h>
23 namespace INTELLI {
24 typedef std::shared_ptr<std::barrier<>> BarrierPtr;
25 #define TIME_LAST_UNIT_MS 1000
26 #define TIME_LAST_UNIT_US 1000000
28 
29  public:
31 
32  static void init_genrand(unsigned long s);
33 
34  static double genrand_real3();
35 
36  static long genrand_int31(void);
37 
38  static unsigned long genrand_int32(void);
39 
40  static std::shared_ptr<std::barrier<>> createBarrier(int count);
41 
42  static void timerStart(Result &result);
43 
44  static void timerEnd(Result &result);
45 
46  static size_t timeLast(size_t past, size_t unitTime);
47  static size_t timeLastUs(struct timeval past);
48  static void printTest(char const *name, int context);
49  //bind to CPU
57  static int bind2Core(int id);
58  //partition
59  static vector<size_t> avgPartitionSizeFinal(size_t inS, std::vector<size_t> partitionWeight);
60  static vector<size_t> weightedPartitionSizeFinal(size_t inS, std::vector<size_t> partitionWeight);
61  static size_t to_periodical(size_t val, size_t period) {
62  if (val < period) {
63  return val;
64  }
65  size_t ru = val % period;
66  /* if(ru==0)
67  {
68  return period;
69  }*/
70  return ru;
71  }
72 };
73 }
74 #endif //IntelliStream_SRC_UTILS_UTILITYFUNCTIONS_HPP_
Definition: Types.h:210
Definition: UtilityFunctions.hpp:27
static int bind2Core(int id)
Definition: DatasetTool.h:10