Hey,
I am building a Dll written using CUDA in the Visual Studio environment. I want to pre-allocate some CUDA memory when the DLL is loaded, and clean them up when the DLL is detached. Here is a sample DllMain call :
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
//do cuda memory allocation here
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
//do cuda memory deallocation here
break;
}
return TRUE;
}
I tried adding the memory allocate and deallocate calls in DllMain. But my application crashes, and it crashes when it tries to do any allocation at DLL_PROCESS_ATTACH, or deallocate at DLL_PROCESS_DETACH.
Can some one help me understand what might be the issue here?
Thanks
Goutham