Well, it’s just a simple CUDA program written in MFC framework. You know, all CUDA examples in NVIDIA SDK were written by using GLUT library, so they only use glut-window. Here, I’m trying to combine CUDA+OpenGL+GLSL in an MFC program, and this is the result.
And the idea is simple, we can write CUDA kernel as a new class. Yeaa… then, you know how to work with a class, rite ?
[sourcecode language=”cpp”]
#pragma once
// includes, system
#include
#include
#include
#include
// includes, project
#include
// Required header to support CUDA vector types
#include
__global__ void kernel( int* g_data );
__global__ void kernel2( int2* g_data );
__global__ void landKernel(float4* pos, unsigned int width, unsigned int height);
class CcudaKernel
{
public:
CcudaKernel(void);
~CcudaKernel(void);
void DoKernel(dim3 gridD, dim3 blockD, int* g_data);
void DoKernel2(dim3 gridD, dim3 blockD, int2* g_data);
void launchLandKernel(float4* pos, unsigned int mesh_width,
unsigned int mesh_height);
void computeGold(char* reference, char* idata, const unsigned int len);
void computeGold2(int2* reference, int2* idata, const unsigned int len);
void runTest(const int argc, const char** argv, char* data, int2* data_int2, unsigned int len);
void loadtotexture(cudaArray* cu_array, cudaChannelFormatDesc channelDesc);
void unbindTexture();
public:
bool success;
};
[/sourcecode]
You can download the complete code from the links below. But, please take a minute to drop email and comment/request for the password, I’ll reply directly to your email within 24 hours.
Update:
I have moved the source to bitbucket.org and open it. So, now you can clone or download it and NO password is needed. Please visit https://bitbucket.org/mteguhsat/cudamfc
Latest test: VS2010 and CUDA 6.5
Old versions (developed in VS 2008 on a 32-bit machine by myself):
Password for old versions: parasatria.tk
for CUDA 3.0 : cudaMFC.rar
for CUDA 3.1 : cudaMFC31.rar (thanks to Jun Wei for experience sharing in compiling this code using CUDA 3.1)
for CUDA 3.2 : use the same code with CUDA 3.1, but you need to make some changes in your project and it’s all about new build rules provided by CUDA toolkit. So, follow these steps (thanks to Manel for giving me idea on this) :
- Put your cursor on project root, then go to Project menu, then click Custom Build Rules.. (see image below)
- A Visual C++ Custom Build Rules Files window will appear.. select one of CUDA Runtime API Build Rule (v3.2) and click OK then.
- Go to the Project’s Properties, find Configuration Properties > Linker > General, and in Additional Library Directories row, add
$(CUDA_PATH)/lib/$(PlatformName)
. - Still in Project’s Properties, find the CUDA Runtime API in the sidebar, click General, then in Additional Include Directories row fill with
$(NVSDKCOMPUTE_ROOT)/C/common/inc
, then click OK. - Compile it now.
using CUDA 4.2 on VS 2010 : cudaMFC2010.rar or mirror. (thanks to Lho). Note: I don’t have chance to test this version currently, so any question regarding this version please address it directly to: lhoffart@free.fr
If you get more problem in compiling the codes, please let me know. 🙂
testimony:
Hello,
Great! Your project’s work, even with NVidia Ion (16 cores), the picture rotate is instant.
I use an ASUS Eee PC Seashell series, Windows 7 32bit & CUDA 3.2 (3.1 don’t recognize Ion).With CUDA 4.0 & 4.2, I have got a lot of redéfinitions between glfreeglut_std.h and GL/glut.h.
But, fortunately, even most recent Geforces are compatible CUDA 3.0.Thank you! Except your blog, CUDA & MFC is strangely untraceable on web and the books.
Now, I can work correctly.I put a short agree message among the comments of your blog. There are almost exclusively comments with ‘send me the password’.
I wish my english is not too bad.Eric (Paris, France).
using CUDA 5 on VS2010 : cuda5MFC10.zip
kau bikin apa lagi ni guh
I need the source password, as i need to merge between MFC and CUDA
hi Eman,
Please check your email. Thx.
Good idea!
I need password!
Hi Jun Wei,
please check your email. thx
After some steps has been taken, it works fine. :=)
1. copy cuda.rules to C:Program FilesMicrosoft Visual Studio 9.0VCVCProjectDefaults
2. remove rendercheck_gl.h from project
3. remove codes below in file redercheck_gl.cpp
/*
CFrameBufferObject::CFrameBufferObject(unsigned int width, unsigned int height,
unsigned int Bpp, fboData &data, fboConfig &config,
bool bUseFloat) :
m_fboData(data),
m_fboConfig(config),
m_bUseFloat(bUseFloat),
m_eGLTarget(GL_TEXTURE_2D)
{
#if !NEW_FBO_CODE
initialize(width, height, m_fboConfig, m_fboData);
CHECK_FBO;
#endif
}
CFrameBufferObject::CFrameBufferObject(unsigned int width, unsigned int height,
unsigned int Bpp, fboData &data, fboConfig &config,
bool bUseFloat, GLenum eTarget) :
m_fboData(data),
m_fboConfig(config),
m_bUseFloat(bUseFloat),
m_eGLTarget(eTarget)
{
#if !NEW_FBO_CODE
initialize(width, height, m_fboConfig, m_fboData);
CHECK_FBO;
#endif
}
*/
testing platform: windows 7 + vs 2008 sp1 + cuda 3.1
Could you please send me the password?
@Jun wei:
Good job, Jun wei !! rendercheck_gl was taken from SDK originally and I used cuda 3.0.
@Bob Zigon:
Hi Bob, please check your email. Thx.
Can I get the password?
I only added CUDA as a DLL to MFC but your method seems better. 😉
Hi Park, you may check your email now. Thanks.
Could you please send me the password? Thanks.
Hi Deyao, done ! please check your email. Thx.
HI! m teguh satria
Could you please send me the password?
Best Regards!
hi, it’s in your inbox now. Thx.
Will love to see that, can you send me a password..
Thank’s
Oups.. miss my email.. sorry..this is the good one..
Can you send me the password ..
Thank’s
Hi Gilles,
Please check your inbox and then enjoy the code.. 😀
It is an interesting mfc project and, I want to know if there is or not a c++ compiler for cuda
thanks in advance
Mr. Pedro
Hi Mr. Pedro, you can take a look at the code now. Feel free to drop any feedback. 🙂
Thanks
Would you please send me the password. I need your program for study purpose. Thank you very much.
Hi Nguyen, check your inbox and enjoy the code.. 🙂
I received your password. I’m enjoying your code ^^
Thank you very much.
Could you please send me the password?
Thank you very much.
Hi, it’s in your inbox now. check it out. 🙂
Please send me the password.
Thank you very much.
Salam/Regards, Muhammad Teguh Satria
Send plese me the password. Thank you.
Send please me the password. Thank you.
I need a password! Please send me. Thank you very much.
hi fenvik and larry, check your inbox now. thx
Send please me the password. Thank you very much.
check your inbox, hattori. thx.
Hi. Nice work!
Could you please send me the password?
Hi Alejo, it’s in your inbox now.
Hi, could you give me the password, please?
Thank you very much!
hi moon, check your inbox now..
Hi
Thanks for your input.
Could you provide me with the password?
Thank you
– j
hi Joe, it’s in your inbox now..
I study cuda, and MFC.
Could you please send me the password?
Thank you. 🙂
hi hyeun, it’s in ur inbox..
Please send me the password.
Thank you very much.
hi, check your inbox..
Hi , could you send me the Password please ?
hi, i’ve sent it your email.. thx
need password
hi sizdah, sorry your email didn’t work. post it again..
“Remote host said: 554 delivery error: dd This user doesn’t have a yahoo.com account(sozdahdreizehn@yahoo.com)”
Could you please send the password.
Thanks
hi Suresh, check your inbox..
Hi.
Please, could you send me the Password?
Hi Jeong, check your inbox now.. Salam/Regards,
thanks for the great job, btw I need password..
please send me to my email linked above.
hi zepa, you may check your inbox now.. thx
Please send me the password.
By the way, nice job.
hi yiguro, do check your inbox, thanks..
heuheu… komputer cepet gw udah dateng, bagi password dong guh… 😀
yes, I need the password too, thx
hi Steve, check your inbox..
Salam / Regards, Muhammad Teguh Satria
Please send me the password also.thanks.
hi sagi, check your inbox now.. Salam / Regards, Muhammad Teguh Satria blog | linkedin
Hi, This is great, exactly what I was looking for. But unfortunately the download link doesn’t seem to work. Could you please send me the password and the code. Thanks a lot in advance.
hi, i don’t see any problem with the link. try again using the password i’ve sent to you.
Can you send me the password please. Tnx
hi mr. lohman, it’s in your inbox now.
Hi, could you pls send me the password? I’m trying to add a MFC activeX into a CUDA program but run into some trouble. Cheers.
hi, do check your inbox.. 😀
would you please give me cudaMFC.rar password .
thanx
hi, it’s in your inbox now.. 🙂
Great job, please send me password.
Thx
hi, in your inbox it is…
Windows 7 (64bit) + cuda 3.2
if use project->properties-> configuration->linker-> advanced->target machine-> select X64. There is a link error.
1>.ReleasecudaMFC.obj : fatal error LNK1112: module machine type ‘X86’ conflicts with target machine type ‘x64’
However, if use project->properties-> configuration->linker-> advanced->target machine-> select X86. There is a link error.
1>.ReleasecudaMFC.obj : fatal error LNK1112: module machine type ‘x64’ conflicts with target machine type ‘X86’.
Appreciate for any suggestion.
Hi Joe Hu, are you using Visual Express ?? actually, Visual Express can only build 32-bit app. Since you’re working with 64-bit CUDA, then you’ll get those conflicts. Check my post here.. http://parasatria.wordpress.com/2010/07/05/another-kotretan
can u give me the password?, thanks
hi, it’s in your inbox..
Password please, I cant wait to try int out…
Good Job.
done ! check your inbox..
Thank you so much for that. That’s the thing that I was looking for my research. I’d also be glad if you could send me the password.
Thank you again,
Best Regards.
Hi Emre, I’ve done, check your inbox..
Hi,
Can you send me the password please?
Thanks.
hi, your inbox…
Great,would you please share it with me?
sure, check the password in your inbox..
Hi,
Great Work!
Can you send me the password please?
Thanks.
hi, done.. check your inbox..
Hi,
Great Job, Could you provide me the password?
Thanks in advance
Hi thanks for the program.Could you send me the password?
@Damien & Ramazan : check your inbox, guys.. 😀
Awesome. Thanks a lot.
Will check it right now
thanks for your kind. I think it’s amazing program!!!
But it is locked… Can I receive the password?
I hope your lucky fortune 🙂
감사합니다.
Hi Yongnim, i’ve sent it to you… thanks.
I beg for the password
Can I receive the password for the .rar file, please?
Manel, Zhiwei.. i’ve sent you the pass.. thx
Great MFC + CUDA startup project.
If you had cuda.rules error try the following:
In order to compile with VS 9.0 (and Windows 7, 64b) and CUDA 3.2 I did the following changes in the project:
1) Edit the cudaMFC.vcproj with the Notepad and change the following line
<DefaultToolFile
FileName="cuda.rules"
<DefaultToolFile
FileName="NvCudaRuntimeApi.rules"
2) delete remove rendercheck_gl.h and .cpp from project
3) Change the Additional Library Directories for the correct ones. In my case: $(CUDA_PATH)/lib/$(PlatformName);
wow.. thanks for sharing, Manel..
Good job. I need password, thanks.
done ! check your inbox..
Hi…pls send me the password
hi dharneesh, check your inbox now…
Hi, please give me the password, thank you very much!
I beg for the password!! thx
I beg for the password..!!
done! check inbox…
I need password. Thank you
Hi,pls send me the password,thx!
i’ve sent it… check your inbox..
Can you please send me the password. I’m doing the same thing but I’m running into linking errors.
Thanks
hi, check your inbox, and then enjoy the code.. 😀
I need the password, thank you.
hi, check your inbox..
i need a password!!
hi, it’s in your inbox already… 😀
Very interesting, can I please get the password?
Do you think the same procedure applies for CUDA 4.0?
Hi,
i am working on CUDA for Data Normalisation for that i require to emerge MFC code in cuda, I found ur code might be helpful, so please send me the password on my mail id.
waiting for ur reply
@Kaj: I’m not working in Win recently, so I’ve no idea for cuda 4.0. But, you can try.. and then please share your experience here.. 😀
@Vishal: it’s in your inbox now.. 😀
Vishal,
I successfully interfaced my CUDA 4.0 code from MFC. However, I didn’t use your code, so I cannot say if the procedure is exactly the same. I wrote a class for my CUDA klernel and wrapped into a DLL which I use from the MFC application.
i see.. in the past, I also tried that way.. but it's not easy to maintain.. i mean in case you want to make some changes in the kernel.. 😀 �
hi and thanx . please password
hi, it’s in your inbox already…
please give me a password thank you
Please send me a password.
@william & jin: i’ve just sent it to you both…
Hi. Thanks for sharing. I’m interested MFC with Cuda.
Please inform me the password.
I am interested in your work.
Please send me the password.
i’ve sent it..
Hi, i’m a newbie in programming and it’s so sad to use cuda with MFC. Please send me the password. It might be a great help.
Thanx.
Could you please send me the password? Thanks
hi, i’ve sent it. check your inbox..
Hi . i recieved the password . Thanks
Hi! I am trying to use MFC with CUDA and would like to look at your sample code. Could you please send me the password. Thanks!
It’s really interesting! Can you give the password?
Thanks for sharing !. I’m also interested MFC with Cuda.
I would love the password.
check your inbox, guys…
Sounds great! Could you please send me the password? Thanks!
Hi, I’m also interested in your sourcecode. Just try to use CUDA with MFC and stuck in my progress, so can you please send me the needed password? Thanks a lot.
hi, it should already be in your inbox now..
please send me the needed password? Thanks a lot.
Hi, please send me too, I’m really interested. Thanks a lot.
Please send me the password. Thanks.
I can’t convert project to VS2010.
My error in VS2010 conversion is this:
The following error has occurred during XML parsing: File: C:TempcudaMFCcudaMFCcudaMFC.vcproj Line: 32 Column: 5 Error Message: Error del sistema: -2146233088. The file ‘C:TempcudaMFCcudaMFCcudaMFC.vcproj’ has failed to load.
Password please….
Hey! Please send me the password :). This looks like it’ll be really helpful.
Well Done
Hi. p
lease send me too~
Hello. May I know the password? thanks! 🙂
It Looks nice y program with MFC and I want to start with CUDA, please send me the Password
i’m sure people above this comment already got the password in their inbox.. 🙂
Dear m teguh satria,could you send me the password,please., I’m really interested,thanks a lot.
hi, i’ve sent it.
First of all, thank you much for the work.
And would you let me know the password?
Glad to you demo, that is what I need.
Thanks for your work.
Can you send me the password?
Also I use cuda 4.0 do I need to do some modification ?
Best,
Lei.
I will try cudaMFC31.rar.
Can you send me the password? Thanks.
Hi, please I need the password. Thanks!
can you send me the password? thx
Hi, I don’t know if you still view this page but if so can i get the password please?
HR,
Ghandi
Good job can i get password? please help me
nice !
please send me password!
GOOD~~~
please send me password !!! thanks
Could you send me the password, I have a movie editor project on CUDA+MFC, but some reason I need to use cuda-opengl… if can plz, send me the passwords.
Dear author of CUDA MFC project,
Could you please send me the password for archive
Nick
Hi please send me the password of rar file
I real need your source file!so Could you please send your password to me?
Thanks a lot ! Email :wyf0536@163.com
Thank you very much!
Hi please send me the password for the file. Email: cmp2009@live.ca
Thanks for sharing your work!
Very useful site! Thanks a lot! Could I also get password for the code, please?
Hi, can i get the password for the source code ? i need to do CUDA code and im really new at this
Hi,can you send me the password? Email : lukeafang@gmail.com
Thank you very much!
Please give me the password. Thank you!
very good example. i was trying to the similar thing, but got constant linking errors. can you give me pass code to the file cudaMFC31.rar? thank you very much.
Hi thanks for your Example. plz send me your password
s3s4m7j5@naver.com thanks 😀
Hi. Your example could be very helpfully for my project. Could you please send me the password for the *.rar file. Thanks in advance. My email is sir_dany_17@yahoo.com
Hi thanks for you. please send me your password ^^
seansun79@nate.com
please send me your password
thanks you!
hongsonfit@gmail.com
Hi, thanks for you. Please send me your password for the rar.
19asdek91@gmail.com
thanks!
Hi!!
Can I get the password for MFC31.rar file.
thank you.
Very interesting project
thanks you for the password (cudaMFC31.rar) and all in advance.
Great! It’s work, CUDA and MFC: it’s very practical and elegant. Not of hesitation, I work with it now.
Very interesting project
Could you send me the password (cudaMFC31.rar).
Thank’s
thank’s I will try to used it with VS 2010.
Have a nice day
Lho
Hello,
This is a new version of the cudaMFC project build with Visual studio 2010 (x86 and x64).
The project use the last cuda sdk release 4.2.
You can download the project with the link bellow and the password is the same as the original project.
Bye
Lho
Just forget the link :
http://dl.free.fr/fUCmfp7cX
hi!, Password please :X
Hi, I am a student at USC. I need password. Thanks a lot!
Could you send me the password? Thanks.
Could you send me the password? Thanks.
Hi.
Please, send me the password.
Thanks.
Could you please send me the password?
please,Send me the password. Thank you.
Im using CUDA 5.0, please, send me a pasword
Hi, I am trying to learn CUDA so looking for PW. please send me.
Hi, Good job. I am learning how to write a kernel class. please send a password to me! Thank you! I appreciate it.
Please, send me the password. Thank you.
may you send me the password for cuda5MFC10.zip as well?
please, send you to me password for cuda5MFC10.zip
I need the source password, as i need to merge between MFC and CUDA
Please send me the password.
azuredsky@live.cn
Please send me pass for CUDA 5.
I just swung by while i was looking for openGL solution, can you share it for “cuda5MFC10.zip”
Please kindly send me the password for cuda5MFC10
Please kindly send me the password for cuda5MFC10 feilongch@gmail.com
Hi
I just start to learn cuda, very thanks for your experience sharing, I had download file cuda5MFC10.zip. Please send me the password. many thanks.
Hi
I just start to learn cuda programming. Thanks for your experience sharing. i had download the file cuda5MFC10.zip. please send me the password. many thanks.
Please send me the password for cuda5MFC10
Great example! Pls send me the password. Thanks
i had download the file cuda5MFC10.zip. please send me the password.
Can not work on windows 7 x64 cuda 5.5 using vs 2012 sp4!
Jun Wei,
I don’t have chance to test it in all machines, in all platforms, in all CUDA versions. As you can see comments below, people share their experiences and give me feedbacks how to make it works in different machines.
Let me know what kind of errors you got. Maybe I could give some directions about what you need to do. Thanks.
can u help me to change this code to CUDA
float h_max(float *h_surf)
{
int i,totpoints;
float hmax =-1.0e6;
totpoints=ni*nj;
for ( i=0; i hmax)
hmax=h_surf[i];
}
return hmax;
}
I just start to learn cuda programming
Hi Efra,
Your code is not complete. hmax is float, you could not put it like this: for ( i=0; i hmax)
The link seems to be broken. Could you send the file and password? Many thanks!
I can’t open it, either. Could you send me the file (cuda5MFC10.zip) directly or update the resources? Thanks.
It works well, thanks.
Hi
I downloaded your last version of VS2010 and CUDA 6.5, but I compiled them in VS2013. The compiling and linking processes were OK, but I failed in run time. It seemed that my glew32.dll (1.11.0[08-11-14]) did not match your program (No entry point …). Therefore, I’d like to know what version of glew32 you had used with them. Or, did I miss anything? Thank you very much!
I am running an Acer NB with Win. 8.1 X64 and Nvidia 750M.
Garry
Hi,
I solved my problem by geting the right glew32.dll from Nvidia. Thanks anyway!
Garry
Please send me the password, my email is 763450476@qq.com, thank you very much
This page was very helpful for me.
I had download the file cuda5MFC10.zip. please send me the password.
Thank you
Hi Chinsan, please clone/download from bitbucket repo and you don’t need any password.