CUDA Atomic Functions - atomic

I'm using Visual Studio 2015 along with CUDA runtime 8.0. I've been trying to use atomic functions but am not able to include the proper header file. I've seen answers where they've used sm_11 to compile the code but what will be the procedure in Visual Studio?

Related

Check if VC++ Redistributable 10 is installed through perl script

I am writing a perl script to check if the Visual C++ Redistributable 2010 x64 is installed in the system already.
I came across two ways according to https://blogs.msdn.microsoft.com/astebner/2010/05/05/mailbag-how-to-detect-the-presence-of-the-visual-c-2010-redistributable-package/
To read the registry for the corresponding entry.
or to use MsiQueryProductStateA
Using Win32::TieRegistry is not a possible option with out per setup.
but using use Win32::API is an option
Trying to use MsiQueryProductStateA with Win32::API
use Win32::API;
$function = Win32::API::More->Import(
'msi', 'INSTALLSTATE MsiQueryProductStateA(LPCSTR szProduct)'
);
Supposed to get some valid return value but getting error
Win32::API::parse_prototype: WARNING unknown output parameter type 'INSTALLSTATE' at C:\Program Files\HP\HP BTO Software\nonOV\Perl\a\lib/5.26.2/MSWin32-x64-multi-thread/Win32/API.pm line 600. 4294967294
Could someone please shed some light on how to use/ import the return type as well and how to use this ?
Thanks in advance
Show how to implement in C++ (not in perl) you can refer to.
I installed Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019.
Return value 5 indicate "The product is installed for the current user."
Find the product code in registry like this:
HKEY_CLASSES_ROOT\Installer\Dependencies\Microsoft.VS.VC_RuntimeAdditionalVSU_x86,v14

Microsoft Visual C++ 8.0 compiler error which occurs when the C++ class API and /or the number of C++ classes in a DLL becomes too large

