FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add collectives and nccl build to CMakeLists.txt · NeutralCode/libgpuarray@c7882ca · GitHub

Commit c7882ca

Browse files
committed
Add collectives and nccl build to CMakeLists.txt
- Fix linking library cuBLAS to target gpuarray-static
1 parent 65dde33 commit c7882ca

4 files changed

Lines changed: 45 additions & 4 deletions

File tree

‎CMakeModules/FindNCCL.cmake‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Find the NCCL libraries
2+
#
3+
# The following variables are optionally searched for defaults
4+
# NCCL_ROOT_DIR: Base directory where all NCCL components are found
5+
#
6+
# The following are set after configuration is done:
7+
# NCCL_FOUND
8+
# NCCL_INCLUDE_DIR
9+
# NCCL_LIBRARY
10+
11+
find_path(NCCL_INCLUDE_DIR NAMES nccl.h
12+
PATHS ${NCCL_ROOT_DIR}/include
13+
)
14+
15+
find_library(NCCL_LIBRARY NAMES nccl
16+
PATHS ${NCCL_ROOT_DIR}/lib ${NCCL_ROOT_DIR}/lib64)
17+
18+
include(FindPackageHandleStandardArgs)
19+
find_package_handle_standard_args(NCCL DEFAULT_MSG NCCL_INCLUDE_DIR NCCL_LIBRARY)
20+
21+
if(NCCL_FOUND)
22+
message(STATUS "Found NCCL (include: ${NCCL_INCLUDE_DIR}, library: ${NCCL_LIBRARY})")
23+
mark_as_advanced(NCCL_INCLUDE_DIR NCCL_LIBRARY)
24+
endif()

‎CMakeModules/FindclBLAS.cmake‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# CLBLAS_FOUND - system has clBLAS
55
# CLBLAS_INCLUDE_DIRS - location of clBLAS.h
66
# CLBLAS_LIBRARIES - location of libclBLAS
7-
#
87

98
IF(CLBLAS_INCLUDE_DIRS)
109
# Already in cache, be silent
@@ -13,7 +12,7 @@ ENDIF (CLBLAS_INCLUDE_DIRS)
1312

1413
FIND_PATH(CLBLAS_ROOT_DIR
1514
NAMES include/clBLAS.h
16-
HINTS /usr/local/ $ENV{CLBLAS_ROOT}
15+
HINTS /usr/local/ $ENV{CLBLAS_ROOT}
1716
DOC "clBLAS root directory.")
1817

1918
FIND_PATH(_CLBLAS_INCLUDE_DIRS

‎src/CMakeLists.txt‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
44

55
find_package(CUDA)
66
find_package(OpenCL)
7+
find_package(NCCL)
78

89
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
910

@@ -40,8 +41,10 @@ gpuarray_error.c
4041
gpuarray_util.c
4142
gpuarray_buffer.c
4243
gpuarray_buffer_blas.c
44+
gpuarray_buffer_collectives.c
4345
gpuarray_array.c
4446
gpuarray_array_blas.c
47+
gpuarray_array_collectives.c
4548
gpuarray_kernel.c
4649
gpuarray_extension.c
4750
gpuarray_elemwise.c
@@ -102,6 +105,14 @@ if (CUDA_FOUND)
102105
if (CUBLAS_SGEMMEX)
103106
add_definitions(-DHAVE_CUBLAS_SGEMMEX)
104107
endif()
108+
109+
if (NCCL_FOUND)
110+
message("Building with NCCL")
111+
add_definitions(-DWITH_CUDA_NCCL)
112+
set(GPUARRAY_SRC ${GPUARRAY_SRC} gpuarray_collectives_cuda_nccl.c)
113+
include_directories("${NCCL_INCLUDE_DIR}")
114+
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${NCCL_LIBRARY})
115+
endif()
105116
endif()
106117

107118
if(OPENCL_FOUND)
@@ -136,7 +147,11 @@ add_library(gpuarray-static STATIC ${GPUARRAY_SRC})
136147

137148
if(CUDA_FOUND)
138149
target_link_libraries(gpuarray ${CUDADRV_LIBRARY} ${CUDA_CUBLAS_LIBRARIES})
139-
target_link_libraries(gpuarray-static ${CUDADRV_LIBRARY} ${CUDA_CUBLAS_LIBRARY})
150+
target_link_libraries(gpuarray-static ${CUDADRV_LIBRARY} ${CUDA_CUBLAS_LIBRARIES})
151+
if (NCCL_FOUND)
152+
target_link_libraries(gpuarray ${NCCL_LIBRARY})
153+
target_link_libraries(gpuarray-static ${NCCL_LIBRARY})
154+
endif()
140155
endif()
141156

142157
if(OPENCL_FOUND)
@@ -151,8 +166,10 @@ endif()
151166
SET(headers
152167
gpuarray/array.h
153168
gpuarray/blas.h
169+
gpuarray/collectives.h
154170
gpuarray/buffer.h
155171
gpuarray/buffer_blas.h
172+
gpuarray_buffer_collectives.c
156173
gpuarray/config.h
157174
gpuarray/elemwise.h
158175
gpuarray/error.h

‎src/gpuarray_buffer_opencl.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@ static int cl_property(gpucontext *c, gpudata *buf, gpukernel *k, int prop_id,
11611161
#endif
11621162

11631163
case GA_CTX_PROP_COMM_OPS:
1164-
// Complete in the future if a multi-gpu collectives API for opencl appears
1164+
// TODO Complete in the future whenif a multi-gpu collectives API for
1165+
// opencl appears
11651166
*((void **)res) = NULL;
11661167
return GA_DEVSUP_ERROR;
11671168

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL