void TWBaseScript::select_random_links(std::vector<TargetObj>* matches, std::vector<LinkScanWorker>& links, const uint fetch_count, const bool fetch_all, const uint total_weights, const bool is_weighted) { // Yay for easy randomisation std::shuffle(links.begin(), links.end(), randomiser); if(!is_weighted) { // Work out how many links to fetch, limiting it to the number available. uint count = fetch_all ? links.size() : fetch_count; if(count > links.size()) count = links.size(); select_links(matches, links, count); } else { // Weighted selection needs cumulative weight information if(is_weighted) build_link_weightsums(links); TargetObj chosen; // Pick the requested number of links for(uint pass = 0; pass < fetch_count; ++pass) { // Weighted mode needs more work to pick the item pick_weighted_link(links, 1 + (randomiser() % total_weights), chosen); // Store the chosen item matches -> push_back(chosen); } } }
int test_invtransform(bool HAS_SSE4_2, bool HAS_AVX, bool HAS_AVX2) { printf("--------------------------------------------------------------------------------\n"); printf(" Inverse Transform Tests\n"); printf("\n"); /* Load some input data for the tests */ const int height = 1080; const int width = 1920; const int stride = ((1920 + 1023)/1024)*1024; void *idata16 = ALIGNED_ALLOC(32, height*stride*sizeof(int16_t)); void *idata32 = ALIGNED_ALLOC(32, height*stride*sizeof(int32_t)); if (!randomiser((char *)idata16, height*stride*sizeof(int16_t))) { printf("Error Getting Random Data\n"); return 1; } /* Need to make sure the samples aren't so large they overflow during the calculations */ for (int y = 0; y < height; y++) { for (int x = 0; x < stride; x++) { ((int16_t *)idata16)[y*stride + x] >>= 2; ((int32_t *)idata32)[y*stride + x] = ((int16_t *)idata16)[y*stride + x]; } } /*for (int y = 0; y < height; y++) { for (int x = 0; x < stride; x++) { ((int32_t *)idata)[y*stride + x] = 1; } }*/ int r = 0; for (int i = 0; !r && i < INVHTRANSFORMTEST_DATA_NUM; i++) { void * idata = (INVHTRANSFORMTEST_DATA[i].sample_size == 2)?idata16:idata32; r = perform_invhtransformtest(INVHTRANSFORMTEST_DATA[i], idata, width, height, stride, HAS_SSE4_2, HAS_AVX, HAS_AVX2); } for (int i = 0; !r && i < INVHTRANSFORMFINALTEST_DATA_NUM; i++) { void * idata = (INVHTRANSFORMFINALTEST_DATA[i].sample_size == 2)?idata16:idata32; r = perform_invhtransformfinaltest(INVHTRANSFORMFINALTEST_DATA[i], idata, width, height, stride, HAS_SSE4_2, HAS_AVX, HAS_AVX2); } for (int i = 0; !r && i < INVVTRANSFORMTEST_DATA_NUM; i++) { void * idata = (INVVTRANSFORMTEST_DATA[i].sample_size == 2)?idata16:idata32; r = perform_invvtransformtest(INVVTRANSFORMTEST_DATA[i], idata, width, height, stride, HAS_SSE4_2, HAS_AVX, HAS_AVX2); } ALIGNED_FREE(idata16); ALIGNED_FREE(idata32); printf("--------------------------------------------------------------------------------\n"); return r; }