Fabcoin Core
0.16.2
P2P Digital Currency
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
cuda
cuda
eqcuda.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <stdint.h>
4
#include <string.h>
5
#include <stdlib.h>
6
#include <stdbool.h>
7
#include <stdio.h>
8
#include <stdexcept>
9
#include <vector>
10
11
#include <cuda.h>
12
#include <cuda_runtime.h>
13
#include <device_launch_parameters.h>
14
15
#ifdef WIN32
16
#define _SNPRINTF _snprintf
17
#else
18
#define _SNPRINTF snprintf
19
#endif
20
21
#ifndef nullptr
22
#define nullptr NULL
23
#endif
24
25
26
#ifdef WIN32
27
#define rt_error std::runtime_error
28
#else
29
class
rt_error
:
public
std::runtime_error
30
{
31
public
:
32
explicit
rt_error
(
const
std::string& str) :
std
::runtime_error(str) {}
33
};
34
#endif
35
36
#define checkCudaErrors(call) \
37
do { \
38
cudaError_t err = call; \
39
if (cudaSuccess != err) { \
40
char errorBuff[512]; \
41
_SNPRINTF(errorBuff, sizeof(errorBuff) - 1, \
42
"CUDA error '%s' in func '%s' line %d", \
43
cudaGetErrorString(err), __FUNCTION__, __LINE__); \
44
throw std::runtime_error(errorBuff); \
45
} \
46
} while (0)
47
48
#define checkCudaDriverErrors(call) \
49
do { \
50
CUresult err = call; \
51
if (CUDA_SUCCESS != err) { \
52
char errorBuff[512]; \
53
_SNPRINTF(errorBuff, sizeof(errorBuff) - 1, \
54
"CUDA error DRIVER: '%d' in func '%s' line %d", \
55
err, __FUNCTION__, __LINE__); \
56
throw rt_error(errorBuff); \
57
} \
58
} while (0)
59
60
typedef
uint64_t
u64
;
61
typedef
uint32_t
u32
;
62
typedef
uint16_t
u16
;
63
typedef
uint8_t
u8
;
64
typedef
unsigned
char
uchar
;
65
66
struct
packer_default;
67
struct
packer_cantor;
68
69
70
typedef
bool (*
fn_cancel
)();
71
typedef
bool (*
fn_validate
)(std::vector<unsigned char>,
unsigned
char
*, int);
72
73
#define PROOFSIZE1 (1<<9)
74
typedef
u32
proof
[
PROOFSIZE1
];
75
struct
equi210_9;
76
struct
eq_cuda_context210_9
77
{
78
int
threadsperblock
;
79
int
totalblocks
;
80
int
device_id
;
81
int
thread_id
;
82
equi210_9*
eq
;
83
equi210_9*
device_eq
;
84
uint32_t *heap0, *
heap1
;
85
void
*
sol_memory
;
86
proof
*
solutions
;
87
88
fn_validate
m_fnValidate
;
89
fn_cancel
m_fnCancel
;
90
91
eq_cuda_context210_9
(
int
thrid,
int
devid,
fn_validate
validate,
fn_cancel
cancel);
92
~
eq_cuda_context210_9
();
93
94
bool
solve(
unsigned
char
*pblock,
unsigned
char
*header,
unsigned
int
headerlen);
95
};
96
97
98
#define MAXREALSOLS 9
99
struct
scontainerreal
{
100
u32
sols[
MAXREALSOLS
][512];
101
u32
nsols
;
102
};
103
104
template
<u32 RB, u32 SM>
struct
equi
;
105
template
<u32 RB, u32 SM, u32 SSM, u32 THREADS,
typename
PACKER>
106
class
eq_cuda_context
107
{
108
equi<RB, SM>
*
device_eq
;
109
scontainerreal
*
solutions
;
110
CUcontext
pctx
;
111
112
public
:
113
eq_cuda_context
(
int
thr_id,
int
dev_id,
fn_validate
validate,
fn_cancel
cancel);
114
void
freemem();
115
~
eq_cuda_context
();
116
117
bool
solve(
unsigned
char
*pblock,
118
unsigned
char
*header,
119
unsigned
int
headerlen);
120
121
fn_validate
m_fnValidate
;
122
fn_cancel
m_fnCancel
;
123
int
thread_id
;
124
int
device_id
;
125
int
throughput
;
126
int
totalblocks
;
127
int
threadsperblock
;
128
int
threadsperblock_digits
;
129
size_t
equi_mem_sz
;
130
u8
*
m_buf
;
131
};
132
133
// RB, SM, SSM, TPB, PACKER... but any change only here will fail..
134
#define CONFIG_MODE_1 9, 1248, 12, 640, packer_cantor
eq_cuda_context::device_eq
equi< RB, SM > * device_eq
Definition:
eqcuda.hpp:108
rt_error::rt_error
rt_error(const std::string &str)
Definition:
eqcuda.hpp:32
eq_cuda_context::threadsperblock_digits
int threadsperblock_digits
Definition:
eqcuda.hpp:128
scontainerreal
Definition:
eqcuda.hpp:99
eq_cuda_context210_9::device_id
int device_id
Definition:
eqcuda.hpp:80
uchar
unsigned char uchar
Definition:
eqcuda.hpp:64
u32
uint32_t u32
Definition:
eqcuda.hpp:61
equi
Definition:
eqcuda.hpp:104
eq_cuda_context210_9::sol_memory
void * sol_memory
Definition:
eqcuda.hpp:85
u16
uint16_t u16
Definition:
eqcuda.hpp:62
eq_cuda_context::totalblocks
int totalblocks
Definition:
eqcuda.hpp:126
eq_cuda_context::device_id
int device_id
Definition:
eqcuda.hpp:124
rt_error
Definition:
eqcuda.hpp:29
std
std::hash for asio::adress
Definition:
Common.h:323
eq_cuda_context::m_buf
u8 * m_buf
Definition:
eqcuda.hpp:130
eq_cuda_context::m_fnCancel
fn_cancel m_fnCancel
Definition:
eqcuda.hpp:122
eq_cuda_context::threadsperblock
int threadsperblock
Definition:
eqcuda.hpp:127
u64
uint64_t u64
Definition:
eqcuda.hpp:60
eq_cuda_context210_9::device_eq
equi210_9 * device_eq
Definition:
eqcuda.hpp:83
fn_validate
bool(* fn_validate)(std::vector< unsigned char >, unsigned char *, int)
Definition:
eqcuda.hpp:71
fn_cancel
bool(* fn_cancel)()
Definition:
eqcuda.hpp:70
eq_cuda_context::m_fnValidate
fn_validate m_fnValidate
Definition:
eqcuda.hpp:121
eq_cuda_context210_9::solutions
proof * solutions
Definition:
eqcuda.hpp:86
eq_cuda_context210_9::m_fnValidate
fn_validate m_fnValidate
Definition:
eqcuda.hpp:88
eq_cuda_context210_9::totalblocks
int totalblocks
Definition:
eqcuda.hpp:79
eq_cuda_context
Definition:
eqcuda.hpp:106
u8
uint8_t u8
Definition:
eqcuda.hpp:63
eq_cuda_context::solutions
scontainerreal * solutions
Definition:
eqcuda.hpp:109
eq_cuda_context::throughput
int throughput
Definition:
eqcuda.hpp:125
eq_cuda_context210_9::eq
equi210_9 * eq
Definition:
eqcuda.hpp:82
scontainerreal::nsols
u32 nsols
Definition:
eqcuda.hpp:101
proof
u32 proof[PROOFSIZE1]
Definition:
eqcuda.hpp:74
eq_cuda_context210_9::m_fnCancel
fn_cancel m_fnCancel
Definition:
eqcuda.hpp:89
eq_cuda_context::equi_mem_sz
size_t equi_mem_sz
Definition:
eqcuda.hpp:129
MAXREALSOLS
#define MAXREALSOLS
Definition:
eqcuda.hpp:98
eq_cuda_context210_9
Definition:
eqcuda.hpp:76
eq_cuda_context::pctx
CUcontext pctx
Definition:
eqcuda.hpp:110
eq_cuda_context210_9::thread_id
int thread_id
Definition:
eqcuda.hpp:81
PROOFSIZE1
#define PROOFSIZE1
Definition:
eqcuda.hpp:73
eq_cuda_context210_9::threadsperblock
int threadsperblock
Definition:
eqcuda.hpp:78
eq_cuda_context::thread_id
int thread_id
Definition:
eqcuda.hpp:123
eq_cuda_context210_9::heap1
uint32_t * heap1
Definition:
eqcuda.hpp:84
Generated on Mon Oct 22 2018 15:15:33 for Fabcoin Core by
1.8.11