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

How to Use IPP Functions in Linux Kernel Space

paul_shu
Beginner
4,487 Views

Hi,

I try hard to write a Linux driver module with IPP functions. But I failed to use ipp funcs in module. I attached my simple test code and makefile. Is there anybody to help me look into it and tell me how to use ipp functions in kernel-space correctly.

Thanks in advance,

Paul

0 Kudos
34 Replies
Bernard
Valued Contributor I
1,496 Views

Here is some information about the IPP in kernel mode both Win OS and Linux: Link://software.intel.com/en-us/articles/code-samples-for-intel-integrated-performance-primitives-intel-ipp-library-71

Please check this directory(zip file) advanced-usage/application/ippsdrv

0 Kudos
Sergey_K_Intel
Employee
1,496 Views

Hi Paul,

Look please into IPP User's Guide for Linux. There's something about PIC and non-PIC libraries. Looks like for driver mode the non-PIC libraries are necessary. They should not contain offset tables.

Regards,
Sergey 

0 Kudos
paul_shu
Beginner
1,496 Views

Hi Sergey,

You are right. non-PIC libraries are necessary for driver mode. But I still can't work. Some errors occured like the system log I posted. And I find an IPP official sample for driver mode "ippsdrv". But I failed to build it on my linux box, it seems like that some floating operations can be found in kernel space.

Paul

Sergey Khlystov (Intel) wrote:

Hi Paul,

Look please into IPP User's Guide for Linux. There's something about PIC and non-PIC libraries. Looks like for driver mode the non-PIC libraries are necessary. They should not contain offset tables.

Regards,
Sergey 

0 Kudos
SergeyKostrov
Valued Contributor II
1,496 Views
>>...it seems like that some floating operations can be found in kernel space. Could you provide more details on these floating operations?
0 Kudos
Bernard
Valued Contributor I
1,496 Views
I do not know how it is implemented on Linux,but; in Windows kernel mode driver is subject to many restrictions.For example you must save the FPU context and restore it later. Regarding Linux here is the Linus's answer when to use floating point operations in linux kernel Link:http://lkml.indiana.edu/hypermail/linux/kernel/0405.3/1620.html
0 Kudos
Bernard
Valued Contributor I
1,496 Views

Here is qouted sentence from one of Linux dev forums regarding floating point code in driver|

"Basically you have to compile hardware floating-point capabilities into your module (with -mhard-float) and use two kernel functions kernel_fpu_begin() and kernel_fpu_end() "

0 Kudos
Igor_A_Intel
Employee
1,496 Views

Use  next define before including IPP

#define  IPPAPI( type,name,arg )   extern type name arg __attribute__ ((regparm(0)));

or use -mregparm=3 for GCC cmd line. Linux kernel mode modules use different ABI - so called "fast call" that corresponds to Borland definition (passing parms are in eax, edx, ecx), not to MS one

regards

Igor

0 Kudos
Igor_A_Intel
Employee
1,496 Views

Use  next define before including IPP

#define  IPPAPI( type,name,arg )   extern type name arg __attribute__ ((regparm(0)));

or use -mregparm=3 for GCC cmd line. Linux kernel mode modules use different ABI - so called "fast call" that corresponds to Borland definition (passing parms are in eax, edx, ecx), not to MS one

regards

Igor

0 Kudos
Igor_A_Intel
Employee
1,496 Views

sorry for "-mregparm=3" - this is not correct - this is default definition for all kenel mode APIs and you should show to compiler that IPP API has different from kernel mode ABI - so only __atribute__(regparm(0)) can help

regards

Igor

0 Kudos
Bernard
Valued Contributor I
1,496 Views

Hi Igor,

so are these routines kernel_fpu_begin() and kernel_fpu_end()  not used(called) from within IPP ?

0 Kudos
SergeyKostrov
Valued Contributor II
1,496 Views
This is what command line help of a GCC compiler displays for mregparm: ... -mregparm = Number of registers used to pass integer arguments ...
0 Kudos
Igor_A_Intel
Employee
1,496 Views

IPP functions are general purpose primitives, they don't have internaly any specific related to user or kernel mode execution. So it is user responsibility to wrapp IPP calls with kernel_fpu_begin()/end().

regards, Igor

0 Kudos
Bernard
Valued Contributor I
1,496 Views

Igor Astakhov (Intel) wrote:

IPP functions are general purpose primitives, they don't have internaly any specific related to user or kernel mode execution. So it is user responsibility to wrapp IPP calls with kernel_fpu_begin()/end().

regards, Igor

Thanks Igor for explaining this.

0 Kudos
paul_shu
Beginner
1,496 Views

Hi Igor,

I used the "__atribute__(regparm(0))" method to fix my problem. Thank you.

And I appreciate all comments from Sergey and iliyapolak.

Paul

Igor Astakhov (Intel) wrote:

Use  next define before including IPP

#define  IPPAPI( type,name,arg )   extern type name arg __attribute__ ((regparm(0)));

or use -mregparm=3 for GCC cmd line. Linux kernel mode modules use different ABI - so called "fast call" that corresponds to Borland definition (passing parms are in eax, edx, ecx), not to MS one

regards

Igor

0 Kudos
Reply