static cl_int queue_whirlcoin_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads) { cl_kernel *kernel; cl_ulong le_target; cl_int status = 0; le_target = *(cl_ulong *)(blk->work->device_target + 24); flip80(clState->cldata, blk->work->data); status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL); //clbuffer, hashes kernel = &clState->kernel; CL_SET_ARG_N(0, clState->CLbuffer0); CL_SET_ARG_N(1, clState->padbuffer8); kernel = clState->extra_kernels; CL_SET_ARG_N(0, clState->padbuffer8); CL_NEXTKERNEL_SET_ARG_N(0, clState->padbuffer8); //hashes, output, target CL_NEXTKERNEL_SET_ARG_N(0, clState->padbuffer8); CL_SET_ARG_N(1, clState->outputBuffer); CL_SET_ARG_N(2, le_target); return status; }
static cl_int queue_whirlpoolx_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads) { uint64_t midblock[8], key[8] = { 0 }, tmp[8] = { 0 }; cl_ulong le_target; cl_int status; le_target = *(cl_ulong *)(blk->work->device_target + 24); flip80(clState->cldata, blk->work->data); memcpy(midblock, clState->cldata, 64); // midblock = n, key = h for (int i = 0; i < 10; ++i) { tmp[0] = WHIRLPOOL_ROUND_CONSTANTS[i]; whirlpool_round(key, tmp); tmp[0] = 0; whirlpool_round(midblock, tmp); for (int x = 0; x < 8; ++x) { midblock[x] ^= key[x]; } } for (int i = 0; i < 8; ++i) { midblock[i] ^= ((uint64_t *)(clState->cldata))[i]; } status = clSetKernelArg(clState->kernel, 0, sizeof(cl_ulong8), (cl_ulong8 *)&midblock); status |= clSetKernelArg(clState->kernel, 1, sizeof(cl_ulong), (void *)(((uint64_t *)clState->cldata) + 8)); status |= clSetKernelArg(clState->kernel, 2, sizeof(cl_ulong), (void *)(((uint64_t *)clState->cldata) + 9)); status |= clSetKernelArg(clState->kernel, 3, sizeof(cl_mem), (void *)&clState->outputBuffer); status |= clSetKernelArg(clState->kernel, 4, sizeof(cl_ulong), (void *)&le_target); return status; }
static cl_int queue_yescrypt_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads) { cl_kernel *kernel = &clState->kernel; unsigned int num = 0; cl_uint le_target; cl_int status = 0; // le_target = (*(cl_uint *)(blk->work->device_target + 28)); le_target = (cl_uint)le32toh(((uint32_t *)blk->work->/*device_*/target)[7]); // le_target = (cl_uint)((uint32_t *)blk->work->target)[7]; // memcpy(clState->cldata, blk->work->data, 80); flip80(clState->cldata, blk->work->data); status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL); CL_SET_ARG(clState->CLbuffer0); CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(clState->padbuffer8); CL_SET_ARG(clState->buffer1); CL_SET_ARG(clState->buffer2); CL_SET_ARG(le_target); return status; }
static cl_int queue_fresh_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads) { cl_kernel *kernel; unsigned int num; cl_ulong le_target; cl_int status = 0; le_target = *(cl_ulong *)(blk->work->device_target + 24); flip80(clState->cldata, blk->work->data); status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL); // shavite 1 - search kernel = &clState->kernel; num = 0; CL_SET_ARG(clState->CLbuffer0); CL_SET_ARG(clState->padbuffer8); // smid 1 - search1 kernel = clState->extra_kernels; CL_SET_ARG_0(clState->padbuffer8); // shavite 2 - search2 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // smid 2 - search3 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // echo - search4 num = 0; CL_NEXTKERNEL_SET_ARG(clState->padbuffer8); CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(le_target); return status; }
int test_nonce(struct mm_work *mw, uint32_t nonce2, uint32_t nonce) { /* Generate the work base on nonce2 */ struct work work; debug32("Test: %08x %08x\n", nonce2, nonce); miner_gen_nonce2_work(mw, nonce2, &work); /* Write the nonce to block header */ uint32_t *work_nonce = (uint32_t *)(work.header + 64 + 12); *work_nonce = bswap_32(nonce); /* Regen hash */ uint32_t *data32 = (uint32_t *)(work.header); unsigned char swap[80]; uint32_t *swap32 = (uint32_t *)swap; unsigned char hash1[32]; uint32_t *hash_32 = (uint32_t *)(hash1 + 28); flip80(swap32, data32); dsha256(swap, 80, hash1); if (*hash_32 != 0) return NONCE_HW; /* Compare hash with target */ return fulltest(hash1, mw->target); }
void skeincoin_prepare_work(dev_blk_ctx *blk, uint32_t *state, uint32_t *pdata) { uint32_t be_data[20]; flip80(be_data, pdata); skeinmid((unsigned char *)blk->ulongMidstate, (const unsigned char *)be_data); memcpy(blk->ulongData, be_data + 16, 12); }
void skeincoin_regenhash(struct work *work) { uint32_t be_data[20]; unsigned char hash1[64]; flip80(be_data, work->data); skeincoin(hash1, (const unsigned char *)be_data, 80); sha256(hash1, 64, work->hash); }
static cl_int queue_lyra2rev2_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads) { cl_kernel *kernel; unsigned int num; cl_int status = 0; cl_ulong le_target; // le_target = *(cl_uint *)(blk->work->device_target + 28); le_target = *(cl_ulong *)(blk->work->device_target + 24); flip80(clState->cldata, blk->work->data); status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL); // blake - search kernel = &clState->kernel; num = 0; // CL_SET_ARG(clState->CLbuffer0); CL_SET_ARG(clState->buffer1); CL_SET_ARG(blk->work->blk.ctx_a); CL_SET_ARG(blk->work->blk.ctx_b); CL_SET_ARG(blk->work->blk.ctx_c); CL_SET_ARG(blk->work->blk.ctx_d); CL_SET_ARG(blk->work->blk.ctx_e); CL_SET_ARG(blk->work->blk.ctx_f); CL_SET_ARG(blk->work->blk.ctx_g); CL_SET_ARG(blk->work->blk.ctx_h); CL_SET_ARG(blk->work->blk.cty_a); CL_SET_ARG(blk->work->blk.cty_b); CL_SET_ARG(blk->work->blk.cty_c); // keccak - search1 kernel = clState->extra_kernels; CL_SET_ARG_0(clState->buffer1); // cubehash - search2 num = 0; CL_NEXTKERNEL_SET_ARG_0(clState->buffer1); // lyra - search3 num = 0; CL_NEXTKERNEL_SET_ARG_N(0, clState->buffer1); CL_SET_ARG_N(1, clState->padbuffer8); // skein -search4 num = 0; CL_NEXTKERNEL_SET_ARG_0(clState->buffer1); // cubehash - search5 num = 0; CL_NEXTKERNEL_SET_ARG_0(clState->buffer1); // bmw - search6 num = 0; CL_NEXTKERNEL_SET_ARG(clState->buffer1); CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(le_target); return status; }
static cl_int queue_bitblock_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads) { cl_kernel *kernel; unsigned int num; cl_ulong le_target; cl_int status = 0; le_target = *(cl_ulong *)(blk->work->device_target + 24); flip80(clState->cldata, blk->work->data); status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL); // blake - search kernel = &clState->kernel; num = 0; CL_SET_ARG(clState->CLbuffer0); CL_SET_ARG(clState->padbuffer8); // bmw - search1 kernel = clState->extra_kernels; CL_SET_ARG_0(clState->padbuffer8); // groestl - search2 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // skein - search3 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // jh - search4 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // keccak - search5 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // luffa - search6 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // cubehash - search7 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // shavite - search8 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // simd - search9 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // echo - search10 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // hamsi - search11 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // fugue - search12 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // hamsi - search11 CL_NEXTKERNEL_SET_ARG_0(clState->padbuffer8); // fugue - search12 num = 0; CL_NEXTKERNEL_SET_ARG(clState->padbuffer8); CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(le_target); return status; }
static cl_int queue_maxcoin_kernel(struct __clState *clState, struct _dev_blk_ctx *blk, __maybe_unused cl_uint threads) { cl_kernel *kernel = &clState->kernel; unsigned int num = 0; cl_int status = 0; flip80(clState->cldata, blk->work->data); status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL, NULL); CL_SET_ARG(clState->CLbuffer0); CL_SET_ARG(clState->outputBuffer); return status; }
void hefty_regenhash(struct work *work) { uint32_t result[8]; unsigned int data[20], datacopy[20]; // 32-aligned memcpy(datacopy, work->data, 80); flip80(data, datacopy); char *hdata = bin2hex((const unsigned char *)data, 80); applog(LOG_DEBUG, "Verifying hefty data %s", hdata); free(hdata); heavycoin_hash((const char*)data, 80, (char*)&result); memcpy(work->hash, &result, 32); }
static cl_int queue_sph_kernel(_clState *clState, dev_blk_ctx *blk, __maybe_unused cl_uint threads) { unsigned char *midstate = blk->work->midstate; cl_kernel *kernel = &clState->kernel; unsigned int num = 0; cl_ulong le_target; cl_int status = 0; le_target = *(cl_ulong *)(blk->work->device_target + 24); flip80(clState->cldata, blk->work->data); status = clEnqueueWriteBuffer(clState->commandQueue, clState->CLbuffer0, true, 0, 80, clState->cldata, 0, NULL,NULL); CL_SET_ARG(clState->CLbuffer0); CL_SET_ARG(clState->outputBuffer); CL_SET_ARG(le_target); return status; }