0

I now change my cuda program into an MFC project, I wrote the function of .cu as an interface function, So I can call it in MFC's dlg,Because I now use the UI thread call, I want to open a work thread to call, but failed.I am making AfxBeginThread, but it does not recognize my interface function.

I use vs2013, win7. my interface function like this:

extern "C" float solveGPU(M_args Parameter_, double Mtime)
JIaminShen
  • 25
  • 5

1 Answers1

1

You could AfxBeginThread use but you have to call yout function from a new function or a static method with he following prototype:

UINT __cdecl MyControllingFunction( LPVOID pParam );

like this:

UINT __cdecl SolveGPUThreadFunction( LPVOID pParam )
{
    YourDialogClass* pThis = (YourDialogClass*)(pParam);

    pThis->result= solveGPU(pThis->Parameter_, pThis->Mtime);
}

and pass this pointer of your dialog as pParam of AfxBeginThread:

CWinThread* pCUDAThread = AfxBeginThread(&SolveGPUThreadFunction, this);

But you can think about using the std::thread instead.

Mihayl
  • 3,821
  • 2
  • 13
  • 32
  • i try to use std::thread ,but i also meet some questions.https://stackoverflow.com/questions/47302074/type-traits1545-error-c2280 – JIaminShen Nov 15 '17 at 07:59