-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathethash_cuda_miner_kernel.h
More file actions
90 lines (75 loc) · 2.1 KB
/
ethash_cuda_miner_kernel.h
File metadata and controls
90 lines (75 loc) · 2.1 KB
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
/* Blah, blah, blah.. all this pedantic nonsense to say that this
source code is made available under the terms and conditions
of the accompanying GNU General Public License */
#pragma once
#include <stdexcept>
#include <string>
#include <sstream>
#include <stdint.h>
#include <cuda_runtime.h>
// It is virtually impossible to get more than
// one solution per stream hash calculation
typedef struct {
uint32_t count;
uint32_t gid;
uint64_t mix[4];
} search_results;
#define ACCESSES 64
#define THREADS_PER_HASH (128 / 16)
typedef struct {
uint4 uint4s[32 / sizeof(uint4)];
} hash32_t;
typedef struct {
uint4 uint4s[128 / sizeof(uint4)];
} hash128_t;
typedef union {
uint32_t words[64 / sizeof(uint32_t)];
uint2 uint2s[64 / sizeof(uint2)];
uint4 uint4s[64 / sizeof(uint4)];
} hash64_t;
typedef union {
uint32_t words[200 / sizeof(uint32_t)];
uint2 uint2s[200 / sizeof(uint2)];
uint4 uint4s[200 / sizeof(uint4)];
} hash200_t;
void set_constants(
hash128_t* _dag,
uint32_t _dag_size,
hash64_t* _light,
uint32_t _light_size
);
void set_header_and_target(
hash32_t _header,
uint64_t _target
);
void run_ethash_search(
uint32_t search_batch_size,
uint32_t workgroup_size,
cudaStream_t stream,
volatile search_results* g_output,
uint64_t start_nonce,
uint32_t parallelHash
);
void ethash_generate_dag(
uint64_t dag_size,
uint32_t blocks,
uint32_t threads,
cudaStream_t stream
);
struct cuda_runtime_error : public virtual std::runtime_error {
cuda_runtime_error(std::string msg) : std::runtime_error(msg) {}
};
#define CUDA_SAFE_CALL(call) \
do { \
cudaError_t err = call; \
if (cudaSuccess != err) { \
std::stringstream ss; \
ss << "CUDA error in func " \
<< __FUNCTION__ \
<< " at line " \
<< __LINE__ \
<< ' ' \
<< cudaGetErrorString(err); \
throw cuda_runtime_error(ss.str()); \
} \
} while (0)