I am using Intel opencl SDK on Windows with Intel HD graphics. Would like to compile my kernel offline then use in host code:
clCreateProgramFromBinary(…)
This link says :
OpenCL™ API Offline Compiler plug-in for Microsoft Visual Studio* IDE enables you to develop OpenCL applications with Visual Studio IDE.
The plug-in supports the following features:
New project templates
New OpenCL file (*.cl) template
Syntax highlighting
Types and functions auto-completion
Offline compilation and build of OpenCL kernels
LLVM code view
Assembly code view
program IR generation
Selection of target OpenCL device – CPU or Intel Graphics
NOTE
To work with the plug-in features, create an OpenCL project template \or convert an existing project into the OpenCL project.
I want to use this feature, so I wanted to know what all I have to install?
As per the note above I should create an OpenCL project template. How do I do this? Also what do we mean by "or convert an existing project into the OpenCL project"
In order to use the feature you just need to have the SDK installed on your system.
To create a new Empty OpenCL project template:
Go to: File > New > Project...
Look for OpenCL group under Templates\Visual C++ section and select Empty OpenCL Project for Windows
Once project created you can add a new OpenCL Code File (Project > Add New Item... > OpenCL > Intel SDK for OpenCL Application File) or add an exisitin *.cl file to the project
Configure the project's options to generate binary file (instructions here): Project > Properties > Intel SDK for OpenCL Applications > General > Generate binary file
Whenever you build the project, the OpenCL compiler will build all attached .cl files and generate for them program binaries.
To convert an existing Visual Studio project (instructions here), do the following:
Right-click on the project you want to convert in the Solution Explorer.
In the project menu click Convert to a project for OpenCL API
Related
I am working on an ARM64 computer with Windows 10 (Windows ARM).
I have installed Visual Studio Community. I can create C/C++ Console programs. It works fine. But generated binary files are compiled for an ARM target.
Is there a way to generate x86 (or x86_64) binary files ?
I have looked inside project configuration but I did not find anything.
Do you know where I can select binary output platform in visual studio ?
Thanks
If you used the "Console App" template for C++ when you created the project, then the project was probably created with two 'platform' configurations: x64 and win32. Change the "active platform" to 'win32'. You can make that change in the "Configuration Manager" or in the standard toolbar.
When I compile some kind of a project in Visual Studio 2015, does it compile it for 32-bit or 64-bit systems? Is there any way to find out? How do I control which version it compiles between the two?
From the menu bar, you can see the current platform for which the project will be compiled.
If you press the little arrow, you can open the Configuration Manager and create new target platforms.
The Configuration Manager is also available under Build ---> Configuration Manager.
i'm new in Optix world and i want to try to make new project in VS 2008.
My question: how can I use and modify the project "tutorial" without compiling all the examples included with SDK?
I try to create new project in VS2008 with "tutorial" files but don't work :/
Thanx for your help!
I am also new in optix and got the same problem.
I have compiled sample1 which give the green screen within Parallel Nsight 2.0 visual studio 2010.
You need to do the following if you are using nvidia parallel nsight:
change NVCC compilation type to PTX file in cuda c/c++ at project properties.
make sure you build optix-sdk samples files using cmake.
open optix-sample.sln and build the all projects.
new libraries has been created like sutil.lib which you need to link to your new project.
create a new cuda runtime project in my case i have used sample1 files.
make sure to do step 1 and then include optix header files and sutil.h from the optix-sdk.
link sutil.lib optix and opengl libraries like opengl32.lib and glut32.lib
You should now be able to build your project.
Finally you need optix sutil freeglut dll files to run your application.
just open Optix-samples sol file , there you can see all the projects attached, find tutorial among them, right click on it and select "set as a startup project" .
Now you can run and edit tutorial alone.
Direct Question: How do I create a simple hello world CUDA project within visual studio 2010?
Background: I've written CUDA kernels. I'm intimately familiar with the .vcproj files from Visual Studio 2005 -- tweaked several by hand. In VS 2005, if I want to build a CUDA kernel, I add a custom build rule and then explicitly define the nvcc call to build the files.
I have migrated to Win 7, and VS 2010 because I really want to try out nSight. I have nSight 1.5 installed. But this is where I'm totally lost. If I proceed as before, nvcc reports that it only supports msvc 8.0 & 9.0. But the website clearly states that it supports VS 2010.
I read somewhere else that I need to have VS 2008 (msvc 9.0) also installed -- my word. Doing so now.
But I'm guessing that at least part of my problems stem from the homegrown custom build tool specifications. Several websites talk about adding a *.rules file to the build, but I've gathered that this is only applicable to VS 2008. Under "Build Customizations" I see CUDA 3.1 and 3.2, but when I add kernels to the project they aren't built. Another website proclaims that the key is three files: Cuda.props Cuda.xml Cuda.targets, but it doesn't say how or where to add these files -- or rather I'll gamble that I just don't understand the notes referenced in the website.
So does anyone know how to create a simple project in VS 2010 which builds a CUDA kernel -- using either the nSight 1.5 setup or the NvCudaRuntimeApi.v3.2.rules file which ships with the CUDA 3.2 RC?
Thanks in advance! I'd offer a bounty, but I only have 65 points total.
CUDA TOOLKIT 4.0 and later
The build customisations file (installed into the Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations directory) "teaches" Visual Studio how to compile and link any .cu files in your project into your application. If you chose to skip installing the customisations, or if you installed VS2010 after CUDA, you can add them later by following the instructions in Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\extras\visual_studio_integration.
Create a new project using the standard MS wizards (e.g. an empty console project)
Implement your host (serial) code in .c or .cpp files
Add the NVIDIA build customisation (right click on the project, Build customizations, tick the relevant CUDA box)
See note 1 if using CUDA 4.0
Implement your wrappers and kernels in .cu files
If you added .cu files before the build customisations, then you'll need to set the type of the .cu files to CUDA C/C++ (right-click on the file, Properties, set Item Type)
Add the CUDA runtime library (right click on the project and choose Properties, then in Linker -> Input add cudart.lib to the Additional Dependencies)
Then just build your project and the .cu files will be compiled to .obj and added to the link automatically
Incidentally I would advocate avoiding cutil if possible, instead roll your own checking. Cutil is not supported by NVIDIA, it's just used to try to keep the examples in the SDK focussed on the actual program and algorithm design and avoid repeating the same things in every example (e.g. command line parsing). If you write your own then you will have much better control and will know what is happening. For example, the cutilSafeCall wrapper calls exit() if the function fails - a real application (as opposed to a sample) should probably handle the failure more elegantly!
NOTE
For CUDA 4.0 only you may need to apply this fix to the build customisations. This patch fixes the following message:
The result "" of evaluating the value "$(CudaBuildTasksPath)" of the "AssemblyFile" attribute in the element is not valid
This answer applies to CUDA 3.2, from 4.0 onwards CUDA supports the VC 10 compiler directly, see other answers for more information
You need either VS 2008 or the 6.1 Windows SDK installed. That's because NSight 1.5 RC or the CUDA 3.2 SDK use the VC 9 compiler under the hood. I've got this working successfully with 2008 installed and am told it should work with the SDK but haven't tried.
With NSight 1.5 and/or the CUDA 3.2 SDK you shouldn't need to muck with any custom build rules. I've been there and it's painful. With the latest builds all that goes away:
Create your VC++ project.
Add a .CU file to it.
Select the project file in the Solution Explorer.
Open Project | Build Customizations...
Check the "CUDA 3.2 (.targets,
.props)" customization.
Select a .CU file in your project and hit Alt-Enter to show it's properties.
Make sure it's Item Type is set to "CUDA C/C++"
It should just build. Let me know if this helps and if you run into problems as this is from memory.
The good news it getting CUDA working with VS 2010 just got much easier.
Ade
BTW: I'll update my blog post.
Another Good tutorial here:
http://www.stevenmarkford.com/installing-nvidia-cuda-with-visual-studio-2010/
if you get an error about '<' note this step (from a previous answer):
If you added .cu files before the build customisations, then you'll need to set the type of the .cu files to CUDA C/C++ (right-click on the file, Properties, set Item Type)
But if you follow their steps, it should work!
I am trying to use CMake for compiling CUDA based application on Windows (Visual Studio 2005). Here is an example stripped down CMake file:
cmake_minimum_required (VERSION 2.6)
project (HELLO)
#Support for CUDA Integration
FIND_PACKAGE(CUDA)
if(CUDA_FOUND)
SET(CUDA_NVCC_FLAGS "-arch;sm_13")
CUDA_ADD_EXECUTABLE(Hello hello.cu)
else(CUDA_FOUND)
message("CUDA is not installed on this system.")
endif()
There are a few issues I wish to understand with this.
When I open the solution file (Hello.sln), I don't see any custom build rule setup for the project (Right click on Project -> Custom build rules)
I do see a "Hello_generated_hello.cu.obj" added to my project in Visual Studio. What is this file and why is it added to the project?
By default CUDA Runtime API section doesn't come in Project properties.
If I enable an appropriate custom build rule (NvCudaRuntimeApi.rules), I can now see CUDA runtime API section. If I now go to GPU subsection, I see the GPU architecture still set to be sm_10.
Even if I use CUDA_INCLUDE_DIRECTORIES() Macro to add some directories for CUDA compilation, I won't see these settings in Project Properties -> CUDA Runtime API -> General -> Additional Include Directories.
I wish to know if FindCUDA() package is very able to properly configure VS 2005 project for CUDA based compilation. May be I need to specify additional options to properly configure the project. I would certainly wish to know that. I wish to make sure that whatever options I have specified through CMakeLists file, I should be able to review them easily in my generated VS 2005 project.
What is appropriate way to configure this?
CMake does not support custom build rules (like the CUDA runtime API .rules file), and therefore you cannot edit the CUDA property sheets that the .rules files provide if you use CMake to configure your project. However you can set any CUDA settings directly in the CMakeLists.txt that generates the project, and rebuilding your project will detect these changes and regenerate and reload the project files automatically.
The additional benefit of FindCUDA (besides being cross-platform) is proper dependency analysis so that you never end up with stale builds like you normally do when using CUDA .cu files in Visual Studio (with or without .rules files).
You can find an examples of using CMake with CUDA in the CUDPP project in the following files:
Top-level CMakeLists for the whole library and sample apps:
http://code.google.com/p/cudpp/source/browse/trunk/CMakeLists.txt
Project-specific CMakeLists file for a library: http://code.google.com/p/cudpp/source/browse/trunk/src/cudpp/CMakeLists.txt
Project-specific CMakeLists file for an executable: http://code.google.com/p/cudpp/source/browse/trunk/apps/simpleCUDPP/CMakeLists.txt
Hope that helps.