Posts

Showing posts with the label vectorization

Finding the intersection of large vectors using MATLAB

Image
Clash Royale CLAN TAG #URR8PPP Finding the intersection of large vectors using MATLAB How can two signals be compared in MATLAB to find their intersection? My signals are large vectors which can contain duplicate values. I have been experimenting with the following approach using intersect , which works fine for a randomly generated signals. intersect % Example case sig1 = rand(100,1); sig2 = [rand(50,1); sig1(end-10:end); rand(50,1)]; % a signal with imposed intersection. [c, ia, ib] = intersect(sig1, sig2); plot(sig2) hold on scatter(ib, sig2(ib), 'filled') hold off I am using this approach for my real data but it does not produce the correct intersection, which is due to duplicate values in the signals. So, I thought to add a very small random noise to both signals and then apply intersect , however, adding a threshold is not possible for intersect . intersect intersect Could someone give me some hints on how the intersection of two large signal measurement can be found robu...

Nested for loop, data dependency [ OpenMP ]

Image
Clash Royale CLAN TAG #URR8PPP Nested for loop, data dependency [ OpenMP ] I have a matrix solver (BiCCG) which is being used to solve set of algebraic equations arising from a 3 dimensional computational domain. I have tried to parallelise it using OpenMP but struggling with performance issues. On inspecting the code using Intel Advisor, it is evident that almost 80% of the solution time goes in the solver out of which there is one function which accounts for 50% of the solution time. Digging even deeper it is found that 5 loops out of 6 loops are performing terribly with no automatic vectorization since they suffer from data dependencies. What I do see is that there is a dependency (for eg in loop 3 ) because there i th iteration is using i-1 iteration's values. How to change the design of the parallelisation such that it can be the most efficient with this algorithm ( rather that changing the algorithm altogether). Whether specifying #pragma omp simd safelen(1) would help. #pra...