/* this is common implementation of write_sd_by_inode method of file plugin either insert stat data or update it */ int write_sd_by_inode_common(struct inode *inode/* object to save */) { int result; assert("nikita-730", inode != NULL); if (reiser4_inode_get_flag(inode, REISER4_NO_SD)) /* object doesn't have stat-data yet */ result = insert_new_sd(inode); else result = update_sd(inode); if (result != 0 && result != -ENAMETOOLONG && result != -ENOMEM) /* Don't issue warnings about "name is too long" */ warning("nikita-2221", "Failed to save sd for %llu: %i", (unsigned long long)get_inode_oid(inode), result); return result; }
void qubithash(void *output, const void *input) { unsigned char hash[128]; // uint32_t hashA[16], hashB[16]; #define hashB hash+64 qubit_ctx_holder ctx; memcpy( &ctx, &qubit_ctx, sizeof(qubit_ctx) ); #ifdef LUFFA_SSE2_BROKEN sph_luffa512 (&ctx.luffa, input, 80); sph_luffa512_close(&ctx.luffa, (void*) hash); #else // init_luffa(&qubit_ctx.luffa,512); update_luffa( &ctx.luffa, (const BitSequence*)input, 80 ); final_luffa( &ctx.luffa, (BitSequence*)hash); #endif cubehashUpdate( &ctx.cubehash, (const byte*) hash,64); cubehashDigest( &ctx.cubehash, (byte*)hash); sph_shavite512( &ctx.shavite, hash, 64); sph_shavite512_close( &ctx.shavite, hash); update_sd( &ctx.simd, (const BitSequence *)hash,512); final_sd( &ctx.simd, (BitSequence *)hash); #ifdef NO_AES_NI sph_echo512 (&ctx.echo, (const void*) hash, 64); sph_echo512_close(&ctx.echo, (void*) hash); #else update_echo ( &ctx.echo, (const BitSequence *) hash, 512); final_echo( &ctx.echo, (BitSequence *) hash); #endif asm volatile ("emms"); memcpy(output, hash, 32); }
inline void Xhash(void *state, const void *input) { Xhash_context_holder ctx; // uint32_t hashA[16], hashB[16]; memcpy(&ctx, &base_contexts, sizeof(base_contexts)); #ifdef AES_NI_GR init_groestl(&ctx.groestl); #endif DATA_ALIGNXY(unsigned char hashbuf[128],16); size_t hashptr; DATA_ALIGNXY(sph_u64 hashctA,8); DATA_ALIGNXY(sph_u64 hashctB,8); #ifndef AES_NI_GR grsoState sts_grs; #endif DATA_ALIGNXY(unsigned char hash[128],16); /* proably not needed */ memset(hash, 0, 128); //blake1-bmw2-grs3-skein4-jh5-keccak6-luffa7-cubehash8-shavite9-simd10-echo11 //---blake1--- /* //blake init blake512_init(&base_contexts.blake1, 512); blake512_update(&ctx.blake1, input, 512); blake512_final(&ctx.blake1, hash); */ DECL_BLK; BLK_I; BLK_W; BLK_C; //---bmw2--- DECL_BMW; BMW_I; BMW_U; #define M(x) sph_dec64le_aligned(data + 8 * (x)) #define H(x) (h[x]) #define dH(x) (dh[x]) BMW_C; #undef M #undef H #undef dH //---grs3---- #ifdef AES_NI_GR update_groestl(&ctx.groestl, (char*)hash,512); final_groestl(&ctx.groestl, (char*)hash); #else GRS_I; GRS_U; GRS_C; #endif //---skein4--- DECL_SKN; SKN_I; SKN_U; SKN_C; //---jh5------ DECL_JH; JH_H; //---keccak6--- DECL_KEC; KEC_I; KEC_U; KEC_C; // asm volatile ("emms"); //--- luffa7 update_luffa(&ctx.luffa,(const BitSequence*)hash,512); final_luffa(&ctx.luffa,(BitSequence*)hash+64); //---cubehash--- cubehashUpdate(&ctx.cubehash,(const byte*) hash+64,64); cubehashDigest(&ctx.cubehash,(byte*)hash); //---shavite--- sph_shavite512 (&ctx.shavite1, hash, 64); sph_shavite512_close(&ctx.shavite1, hash+64); //sph_simd512 (&ctx.simd1, hashA, 64); // sph_simd512_close(&ctx.simd1, hashB); //-------simd512 vect128 -------------- update_sd(&ctx.ctx_simd1,(const BitSequence *)hash+64,512); final_sd(&ctx.ctx_simd1,(BitSequence *)hash); //---echo--- #ifdef AES_NI update_echo (&ctx.echo1,(const BitSequence *) hash, 512); final_echo(&ctx.echo1, (BitSequence *) hash+64); #else sph_echo512 (&ctx.echo1, hash, 64); sph_echo512_close(&ctx.echo1, hash+64); #endif memcpy(state, hash+64, 32); }
static void x14hash(void *output, const void *input) { unsigned char hash[128]; // uint32_t hashA[16], hashB[16]; #define hashB hash+64 x14_ctx_holder ctx; memcpy(&ctx, &x14_ctx, sizeof(x14_ctx)); #ifdef NO_AES_NI grsoState sts_grs; #endif unsigned char hashbuf[128]; size_t hashptr; sph_u64 hashctA; sph_u64 hashctB; //---blake1--- DECL_BLK; BLK_I; BLK_W; BLK_C; //---bmw2--- DECL_BMW; BMW_I; BMW_U; #define M(x) sph_dec64le_aligned(data + 8 * (x)) #define H(x) (h[x]) #define dH(x) (dh[x]) BMW_C; #undef M #undef H #undef dH //---groestl---- #ifdef NO_AES_NI // use SSE2 optimized GRS if possible GRS_I; GRS_U; GRS_C; // sph_groestl512 (&ctx.groestl, hash, 64); // sph_groestl512_close(&ctx.groestl, hash); #else update_groestl( &ctx.groestl, (char*)hash,512); final_groestl( &ctx.groestl, (char*)hash); #endif //---skein4--- DECL_SKN; SKN_I; SKN_U; SKN_C; //---jh5------ DECL_JH; JH_H; //---keccak6--- DECL_KEC; KEC_I; KEC_U; KEC_C; //--- luffa7 update_luffa( &ctx.luffa, (const BitSequence*)hash,512); final_luffa( &ctx.luffa, (BitSequence*)hashB); // 8 Cube cubehashUpdate( &ctx.cubehash, (const byte*) hashB,64); cubehashDigest( &ctx.cubehash, (byte*)hash); // 9 Shavite sph_shavite512( &ctx.shavite, hash, 64); sph_shavite512_close( &ctx.shavite, hashB); // 10 Simd update_sd( &ctx.simd, (const BitSequence *)hashB,512); final_sd( &ctx.simd, (BitSequence *)hash); //11---echo--- #ifdef NO_AES_NI sph_echo512(&ctx.echo, hash, 64); sph_echo512_close(&ctx.echo, hashB); #else update_echo ( &ctx.echo, (const BitSequence *) hash, 512); final_echo( &ctx.echo, (BitSequence *) hashB); #endif // X13 algos // 12 Hamsi sph_hamsi512(&ctx.hamsi, hashB, 64); sph_hamsi512_close(&ctx.hamsi, hash); // 13 Fugue sph_fugue512(&ctx.fugue, hash, 64); sph_fugue512_close(&ctx.fugue, hashB); // X14 Shabal sph_shabal512(&ctx.shabal, hashB, 64); sph_shabal512_close(&ctx.shabal, hash); asm volatile ("emms"); memcpy(output, hash, 32); }
void Optimization::optimize() { tt.tic(); current_iteration = 0; start_dist = 0.1; current_dist = start_dist; _current_seeds = 0; while (max_iterations>current_iteration&&min_dist<dist_update) { //emit emit_progress(0); std::vector<Method_Coefficients> seeds = generate_seeds(this->coefficients_end); for(std::vector<Method_Coefficients>::iterator kit = seeds.begin(); kit < seeds.end(); kit++) { Method_Coefficients seed = *kit; make_coefficients_positive(seed); WorkerSphereFollowing * worker = new WorkerSphereFollowing(1); // worker->set_control(this->controller); worker->setOptimize(shared_from_this()); worker->set_coefficients(seed); worker->setA(coefficients_end.a); worker->setB(coefficients_end.b); worker->setFac(coefficients_end.fact); worker->setMinRad(coefficients_end.minRad); worker->setCloudPtr(_cloud_ptr); worker->setTreeID(treeID); worker->setIsStem(isStem); this->start(worker); } current_iteration ++; this->waitForDone(); end_dist = current_dist; start_dist = end_dist; update_sd(); coefficients_start = coefficients_end; } std::vector<float> minRadii; minRadii.push_back(0.015); minRadii.push_back(0.02); minRadii.push_back(0.025); minRadii.push_back(0.03); minRadii.push_back(0.035); minRadii.push_back(0.04); minRadii.push_back(0.045); if(!qFuzzyCompare(coefficients_start.minRad,0.0025f)) { for(std::vector<float>::iterator f_it = minRadii.begin(); f_it < minRadii.end(); f_it++) { float radius = *f_it; WorkerSphereFollowing * worker = new WorkerSphereFollowing(1); // worker->set_control(this->controller); worker->setOptimize(shared_from_this()); worker->set_coefficients(coefficients_start); worker->setA(coefficients_end.a); worker->setB(coefficients_end.b); worker->setFac(coefficients_end.fact); worker->setMinRad(radius); worker->setCloudPtr(_cloud_ptr); worker->setTreeID(treeID); worker->setIsStem(isStem); this->start(worker); } } this->waitForDone(); end_dist = current_dist; start_dist = end_dist; update_sd(); coefficients_start = coefficients_end; }