I am currently learning to use CUDA to speed up calculations. The book I am working with uses C code on the CPU to supply certain variables etc.. So I would like to compile the give code in Mathematica. I found an instance for this in the help CUDALink/tutorial/Programming#120112373 chapter Compiling for CUDA.
Needs["CCompilerDriver`"]
Needs["CUDALink`"]
The NVCCComplier is listed after loading the above stated links and the CUDAFunctionLoad is also working. The output of CCompilers[]
is:
{{Name->Visual Studio,
Compiler->CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
CompilerInstallation->C:\Program Files (x86)\Microsoft Visual Studio 10.0,
CompilerName->Automatic},
{Name->NVIDIA CUDA Compiler,
Compiler->NVCCCompiler,
CompilerInstallation->C:\Users\gbj\AppData\Roaming\Mathematica\
Paclets\Repository\CUDAResources-Win64-10.2.0.3\CUDAToolkit\bin\,
CompilerName->Automatic
}}
testFileName = FileNameJoin[{$CUDALinkPath, "SupportFiles", "cudaDLL.cu"}];
FilePrint[testFileName]
Also works fine and gives the same code than listed in the example. When I try to create a library with
CreateLibrary[{testFileName},"testDLL","Compiler"->NVCCCompiler]
the return is $Failed.
Added:
With ShellOutputFunction->Print as a opition for CreateLibrary I get:
C:\Users\gbj\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\ \Windows-x86-64\Working-goe-nb-0422-7460-5372-11>call "C:\Program \ Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 Setting environment for using Microsoft Visual Studio 2010 x64 tools. nvcc fatal : Unsupported gpu architecture 'compute_51'
Edit:
CUDAInformation[]
gives:
{1->{Name->NVS 5200M,Clock Rate->1344000,Compute Capabilities->2.1,GPU Overlap->1,Maximum Block Dimensions->{1024,1024,64},Maximum Grid Dimensions->{65535,65535,65535},Maximum Threads Per Block->1024,Maximum Shared Memory Per Block->49152,Total Constant Memory->65536,Warp Size->32,Maximum Pitch->2147483647,Maximum Registers Per Block->32768,Texture Alignment->512,Multiprocessor Count->2,Core Count->64,Execution Timeout->1,Integrated->False,Can Map Host Memory->True,Compute Mode->Default,Texture1D Width->65536,Texture2D Width->65536,Texture2D Height->65535,Texture3D Width->2048,Texture3D Height->2048,Texture3D Depth->2048,Texture2D Array Width->16384,Texture2D Array Height->16384,Texture2D Array Slices->2048,Surface Alignment->512,Concurrent Kernels->True,ECC Enabled->False,TCC Enabled->False,Total Memory->1073741824}}
CUDAResourcesInformation[]
returns
{{Name->CUDAResources,Version->10.2.0.3,BuildNumber->,Qualifier->Win64,WolframVersion->10.*,SystemID->{Windows-x86-64},Description->{ToolkitVersion -> 7.0, MinimumDriver -> 300.0},Category->,Creator->,Publisher->,Support->,Internal->False,Location->C:\Users\gbj\AppData\Roaming\Mathematica\Paclets\Repository\CUDAResources-Win64-10.2.0.3,Context->{},Enabled->True,Loading->Manual,Hash->7326e294f5e53407e2ce826e5b3ce301}}
I have no idea why that is and what to do to make it work. Two questions I have now:
1) Can someone give a hint what to do to make it work?
Maybe someone can test it on his machine and confirm it is working in general.
2) Why is this CreateLibrary compiling a DLL and not a lib which I could load with LibraryFunctionLoad?->answered
My system: Windows 7 (64bit), CUDA 7.5.18 installed, MM 10.3, Microsoft Visual Studio 2010
"ShellOutputFunction" -> Print
in CreateLibrary. $\endgroup$Compile[{x}, x + 1, CompilationTarget -> "C"]
$\endgroup$