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

FFTFwd segfaults in Java VM

tctbw
Beginner
283 Views
Hello,

my aim is to filter an image with Java and to use IPP as a fast fft library.

So far I've managed to call the ipp with JNI and to really filter an image the way I want. But as my program continues, the JavaVM segfaults.

I've tracked that segfault back to the call of ippiFFTFwd_RToPack_32f_C4R (without it, nothing segfaults) and I'd really appreciate if you could track down this nasty bug, as I didn't succeed with that.


JNIEXPORT void JNICALL Java_de_ethrandil_imageequalizer_fftutils_impl_PPIImageFFT_setImage
(JNIEnv *env, jobject obj, jintArray argbArray, jint orderWidth, jint orderHeight)
{
const int width = 1< const int height = 1< const int pixelCount = width * height;
const IppiSize imageSize = { width, height };

//Allocate memory for image and ffted image
Ipp8u* input8u;
Ipp32f* input32f;
Ipp32f *fftImage32f;

int stepInput8u, stepInput32f, stepFftImage32f;
input8u = ippiMalloc_8u_C4(width, height, &stepInput8u);
input32f = ippiMalloc_32f_C4(width, height, &stepInput32f);
fftImage32f = ippiMalloc_32f_C4(width, height, &stepFftImage32f);

//Load interlaced pixel values from Java
//The trick is, that jint is 4 bytes long and so generates an interlaced 4channel pixel.
(*env)->GetIntArrayRegion(env, argbArray, 0, pixelCount, (jint*)input8u);

//Convert to 32bit float image
ippiConvert_8u32f_C4R(input8u, stepInput8u, input32f, stepInput32f, imageSize);
ippiFree( input8u );

//Allocate FFT-Specs
IppiFFTSpec_R_32f *spec;
IppStatus status;
int bufferSize;

status = ippiFFTInitAlloc_R_32f(&spec, orderWidth, orderHeight, IPP_FFT_DIV_INV_BY_N, ippAlgHintAccurate);

//Perform FFT on 32bit image
status = ippiFFTFwd_RToPack_32f_C4R( input32f, stepInput32f,
fftImage32f, stepFftImage32f,
spec, 0 );

//Drop input image
ippiFree( input32f );

//Store pointer to ffted Image and Specs in java object
jclass cls = (*env)->GetObjectClass(env, obj);
jfieldID imagePointerFieldID = (*env)->GetFieldID(env, cls, "_nativeImagePointer", "J");
&nb sp; (*env)->SetLongField(env, obj, imagePointerFieldID, toJava( fftImage32f ));
jfieldID specPointerFieldID = (*env)->GetFieldID(env, cls, "_nativeFFTSpecPointer", "J");
(*env)->SetLongField(env, obj, specPointerFieldID, toJava( spec ));

return;
}


I am using ipp 5.3.3.075 on 64bit Ubuntu Linux 8.04 and a Core2Duo cpu.
0 Kudos
2 Replies
tctbw
Beginner
283 Views
Javas problematic frame was always in libpthread.so. To disable multithreading I switched to static linking and that solved the problem. But that is not what I want - faster is better. Does anyone have an idea if i could use threading in a java-compliant way?
0 Kudos
Ying_S_Intel
Employee
283 Views
Quoting - tctbw
Javas problematic frame was always in libpthread.so. To disable multithreading I switched to static linking and that solved the problem. But that is not what I want - faster is better. Does anyone have an idea if i could use threading in a java-compliant way?


Could you please providethe orderWidth and orderHeight values. Does it also fail with ippSetNumThreads(1)?

0 Kudos
Reply