User forums > Using Code::Blocks
Using OpenMP in Thread
(1/1)
seeing:
I have Created a DLL using openmp, the file is
--- Code: ---extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
// attach to process
// return FALSE to fail DLL load
break;
case DLL_PROCESS_DETACH:
// detach from process
break;
case DLL_THREAD_ATTACH:
// attach to thread
break;
case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
}
//---------------------------------------------------------------------------
DLL_EXPORT void __stdcall Test(Byte *Source, int size)
{
#pragma omp parallel for
for(int i=0; i<size; i++)
{
if(Source[i] == 5)
Source[i] = 22;
}
}
//---------------------------------------------------------------------------
--- End code ---
And I write a test program using by bcb, the code is
--- Code: --- int size = 10;
Byte *src = new Byte[size];
for(int i=0; i<size; i++)
src[i] = i % 10;
Test(src, size);
--- End code ---
if I run this code in botton click event, it's ok.
But, if I run this code in Thread, it has crashed. Using GDB to debug, ths program received signal SIGSEGV, Segmentation fault.
why?
thanks a lot.
Jenna:
Unrelated to C::B and therefore vioalting our forums/websites rules.
Please ask in an appropriate c++/openMP forum.
If you know what is wrong, but you don't know how (or where) to set it up in C::B, feel free to come back and ask again.
Topic locked !
Navigation
[0] Message Index
Go to full version