[GPU-Plugin] Support for building to specific GPU architectures (#2390)

* Support for builing gpu-plugins to specific GPU architectures
1. Option GPU_COMPUTE_VER exposed from both Makefile and CMakeLists.txt
2. updater_gpu documentation updated accordingly

* Re-introduced GPU_COMPUTE_VER option in the cmake flow.
This seems to fix the compile-time, rdc=true and copy-constructor related
errors seen and discussed in PR #2390.
This commit is contained in:
Thejaswi 2017-06-13 03:21:38 +05:30 committed by Rory Mitchell
parent 65d2513714
commit 34dfe2f6de
3 changed files with 32 additions and 29 deletions

View File

@ -3,6 +3,8 @@ project (xgboost)
find_package(OpenMP) find_package(OpenMP)
option(PLUGIN_UPDATER_GPU "Build GPU accelerated tree construction plugin") option(PLUGIN_UPDATER_GPU "Build GPU accelerated tree construction plugin")
set(GPU_COMPUTE_VER 50;52;60;61 CACHE STRING
"Space separated list of compute versions to be built against")
if(PLUGIN_UPDATER_GPU) if(PLUGIN_UPDATER_GPU)
find_package(CUDA REQUIRED) find_package(CUDA REQUIRED)
endif() endif()
@ -107,35 +109,29 @@ if(PLUGIN_UPDATER_GPU)
set(NCCL_DIRECTORY ${PROJECT_SOURCE_DIR}/nccl) set(NCCL_DIRECTORY ${PROJECT_SOURCE_DIR}/nccl)
include_directories(${NCCL_DIRECTORY}/src) include_directories(${NCCL_DIRECTORY}/src)
set(LINK_LIBRARIES ${LINK_LIBRARIES} ${CUDA_LIBRARIES}) set(LINK_LIBRARIES ${LINK_LIBRARIES} ${CUDA_LIBRARIES})
#Find cub
#Find cub set(CUB_DIRECTORY ${PROJECT_SOURCE_DIR}/cub/)
set(CUB_DIRECTORY ${PROJECT_SOURCE_DIR}/cub/) include_directories(${CUB_DIRECTORY})
include_directories(${CUB_DIRECTORY})
#Find googletest #Find googletest
set(GTEST_DIRECTORY "${CACHE_PREFIX}" CACHE PATH "Googletest directory") set(GTEST_DIRECTORY "${CACHE_PREFIX}" CACHE PATH "Googletest directory")
include_directories(${GTEST_DIRECTORY}/include) include_directories(${GTEST_DIRECTORY}/include)
#gencode flags
# plugin set(GENCODE_FLAGS "")
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-lineinfo;--expt-extended-lambda") foreach(ver ${GPU_COMPUTE_VER})
set(GENCODE_FLAGS "${GENCODE_FLAGS}-gencode arch=compute_${ver},code=sm_${ver};")
endforeach()
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--expt-extended-lambda;${GENCODE_FLAGS};-lineinfo;")
if(NOT MSVC)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Xcompiler -fPIC")
endif()
set(CUDA_SOURCES set(CUDA_SOURCES
plugin/updater_gpu/src/updater_gpu.cu plugin/updater_gpu/src/updater_gpu.cu
plugin/updater_gpu/src/gpu_hist_builder.cu plugin/updater_gpu/src/gpu_hist_builder.cu
) )
include(${PROJECT_SOURCE_DIR}/cmake/Utils.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/Cuda.cmake)
# use below for forcing specific arch # use below for forcing specific arch
#cuda_compile(CUDA_OBJS ${CUDA_SOURCES} ${CUDA_NVCC_FLAGS} -arch=compute_52) cuda_compile(CUDA_OBJS ${CUDA_SOURCES} ${CUDA_NVCC_FLAGS})
# use below for auto-detect, but gpu_grow currently doesn't work with 61
xgboost_cuda_compile(CUDA_OBJS ${CUDA_SOURCES} ${CUDA_NVCC_FLAGS})
if(MSVC)
else()
cuda_add_library(updater_gpu STATIC ${CUDA_SOURCES})
set(LINK_LIBRARIES ${LINK_LIBRARIES} updater_gpu)
endif()
else() else()
set(CUDA_OBJS "") set(CUDA_OBJS "")
set(updater_gpu "")
endif() endif()
add_library(objxgboost OBJECT ${SOURCES}) add_library(objxgboost OBJECT ${SOURCES})

View File

@ -93,12 +93,12 @@ endif
CFLAGS += $(OPENMP_FLAGS) CFLAGS += $(OPENMP_FLAGS)
# for using GPUs # for using GPUs
COMPUTE ?= 60 35 GPU_COMPUTE_VER ?= 50 52 60 61
NVCC = nvcc NVCC = nvcc
INCLUDES = -Iinclude -I$(DMLC_CORE)/include -I$(RABIT)/include INCLUDES = -Iinclude -I$(DMLC_CORE)/include -I$(RABIT)/include
INCLUDES += -I$(CUB_PATH) INCLUDES += -I$(CUB_PATH)
INCLUDES += -I$(GTEST_PATH)/include INCLUDES += -I$(GTEST_PATH)/include
CODE = $(foreach ver,$(COMPUTE),-gencode arch=compute_$(ver),code=sm_$(ver)) CODE = $(foreach ver,$(GPU_COMPUTE_VER),-gencode arch=compute_$(ver),code=sm_$(ver))
NVCC_FLAGS = --std=c++11 $(CODE) $(INCLUDES) -lineinfo --expt-extended-lambda NVCC_FLAGS = --std=c++11 $(CODE) $(INCLUDES) -lineinfo --expt-extended-lambda
NVCC_FLAGS += -Xcompiler=$(OPENMP_FLAGS) -Xcompiler=-fPIC NVCC_FLAGS += -Xcompiler=$(OPENMP_FLAGS) -Xcompiler=-fPIC
ifeq ($(PLUGIN_UPDATER_GPU),ON) ifeq ($(PLUGIN_UPDATER_GPU),ON)

View File

@ -90,12 +90,27 @@ Visual studio community 2015, supported by cuda toolkit (http://docs.nvidia.com/
### For Developers! ### For Developers!
In case you want to build only for a specific GPU(s), for eg. GP100 and GP102,
whose compute capability are 60 and 61 respectively:
```bash
$ cmake .. -DPLUGIN_UPDATER_GPU=ON -DGPU_COMPUTE_VER="60;61"
```
By default, the versions will include support for all GPUs in Maxwell and Pascal architectures.
### Using make ### Using make
Now, it also supports the usual 'make' flow to build gpu-enabled tree construction plugins. It's currently only tested on Linux. From the xgboost directory Now, it also supports the usual 'make' flow to build gpu-enabled tree construction plugins. It's currently only tested on Linux. From the xgboost directory
```bash ```bash
# make sure CUDA SDK bin directory is in the 'PATH' env variable # make sure CUDA SDK bin directory is in the 'PATH' env variable
$ make PLUGIN_UPDATER_GPU=ON $ make PLUGIN_UPDATER_GPU=ON
``` ```
Similar to cmake, if you want to build only for a specific GPU(s):
```bash
$ make PLUGIN_UPDATER_GPU=ON GPU_COMPUTE_VER="60 61"
```
### For Developers!
Now, some of the code-base inside gpu plugins have googletest unit-tests inside 'tests/'. Now, some of the code-base inside gpu plugins have googletest unit-tests inside 'tests/'.
They can be enabled run along with other unit-tests inside '<xgboostRoot>/tests/cpp' using: They can be enabled run along with other unit-tests inside '<xgboostRoot>/tests/cpp' using:
```bash ```bash
@ -131,19 +146,11 @@ $ make PLUGIN_UPDATER_GPU=ON GTEST_PATH=${CACHE_PREFIX} test
[Mitchell, Rory, and Eibe Frank. Accelerating the XGBoost algorithm using GPU computing. No. e2911v1. PeerJ Preprints, 2017.](https://peerj.com/preprints/2911/) [Mitchell, Rory, and Eibe Frank. Accelerating the XGBoost algorithm using GPU computing. No. e2911v1. PeerJ Preprints, 2017.](https://peerj.com/preprints/2911/)
## Author ## Author
<<<<<<< HEAD
Rory Mitchell,
Jonathan C. McKinney,
Shankara Rao Thejaswi Nanditale,
Vinay Deshpande,
and the rest of the H2O.ai and NVIDIA team.
=======
Rory Mitchell Rory Mitchell
Jonathan C. McKinney Jonathan C. McKinney
Shankara Rao Thejaswi Nanditale Shankara Rao Thejaswi Nanditale
Vinay Deshpande Vinay Deshpande
... and the rest of the H2O.ai and NVIDIA team. ... and the rest of the H2O.ai and NVIDIA team.
>>>>>>> d2fbbdf4a39fa1f0af5cbd59a7912cf5caade34e
Please report bugs to the xgboost/issues page. Please report bugs to the xgboost/issues page.