3
3
# See file LICENSE for terms.
4
4
#
5
5
6
+ # Define CUDA language
7
+ AC_LANG_DEFINE([ CUDA] , [ cuda] , [ NVCC] , [ NVCC] , [ C++] , [
8
+ ac_ext=cu
9
+ ac_compile="$NVCC $BASE_NVCCFLAGS $NVCCFLAGS -c -o conftest.o conftest.$ac_ext"
10
+ ac_link="$NVCC $BASE_NVCCFLAGS $NVCCFLAGS -o conftest conftest.o"
11
+ ] ,
12
+ [ rm -f conftest.o conftest.$ac_ext conftest] )
13
+
14
+ # Define CUDA language compiler
15
+ AC_DEFUN ( [ AC_LANG_COMPILER(CUDA)] , [
16
+ AC_ARG_WITH ( [ nvcc-gencode] ,
17
+ [ AS_HELP_STRING ( [ --with-nvcc-gencode=(OPTS)] , [ Build for specific GPU architectures] ) ] ,
18
+ [ ] ,
19
+ [ with_nvcc_gencode="-gencode=arch=compute_80,code=sm_80"] )
20
+
21
+ AC_ARG_VAR ( [ NVCC] , [ nvcc compiler path] )
22
+ AC_ARG_VAR ( [ NVCCFLAGS] , [ nvcc compiler flags] )
23
+ BASE_NVCCFLAGS="$BASE_NVCCFLAGS $with_nvcc_gencode"
24
+ AC_CHECK_TOOL ( [ NVCC] , [ nvcc] , [ ] )
25
+ AC_SUBST ( [ NVCC] , [ $NVCC] )
26
+ ] )
27
+
28
+ # Check for nvcc compiler support
29
+ AC_DEFUN ( [ UCX_CUDA_CHECK_NVCC] , [
30
+ AS_IF ( [ test "x$NVCC" != "x"] , [
31
+ AC_MSG_CHECKING ( [ $NVCC needs explicit c++11 option] )
32
+ AC_LANG_PUSH ( [ CUDA] )
33
+ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [ [
34
+ #if __cplusplus < 201103L
35
+ #error missing C++11
36
+ #endif
37
+ ] ] ) ] ,
38
+ [ AC_MSG_RESULT ( [ no] ) ] ,
39
+ [ AC_MSG_RESULT ( [ yes] )
40
+ BASE_NVCCFLAGS="$BASE_NVCCFLAGS -std=c++11"] )
41
+ AC_LANG_POP
42
+
43
+ AC_MSG_CHECKING ( [ $NVCC can compile] )
44
+ AC_LANG_PUSH ( [ CUDA] )
45
+ AC_COMPILE_IFELSE ( [ AC_LANG_SOURCE ( [ [
46
+ #include <cuda_runtime.h>
47
+ __global__ void my_kernel(void) {}
48
+ int main(void) { my_kernel<<<1, 1>>>(); return 0; }
49
+ ] ] ) ] ,
50
+ [ AC_MSG_RESULT ( [ yes] ) ] ,
51
+ [ AC_MSG_RESULT ( [ no] )
52
+ NVCC=""] )
53
+ AC_LANG_POP
54
+ ] )
55
+
56
+ AM_CONDITIONAL([ HAVE_NVCC] , [ test "x$NVCC" != x] )
57
+ ] )
58
+
59
+ # Check for CUDA support
6
60
AC_DEFUN ( [ UCX_CHECK_CUDA] ,[
7
61
8
62
AS_IF ( [ test "x$cuda_checked" != "xyes"] ,
9
63
[
10
64
AC_ARG_WITH ( [ cuda] ,
11
65
[ AS_HELP_STRING ( [ --with-cuda=(DIR)] , [ Enable the use of CUDA (default is guess).] ) ] ,
12
66
[ ] , [ with_cuda=guess] )
13
- AC_ARG_WITH ( [ nvcc] ,
14
- AS_HELP_STRING ( [ --with-nvcc] , [ Enable NVCC compiler support (default is guess)] ) ,
15
- [ ] ,
16
- [ with_nvcc="guess"] )
17
- AC_ARG_WITH ( [ nvcc-gencode] ,
18
- AS_HELP_STRING ( [ --with-nvcc-gencode=(OPTS)] , [ Build for specific GPU architectures] ) ,
19
- [ ] ,
20
- [ with_nvcc_gencode="-gencode=arch=compute_80,code=sm_80"] )
21
67
22
68
AS_IF ( [ test "x$with_cuda" = "xno"] ,
23
69
[
24
70
cuda_happy=no
25
71
have_cuda_static=no
26
- nvcc_happy=no
27
72
NVCC=""
28
73
] ,
29
74
[
@@ -106,50 +151,10 @@ AS_IF([test "x$cuda_checked" != "xyes"],
106
151
[ AC_DEFINE ( [ HAVE_CUDA_FABRIC] , 1 , [ Enable CUDA fabric handle support] ) ] ,
107
152
[ ] , [ [ #include <cuda.h>] ] )
108
153
109
- # Check NVCC exists and able to compile
110
- nvcc_happy="no"
111
- AC_ARG_VAR ( [ NVCC] , [ nvcc compiler path] )
112
- AC_ARG_VAR ( [ NVCCFLAGS] , [ nvcc compiler flags] )
113
- AS_IF ( [ test "x$with_nvcc" != "xno"] ,
114
- [ AC_PATH_PROGS ( NVCC , nvcc , "" , $CUDA_BIN_PATH:$PATH )
115
- AC_LANG_PUSH ( [ C] )
116
- AC_LANG_CONFTEST ( [ AC_LANG_SOURCE ( [ [
117
- #if __cplusplus < 201103L
118
- #error missing C++11
119
- #endif
120
- ] ] ) ] )
121
- mv conftest.c conftest.cu
122
- AC_MSG_CHECKING ( [ $NVCC needs explicit C++11 option] )
123
- AS_IF ( [ $NVCC -c conftest.cu 2>&AS_MESSAGE_LOG_FD ] ,
124
- [ AC_MSG_RESULT ( [ no] ) ] ,
125
- [ AC_MSG_RESULT ( [ yes] )
126
- BASE_NVCCFLAGS="$BASE_NVCCFLAGS -std=c++11"] )
127
- rm conftest.cu
128
- AC_LANG_POP ] )
129
-
130
- AS_IF ( [ test "x$NVCC" != "x"] ,
131
- [ AC_LANG_PUSH ( [ C] )
132
- AC_LANG_CONFTEST ( [ AC_LANG_SOURCE ( [ [ #include <cuda_runtime.h>] ] ) ] )
133
- mv conftest.c conftest.cu
134
- AC_MSG_CHECKING ( [ $NVCC can compile] )
135
- AS_IF ( [ $NVCC -c conftest.cu 2>&AS_MESSAGE_LOG_FD ] ,
136
- [ AC_MSG_RESULT ( [ yes] )
137
- BASE_NVCCFLAGS="$BASE_NVCCFLAGS $with_nvcc_gencode -g -lineinfo"
138
- nvcc_happy="yes"] ,
139
- [ AC_MSG_RESULT ( [ no] )
140
- cat conftest.cu >&AS_MESSAGE_LOG_FD ] )
141
- rm conftest.cu
142
- AC_LANG_POP
143
- ] )
144
-
145
154
CPPFLAGS="$save_CPPFLAGS"
146
155
LDFLAGS="$save_LDFLAGS"
147
156
LIBS="$save_LIBS"
148
157
149
- AS_IF ( [ test "x$with_nvcc" = "xyes" -a "x$nvcc_happy" = "xno"] ,
150
- [ AC_MSG_ERROR ( [ nvcc compiler is not functional] ) ] ,
151
- [ ] )
152
-
153
158
AS_IF ( [ test "x$cuda_happy" = "xyes"] ,
154
159
[ AC_SUBST ( [ CUDA_CPPFLAGS] , [ "$CUDA_CPPFLAGS"] )
155
160
AC_SUBST ( [ CUDA_LDFLAGS] , [ "$CUDA_LDFLAGS"] )
@@ -166,8 +171,8 @@ AS_IF([test "x$cuda_checked" != "xyes"],
166
171
cuda_checked=yes
167
172
AM_CONDITIONAL([ HAVE_CUDA] , [ test "x$cuda_happy" != xno] )
168
173
AM_CONDITIONAL([ HAVE_CUDA_STATIC] , [ test "X$have_cuda_static" = "Xyes"] )
169
- AM_CONDITIONAL([ HAVE_NVCC] , [ test "x$nvcc_happy" != xno] )
170
174
175
+ UCX_CUDA_CHECK_NVCC
171
176
] ) # "x$cuda_checked" != "xyes"
172
177
173
178
] ) # UCX_CHECK_CUDA
0 commit comments