I have troubles when compiling my code.
First of all, I have to state something:
I have no issues to run other simpler CUDA codes in my GTX650Ti GPU. Thrust exception: "thrust::system::system_error at memory location 0x00000000"
I've been working in a class with several methods and for some unknown reason, this program leads me to the error: Error C2059: syntax error: '<'
This is part of the code:
__global__ void linearSpaceKernel(double *result, double base, double delta, unsigned int size)
{
unsigned int i = blockDim.x * blockIdx.x + threadIdx.x;
if (i < size)
result[i] = base + double(i) * delta;
cudaThreadSynchronize();
}
void foo::setRange(const double &lower, const double &upper, const unsigned int &samples)
{
vector<double> result(samples);
double dx = (upper - lower) / (samples - 1);
if (isCUDA)
{
device_vector<double> dev_result(samples);
linearSpaceKernel<<<1, samples>>>(raw_pointer_cast(dev_result.data()), lower, dx, samples);
thrust::copy(dev_result.begin(), dev_result.end(), result.begin());
}
else
{
double summation = lower;
for (unsigned int i = 0; i < samples; i++)
{
result[i] = summation;
summation += dx;
}
}
dis = result;
}
I omitted the CUDA error functions and the rest of the code to keep my code short and clear.
I have to clear that setRange is a class member function of foo that calls the kernel linearSpaceVector(). This class provides a Boolean called isCUDA which is used to let the user decide if the execution will be performed in the host or in the device. At the end, both execution options update the vector dis, which is a class member vector.
The main function is defined in fooTest.cu as follows:
#include "foo.cuh"
int main()
{
CUDAinit();
foo A;
A.isCUDA = true;
A.setRange(0, 1, 100);
cin.get();
}
The output is the following:
1>------ Build started: Project: fs, Configuration: Debug Win32 ------
1> Compiling CUDA source file ..\..\..\..\..\OneDrive\Documentos\Cátedras CONACyT\UTM\Research\FLS\Programs\fsTest.cu...
1>
1> C:\Users\Arturo\Documents\Visual Studio 2013\Projects\fs\fs>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --use-local-env --cl-version 2013 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\fsTest.cu.obj "C:\Users\Arturo\OneDrive\Documentos\Cátedras CONACyT\UTM\Research\FLS\Programs\fsTest.cu"
1> fsTest.cu
1> fs.cu
1> c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\detail\error_category.inl(102): warning C4996: 'strerror': This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 12.0\vc\include\string.h(168) : see declaration of 'strerror'
1> c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\cuda\detail\bulk\detail\pointer_traits.hpp(55): warning C4800: 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning)
1> c:\users\arturo\onedrive\documentos\cátedras conacyt\utm\research\fls\programs\fs.cu(332): error C2059: syntax error : '<'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
And the errors are listed as:
3 Error C2059: syntax error : '<' c:\users\arturo\onedrive\documentos\cátedras conacyt\utm\research\fls\programs\fs.cu 332 1 fs
4 IntelliSense: expected an expression c:\Users\Arturo\OneDrive\Documentos\Cátedras CONACyT\UTM\Research\FLS\Programs\fs.cu 332 23 fs
Warning 2 warning C4800: 'unsigned int' : forcing value to bool 'true' or 'false' (performance warning) c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\cuda\detail\bulk\detail\pointer_traits.hpp 55 1 fs
Warning 1 warning C4996: 'strerror': This function or variable may be unsafe. Consider using strerror_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\program files\nvidia gpu computing toolkit\cuda\v7.5\include\thrust\system\detail\error_category.inl 102 1 fs