cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Steven_Makoviac
Journeyman III

Java, JNI, Brook+, dll EXCEPTION_ACCESS_VIOLATION

Hi folks,

i've a problem with a Java program which is loading a dll to compute several things on the GPU. I trieded many things and at the moment i don't know, maybe it's a bug. Everytime i want to call a kernel the program crashes with a Java Exception: An unexpected error has been detected by the Java Runtime Environment EXCEPTION_ACCESS_VIOLATION.

I reduced everything to find the error but i can't find it, this is the kernel:

kernel void sum(float a<>, float b<>, out float c<>
{
  c = a + b;
}

 

This is the function in the dll that calls the kernel:

JNIEXPORT void JNICALL funk
  (JNIEnv *env, jobject obj,)
  { 
 unsigned int ssize = 10000;
 const unsigned int DATA_SIZE = 10000;
 float data1[DATA_SIZE];
 float data2[DATA_SIZE];
 Stream<float> stream1(1,&ssize);
 Stream<float> stream2(1,&ssize);
 Stream<float> stream3(1,&ssize);
 std::fill(data1,data1+DATA_SIZE,50.0f);
 std::fill(data2,data2+DATA_SIZE,50.0f);
 stream1.read(data1);
 stream2.read(data2);
 sum(stream1,stream2,stream3);
 float data3[DATA_SIZE];
 stream3.write(data3);
 std::copy(data3,data3+DATA_SIZE,ostream_iterator<float>(cout," "));

  } 

This is how i compile the dll:

cl.exe  /EHsc -I%jdkp%  -I%jdkw32% -I%brook% -I%common% -LD main.cpp gpu.cpp -FeGPU_DLL.dll /link /LIBPATH:%brooklibs% %libs%

 The whole thing works as a normal program, but in the dll it crashes. If i remove the kernel call ( sum(stream1,stream2,stream3)) from the program there is also no Error.  Every call from the dll to the GPU causes an error. What i'm doing wrong?

 

0 Likes
0 Replies