-
Notifications
You must be signed in to change notification settings - Fork 27
/
algorithm.h
142 lines (130 loc) · 3.6 KB
/
algorithm.h
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef ALGORITHM_H
#define ALGORITHM_H
#ifdef __APPLE_CC__
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>
#endif
#include <inttypes.h>
#include <stdbool.h>
#include "ocl/build_kernel.h" // For the build_kernel_data type
typedef enum {
ALGO_MTP,
ALGO_HEAVYHASH,
ALGO_UNK,
ALGO_ALLIUM,
ALGO_ALLIUM_NAVI,
ALGO_CRE,
ALGO_SCRYPT,
ALGO_NSCRYPT,
ALGO_PASCAL,
ALGO_X11,
ALGO_0X10,
ALGO_0X10_NAVI,
ALGO_X13,
ALGO_X14,
ALGO_X15,
ALGO_X22I,
ALGO_X25X,
ALGO_KECCAK,
ALGO_QUARK,
ALGO_TWE,
ALGO_FUGUE,
ALGO_NIST,
ALGO_FRESH,
ALGO_WHIRL,
ALGO_NEOSCRYPT,
ALGO_NEOSCRYPT_XAYA,
ALGO_NEOSCRYPT_NAVI,
ALGO_NEOSCRYPT_XAYA_NAVI,
ALGO_WHIRLPOOLX,
ALGO_LYRA2RE,
ALGO_LYRA2REV2,
ALGO_LYRA2REV3,
ALGO_LYRA2Z,
ALGO_LYRA2Z_NAVI,
ALGO_LYRA2ZZ,
ALGO_LYRA2H,
ALGO_PLUCK,
ALGO_YESCRYPT,
ALGO_YESCRYPT_MULTI,
ALGO_YESCRYPT_NAVI,
ALGO_YESCRYPTR16,
ALGO_YESCRYPTR16_NAVI,
ALGO_BLAKECOIN,
ALGO_BLAKE,
ALGO_SIA,
ALGO_DECRED,
ALGO_VANILLA,
ALGO_ETHASH,
ALGO_LBRY,
ALGO_PHI,
ALGO_PHI2,
ALGO_PHI2_NAVI,
ALGO_SIBCOIN,
ALGO_ARGON2D
} algorithm_type_t;
extern const char *algorithm_type_str[];
extern void gen_hash(const unsigned char *data, unsigned int len, unsigned char *hash);
struct __clState;
struct _dev_blk_ctx;
struct _build_kernel_data;
struct cgpu_info;
struct work;
/* Describes the Scrypt parameters and hashing functions used to mine
* a specific coin.
*/
typedef struct _algorithm_t {
char name[20]; /* Human-readable identifier */
algorithm_type_t type; //algorithm type
const char *kernelfile; /* alternate kernel file */
uint32_t n; /* N (CPU/Memory tradeoff parameter) */
uint8_t nfactor; /* Factor of N above (n = 2^nfactor) */
double diff_multiplier1;
double diff_multiplier2;
double share_diff_multiplier;
uint32_t xintensity_shift;
uint32_t intensity_shift;
uint32_t found_idx;
unsigned long long diff_numerator;
uint32_t diff1targ;
size_t n_extra_kernels;
long rw_buffer_size;
cl_command_queue_properties cq_properties;
void(*regenhash)(struct work *);
void(*calc_midstate)(struct work *);
void(*prepare_work)(struct _dev_blk_ctx *, uint32_t *, uint32_t *);
cl_int(*queue_kernel)(struct __clState *, struct _dev_blk_ctx *, cl_uint);
void(*gen_hash)(const unsigned char *, unsigned int, unsigned char *);
void(*set_compile_options)(struct _build_kernel_data *, struct cgpu_info *, struct _algorithm_t *);
} algorithm_t;
typedef struct _algorithm_settings_t
{
const char *name;
algorithm_type_t type;
const char *kernelfile;
double diff_multiplier1;
double diff_multiplier2;
double share_diff_multiplier;
uint32_t xintensity_shift;
uint32_t intensity_shift;
uint32_t found_idx;
unsigned long long diff_numerator;
uint32_t diff1targ;
size_t n_extra_kernels;
long rw_buffer_size;
cl_command_queue_properties cq_properties;
void (*regenhash)(struct work *);
void (*calc_midstate)(struct work *);
void (*prepare_work)(struct _dev_blk_ctx *, uint32_t *, uint32_t *);
cl_int (*queue_kernel)(struct __clState *, struct _dev_blk_ctx *, cl_uint);
void (*gen_hash)(const unsigned char *, unsigned int, unsigned char *);
void (*set_compile_options)(build_kernel_data *, struct cgpu_info *, algorithm_t *);
} algorithm_settings_t;
/* Set default parameters based on name. */
void set_algorithm(algorithm_t* algo, const char* name);
/* Set to specific N factor. */
void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor);
/* Compare two algorithm parameters */
bool cmp_algorithm(const algorithm_t* algo1, const algorithm_t* algo2);
#endif /* ALGORITHM_H */