If I compile an example with Visual C++ Express from the SDK I don’t have any problems, I can run it…
Now, I’m trying to use the CUDA plugin for Matlab ith Matlab2007b and Visual C++2005 Express edition, I can compile a mex file with no problem, but I can’t compile the example :
Szeta.cu
"C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\crtdefs.h", line 472: error:
invalid combination of type specifiers
typedef unsigned short wchar_t;
^
"c:\cuda\include\common_functions.h", line 55: warning: dllexport/dllimport
conflict with "clock" (declared at line 176 of "C:\Program
Files\Microsoft Visual Studio 8\VC\INCLUDE\time.h");
dllimport/dllexport dropped
extern __declspec(__host__) __declspec(__device__) clock_t clock(void);
^
1 error detected in the compilation of "C:\DOCUME~1\JEAN-B~1\LOCALS~1\Temp/tmpxft_00000f00_00000000-5.ii".
F:\MATLAB~1\BIN\NVMEX.PL: Error: Compile of 'Szeta.cu' failed.
@echo off
rem MSVC80OPTS.BAT
rem
rem Compile and link options used for building MEX-files
rem using the Microsoft Visual C++ compiler version 8.0
rem
rem $Revision: 1.1.10.2 $ $Date: 2006/06/23 19:04:53 $
rem
rem ********************************************************************
rem General parameters
rem ********************************************************************
set MATLAB=%MATLAB%
set VS80COMNTOOLS=%VS80COMNTOOLS%
set VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8
set VCINSTALLDIR=%VSINSTALLDIR%\VC
set PATH=%VCINSTALLDIR%\BIN\;%VCINSTALLDIR%\PlatformSDK\bin;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\SDK\v2.0\bin;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%VCINSTALLDIR%\VCPackages;%MATLAB_BIN%;%PATH%
set INCLUDE=%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\PlatformSDK\INCLUDE;%VSINSTALLDIR%\SDK\v2.0\include;%INCLUDE%
set LIB=%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%VCINSTALLDIR%\PlatformSDK\lib;%VSINSTALLDIR%\SDK\v2.0\lib;%MATLAB%\extern\lib\win32;%LIB%
set MW_TARGET_ARCH=win32
rem ********************************************************************
rem Compiler parameters
rem ********************************************************************
set COMPILER=nvcc
set COMPFLAGS=-c -Xcompiler "/c /Zp8 /GR /W3 /EHsc- /Zc:wchar_t- /DMATLAB_MEX_FILE /nologo"
set OPTIMFLAGS=-Xcompiler "/MD /O2 /Oy- /DNDEBUG"
set DEBUGFLAGS=-Xcompiler "/MD /Zi /Fd"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set NAME_OBJECT=-o
rem ********************************************************************
rem Linker parameters
rem ********************************************************************
set LIBLOC=%MATLAB%\extern\lib\win32\microsoft
set LINKER=link
rem set LINKER=nvcc
set LINKFLAGS=/dll /export:%ENTRYPOINT% /MAP /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /implib:%LIB_NAME%.x /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
set LINKOPTIMFLAGS=
set LINKDEBUGFLAGS=/DEBUG /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set LINK_FILE=
set LINK_LIB=
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
set RSP_FILE_INDICATOR=@
rem ********************************************************************
rem Resource compiler parameters
rem ********************************************************************
set RC_COMPILER=rc /fo "%OUTDIR%mexversion.res"
set RC_LINKER=
set POSTLINK_CMDS=del "%OUTDIR%%MEX_NAME%.map"
set POSTLINK_CMDS1=del %LIB_NAME%.x
set POSTLINK_CMDS2=mt -outputresource:"%OUTDIR%%MEX_NAME%%MEX_EXT%";2 -manifest "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS3=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
The compiler flags need an additional -D_WCHAR_T_DEFINED
@echo off
rem MSVC80OPTS.BAT
rem
rem Compile and link options used for building MEX-files
rem using the Microsoft Visual C++ compiler version 8.0
rem
rem $Revision: 1.1.10.2 $ $Date: 2006/06/23 19:04:53 $
rem
rem ********************************************************************
rem General parameters
rem ********************************************************************
set MATLAB=%MATLAB%
set VS80COMNTOOLS=%VS80COMNTOOLS%
set VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8
set VCINSTALLDIR=%VSINSTALLDIR%\VC
set PATH=%VCINSTALLDIR%\BIN\;%VCINSTALLDIR%\PlatformSDK\bin;%VSINSTALLDIR%\Common7\IDE;%VSINSTALLDIR%\SDK\v2.0\bin;%VSINSTALLDIR%\Common7\Tools;%VSINSTALLDIR%\Common7\Tools\bin;%VCINSTALLDIR%\VCPackages;%MATLAB_BIN%;%PATH%
set INCLUDE=%VCINSTALLDIR%\ATLMFC\INCLUDE;%VCINSTALLDIR%\INCLUDE;%VCINSTALLDIR%\PlatformSDK\INCLUDE;%VSINSTALLDIR%\SDK\v2.0\include;%INCLUDE%
set LIB=%VCINSTALLDIR%\ATLMFC\LIB;%VCINSTALLDIR%\LIB;%VCINSTALLDIR%\PlatformSDK\lib;%VSINSTALLDIR%\SDK\v2.0\lib;%MATLAB%\extern\lib\win32;%LIB%
set MW_TARGET_ARCH=win32
rem ********************************************************************
rem Compiler parameters
rem ********************************************************************
set COMPILER=nvcc
set COMPFLAGS=-c -D_WCHAR_T_DEFINED -Xcompiler "/c /Zp8 /GR /W3 /EHsc- /Zc:wchar_t- /DMATLAB_MEX_FILE /nologo"
set OPTIMFLAGS=-D_WCHAR_T_DEFINED -Xcompiler "/MD /O2 /Oy- /DNDEBUG"
set DEBUGFLAGS=-D_WCHAR_T_DEFINED -Xcompiler "/MD /Zi /Fd"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set NAME_OBJECT=-o
rem ********************************************************************
rem Linker parameters
rem ********************************************************************
set LIBLOC=%MATLAB%\extern\lib\win32\microsoft
set LINKER=link
rem set LINKER=nvcc
set LINKFLAGS=/dll /export:%ENTRYPOINT% /MAP /LIBPATH:"%LIBLOC%" libmx.lib libmex.lib libmat.lib /implib:%LIB_NAME%.x /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
set LINKOPTIMFLAGS=
set LINKDEBUGFLAGS=/DEBUG /PDB:"%OUTDIR%%MEX_NAME%%MEX_EXT%.pdb"
set LINK_FILE=
set LINK_LIB=
set NAME_OUTPUT=/out:"%OUTDIR%%MEX_NAME%%MEX_EXT%"
set RSP_FILE_INDICATOR=@
rem ********************************************************************
rem Resource compiler parameters
rem ********************************************************************
set RC_COMPILER=rc /fo "%OUTDIR%mexversion.res"
set RC_LINKER=
set POSTLINK_CMDS=del "%OUTDIR%%MEX_NAME%.map"
set POSTLINK_CMDS1=del %LIB_NAME%.x
set POSTLINK_CMDS2=mt -outputresource:"%OUTDIR%%MEX_NAME%%MEX_EXT%";2 -manifest "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
set POSTLINK_CMDS3=del "%OUTDIR%%MEX_NAME%%MEX_EXT%.manifest"
I have a similar problem with Matlab R2007b and plugin 1.1…
I can correctly execute the code mentioned below:
…but when I try to compile CUDA code like the one in the example:
I receive this message:
I’ve already done the setup of “nvmex” choosing M$ Visual Studio 8 but I always receive the same message. I don’t know how to use the plugin with Matlab. I don’t understand if compiling those programs is mandatory or I just need to replace fft2 and ifft2 files in mathlab with the ones i just created :D
Segmentation violation detected at Wed Jan 09 13:35:17 2008
Configuration:
MATLAB Version: 7.2.0.232 (R2006a)
MATLAB License: 161051
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 2)
Processor ID: x86 Family 15 Model 8 Stepping 2, AuthenticAMD
Virtual Machine: Java 1.5.0 with Sun Microsystems Inc. Java HotSpot™ Client VM mixed mode
Default Charset: windows-1251
how do you get to be a hardware alpha/beta tester? we’re going to be doing image processing with a Red One camera which throws out 4k compressed frames and 2k uncompressed data. i’d like to see what kind of cutting edge stuff you got.
which Szeta
C:\Documents and Settings\CUDA\Desktop\CUDA\Szeta.m
tic; FS_2Dturb(128,1,1,1); toc;
CFL =
0.1017
Gsqav =
1.1995
Elapsed time is 8.506012 seconds.
tic; FS_vortex; toc;
ans =
512
Elapsed time is 216.061310 seconds.
but when i try to compile the CUDA source The following error is showing up that it could not open the file kernel32.lib…some body please help me as i am anew bie…
nvmex -f nvmexopts.bat Szeta.cu -ID:\Programming\CUDA\include -LD:\Programming\CUDA\lib -lcufft -lcudart
Szeta.cu
“d:\programming\cuda\include\common_functions.h”, line 55: warning:
dllexport/dllimport conflict with “clock” (declared at line 176 of
“D:\Programming\Microsoft Visual Studio 8\VC\INCLUDE\time.h”);
dllimport/dllexport dropped
extern __declspec(host) __declspec(device) clock_t clock(void) ;
^
I have found the solution (at least for my machine, Matlab 2009a, Visual Studio 2008 (9.0) )
1st: The linker searches for some libraries, such as kernel32.lib, in %MATLAB%\extern\lib\win32\microsoft% (see nvmexopt.bat)
The libraries are in the MSVC SDK path in “C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin”
Copy all the files (*.lib) of the second (MSVC) to the first directory (MATLAB).
2nd: After that I encountered a problem with the mt command in the pre-last line of the nvmexopts.bat file
set POSTLINK_CMDS2=mt … bla bla
replace it with
set POSTLINK_CMDS2=“C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe” … bla bla
3rd: One minor change is the path of the visual studio:
set VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 9.0
instead of Visual Studio 8.0
Of course, maybe somebody can give a more efficient solution.
I did what you say and it works, I can compile with Matlab 2007b and Visual Studio 9.0
and I run the exemple to solve the Euler equation and I obtain the same results, therefore, It works.
However, Matlab continues giving me this fail with these warnings:
mex fft2_cuda.c -IC:\CUDA\include -LC:\CUDA\lib -lcudart -lcufft
Writing library for fft2_cuda.mexw32
c:\docume~1\josant~1\config~1\temp\mex_30a60ef5-40e7-4a67-9c81-c4e847b5aec2\fft2_cuda.obj .text: undefined reference to ‘_cudaMalloc@8’
c:\docume~1\josant~1\config~1\temp\mex_30a60ef5-40e7-4a67-9c81-c4e847b5aec2\fft2_cuda.obj .text: undefined reference to ‘_cudaMemcpy@16’
c:\docume~1\josant~1\config~1\temp\mex_30a60ef5-40e7-4a67-9c81-c4e847b5aec2\fft2_cuda.obj .text: undefined reference to ‘_cufftPlan2d@16’
c:\docume~1\josant~1\config~1\temp\mex_30a60ef5-40e7-4a67-9c81-c4e847b5aec2\fft2_cuda.obj .text: undefined reference to ‘_cufftExecC2C@16’
c:\docume~1\josant~1\config~1\temp\mex_30a60ef5-40e7-4a67-9c81-c4e847b5aec2\fft2_cuda.obj .text: undefined reference to ‘_cufftDestroy@4’
c:\docume~1\josant~1\config~1\temp\mex_30a60ef5-40e7-4a67-9c81-c4e847b5aec2\fft2_cuda.obj .text: undefined reference to ‘_cudaFree@4’
C:\ARCHIV~1\MATLAB\R2007B\BIN\MEX.PL: Error: Link of ‘fft2_cuda.mexw32’ failed.
??? Error using ==> mex at 208
Unable to complete successfully.
Although the fft2_cuda.mex32 is created in any case.
Is it something about the mex file?. About Matlab?