cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

const24
Journeyman III

Problem with Dynamic-link libraries

I have simple c++ console project that running simple function on gpu, all work fine.

But when i have built this project as dll and used this dll on other simple application, the program has been crashed with exception  "Access violation reading location 0x00000000".

When I am running any function on gpu at this application it's working and function in dll is working too.

Please tell me what's wrong?

0 Likes
5 Replies
the729
Journeyman III

Hi const24,

Actually, with visual studio, you can step into the DLL and see what causes the access violation.

 

0 Likes

Are you using XP for your development? Do you load the dll at runtime?

0 Likes

Hi the729,

When I using debugging, and go step by step into DLL program crash when begin gpu function with memory violation exception, but if I run any gpu funtion in main() all work fine.

Hi gaurav.gard,

yes I using WinXP 32 bit, yes I load the dll at runtime

0 Likes

Brook+ uses one thread local variable in the generated CPP and XP (not Vista or Linux) has limitation on using thread local variable in a dll and calling LoadLibrary() on this dll (more information at http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx).

There are two possible solution of this issue. You can choose any one of them-
1. Instead of loading libraries at runtime, make them link time dependent.
2. Change line 48 of KernelInterface.h (under $(BROOKROOT)\ sdk\include\brook) from #define __THREAD__ __declspec(thread) to #define __THREAD__ and rebuild your application or dll (no need to build Brook+ source). This change should not affect your application until your application is calling the same kernel from multiple threads.

0 Likes

I'am use second solution variant and all work fine!

Thank you gaurav.garg!

0 Likes