mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
Merge branch 'device_refactor' of https://github.com/luke-jr/cgminer into fpga
This commit is contained in:
commit
9eb3ac426b
9
adl.c
9
adl.c
@ -212,6 +212,15 @@ void init_adl(int nDevs)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!gpus[gpu].enabled) {
|
||||
gpus[i].gpu_engine =
|
||||
gpus[i].gpu_memclock =
|
||||
gpus[i].gpu_vddc =
|
||||
gpus[i].gpu_fan =
|
||||
gpus[i].gpu_powertune = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
gpus[gpu].has_adl = true;
|
||||
/* Flag adl as active if any card is successfully activated */
|
||||
adl_active = true;
|
||||
|
12
api.c
12
api.c
@ -387,7 +387,7 @@ void gpustatus(int gpu, bool isjson)
|
||||
#endif
|
||||
gt = gv = gm = gc = ga = gf = gp = pt = 0;
|
||||
|
||||
if (gpu_devices[gpu])
|
||||
if (cgpu->enabled)
|
||||
enabled = (char *)YES;
|
||||
else
|
||||
enabled = (char *)NO;
|
||||
@ -662,13 +662,13 @@ void gpuenable(SOCKETTYPE c, char *param, bool isjson)
|
||||
return;
|
||||
}
|
||||
|
||||
if (gpu_devices[id]) {
|
||||
if (gpus[id].enabled) {
|
||||
strcpy(io_buffer, message(MSG_ALRENA, id, isjson));
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < gpu_threads; i++) {
|
||||
gpu = thr_info[i].cgpu->cpu_gpu;
|
||||
gpu = thr_info[i].cgpu->device_id;
|
||||
if (gpu == id) {
|
||||
thr = &thr_info[i];
|
||||
if (thr->cgpu->status != LIFE_WELL) {
|
||||
@ -676,7 +676,7 @@ void gpuenable(SOCKETTYPE c, char *param, bool isjson)
|
||||
return;
|
||||
}
|
||||
|
||||
gpu_devices[id] = true;
|
||||
gpus[id].enabled = true;
|
||||
tq_push(thr->q, &ping);
|
||||
|
||||
}
|
||||
@ -705,12 +705,12 @@ void gpudisable(SOCKETTYPE c, char *param, bool isjson)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gpu_devices[id]) {
|
||||
if (!gpus[id].enabled) {
|
||||
strcpy(io_buffer, message(MSG_ALRDIS, id, isjson));
|
||||
return;
|
||||
}
|
||||
|
||||
gpu_devices[id] = false;
|
||||
gpus[id].enabled = false;
|
||||
|
||||
strcpy(io_buffer, message(MSG_GPUDIS, id, isjson));
|
||||
}
|
||||
|
82
miner.h
82
miner.h
@ -208,9 +208,35 @@ struct gpu_adl {
|
||||
};
|
||||
#endif
|
||||
|
||||
struct cgpu_info;
|
||||
struct thr_info;
|
||||
struct work;
|
||||
|
||||
struct device_api {
|
||||
char*name;
|
||||
|
||||
// API-global functions
|
||||
void (*api_detect)();
|
||||
|
||||
// Device-specific functions
|
||||
void (*reinit_device)(struct cgpu_info*);
|
||||
void (*get_statline)(char*, struct cgpu_info*);
|
||||
|
||||
// Thread-specific functions
|
||||
bool (*thread_prepare)(struct thr_info*);
|
||||
uint64_t (*can_limit_work)(struct thr_info*);
|
||||
bool (*thread_init)(struct thr_info*);
|
||||
void (*free_work)(struct thr_info*, struct work*);
|
||||
bool (*prepare_work)(struct thr_info*, struct work*);
|
||||
uint64_t (*scanhash)(struct thr_info*, struct work*, uint64_t);
|
||||
void (*thread_shutdown)(struct thr_info*);
|
||||
};
|
||||
|
||||
struct cgpu_info {
|
||||
int is_gpu;
|
||||
int cpu_gpu;
|
||||
int cgminer_id;
|
||||
struct device_api *api;
|
||||
int device_id;
|
||||
bool enabled;
|
||||
int accepted;
|
||||
int rejected;
|
||||
int hw_errors;
|
||||
@ -221,6 +247,8 @@ struct cgpu_info {
|
||||
char init[40];
|
||||
struct timeval last_message_tv;
|
||||
|
||||
int threads;
|
||||
|
||||
bool dynamic;
|
||||
int intensity;
|
||||
#ifdef HAVE_ADL
|
||||
@ -257,6 +285,7 @@ struct thr_info {
|
||||
pthread_t pth;
|
||||
struct thread_q *q;
|
||||
struct cgpu_info *cgpu;
|
||||
void *cgpu_data;
|
||||
struct timeval last;
|
||||
struct timeval sick;
|
||||
|
||||
@ -352,57 +381,62 @@ extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
|
||||
extern char *bin2hex(const unsigned char *p, size_t len);
|
||||
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
|
||||
|
||||
extern unsigned int ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
|
||||
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone, uint32_t nonce);
|
||||
|
||||
extern unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
|
||||
typedef bool (*sha256_func)(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone, uint32_t nonce);
|
||||
uint32_t max_nonce,
|
||||
uint32_t *last_nonce,
|
||||
uint32_t nonce);
|
||||
|
||||
extern unsigned int scanhash_sse2_amd64(int, const unsigned char *pmidstate,
|
||||
extern bool ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
|
||||
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone);
|
||||
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
|
||||
|
||||
extern bool scanhash_via(int, unsigned char *data_inout,
|
||||
extern bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
|
||||
|
||||
extern bool scanhash_via(int, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
|
||||
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
|
||||
|
||||
extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
|
||||
unsigned char *hash1, unsigned char *hash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
|
||||
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
|
||||
|
||||
extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
|
||||
unsigned char *hash1, unsigned char *hash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
|
||||
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
|
||||
|
||||
extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
|
||||
unsigned char *hash1, unsigned char *hash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done, uint32_t nonce);
|
||||
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
|
||||
|
||||
extern int scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
|
||||
extern bool scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce);
|
||||
|
||||
extern int scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
|
||||
extern bool scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce);
|
||||
|
||||
extern int scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
|
||||
extern bool scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce);
|
||||
|
||||
extern int
|
||||
@ -431,6 +465,7 @@ extern bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, flo
|
||||
extern void api(void);
|
||||
|
||||
#define MAX_GPUDEVICES 16
|
||||
#define MAX_DEVICES 32
|
||||
#define MAX_POOLS (32)
|
||||
|
||||
extern int nDevs;
|
||||
@ -444,9 +479,10 @@ extern struct work_restart *work_restart;
|
||||
extern struct cgpu_info gpus[MAX_GPUDEVICES];
|
||||
extern int gpu_threads;
|
||||
extern double total_secs;
|
||||
extern bool gpu_devices[MAX_GPUDEVICES];
|
||||
extern int mining_threads;
|
||||
extern struct cgpu_info *cpus;
|
||||
extern int total_devices;
|
||||
extern struct cgpu_info *devices[];
|
||||
extern int total_pools;
|
||||
extern struct pool *pools[MAX_POOLS];
|
||||
extern const char *algo_names[];
|
||||
|
@ -101,14 +101,16 @@ static const unsigned int pSHA256InitState[8] =
|
||||
{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
|
||||
|
||||
|
||||
unsigned int ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
|
||||
bool ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce)
|
||||
{
|
||||
unsigned int *nNonce_p = (unsigned int*)(pdata + 12);
|
||||
unsigned int *nNonce_p = (unsigned int*)(pdata + 76);
|
||||
|
||||
pdata += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
@ -132,17 +134,18 @@ unsigned int ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
|
||||
((unsigned int*)phash)[i] = thash[i][j];
|
||||
|
||||
if (fulltest(phash, ptarget)) {
|
||||
*nHashesDone = nonce;
|
||||
*nNonce_p = nonce + j;
|
||||
return nonce + j;
|
||||
nonce += j;
|
||||
*last_nonce = nonce;
|
||||
*nNonce_p = nonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((nonce >= max_nonce) || work_restart[thr_id].restart)
|
||||
{
|
||||
*nHashesDone = nonce;
|
||||
return -1;
|
||||
*last_nonce = nonce;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,14 +74,16 @@ static const unsigned int pSHA256InitState[8] =
|
||||
{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
|
||||
|
||||
|
||||
unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
|
||||
bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce)
|
||||
{
|
||||
unsigned int *nNonce_p = (unsigned int*)(pdata + 12);
|
||||
unsigned int *nNonce_p = (unsigned int*)(pdata + 76);
|
||||
|
||||
pdata += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
@ -104,17 +106,18 @@ unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
|
||||
((unsigned int*)phash)[i] = thash[i][j];
|
||||
|
||||
if (fulltest(phash, ptarget)) {
|
||||
*nHashesDone = nonce;
|
||||
*nNonce_p = nonce + j;
|
||||
return nonce + j;
|
||||
nonce += j;
|
||||
*last_nonce = nonce;
|
||||
*nNonce_p = nonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((nonce >= max_nonce) || work_restart[thr_id].restart)
|
||||
{
|
||||
*nHashesDone = nonce;
|
||||
return -1;
|
||||
*last_nonce = nonce;
|
||||
return false;
|
||||
}
|
||||
|
||||
nonce += NPAR;
|
||||
|
@ -97,11 +97,13 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
|
||||
unsigned char *data,
|
||||
unsigned char *hash1, unsigned char *hash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t n)
|
||||
{
|
||||
uint32_t *hash32 = (uint32_t *) hash;
|
||||
uint32_t *nonce = (uint32_t *)(data + 12);
|
||||
uint32_t *nonce = (uint32_t *)(data + 76);
|
||||
|
||||
data += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
@ -113,12 +115,12 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
|
||||
runhash(hash, hash1, sha256_init_state);
|
||||
|
||||
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((n >= max_nonce) || work_restart[thr_id].restart) {
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -579,11 +581,13 @@ bool scanhash_asm32(int thr_id, const unsigned char *midstate,
|
||||
unsigned char *data,
|
||||
unsigned char *hash1, unsigned char *hash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t n)
|
||||
{
|
||||
uint32_t *hash32 = (uint32_t *) hash;
|
||||
uint32_t *nonce = (uint32_t *)(data + 12);
|
||||
uint32_t *nonce = (uint32_t *)(data + 76);
|
||||
|
||||
data += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
@ -595,12 +599,12 @@ bool scanhash_asm32(int thr_id, const unsigned char *midstate,
|
||||
runhash32(hash, hash1, sha256_init_state);
|
||||
|
||||
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((n >= max_nonce) || work_restart[thr_id].restart) {
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -242,13 +242,15 @@ const uint32_t sha256_init_state[8] = {
|
||||
bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
|
||||
unsigned char *hash1, unsigned char *hash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t n)
|
||||
{
|
||||
uint32_t *hash32 = (uint32_t *) hash;
|
||||
uint32_t *nonce = (uint32_t *)(data + 12);
|
||||
uint32_t *nonce = (uint32_t *)(data + 76);
|
||||
unsigned long stat_ctr = 0;
|
||||
|
||||
data += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
while (1) {
|
||||
@ -261,12 +263,12 @@ bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
|
||||
stat_ctr++;
|
||||
|
||||
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((n >= max_nonce) || work_restart[thr_id].restart) {
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -50,14 +50,14 @@ const uint32_t sha256_init[8]__attribute__((aligned(0x100))) =
|
||||
__m128i g_4sha256_k[64];
|
||||
__m128i sha256_consts_m128i[64]__attribute__((aligned(0x1000)));
|
||||
|
||||
int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
|
||||
bool scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce)
|
||||
{
|
||||
uint32_t *nNonce_p = (uint32_t *)(pdata + 12);
|
||||
uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
|
||||
uint32_t m_midstate[8], m_w[16], m_w1[16];
|
||||
__m128i m_4w[64] __attribute__ ((aligned (0x100)));
|
||||
__m128i m_4hash[64] __attribute__ ((aligned (0x100)));
|
||||
@ -65,6 +65,8 @@ int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
|
||||
__m128i offset;
|
||||
int i;
|
||||
|
||||
pdata += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
/* For debugging */
|
||||
@ -114,19 +116,20 @@ int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
|
||||
}
|
||||
|
||||
if (fulltest(phash, ptarget)) {
|
||||
*nHashesDone = nonce;
|
||||
*nNonce_p = nonce + j;
|
||||
return nonce + j;
|
||||
nonce += j;
|
||||
*last_nonce = nonce + 1;
|
||||
*nNonce_p = nonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nonce += 4;
|
||||
|
||||
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
|
||||
{
|
||||
*nHashesDone = nonce;
|
||||
return -1;
|
||||
*last_nonce = nonce;
|
||||
return false;
|
||||
}
|
||||
|
||||
nonce += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,14 @@ const uint32_t sha256_32init[8]__attribute__((aligned(0x100))) =
|
||||
__m128i g_4sha256_k[64];
|
||||
__m128i sha256_consts_m128i[64]__attribute__((aligned(0x1000)));
|
||||
|
||||
int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
|
||||
bool scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce)
|
||||
{
|
||||
uint32_t *nNonce_p = (uint32_t *)(pdata + 12);
|
||||
uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
|
||||
uint32_t m_midstate[8], m_w[16], m_w1[16];
|
||||
__m128i m_4w[64] __attribute__ ((aligned (0x100)));
|
||||
__m128i m_4hash[64] __attribute__ ((aligned (0x100)));
|
||||
@ -65,6 +65,8 @@ int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
|
||||
__m128i offset;
|
||||
int i;
|
||||
|
||||
pdata += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
/* Message expansion */
|
||||
@ -105,20 +107,21 @@ int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
|
||||
}
|
||||
|
||||
if (fulltest(phash, ptarget)) {
|
||||
*nHashesDone = nonce;
|
||||
*nNonce_p = nonce + j;
|
||||
return nonce + j;
|
||||
nonce += j;
|
||||
*last_nonce = nonce;
|
||||
*nNonce_p = nonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart)) {
|
||||
*last_nonce = nonce;
|
||||
return false;
|
||||
}
|
||||
|
||||
nonce += 4;
|
||||
|
||||
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
|
||||
{
|
||||
*nHashesDone = nonce;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,19 +49,21 @@ static uint32_t g_sha256_hinit[8] =
|
||||
|
||||
__m128i g_4sha256_k[64];
|
||||
|
||||
int scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
|
||||
bool scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *pdata,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *ptarget,
|
||||
uint32_t max_nonce, unsigned long *nHashesDone,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t nonce)
|
||||
{
|
||||
uint32_t *nNonce_p = (uint32_t *)(pdata + 12);
|
||||
uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
|
||||
uint32_t m_midstate[8], m_w[16], m_w1[16];
|
||||
__m128i m_4w[64], m_4hash[64], m_4hash1[64];
|
||||
__m128i offset;
|
||||
int i;
|
||||
|
||||
pdata += 64;
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
/* For debugging */
|
||||
@ -113,19 +115,20 @@ int scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
|
||||
}
|
||||
|
||||
if (fulltest(phash, ptarget)) {
|
||||
*nHashesDone = nonce;
|
||||
*nNonce_p = nonce + j;
|
||||
return nonce + j;
|
||||
nonce += j;
|
||||
*last_nonce = nonce;
|
||||
*nNonce_p = nonce;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nonce += 4;
|
||||
|
||||
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
|
||||
{
|
||||
*nHashesDone = nonce;
|
||||
return -1;
|
||||
*last_nonce = nonce;
|
||||
return false;
|
||||
}
|
||||
|
||||
nonce += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
12
sha256_via.c
12
sha256_via.c
@ -19,9 +19,11 @@ static void via_sha256(void *hash, void *buf, unsigned len)
|
||||
:"memory");
|
||||
}
|
||||
|
||||
bool scanhash_via(int thr_id, unsigned char *data_inout,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, unsigned long *hashes_done,
|
||||
bool scanhash_via(int thr_id, const unsigned char *pmidstate,
|
||||
unsigned char *data_inout,
|
||||
unsigned char *phash1, unsigned char *phash,
|
||||
const unsigned char *target,
|
||||
uint32_t max_nonce, uint32_t *last_nonce,
|
||||
uint32_t n)
|
||||
{
|
||||
unsigned char data[128] __attribute__((aligned(128)));
|
||||
@ -70,12 +72,12 @@ bool scanhash_via(int thr_id, unsigned char *data_inout,
|
||||
dout32[i] = swab32(data32[i]);
|
||||
}
|
||||
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((n >= max_nonce) || work_restart[thr_id].restart) {
|
||||
*hashes_done = n;
|
||||
*last_nonce = n;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user