Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Vector find optimize routine

lgmendes
Beginner
283 Views

Dear all,

How can I write the following code using the mkl (or other Intel library) optimized vector routines? The main idea is to remove the for in the "main" code.

for (v=vsize;v--;){

if (estimate > 0.05) {
estimate = 200.0;
} else {
estimate = 1.0;
}

}

Thanks in advance,

Luis

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
283 Views

Luis,

there are no such routines into MKL, but you can find similar functionality in Intel IPP.

Please see into signal processing functionality - threshold functions, which performs the threshold operation on the elements of a vector by limiting the element values by specified value.

as an example:

IppStatus ippsThreshold_64f(const Ipp64f* pSrc, Ipp64f* pDst, int len, Ipp64f level, IppCmpOp relOp);

where Ipp64f == double precison

Please let us know if any furher guiestions or example .

--Gennady

0 Kudos
TimP
Honored Contributor III
283 Views
Quoting lgmendes
The main idea is to remove the for in the "main" code.

for (v=vsize;v--;){

if (estimate > 0.05) {
estimate = 200.0;
} else {
estimate = 1.0;
}

}

You should be able to vectorize this with icc, something along the line of

#pragma vector always

for (v=0; vestimate = (estimate > 0.05) ? 200. : 1.

If you don't like for() you should be using Fortran:

estimate(0:vsize-1) = merge(200d0,1d0,estimate(0:vsize-1) > .05d0)

0 Kudos
Reply