Community
cancel
Showing results for
Did you mean:
Beginner
117 Views

VSL in C#

I'm looking for an example wrapper for the VSL functions and not finding one. The examples referred to in this article do not work: http://software.intel.com/en-us/articles/using-intel-mkl-in-your-c-program/

I'm specifically looking for how to use MKL to calculation the standard deviation/RMS of the elements of a vector - I think the functions are in the VSL?

Janene

1 Solution
Employee
117 Views
Hi Janene, Can you please clarify the structure of your dataset in the example? Which of the variants below is correct: 1. the dimension of your random vector is 1 and number of observations 9 or 2. the dimension of your random vector is 9 and number of observations is 1? If you assume the first case please set task dimension p to 1 and number of observations n to vector.Length. If you assume the second case (that is, you have just one observation of 9d vector) the estimates are expected to be of size 9, and you need to allocate arrays of size 9 for mean/min/max/mom (min and max arrays should be properly initialized) Another observation is that in the signature vsldSSCompute([In] IntPtr task, [In] int estimates, [In] int method); you use 32 bit integer for the parameter "estimates" while in Intel(R) MKL this parameter is 64-bit integer (this, however, is not expected to impact on the result in your example). Please, let me know which result you have after the fixes on your side. Thanks, Andrey
9 Replies
Employee
117 Views
Intel MKL does not provide functions to compute RMS and standard deviation directly. But the VSL component already provides high performance functions to compute the second order raw algebraic moments and the variance (a.k.a. second order central moments). With these, it's really straightforward to roll your own RMS/standard deviation functions: • Compute the 2nd order raw moment (passing VSL_SS_ED_2R_MOM to vslSSEditTask), and then take the sqrt of it to get RMS. • Compute the variance (passing VSL_SS_ED_2C_MOM to vslSSEditTask), and then take the sqrt of it to get standard deviation. Let me know if this helps.
Beginner
117 Views
Thanks Zhang. Do you have an example of a wrapper for VSL so I can access it via C#? Janene
Employee
117 Views
Thanks, Zhang
Beginner
117 Views
[EDITED] I've used the examples to construct a test wrapper, but I'm having difficulty getting the task to calculate properly. A bit of assistance would be appreciated. I've attached my attempt. Thank you in advance, Janene
Employee
117 Views
Hi Janene, As a quick comment on your code: you use double precision version of the VSL SS task constructor and editors (which is specified by letter 'd' after 'vsl' prefix in the function names) VSL.vsldSSNewTask(ref task, ref dim, ref n, ref VSL.VSL_SS_MATRIX_STORAGE_ROWS, A, null, null); VSL.vsldSSEditTask(task, VSL.VSL_SS_ED_MIN, min_est); VSL.vsldSSEditTask(task, VSL.VSL_SS_ED_MAX, max_est); but use single precision version of the Compute function ( letter 's' after 'vsl' prefix): VSL.vslsSSCompute(task, VSL.VSL_SS_MIN | VSL.VSL_SS_MAX, VSL.VSL_SS_METHOD_FAST); I wonder if this could the reason of the wrong result? Thanks, Andrey
Beginner
117 Views