Category : performance

Description: I have multiple threads (4-32). These threads can all access an array: int resources[1024]. Resources array contains different values (0-1023). There can only be one instance of a single resource(int). Each thread requires different number of resources, which are at some point returned back to the array. Threads can ask for resources more than ..

Read more

There is a QTabWidget containing custom widgets (all widgets are the same type). I need to update the contents of each of these widgets on a QTimer::timeout signal and I have two options for how to proceed: for each new widget connect(timer_name, &QTimer::timeout, widget_name, &WidgetClass::update) the only connection of the timer to the handler slot ..

Read more

I have python+numba and corresponding eigen C++ piece of function. Numba func: @njit(parallel=True ) def Search_2(compare_desc, p_descs, ): for x in prange(p_descs.shape[0]): dist = np.sum(np.square(compare_desc – p_descs[x])) if float(0.5) < threshold: name_number = x Eigen Version: for (int x = start; x < stop; x++) { auto distance = ( db.row(x)- current ).squaredNorm(); if (distance ..

Read more

I’m trying to convert this scalar code: struct CICDecimator { static constexpr int64_t scale = ((int64_t)1) << 32; int mStages; int mFactor; float mGainCorrection; int64_t *pIntegrators; int64_t *pCombs; CICDecimator(int stages = 4, int factor = 8) { assert(stages > 0); assert(factor > 0); mStages = stages; pIntegrators = new int64_t[mStages + 1]{}; pCombs = new ..

Read more

I’m getting wrong answer when I run the program.It is a question from codechef contest . Here is the link for question : https://www.codechef.com/TAW22021/problems/TAW221A1 Here is my code : #include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t,p=0; vector<int> a; while(cin>>t) { a.push_back(t); } int var = *min_element(a.begin(),a.end()); for(auto i=a.begin();i!=(a.end()-1);i++) { int val=*i; ..

Read more