Multithreading 如何在MFC中打开线程以运行cuda函数?

Multithreading 如何在MFC中打开线程以运行cuda函数?,multithreading,cuda,mfc,Multithreading,Cuda,Mfc,我现在将我的cuda程序更改为MFC项目,我编写了.cu函数作为接口函数,因此我可以在MFC的dlg中调用它,因为我现在使用UI线程调用,我想打开一个工作线程进行调用,但失败了。我正在制作AfxBeginThread,但它无法识别我的接口函数 我使用vs2013,win7。 我的界面功能如下: extern "C" float solveGPU(M_args Parameter_, double Mtime) UINT __cdecl SolveGPUThreadFunction( LPVOI

我现在将我的cuda程序更改为MFC项目,我编写了.cu函数作为接口函数,因此我可以在MFC的dlg中调用它,因为我现在使用UI线程调用,我想打开一个工作线程进行调用,但失败了。我正在制作AfxBeginThread,但它无法识别我的接口函数

我使用vs2013,win7。 我的界面功能如下:

extern "C" float solveGPU(M_args Parameter_, double Mtime)
UINT __cdecl SolveGPUThreadFunction( LPVOID pParam )
{
    YourDialogClass* pThis = (YourDialogClass*)(pParam);

    pThis->result= solveGPU(pThis->Parameter_, pThis->Mtime);
}
您可以使用,但必须使用以下原型从新函数或静态方法调用yout函数:

UINT __cdecl MyControllingFunction( LPVOID pParam );
像这样:

extern "C" float solveGPU(M_args Parameter_, double Mtime)
UINT __cdecl SolveGPUThreadFunction( LPVOID pParam )
{
    YourDialogClass* pThis = (YourDialogClass*)(pParam);

    pThis->result= solveGPU(pThis->Parameter_, pThis->Mtime);
}
并将对话框的
指针作为
AfxBeginThread的
pParam
传递:

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

但是您可以考虑改用std::thread。

我尝试使用std::thread,但也遇到了一些问题。