Compiling nbody sample, CUDA 7.5 and Visual Studio 2013

Just upgraded to Visual Studio 2013 and CUDA 7.5 on Win7 x64 with 4 x (Kepler) Titan.

I’ve built and run a few samples ok (compute_35,sm_35), but when building the nbody sample
CUDA_Samples\5_Simulations\nbody\bodysystemcuda.cu, compiler complains about line 249

D:/VS/CUDA_Samples/5_Simulations/nbody/bodysystemcuda.cu(249):
error C2146: syntax error : missing ‘;’ before identifier ‘numBlocks’

(249) integrateBodies<<< numBlocks, blockSize, sharedMemSize >>> (… 8 args …)

Where did I go wrong? Is template syntax ok?
thanks - Nigel

I have a system with VS2013, CUDA 7.5 on Win7 x64. I just built that sample code without any errors.

  1. Are you using the supplied VS2013 solution file to build the code?
  2. Are you building the CUDA 7.5 sample code? (and not some previous version)
  3. Have you changed any project settings in the solution?

Here is my full build output:

1>------ Rebuild All started: Project: nbody, Configuration: Debug x64 ------
1>  
1>  C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5_Simulations\nbody>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.exe" -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64"  -I./ -I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include"  -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile  -Xcompiler "/wd 4819"  -g   -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -o x64/Debug/bodysystemcuda.cu.obj "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5_Simulations\nbody\bodysystemcuda.cu" -clean 
1>  bodysystemcuda.cu
1>  Compiling CUDA source file bodysystemcuda.cu...
1>  
1>  C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5_Simulations\nbody>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_37,code=\"sm_37,compute_37\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" -gencode=arch=compute_52,code=\"sm_52,compute_52\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64"  -I./ -I../../common/inc -I./ -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\/include" -I../../common/inc -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include"  -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile -cudart static -Xcompiler "/wd 4819"  -g   -DWIN32 -DWIN32 -D_MBCS -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MTd " -o x64/Debug/bodysystemcuda.cu.obj "C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5_Simulations\nbody\bodysystemcuda.cu" 
1>  bodysystemcuda.cu
1>  render_particles.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xutility(2904): warning C4244: 'initializing' : conversion from '__int64' to 'ptrdiff_t', possible loss of data
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xutility(2905): warning C4244: 'initializing' : conversion from '__int64' to 'ptrdiff_t', possible loss of data
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(1297): warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(1294) : while compiling class template member function 'std::_String_iterator<std::_String_val<std::_Simple_types<char>>> std::basic_string<char,std::char_traits<char>,std::allocator<char>>::insert(std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,_Elem)'
1>          with
1>          [
1>              _Elem=char
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(1709) : see reference to function template instantiation 'std::_String_iterator<std::_String_val<std::_Simple_types<char>>> std::basic_string<char,std::char_traits<char>,std::allocator<char>>::insert(std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,_Elem)' being compiled
1>          with
1>          [
1>              _Elem=char
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\stdexcept(31) : see reference to class template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(204): warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(202) : while compiling class template member function 'int std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>::operator -(const std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>> &) const'
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(2267) : see reference to function template instantiation 'int std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>::operator -(const std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>> &) const' being compiled
1>          C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5\common\inc\helper_string.h(461) : see reference to class template instantiation 'std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>' being compiled
1>  nbody.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xutility(2904): warning C4244: 'initializing' : conversion from '__int64' to 'ptrdiff_t', possible loss of data
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xutility(2905): warning C4244: 'initializing' : conversion from '__int64' to 'ptrdiff_t', possible loss of data
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(1297): warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(1294) : while compiling class template member function 'std::_String_iterator<std::_String_val<std::_Simple_types<char>>> std::basic_string<char,std::char_traits<char>,std::allocator<char>>::insert(std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,_Elem)'
1>          with
1>          [
1>              _Elem=char
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(1709) : see reference to function template instantiation 'std::_String_iterator<std::_String_val<std::_Simple_types<char>>> std::basic_string<char,std::char_traits<char>,std::allocator<char>>::insert(std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>,_Elem)' being compiled
1>          with
1>          [
1>              _Elem=char
1>          ]
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\stdexcept(31) : see reference to class template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' being compiled
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(204): warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(202) : while compiling class template member function 'int std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>::operator -(const std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>> &) const'
1>          C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xstring(2267) : see reference to function template instantiation 'int std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>::operator -(const std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>> &) const' being compiled
1>          C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5\common\inc\helper_string.h(461) : see reference to class template instantiation 'std::_String_const_iterator<std::_String_val<std::_Simple_types<char>>>' being compiled
1>  Generating Code...
1>     Creating library ../../bin/win64/Debug/nbody.lib and object ../../bin/win64/Debug/nbody.exp
1>  nbody_vs2013.vcxproj -> C:\ProgramData\NVIDIA Corporation\CUDA Samples\v7.5_Simulations\nbody\../../bin/win64/Debug/nbody.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Thanks for confirming it should work - I’ll dig deeper and try and find what’s different.

Just to confirm: I get this error when building default nbody_vs2013.sln.

Also, 10 other samples build and run fine… ?!