Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: no instance of overloaded function "atomicAdd" matches the argument list #11

Closed
mathmax12 opened this issue Jan 17, 2022 · 2 comments

Comments

@mathmax12
Copy link

Hi ,
I am tring to build the code with the cuda and cudann.
The installation of cuda and cudnn is good and when build the tandem code I got followings:
Any suggestions are appreciated.

Scanning dependencies of target cuda_coarse_tracker
[ 1%] Building CXX object libdr/cuda_coarse_tracker/CMakeFiles/cuda_coarse_tracker.dir/src/cuda_coarse_tracker.cpp.o
[ 3%] Building CUDA object libdr/cuda_coarse_tracker/CMakeFiles/cuda_coarse_tracker.dir/src/cuda_coarse_tracker_private.cu.o
/tDisk-1/workspace/bigtree/workspace/slam/tandem/tandem/libdr/cuda_coarse_tracker/src/cuda_coarse_tracker_private.cu(355): error: no instance of overloaded function "atomicAdd" matches the argument list
argument types are: (double *, const double)
detected during instantiation of "void calcGKernel<TPB,Accum>(float, float, float2, float, int, int, const float *, const float *, const float *, const float *, const float *, const float *, const float *, const float *, Accum *) [with TPB=128, Accum=double]"
(429): here

/tDisk-1/workspace/bigtree/workspace/slam/tandem/tandem/libdr/cuda_coarse_tracker/src/cuda_coarse_tracker_private.cu(355): error: no instance of overloaded function "atomicAdd" matches the argument list
argument types are: (double *, const double)
detected during instantiation of "void calcGKernel<TPB,Accum>(float, float, float2, float, int, int, const float *, const float *, const float *, const float *, const float *, const float *, const float *, const float *, Accum *) [with TPB=4, Accum=double]"
(445): here

2 errors detected in the compilation of "/tDisk-1/workspace/bigtree/workspace/slam/tandem/tandem/libdr/cuda_coarse_tracker/src/cuda_coarse_tracker_private.cu".
libdr/cuda_coarse_tracker/CMakeFiles/cuda_coarse_tracker.dir/build.make:92: recipe for target 'libdr/cuda_coarse_tracker/CMakeFiles/cuda_coarse_tracker.dir/src/cuda_coarse_tracker_private.cu.o' failed
make[2]: *** [libdr/cuda_coarse_tracker/CMakeFiles/cuda_coarse_tracker.dir/src/cuda_coarse_tracker_private.cu.o] Error 1
CMakeFiles/Makefile2:298: recipe for target 'libdr/cuda_coarse_tracker/CMakeFiles/cuda_coarse_tracker.dir/all' failed
make[1]: *** [libdr/cuda_coarse_tracker/CMakeFiles/cuda_coarse_tracker.dir/all] Error 2
Makefile:100: recipe for target 'all' failed
make: *** [all] Error 2

@ko440124
Copy link

Try to add the following code at the beginning of 'cuda_coarse_tracker_private.cu'

#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
#else
__device__ double atomicAdd(double* address, double val)
{
    unsigned long long int* address_as_ull =
                              (unsigned long long int*)address;
    unsigned long long int old = *address_as_ull, assumed;

    do {
        assumed = old;
        old = atomicCAS(address_as_ull, assumed,
                        __double_as_longlong(val +
                               __longlong_as_double(assumed)));

    // Note: uses integer comparison to avoid hang in case of NaN (since NaN != NaN)
    } while (assumed != old);

    return __longlong_as_double(old);
}
#endif

I find this at https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html. It works in my case, however, I haven't tried the evaluation yet.

@mathmax12
Copy link
Author

@ko440124 Thanks for that. After recasting the double* input to float*, it works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants