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

oneMKL sorting

geerits
New Contributor I
361 Views

Dear reader,

 

I'm evaluating the possibility of using MKL instead of IMSL as the latter requests huge fees for commercializing software that contains IMSL routines. Just recently, with some help from the Intel community, I tested the MKL SVD routine, which seems to work just fine. But what about the more basic work like "sorting"? I couldn't find anything. Any comments/suggestions? I also need the indices pertaining to the sorted array.

 

With kind regards,

Tim.

0 Kudos
1 Solution
mecej4
Black Belt
326 Views

SVRGP/DSVRGP are described in the IMSL documentation to be implementations of Singleton's version of Quicksort. If your need is to do a sort and then search the sorted array with new values, I do not see why you need to form an index array.

If the number of items is around 500, I think that a hybrid sort with quicksort down to partitions of size on the neighborhood of 80, followed by insertion sort of the smaller partitions, is what would be most efficient.

The C library functions qsort() and bsearch() are worth trying. They do not explicitly provide for an index array, but you can achieve the same purpose by using a struct composed of value:index pairs.

View solution in original post

6 Replies
mecej4
Black Belt
346 Views

Sorting is, for a number of reasons, not considered a mathematical topic, and is not to be expected in MKL, which stands for Math Kernel Library. The runtime library of the programming language that you use (C/C++ or Fortran), however, usually provides for sorting.

Please state your requirement more completely -- are you sorting an array of integers, reals, or strings? Or sorting an array of user-defined type? How many items to you expect to sort, and how often? Do you require the order of equal items to be preserved? Is there a specific IMSL sorting routine that you are trying to substitute for?

The IPP library, which is an optional component of OneAPI, contains routines for sorting, as well. However, IPP aims to process arrays of small to medium size, not large size.

geerits
New Contributor I
336 Views

Hi mecej4,

Ok, good to know! Then I assume that searching an array for a value (e.g., <=number) is also not contained in MKL?

 

I'm using IMSL routine DSVRGP (the double precision version of SVRGP()) to sort an array of type double. I do that on many occasions. The call occurs in a parallelized loop (I use OpenMP, while using the Intel C++ compiler [Version 19]). Although the array sizes (N) differ from call to call, I can say that N<=500. Does that qualify for using the IPP library?

 

PS: I also need to know the original indices pertaining to the sorted values.

 

With kind regards,

Tim. 

 

mecej4
Black Belt
327 Views

SVRGP/DSVRGP are described in the IMSL documentation to be implementations of Singleton's version of Quicksort. If your need is to do a sort and then search the sorted array with new values, I do not see why you need to form an index array.

If the number of items is around 500, I think that a hybrid sort with quicksort down to partitions of size on the neighborhood of 80, followed by insertion sort of the smaller partitions, is what would be most efficient.

The C library functions qsort() and bsearch() are worth trying. They do not explicitly provide for an index array, but you can achieve the same purpose by using a struct composed of value:index pairs.

geerits
New Contributor I
272 Views

Ok, thanks for your info. I'm going to look into this and will let you know about the outcome.

 

PS: As to your question/statement: "If your need is to do a sort and then search the sorted array with new values, I do not see why you need to form an index array." I just need to know the index in the original array that corresponds to the minimum value of the sorted array (usually the first entry in the sorted array).

 

Best regards,

Tim.

ShanmukhS_Intel
Moderator
275 Views

Hi,

 

Has the information provided helped? Kindly let us know if we could close this thread from our end.

 

Best Regards,

Shanmukh.SS

 

ShanmukhS_Intel
Moderator
246 Views

Hi,


Thanks for accepting the solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Best Regards,

Shanmukh.SS



Reply