I am pretty new with alglib and Cuda. I am trying to use Alglib for nonlinear list square fitting. Codes are working when I compile it in VC++ (.cpp) but when I am trying to compile same code but in a cuda file (.cu) it gives me this error:
Error 6 error C2668: 'round' : ambiguous call to overloaded function
Error 7 error C2668: 'round' : ambiguous call to overloaded function
Error 8 error C2668: 'round' : ambiguous call to overloaded function
Error 9 error C2668: 'trunc' : ambiguous call to overloaded function
Error 10 error MSB3721:
The command ""D:\NVIDIA\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2012 -ccbin "D:\Programme (x86)\Microsoft Visual Studio 11.0\VC\bin" -ID:\NVIDIA\include -ID:\NVIDIA\include --keep-dir Release -maxrregcount=0 --machine 32 --compile -cudart static -D_MBCS -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MD " -o Release\min.cu.obj "...\min.cu"" exited with code 2. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 6.0.targets 597 9 Cuda_lsfit
Here is my codes :
# include <iostream>
# include "cuda_runtime.h"
# include "device_launch_parameters.h"
# include <cuda.h>
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "interpolation.h"
using namespace alglib;
void function_cx_1_func(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr)
{
// main function
func = abs(c[0]*(1-exp(-x[0]/c[1])));;
}
int main(int argc, char **argv)
{
real_2d_array x = "[[50],[400],[550],[750],[1200],[2000]]";
real_1d_array y = "[1384,792,642,258,91,868]";
real_1d_array c = "[0.5,500]";
double epsf = 0; //minimum of step size difference
double epsx = 0.000001; //minimum of function changes
ae_int_t maxits = 0; //maximum iteration 0 = unlimitted number
ae_int_t info;
lsfitstate state; // structure contains information about algoritm
lsfitreport rep;
double diffstep = 0.0001;
// Fitting
lsfitcreatef(x, y, c, diffstep, state);
lsfitsetcond(state, epsf, epsx, maxits);
alglib::lsfitfit(state, function_cx_1_func);
lsfitresults(state, info, c, rep);
printf("%d\n", int(info));
printf("%s\n", c.tostring(1).c_str());
return 0;
}
Any solution would be appreciated.
Thanks, Mohsen
trunc()
orround()
in the posted code. These functions are supported in CUDA device code and they are overloaded for argument types offloat
anddouble
. Calling with an argument of any other type could cause the kind of error message you are seeing. However the error messages you are showing seem to be MSVC error messages, so the problem seems to be in the host code portion of the .cu file. Check the prototypes in the host header files (are you including all necessary header files ?) and compare the argument type passed inside the application code. – njuffausing namespace alglib;
– talonmies