Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Fix warnings, build adjustments in CMake (#209)
Browse files Browse the repository at this point in the history
* Fix warnings, build adjustments in CMake

* fix cuda variable-declaration order problems

* Remove gpu flavors below 30, no longer compatible
  • Loading branch information
cjolivier01 authored and piiswrong committed Feb 1, 2017
1 parent 3adb817 commit 7642202
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ rabit
dmlc-core
*.db
*.bak
build
48 changes: 32 additions & 16 deletions cmake/Cuda.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ endif()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" SUPPORT_CXX11)


# Known NVIDIA GPU achitectures mshadow can be compiled for.
# This list will be used for CUDA_ARCH_NAME = All option
if(${CUDA_VERSION} GREATER 7.5)
set(mshadow_known_gpu_archs "20 21(20) 30 35 50 52 60 61")
else()
set(mshadow_known_gpu_archs "20 21(20) 30 35 50 52")
endif()


################################################################################################
# A function for automatic detection of GPUs installed (if autodetection is enabled)
# Usage:
Expand Down Expand Up @@ -167,17 +157,14 @@ macro(mshadow_cuda_compile objlist_variable)
endforeach()
if(UNIX OR APPLE)
list(APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC)
if(SUPPORT_CXX11)
list(APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC --std=c++11)
endif()
endif()

if(APPLE)
list(APPEND CUDA_NVCC_FLAGS -Xcompiler -Wno-unused-function)
endif()

set(CUDA_NVCC_FLAGS_DEBUG "${CUDA_NVCC_FLAGS_DEBUG} -G -lineinfo")

if(MSVC)
# disable noisy warnings:
# 4819: The file contains a character that cannot be represented in the current code page (number).
Expand All @@ -191,6 +178,14 @@ macro(mshadow_cuda_compile objlist_variable)
endforeach(flag_var)
endif()

# If the build system is a container, make sure the nvcc intermediate files
# go into the build output area rather than in /tmp, which may run out of space
if(IS_CONTAINER_BUILD)
set(CUDA_NVCC_INTERMEDIATE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "Container build enabled, so nvcc intermediate files in: ${CUDA_NVCC_INTERMEDIATE_DIR}")
list(APPEND CUDA_NVCC_FLAGS "--keep --keep-dir ${CUDA_NVCC_INTERMEDIATE_DIR}")
endif()

cuda_compile(cuda_objcs ${ARGN})

foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
Expand Down Expand Up @@ -232,7 +227,16 @@ endfunction()
### Non macro section
################################################################################################

find_package(CUDA 5.5 QUIET)
# Try to prime CUDA_TOOLKIT_ROOT_DIR by looking for libcudart.so
if(NOT CUDA_TOOLKIT_ROOT_DIR)
find_library(CUDA_LIBRARY_PATH libcudart.so PATHS ENV LD_LIBRARY_PATH PATH_SUFFIXES lib lib64)
if(CUDA_LIBRARY_PATH)
get_filename_component(CUDA_LIBRARY_PATH ${CUDA_LIBRARY_PATH} DIRECTORY)
set(CUDA_TOOLKIT_ROOT_DIR "${CUDA_LIBRARY_PATH}/..")
endif()
endif()

find_package(CUDA 5.5 QUIET REQUIRED)
find_cuda_helper_libs(curand) # cmake 2.8.7 compartibility which doesn't search for curand

if(NOT CUDA_FOUND)
Expand All @@ -245,6 +249,18 @@ include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
list(APPEND mshadow_LINKER_LIBS ${CUDA_CUDART_LIBRARY}
${CUDA_curand_LIBRARY} ${CUDA_CUBLAS_LIBRARIES})

# Known NVIDIA GPU achitectures mshadow can be compiled for.
# This list will be used for CUDA_ARCH_NAME = All option
if(CUDA_ARCH_ALL)
set(mshadow_known_gpu_archs "${CUDA_ARCH_ALL}")
else()
if(${CUDA_VERSION} GREATER 7.5)
set(mshadow_known_gpu_archs "30 35 50 52 60 61")
else()
set(mshadow_known_gpu_archs "30 35 50 52")
endif()
endif()

# cudnn detection
if(USE_CUDNN)
detect_cuDNN()
Expand Down
2 changes: 2 additions & 0 deletions cmake/mshadowUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include("${CMAKE_CURRENT_LIST_DIR}/Utils.cmake")

2 changes: 1 addition & 1 deletion mshadow/extension/broadcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ broadcast_scalar(const expr::Exp<SrcExp, DType, etype> &src, Shape<dimdst> shape
TypeCheckPass<ExpInfo<SrcExp>::kDim == 1>
::Error_Expression_Does_Not_Meet_Dimension_Req();
typedef ShapeCheck<1, SrcExp> ShapeCheckDim1SrcExp;
CHECK_EQ(ShapeCheckDim1SrcExp::Check(src.self())[0], 1)
CHECK_EQ(ShapeCheckDim1SrcExp::Check(src.self())[0], 1U)
<< "broadcast_scalar, source need to be scalar expression";
return BroadcastScalarExp<SrcExp, DType, dimdst>(src.self(), shape);
}
Expand Down
6 changes: 3 additions & 3 deletions mshadow/extension/broadcast_with_axis.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ const TShape &axes, const TShape &sizes) {
template<typename SrcExp, typename DType, int etype, typename TShape>
inline BroadcastWithMultiAxesExp<SrcExp, DType, ExpInfo<SrcExp>::kDim>
broadcast_to(const Exp<SrcExp, DType, etype> &src, const TShape &target_shape) {
static const int dimsrc = ExpInfo<SrcExp>::kDim;
static const size_t dimsrc = ExpInfo<SrcExp>::kDim;
CHECK_EQ(target_shape.ndim(), dimsrc);
std::vector<index_t> axes_vec, sizes_vec;
Shape<dimsrc> src_shape = ShapeCheck<dimsrc, SrcExp>::Check(src.self());
for (int i = 0; i < dimsrc; ++i) {
for (size_t i = 0; i < dimsrc; ++i) {
if (src_shape[i] != target_shape[i]) {
CHECK_EQ(src_shape[i], 1) << "broadcasting axis must have size 1, received shape="
CHECK_EQ(src_shape[i], 1U) << "broadcasting axis must have size 1, received shape="
<< src_shape << " target_shape=" << target_shape;
axes_vec.push_back(i);
sizes_vec.push_back(target_shape[i]);
Expand Down
2 changes: 1 addition & 1 deletion mshadow/tensor_cpu-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ inline void VectorDot(Tensor<Device, 1, DType> dst,
const Tensor<Device, 1, DType> &rhs) {
CHECK_EQ(lhs.size(0), rhs.size(0))
<< "VectorDot: Shape mismatch";
CHECK_EQ(dst.size(0), 1)
CHECK_EQ(dst.size(0), 1U)
<< "VectorDot: expect dst to be scalar";
expr::BLASEngine<Device, DType>::SetStream(lhs.stream_);
mshadow::expr::BLASEngine<Device, DType>::dot(
Expand Down

0 comments on commit 7642202

Please sign in to comment.