Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6740 Discussions

Using ipps in Visual Basic 2005 and .NET in general

albusmw
Beginner
567 Views

Hello!

I would like to use the Intel IPP within my Visual Basic 2005 projects.

I am not able to call any function as I do not know how to generate the IntPtr to my floating point arrays.
If anybody could e.g. show me how to use the ippsAdd_64ffunction to add2 10-element vectors, I would be very glad ...

Best regards,

Martin.

0 Kudos
5 Replies
Vladimir_Dudnik
Employee
567 Views

Hi Martin,

You can take a look on IPP VB sample, available on IPP Samples pagelook at Development Environment section.

Regards,
Vladimir

0 Kudos
albusmw
Beginner
567 Views

Hello, Vladimir,

thanks for your fast reply. The problem is that all examples are based on the ippi function where the pointer IntPtr to the data can be obtained by the special function Scan0.

Within e.g. a floating point vector, I don't know how to get the pointer to that floating point vector.

If you could just add the correct line in the following code, I would be very happy:

Dim

X() As Single = {1, 2, 3, -4, -5}
Dim I_Ptr As
IntPtr = ?????
ipp.sp.ippsAbs_32f_I(I_Ptr, 5)

Best regards,

Martin.

0 Kudos
Vladimir_Dudnik
Employee
567 Views

Hello Martin,

our expert suggest you to use the following piece of code:

Dim X() As Single = {1, 2, 3, -4, -5}
Dim I_Ptr As IntPtr = Marshal.UnsafeAddrOfPinnedArrayElement(X, 0)
ipp.sp.ippsAbs_32f_I(I_Ptr, 5)

Regards,
Vladimir

0 Kudos
albusmw
Beginner
567 Views

Hi!

Thanks for the help, this did solve some problem.

Could you please tell me how I get the IntPtr to one single value, e.g. to use the ippsMax function? At the moment, I do it the way you can see below which is not very elegant. (I write a wrapper around the IPP function to give a more conveniant access to them).

By the way, is there any plan by Intel to provide such a wrapper which uses e.g. function overloading, ... to provide such an easy access?

Best regards,

Martin.

Public Function ippsMax(ByRef Array() As Single, ByRef Max As Single) As ipp.IppStatus

Dim RetVal As ipp.IppStatus : Dim TempVal(0 To 0) As Single

RetVal = ipp.sp.ippsMax_16s(GetPtr(Array), Array.Length, GetPtr(TempVal))

Max = TempVal(0) :

Return RetVal

End Function

Public

Function GetPtr(ByRef Array() As Single) As IntPtr

Return System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(Array, 0)

End Function

0 Kudos
Vladimir_Dudnik
Employee
567 Views

Hello,

there is answer from our expert:

you need to useShortfor 16-bit data notSingle. the one of the reason why we deliver VB wrapper sample as a sample, not a complete solution is that you can implement it in different ways. You can change in sample sources for functions like ippsMax the following:

Declare

Function _

ippsMax_16s

Lib "ipps-5.2.dll" _

(

ByVal pSrc As IntPtr, ByVal len As Integer, ByRef pMax As Short) As IppStatus

and then in your example

Public

Function ippsMax(ByRef Array() As Short, ByRef Max As Short) As ipp.IppStatus

Dim RetVal As ipp.IppStatus

RetVal = ippsMax_16s(GetPtr(Array), Array.Length, Max)

Return RetVal

End

Function

Public Function GetPtr(ByRef Array() As Short) As IntPtr

Return System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(Array, 0)

End Function

Regards,
Vladimir

0 Kudos
Reply