-
Notifications
You must be signed in to change notification settings - Fork 6
/
hasher.h
59 lines (45 loc) · 1.33 KB
/
hasher.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
/* Copyright (C) 2013 David G. Andersen. All rights reserved.
*
* Use of this code is covered under the Apache 2.0 license, which
* can be found in the file "LICENSE"
*/
#ifndef _CUDAHASHER_H_
#define _CUDAHASHER_H_
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string>
struct scrypt_hash {
uint32_t b[16];
uint32_t bx[16];
} __attribute__((packed));
typedef struct {
uint32_t data[20];
uint32_t target[8];
uint32_t initial_midstate[8];
} scan_job;
class CudaHasher {
public:
CudaHasher();
int Initialize();
int ComputeHashes(const scrypt_hash *in, scrypt_hash *out, int n_hashes);
~CudaHasher();
int ScanNCoins(uint32_t *pdata, const uint32_t *ptarget, int n, volatile int *stop, unsigned long *hashes_done);
int TestLoadStore();
int GetBatchSize() const { return batchsize; }
private:
uint32_t *dev_keys; // internal code is still viewing these as uint32_t blobs.
uint32_t *dev_scratch;
uint32_t *dev_output;
uint32_t *dev_tstate;
uint32_t *dev_ostate;
scan_job *dev_job;
uint32_t *scan_output;
int batchsize;
int n_blocks;
};
static const int THREADS_PER_SCRYPT_BLOCK = 4;
static const int THREADS_PER_CUDA_BLOCK = 192; // Must be a multiple of TPScB
static const int SCRYPT_SCRATCH_PER_BLOCK = (32*1024);
static const int SCRYPT_WIDTH = 16;
#endif /* _CUDAHASHER_H_ */