@@ -5,18 +5,6 @@ if(CMAKE_COMPILER_IS_GNUCC)
55 add_definitions (-Wdeclaration-after-statement )
66endif ()
77
8- find_package (CUDA )
9- find_package (OpenCL )
10- if (OpenCL_FOUND)
11- find_package (clBLAS )
12- if (NOT CLBLAS_FOUND)
13- find_package (CLBlast )
14- endif ()
15- endif ()
16- if (CUDA_FOUND)
17- find_package (NCCL )
18- endif ()
19-
208include_directories ("${CMAKE_CURRENT_SOURCE_DIR} " )
219
2210add_custom_command (
@@ -60,6 +48,12 @@ gpuarray_kernel.c
6048gpuarray_extension.c
6149gpuarray_elemwise.c
6250gpuarray_reduction.c
51+ gpuarray_buffer_cuda.c
52+ gpuarray_blas_cuda_cublas.c
53+ gpuarray_collectives_cuda_nccl.c
54+ gpuarray_buffer_opencl.c
55+ gpuarray_blas_opencl_clblas.c
56+ gpuarray_blas_opencl_clblast.c
6357)
6458
6559check_function_exists (strlcat HAVE_STRL )
@@ -77,93 +71,16 @@ if(NOT HAVE_MKSTEMP)
7771 list (APPEND _GPUARRAY_SRC gpuarray_mkstemp.c)
7872endif ()
7973
80- if (CUDA_FOUND)
81- if (NCCL_FOUND)
82- if (CUDA_VERSION_MAJOR LESS 7)
83- message ( WARNING "This package requires CUDA 7.0 or more (building with NCCL). Found version ${CUDA_VERSION_STRING} " )
84- set (CUDA_FOUND 0)
85- endif ()
86- else (NCCL_FOUND )
87- if (CUDA_VERSION_MAJOR LESS 6 OR
88- (CUDA_VERSION_MAJOR EQUAL 6 AND CUDA_VERSION_MINOR EQUAL 0))
89- message ( WARNING "This package requires CUDA 6.5 or more. Found version ${CUDA_VERSION_STRING} " )
90- set (CUDA_FOUND 0)
91- endif ()
92- endif (NCCL_FOUND )
93- endif ()
94-
95- if (CUDA_FOUND)
96- if (APPLE )
97- FIND_LIBRARY (CUDADRV_LIBRARY CUDA )
98- FIND_PATH (CUDADRV_INCLUDE CUDA/cuda.h )
99- # this is somewhat a hack, but otherwise cublas_v2.h isn't found
100- set (CUDADRV_INCLUDE ${CUDADRV_INCLUDE} ${CUDA_TOOLKIT_INCLUDE} )
101- endif ()
102- if (NOT CUDADRV_LIBRARY)
103- set (CUDADRV_LIBRARY ${CUDA_CUDA_LIBRARY} )
104- set (CUDADRV_INCLUDE ${CUDA_TOOLKIT_INCLUDE} )
105- endif ()
106-
107- find_cuda_helper_libs (nvrtc )
108-
109- if (CUDA_nvrtc_LIBRARY)
110- message (STATUS "Building with NVRTC" )
111- add_definitions (-DWITH_NVRTC )
112- set (CUDADRV_LIBRARY ${CUDADRV_LIBRARY} ${CUDA_nvrtc_LIBRARY} )
113- else ()
114- add_definitions (-DNVCC_BIN=${CUDA_NVCC_EXECUTABLE} )
115- endif ()
116-
117- list (APPEND _GPUARRAY_SRC gpuarray_buffer_cuda.c)
118- add_definitions (-DWITH_CUDA )
119- include_directories (${CUDADRV_INCLUDE} )
120-
121- list (APPEND _GPUARRAY_SRC gpuarray_blas_cuda_cublas.c)
122- add_definitions (-DWITH_CUDA_CUBLAS )
123-
124- set (CMAKE_REQUIRED_LIBRARIES ${CUDA_CUBLAS_LIBRARIES} )
125-
126- check_function_exists (cublasSgemmEx CUBLAS_SGEMMEX )
127- if (CUBLAS_SGEMMEX)
128- add_definitions (-DHAVE_CUBLAS_SGEMMEX )
129- endif ()
130-
131- if (NCCL_FOUND)
132- message (STATUS "Building with NCCL" )
133- set (BUILD_WITH_COLLECTIVES 1 PARENT_SCOPE )
134- add_definitions (-DWITH_CUDA_NCCL )
135- list (APPEND _GPUARRAY_SRC gpuarray_collectives_cuda_nccl.c)
136- include_directories (${NCCL_INCLUDE_DIR} )
137- endif ()
138- endif ()
139-
140- if (OpenCL_FOUND)
141- list (APPEND _GPUARRAY_SRC gpuarray_buffer_opencl.c)
142- add_definitions (-DWITH_OPENCL )
143- include_directories (${OpenCL_INCLUDE_DIRS} )
144-
145- if (CLBLAS_FOUND)
146- message (STATUS "Building with CLBLAS" )
147- list (APPEND _GPUARRAY_SRC gpuarray_blas_opencl_clblas.c)
148- add_definitions (-DWITH_OPENCL_CLBLAS )
149- include_directories (${CLBLAS_INCLUDE_DIRS} )
150- elseif (CLBLAS_FOUND)
151- message (STATUS "Building with CLBLAST" )
152- list (APPEND _GPUARRAY_SRC gpuarray_blas_opencl_clblast.c)
153- add_definitions (-DWITH_OPENCL_CLBLAST )
154- include_directories (${CLBLAST_INCLUDE_DIRS} )
155- endif ()
156- endif ()
157-
15874configure_file (
15975 ${CMAKE_CURRENT_SOURCE_DIR} /private_config.h.in
16076 ${CMAKE_CURRENT_SOURCE_DIR} /private_config.h
16177 )
16278
16379add_subdirectory (util )
80+ add_subdirectory (loaders )
16481
16582set_rel (GPUARRAY_SRC ${_GPUARRAY_SRC} )
166- list (APPEND GPUARRAY_SRC ${UTIL_SRC} )
83+ list (APPEND GPUARRAY_SRC ${UTIL_SRC} ${LOADERS_SRC} )
16784
16885add_library (gpuarray SHARED ${GPUARRAY_SRC} )
16986set_target_properties (gpuarray PROPERTIES
@@ -174,23 +91,8 @@ set_target_properties(gpuarray PROPERTIES
17491
17592add_library (gpuarray-static STATIC ${GPUARRAY_SRC} )
17693
177- if (CUDA_FOUND)
178- target_link_libraries (gpuarray ${CUDADRV_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} )
179- target_link_libraries (gpuarray-static ${CUDADRV_LIBRARY} ${CUDA_CUBLAS_LIBRARIES} )
180- if (NCCL_FOUND)
181- target_link_libraries (gpuarray ${NCCL_LIBRARY} )
182- target_link_libraries (gpuarray-static ${NCCL_LIBRARY} )
183- endif ()
184- endif ()
185-
186- if (OpenCL_FOUND)
187- target_link_libraries (gpuarray ${OpenCL_LIBRARIES} )
188- target_link_libraries (gpuarray-static ${OpenCL_LIBRARIES} )
189- if (CLBLAS_FOUND)
190- target_link_libraries (gpuarray ${CLBLAS_LIBRARIES} )
191- target_link_libraries (gpuarray-static ${CLBLAS_LIBRARIES} )
192- endif ()
193- endif ()
94+ target_link_libraries (gpuarray ${CMAKE_DL_LIBS} )
95+ target_link_libraries (gpuarray-static ${CMAKE_DL_LIBS} )
19496
19597set (headers
19698 gpuarray/array.h
0 commit comments