void TwoDArraysTest::testCopyConstructor() { TwoDArray<int> work_data; setup2DArray (work_data, 20, 30, 0); TwoDArray<int> work_copy(work_data); bool ret_val = equalArrays<int> (work_data, work_copy); CPPUNIT_ASSERT (ret_val == true); }
// called by every thread, copies the backup to each thread's work. void hodl_resync_threads( struct work* work ) { int nonce_index = algo_gate.nonce_index; pthread_barrier_wait( &hodl_barrier ); if ( memcmp( work->data, hodl_work.data, algo_gate.work_cmp_size ) ) { work_free( work ); work_copy( work, &hodl_work ); } work->data[ nonce_index ] = swab32( hodl_work.data[ nonce_index ] ); }
void zr5_init_nonce( struct work* work, struct work* g_work, int thr_id ) { // ignore POK in first word // const int nonce_i = 19; const int wkcmp_sz = 72; // (19-1) * sizeof(uint32_t) uint32_t *nonceptr = algo_gate.get_nonceptr( work->data ); if ( memcmp( &work->data[1], &g_work->data[1], wkcmp_sz ) ) { work_free( work ); work_copy( work, g_work ); *nonceptr = 0xffffffffU / opt_n_threads * thr_id; if ( opt_randomize ) *nonceptr += ( (rand() *4 ) & UINT32_MAX ) / opt_n_threads; } else ++(*nonceptr); }
void std_init_nonceptr ( struct work* work, struct work* g_work, uint32_t **nonceptr, int wkcmp_offset, int wkcmp_sz, int nonce_oft, int thr_id ) { if ( memcmp( &work->data[wkcmp_offset], &g_work->data[wkcmp_offset], wkcmp_sz ) || jsonrpc_2 ? memcmp( ( (uint8_t*) work->data ) + 43, ( (uint8_t*) g_work->data ) + 43, 33 ) : 0 ) { work_free( work ); work_copy( work, g_work ); *nonceptr = (uint32_t*)( ( (char*)work->data ) + nonce_oft ); *nonceptr[0] = 0xffffffffU / opt_n_threads * thr_id; if ( opt_randomize ) *nonceptr[0] += ( (rand() *4 ) & UINT32_MAX ) / opt_n_threads; } else ++(*nonceptr[0]); }
void zr5_get_new_work( struct work* work, struct work* g_work, int thr_id, uint32_t* end_nonce_ptr, bool clean_job ) { // ignore POK in first word // const int nonce_i = 19; const int wkcmp_sz = 72; // (19-1) * sizeof(uint32_t) uint32_t *nonceptr = algo_gate.get_nonceptr( work->data ); if ( memcmp( &work->data[1], &g_work->data[1], wkcmp_sz ) && ( clean_job || ( *nonceptr >= *end_nonce_ptr ) ) ) { work_free( work ); work_copy( work, g_work ); *nonceptr = ( 0xffffffffU / opt_n_threads ) * thr_id; if ( opt_randomize ) *nonceptr += ( (rand() *4 ) & UINT32_MAX ) / opt_n_threads; *end_nonce_ptr = ( 0xffffffffU / opt_n_threads ) * (thr_id+1) - 0x20; } else ++(*nonceptr); }
// called only by thread 0, saves a backup of g_work void hodl_get_new_work( struct work* work, struct work* g_work) { work_free( &hodl_work ); work_copy( &hodl_work, g_work ); hodl_work.data[ algo_gate.nonce_index ] = ( clock() + rand() ) % 9999; }