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

Illegal instruction with ippiLabelMarkers_8u_C1IR

bibi88
Beginner
880 Views
Hello,

I'm trying to use ippiLabelMarkers_8u_C1IR to segment an image (4 connectivity) but I get an illegal instruction using it. Here is a very easy example where I get an illegal instruction. Could you please help me to understand what's wrong with the previous-last line? Thank you in advance!


Ipp8u pSrc[5*5] = { 1, 2, 4, 1, 2,
5, 1, 2, 1, 2,
1, 2, 1, 2, 1,
1, 2, 1, 2, 1,
2, 1, 5, 1, 2};

IppiSize roiSize = {5, 5};
int srcStep = 5;
int BufferSize, number_markers, pitch_buffer;

ippiLabelMarkersGetBufferSize_8u_C1R(roiSize, &BufferSize);

Ipp8u* pBuffer = (Ipp8u*) ippMalloc(BufferSize);

ippiLabelMarkers_8u_C1IR(pSrc, srcStep, roiSize, 1, 254, ippiNormL1, &number_markers, pBuffer);

ippiFree(pBuffer);

Regards.
0 Kudos
7 Replies
Vladimir_Dudnik
Employee
880 Views
Hello,

how did you detect that issue is with illegal instruction?

What I can see from your sample is that you allocate memory with ippMallic function but deallocate this memory with ippiFree function.

According IPP documentation you have to use ippFree as a counterpart with this function:

ippMalloc

Allocates memory aligned to 32-byte boundary.

Syntax

void* ippMalloc(int length);

Parameters

len

Size (in bytes) of the allocated block.

Description

The function ippMalloc is declared in the ippcore.h file. This function allocates memory block aligned to a 32-byte boundary.

Return Values

The return value of ippMalloc is a pointer to an aligned memory block. To free this block, use only the function ippFree.


That might the reason of your issue

Regards,
Vladimir
0 Kudos
bibi88
Beginner
880 Views
Sorry for the fault in ippiFree, but the fault didn't come from there.
The illegal instruction comes from ippiFloodFill_4Con_8u_C1IR() and it seems /001 is written 25 times in pSrc.

Regards.
0 Kudos
Vladimir_Dudnik
Employee
880 Views
I'm not quite get your complain. In your sample in the beginning of thread there is no ippiFloodFill_4Con_8u_C1IR call at all! And who and what write 25 times to pSrc? Would not it be easier if you attach simple test case which reproduce the problem?

Vladimir
0 Kudos
Vladimir_Dudnik
Employee
880 Views
Ok, I see, ippiFloodFill is called inside ippiLabelMarker function. In order to reproduce and investigate the issue easely we will need some additiona info. What processor and OS you are running on? What version of IPP you linked and how did you link statically or dynamically?

Vladimir
0 Kudos
bibi88
Beginner
880 Views
Thanks for your interest.
I'm working on a CPU Intel s1366 Core i7-950 3.06Ghz 8Mb.
My OS is Ubuntu 64 bits: Linux 2.6.35-24-generic #42-Ubuntu SMP Thu Dec 2 02:41:37 UTC 2010 x86_64 GNU/Linux
My IPP version ipp version is 6.1.6.063/em64t.
I'm using Codebloc as IDE, and the link is done by adding in the linker list all that is in /opt/intel/ipp/6.1.6.063/em64t/sharedlib and adding to my linker options the following list:

-lguide -lippccem64t -lippchu8 -lippdcem64t -lippdiu8 -lippim7 -lippjy8 -lipprmx -lippse9 -lippsry8 -lippvmem64t -limf -lippccm7 -lippchy8 -lippdcm7 -lippdiy8 -lippimx -lippme9 -lipprn8 -lippsem64t -lippsu8 -lippvmm7 -liomp5 -lippccmx -lippcoreem64t -lippdcmx -lippgene9 -lippin8 -lippmem64t -lippru8 -lippsm7 -lippsy8 -lippvmmx -lippace9 -lippccn8 -lippcve9 -lippdcn8 -lippgenem64t -lippiu8 -lippmm7 -lippry8 -lippsmx -lippvce9 -lippvmn8 -lippacem64t -lippccu8 -lippcvem64t -lippdcu8 -lippgenm7 -lippiy8 -lippmmx -lippsce9 -lippsn8 -lippvcem64t -lippvmu8 -lippacm7 -lippccy8 -lippcvm7 -lippdcy8 -lippgenmx -lippje9 -lippmn8 -lippscem64t -lippsre9 -lippvcm7 -lippvmy8 -lippacmx -lippche9 -lippcvmx -lippdie9 -lippgenn8 -lippjem64t -lippmu8 -lippscm7 -lippsrem64t -lippvcmx -lirc -lippacn8 -lippchem64t -lippcvn8 -lippdiem64t -lippgenu8 -lippjm7 -lippmy8 -lippscmx -lippsrm7 -lippvcn8 -lsvml -lippacu8 -lippchm7 -lippcvu8 -lippdim7 -lippgeny8 -lippjmx -lippre9 -lippscn8 -lippsrmx -lippvcu8 -lippacy8 -lippchmx -lippcvy8 -lippdimx -lippie9 -lippjn8 -lipprem64t -lippscu8 -lippsrn8 -lippvcy8 -lippcce9 -lippchn8 -lippdce9 -lippdin8 -lippiem64t -lippju8 -lipprm7 -lippscy8 -lippsru8 -lippvme9 -pthread

I know I just need the *64t, but I never have done the change since it has worked until now.
I've also included the include all the .h (/opt/intel/ipp/6.1.6.063/include) in my include option and put #include "ipp.h" at the top of the example code that I gave to you previously.

Regards.

0 Kudos
Vladimir_Dudnik
Employee
880 Views
Thanks for detailed info! That's really helpful. And first I'd like you to get your link options correct and see if that solve the problem.

Seems you put all libraries you find in IPP package to your linker, but in fact it should not be done in that way. Please check IPP Knowledge Base to learn how to link IPP with your application for more details.

Here, I'll provide you brief instructioons. As you link with IPP dynamic libraries you only need to link with dynamic dispatcher libs, then dispatcher will detect at run time what is your processor and will load appropriate processor specific library automatically. That's said, you will need to link with only the libraries which have em64t in their name (for 64-bit application). Although it may work for youbefore when you mix everything but it is really depend on order of libraries in your linker option and is not guaranteed to work. The problem is that some libraries might be initialized by dispatcher (when you linker finds dispatcher lib in your options before other libs)and other libraries might use either PX code or any other, depending on the order of libs. That even might be a case thatlinker findin your optionsAVX specific library first and so it is notuse dispatcher to check if this library may run on your processor, resulting in illegal instruction at run time.
You will avoid that complication if you link with dispatcher libraries only and let dispatcher to use the right processor specific library automatically.

Vladimir
0 Kudos
bibi88
Beginner
880 Views
Hello Vladimir,

As usual, you had right! That was the order of the librairies. I just included

-lippccem64t -lippdcem64t -lippvmem64t -lippsem64t -lippcoreem64t -lippmem64t -lippgenem64t -lippacem64t -lippcvem64t -lippvcem64t -lippscem64t -lippjem64t -lippsrem64t -lippchem64t -lippdiem64t -lipprem64t -lippiem64t -pthread

and the corresponding librairies and it works.

Thank you!
0 Kudos
Reply