I was wondering if anyone knew what the number of the Microsoft Visual C++ 8.0 compiler error which occurs when a C++ class API and /or the number of C++ classes in a DLL becomes too large.
Thank you for your help.
My answer to this question is:
That would probably most likely be Microsoft Visual C++ compiler C1002
(http://msdn.microsoft.com/en-US/library/c9e6fs6b%28v=vs.80%29.aspx):
"compiler is out of heap space in pass 2"
Fatal Error C1002
Visual Studio 2005 Other Versions Visual Studio 2012 Visual Studio 2010 Visual Studio 2008 Visual Studio .NET 2003 1 out of 3 rated this helpful - Rate this topic
Error Message
compiler is out of heap space in pass 2
The compiler ran out of dynamic memory space during its second pass, probably due to a program with too many symbols or complex expressions.
To fix by using the following possible solutions
1.Divide the source file into several smaller files.
2.Break expressions into smaller subexpressions.
3.Remove other programs or drivers that consume memory
Please let me know your opinionof this proposed answer.
the solution to this problem i was told this morning is to close the Visual Studio C++ 2008 environment and then restart ii up again.
Shown below is the latest answer I received to the Stack Overflow question:
Microsoft Visual C++ 8.0 compiler error which occurs when the C++ class API and /or the number of C++ classes in a DLL becomes too large
"the compiler's input objects are source files, not dll's. the dll is output of the linker. i never have seen a source file that was too big for compilation. the biggest file i can remember had about 50,000 lines. it probably included header files of same or greater total size.
if your system is low on heap memory it is more likely that the linker would report problems or error because of this. in my opinion it is only a rare chance to happen on a modern system. you also could/should upgrade to newer version of visual studio, for example visual studio 2012 (vc11) is 7 years younger than your compiler. if you were developing on windows xp you should go to vs2008 (vc9) which is more stable than vc8"

Is it possible to create a win64 MEX file that does not require Microsoft Visual C++ Runtime libraries

I am trying to see if you can distribute a MEX file without requiring the end user to install the C++ runtime libraries.
When you use visual 2010 express to create MEXs, Matlab issues this warning :
Warning: Applications/components generated using Microsoft Visual C++
2010 require that the Microsoft Visual Studio 2010 run-time
libraries be available on the computer used for deployment.
To redistribute your applications/components, be sure that the
deployment machine has these run-time libraries.
Is there a compiler that doesn't require to install the run-time libraries on the end machine?
Yes there is: MinGW(-w64) GCC. It only links to the OS library msvcrt.dll (when you link with the -static option), which requires no installation and is part of Windows.
To get Matlab to work with that, you'll need to jump through some hoops. Here is some information. Ignore the Cygwin stuff, and be sure to use a MinGW-w64 toolchain targetting x64 Windows from the link above. Note I haven't personally tested this, but this is your best bet. It's also unsupported by Mathworks, so you are on your own.
As an aside, what's the problem with installing the MSVC++2010 redistributable anyways? There's no effect on licensing, and running MEX code implies having Matlab installed. Installing one more little thing won't be that much trouble IMHO.

How to use CMake and Visual Studio 2010 (64 bit) to build a MATLAB R2011a (64 bit) mex file?

I would like to write a CMakeLists.txt such that CMake writes a Visual Studio 2010 (64 bit) solution file to build a mex function for MATLAB R2011a (64 bit) from C++ code example.cxx.
I do not want to use MATLAB's compiler wrapper mex but set up the Visual Studio solution file such that Visual C++ links the relevant MATLAB libraries.
example.cxx has no dependencies except for the MATLAB libraries that are necessary for mex files.
CMake 2.8.7 is set up correctly such that it uses the 64 bit generator for Visual Studio 2010.
The essence of what I am doing right now is
find_package(Matlab)
add_library(example STATIC example.cxx)
target_link_libraries(example ${MATLAB_LIBRARIES})
Neither the compiler nor the linker issues any errors. I install the output example.lib under the name example.mexw64 in a directory in MATLAB's path. When I call example from MATLAB, I get the error message
??? Invalid MEX-file
'C:\...\example.mexw64':
C:\...\example.mexw64 is not a valid Win32 application.
Any suggestions are welcome!
I had the same problem and this link was very helpful (also serves as a nice example of how to use ITK in a MATLAB MEX file btw). I think for your case, you need to add the link flag "/export:mexFunction" to your CMakeLists.txt file. Example below:
PROJECT(example)
FIND_PACKAGE(Matlab REQUIRED)
INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR})
ADD_LIBRARY(example MODULE example.cpp)
ADD_DEFINITIONS(-DMATLAB_MEX_FILE)
# Needed for entry point.
SET_TARGET_PROPERTIES(example
PROPERTIES
LINK_FLAGS "/export:mexFunction"
)
# Change the dll extension to a mex extension.
set_target_properties(example PROPERTIES SUFFIX ".mexw64")
TARGET_LINK_LIBRARIES(example ${MATLAB_LIBRARIES})
Note that the FIND_PACKAGE(Matlab) doesn't seem to work all that well, so that may be a problem for some people. I had to get around it by hard-coding the MATLAB paths into CMakeLists.txt (not shown in this example).
Matlab mex files are dll`s not libs. Try making cmake (not an expert on that) create a dynamic librart، not static.

Get started with CUDA in Matlab

Hey there,
I need to get started to Cuda in Matlab. As I need additional functions than provided from matlab, I need to write my own c++ code, e.g. I want to run my program on 1..N GPU-processors and compare the results to calculate the speedup, which is not supported by Matlab itself (as Matlab always optimizes itself to use all processors).
Now I wonder how to get started best. I already read a lot of papers, but I still wonder for example, what those files are all about:
.cu
.cubin
.ptx
.mex
So which way do I need to go? Writing my code to a .cu file and than compiling it (which tool to use?
My computer is:
Q9550 with GTX460,
Win7 x64,
Matlab R2010b x64,
Visual Express C++ 2008 (free -> 32bit version),
Cuda Toolkit 3.2 (64bit),
Latest Nvidia Driver and GPU Programming SDK 3.2.16_win_64
How to get on? When I try to open one of the examples out of the GPU Programming SDK, e.g. the file vectorAdd_vc90.vcproj ouf ot C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\src\vectorAdd
I get
"The following XML parsing-error occured:
File: C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\src\vectorAdd\vectorAdd_vc90.vcproj
Row: 22
Column: 4
Fehlermeldung:
The user build-file "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\NvCudaRuntimeApi.rules" wasnt found or couldn't be loaded
The file "C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\src\vectorAdd\vectorAdd_vc90.vcproj" couldn't be loaded"
When I just open the vectorAdd.cu I don't find any way to compile it to run it in Matlab. Perhaps it would also be possible to just work completely without Visual Studio, so that I write my code in Notepad++ for example and compile it myself?
Thanks a lot in advance guys!
If you have access to Parallel Computing Toolbox, you can use the GPU directly using GPUArrays. You can also more easily integrate your own hand-written CUDA code using the parallel.gpu.CUDAKernel object
If the parallel toolbox isn't available, you can still use the mexFunction capability to use the GPU's
http://www.mathworks.com.au/help/distcomp/create-and-run-mex-files-containing-cuda-code.html
I dont think this is available for earlier versions than 2013a. In this case, you can write the mexfunction entry point and include the cuda function calls to pass the memory to and from the device
http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/