views:

95

answers:

1

I am trying to test some typical cuda functions during the configure process. How can I write it in my configure.ac? Something like:

AC_TRY_COMPILE([],
[
__global__ static void test_cuda() {
    const int tid = threadIdx.x;
    const int bid = blockIdx.x;
    __syncthreads();
}
],
[cuda_comp=ok],[cuda_comp=no])

But nvcc is not defined in AC_LANG. Must I create my own m4 macros?

+2  A: 

I am highly doubtful whether it is possible to cleanly hook into the AC_LANG, AC_TRY_COMPILE etc. series of macros without actually rewriting parts of autoconf.

The safe bet for you is to just write a test. Unless you need that test in several projects, you do not even need to wrap the test in m4 macros.

The test would first check for nvcc, then create some test source file and finally try compiling that using $NVCC. Then it needs to examine the results of the compilation (return code and generated files), and finally to clean up any files it might have generated.

Something like

AC_ARG_VAR([NVCC], [nvcc compiler to use])
AC_PATH_PROG([NVCC], [nvcc], [no])
working_nvcc=no
if test "x$NVCC" != "xno"
the
    AC_MSG_CHECKING([whether nvcc works])
    cat>conftest.c<<EOF
    __global__ whatever() {
       ...
    }
EOF
    if $NVCC conftest.c && test_whether_output_files_are_ok
    then
        working_nvcc=yes
    fi
    rm -f conftest.c conftest.o conftest.what conftest.ever
    AC_MSG_RESULT([$working_nvcc])
fi
AM_CONDITIONAL([WORKING_NVCC], [test "x$working_nvcc" = "xyes"])
ndim
Thanks a lot. This is more a general autotools answer, but it is exactly what I need.
Jérôme