Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

CUDA error on abs

📅 2013-Oct-10 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ abs, cuda, error ⬩ 📚 Archive


This was CUDA code that compiled without errors on Windows. But, when compiled on Linux, it gave this error: error: calling a __host__ function("std::abs<short> ") from a __global__ function("kernelHelloWorld") is not allowed

The line in the kernelHelloWorld which caused the error was something like this:

short s = abs(getMeAFloat());


Finding no solution to this, I changed the abs to fabsf, which is supported in CUDA:

short s = fabsf(getMeAFloat());

Tried with: CUDA 5.5 and Ubuntu 12.04 LTS