forked from pooler/cpuminer
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsalsa_kernel.h
76 lines (61 loc) · 2.38 KB
/
salsa_kernel.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
#ifndef SALSA_KERNEL_H
#define SALSA_KERNEL_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int uint32_t; // define this as 32 bit type derived from int
// from salsa_kernel.cu
extern int device_map[8];
extern int device_interactive[8];
extern int device_texturecache[8];
extern int device_singlememory[8];
extern char *device_config[8];
extern char *device_name[8];
extern bool autotune;
// CUDA externals
extern int cuda_num_devices();
extern void cuda_shutdown(int thr_id);
extern int cuda_throughput(int thr_id);
extern uint32_t *cuda_transferbuffer(int thr_id, int stream);
extern void cuda_scrypt_HtoD(int thr_id, uint32_t *X, int stream, bool flush);
extern void cuda_scrypt_core(int thr_id, int stream, bool flush);
extern void cuda_scrypt_DtoH(int thr_id, uint32_t *X, int stream, bool flush);
extern void cuda_scrypt_sync(int thr_id, int stream);
extern void computeGold(uint32_t *idata, uint32_t *reference, uint32_t *V);
#ifdef __NVCC__
#include <cuda_runtime.h>
extern cudaError_t MyStreamSynchronize(cudaStream_t stream, int situation, int thr_id);
#endif
#ifdef __cplusplus
}
// If we're in C++ mode, we're either compiling .cu files or scrypt.cpp
#ifdef __NVCC__
/**
* An pure virtual interface for a CUDA kernel implementation.
* TODO: encapsulate the kernel launch parameters in some kind of wrapper.
*/
class KernelInterface
{
public:
virtual void set_scratchbuf_constants(int MAXWARPS, uint32_t** h_V) = 0;
virtual bool run_kernel(dim3 grid, dim3 threads, int WARPS_PER_BLOCK, int thr_id, cudaStream_t stream, uint32_t* d_idata, uint32_t* d_odata, int *mutex, bool interactive, bool benchmark, int texture_cache) = 0;
virtual bool bindtexture_1D(uint32_t *d_V, size_t size) = 0;
virtual bool bindtexture_2D(uint32_t *d_V, int width, int height, size_t pitch) = 0;
virtual bool unbindtexture_1D() = 0;
virtual bool unbindtexture_2D() = 0;
virtual char get_identifier() = 0;
virtual int max_warps_per_block() = 0;
virtual int get_texel_width() = 0;
};
// Define work unit size
#define WU_PER_WARP 32
#define WU_PER_BLOCK (WU_PER_WARP*WARPS_PER_BLOCK)
#define WU_PER_LAUNCH (GRID_BLOCKS*WU_PER_BLOCK)
#define SCRATCH (32768+64)
// Not performing error checking is actually bad, but...
#define checkCudaErrors(x) x
#define getLastCudaError(x)
#endif // #ifdef __NVCC__
#endif // #ifdef __cplusplus
#endif // #ifndef SALSA_KERNEL_H