-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.hpp
76 lines (68 loc) · 2.1 KB
/
utils.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <memory>
#include <gmpxx.h>
enum PackType {TYPE_UNKNOWN, TYPE_MINIMAL, TYPE_COMPUTE, TYPE_COMBINE, TYPE_COMBINE2};
struct NativePQT {
mpz_class P, Q, T;
};
struct PQT {
std::shared_ptr<mpz_class> P, Q, T;
};
class ReqPack {
int id_;
int n1_;
int n2_;
PackType type_;
std::shared_ptr<mpz_class> a_, b_, c_, d_;
std::shared_ptr<mpf_class> fa_, fb_;
public:
ReqPack();
ReqPack(int id);
ReqPack(int id, int n1, int n2);
ReqPack(int id, std::shared_ptr<mpz_class> a, std::shared_ptr<mpz_class> b);
ReqPack(int id, std::shared_ptr<mpf_class> fa);
ReqPack(int id, std::shared_ptr<mpf_class> fa, std::shared_ptr<mpf_class> fb);
ReqPack(int id, std::shared_ptr<mpz_class> a, std::shared_ptr<mpz_class> b, std::shared_ptr<mpz_class> c, std::shared_ptr<mpz_class> d);
int GetID();
int GetN1();
int GetN2();
PackType GetType();
std::shared_ptr<mpz_class> Geta();
std::shared_ptr<mpz_class> Getb();
std::shared_ptr<mpz_class> Getc();
std::shared_ptr<mpz_class> Getd();
std::shared_ptr<mpf_class> Getfa();
std::shared_ptr<mpf_class> Getfb();
void Invalidate();
bool IsValid();
};
class RespPack {
int id_;
int n1_;
int n2_;
std::shared_ptr<PQT> result_;
PackType type_;
std::shared_ptr<mpz_class> a_;
std::shared_ptr<mpf_class> fa_;
public:
RespPack();
RespPack(int id, int n1, int n2, std::shared_ptr<PQT> result);
RespPack(int id, std::shared_ptr<PQT> result);
RespPack(ReqPack& rp, std::shared_ptr<PQT> result);
RespPack(int id, std::shared_ptr<mpz_class> a);
RespPack(ReqPack& rp, std::shared_ptr<mpz_class> a);
RespPack(ReqPack& rp, std::shared_ptr<mpf_class> fa);
int GetID();
int GetN1();
int GetN2();
std::shared_ptr<PQT> GetResult();
PackType GetType();
std::shared_ptr<mpz_class> Geta();
std::shared_ptr<mpf_class> Getfa();
void Invalidate();
bool IsValid();
};
void ClockStart();
void ClockEnd(int ms);
void SetCpuAffinity(int cpu_no, std::thread& thread_obj);
void SetCpuAffinity(int cpu_no);
uint32_t GetBatchNum(int num_of_cores);