cuda cross compiling issue for target aarch64-linux-androideabi

I was wondering if anyone has encountered this issue when cross compiling cuda on Nvidia TX2 running android.

The error is

In file included from :1:
In file included from prebuilts/clang/host/linux-x86/clang-4667116/lib64/clang/7.0.1/include/__clang_cuda_runtime_wrapper.h:219:
…/cuda/targets/aarch64-linux-androideabi/include/math_functions.hpp:3477:19: error: no matching function for call to ‘__isinf’
if (a == 0.0 || __isinf(a)) {
^~~~~~~
…/cuda/targets/aarch64-linux-androideabi/include/math_functions_dbl_ptx3.hpp:165:38: note: candidate function not viable: call to device function
from host function
MATH_FUNCTIONS_DBL_PTX3_DECL int __isinf(double a) __THROW
^
In file included from :1:
In file included from …/prebuilts/clang/host/linux-x86/clang-4667116/lib64/clang/7.0.1/include/__clang_cuda_runtime_wrapper.h:219:
…/cuda/targets/aarch64-linux-androideabi/include/math_functions.hpp:3501:19: error: no matching function for call to ‘__isinf’
if (a == 0.0 || __isinf(a)) {
^~~~~~~
…/cuda/targets/aarch64-linux-androideabi/include/math_functions_dbl_ptx3.hpp:165:38: note: candidate function not viable: call to device function
from host function
MATH_FUNCTIONS_DBL_PTX3_DECL int __isinf(double a) __THROW
^
In file included from :1:
In file included from …/prebuilts/clang/host/linux-x86/clang-4667116/lib64/clang/7.0.1/include/__clang_cuda_runtime_wrapper.h:219:
…/cuda/targets/aarch64-linux-androideabi/include/math_functions.hpp:3527:7: error: no matching function for call to ‘__isinf’
if (__isinf(a)) {
^~~~~~~
…/aarch64-linux-androideabi/include/math_functions_dbl_ptx3.hpp:165:38: note: candidate function not viable: call to device function
from host function
MATH_FUNCTIONS_DBL_PTX3_DECL int __isinf(double a) __THROW
^
3 errors generated when compiling for sm_20.

The command I used is following

prebuilts/clang/host/linux-x86/clang-4667116/bin/clang++
-v
-target aarch64-linux-androideabi
–cuda-path=/cuda/targets/aarch64-linux-androideabi
-I ./cuda/targets/aarch64-linux-androideabi/
-I …/platforms/android-24/arch-arm64/usr/include
-I .prebuilts/ndk/current/sources/sources/cxx-stl/gnu-libstdc++/4.9/include
-I prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include
-I ndk/sources/cxx-stl/system/include
-L ./cuda/targets/aarch64-linux-androideabi/lib
-lcudart -lcudart_static -ldl -lrt -pthread \

-o axpy axpy.cu

clang version I am using is

Android (4667116 based on r326829) clang version 7.0.1 (https://android.googlesource.com/toolchain/clang 76e4d638afc560ad21845fad570888bef8c18045) (https://android.googlesource.com/toolchain/llvm 67f3e6a51d93777841e0fb6d07f71fdf343df239) (based on LLVM 7.0.1svn)
Target: aarch64–linux-android
Thread model: posix

I dont have any issues build this file for native platform (ubuntu14.04)
clang++

–cuda-path=/usr/local/cuda-8.0
-I /usr/local/cuda-8.0/include
-L/usr/local/cuda-8.0/lib64
-lcudart -lcudart_static -ldl -lrt -pthread
-o axpy axpy.cu

any guidance is appreciated.

+Artem Belevich

It’s hard to tell what exactly is going on. I have neither CUDA 8 for ARM, nor, apparently, any ARM-specific headers – clang complains that it can’t find .

Complaints about calling device function from host function usually indicate that we’re missing a host version of the callee, in this case ‘__isinf(double)’. I’d start with checking whether it’s available for c++ compilation. If it is, then you’ll need to figure out why it’s not included in time for cuda’s pre-included headers to work. If the function is not available in principle, then you may need to provide a stub. Or figure out why cuda headers define host functions. It’s possible that the preprocessor magic clang currently uses to make CUDA headers work on x86 may need to be adjusted for ARM.

–Artem