Skip to content

Commit

Permalink
Merge pull request #204 from BioDataAnalysis/bda_several_build_improv…
Browse files Browse the repository at this point in the history
…ements

Several build improvements
  • Loading branch information
zeyiwen committed Feb 11, 2020
2 parents b747745 + 2fce9a3 commit cf708d5
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 28 deletions.
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ endif()

option(BUILD_SHARED_LIBS "Build as a shared library" ON)
option(USE_CUDA "Compile with CUDA" ON)
option(USE_EIGEN "Compile with Eigen" OFF)
option(BUILD_TESTS "Build Tests" OFF)
option(USE_DOUBLE "Use double as kernel_type" OFF)

Expand All @@ -21,14 +20,14 @@ endif()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
if (MSVC AND BUILD_SHARED_LIBS)
set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()

find_package(Threads)
find_package(OpenMP REQUIRED)
add_definitions("-DELPP_NO_LOG_TO_FILE")

if (USE_CUDA AND USE_EIGEN)
message (FATAL_ERROR "CUDA and Eigen are mutually exclusive. Please specify either USE_CUDA or USE_EIGEN, not both.")
endif ()

if (USE_CUDA)
message("Compile with CUDA")
find_package(CUDA REQUIRED QUIET)
Expand All @@ -39,9 +38,6 @@ if (USE_CUDA)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_MWAITXINTRIN_H_INCLUDED -D_FORCE_INLINES")
else ()
message("Compile without CUDA")
endif ()

if (USE_EIGEN)
find_package (Eigen3 3.3 NO_MODULE)
if (Eigen3_FOUND)
message("using external Eigen3 for acceleration")
Expand All @@ -51,7 +47,9 @@ if (USE_EIGEN)
message("using internal Eigen3 for acceleration")
include_directories(${PROJECT_SOURCE_DIR}/eigen)
endif ()
add_compile_options("-march=native")
if (NOT CMAKE_CXX_FLAGS MATCHES "-march")
add_compile_options("-march=native")
endif ()
endif ()

if (CMAKE_VERSION VERSION_LESS "3.1")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ cmake -DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6 ..
```bash
# in thundersvm root directory
git submodule init eigen && git submodule update
mkdir build && cd build && cmake -DUSE_CUDA=OFF -DUSE_EIGEN=ON .. && make -j
mkdir build && cd build && cmake -DUSE_CUDA=OFF .. && make -j
```
If ```make -j``` doesn't work, please simply use ```make```. The number of CPU cores to use can be specified by the ```-o``` option (e.g., ```-o 10```), and refer to [Parameters](docs/parameters.md) for more information.

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ before_build:
cd build
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -DUSE_EIGEN=ON -DBUILD_TESTS=ON -G "Visual Studio 14 2015 Win64"
cmake .. -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -DBUILD_TESTS=ON -G "Visual Studio 14 2015 Win64"
build:
project: build/thundersvm.sln
parallel: true
Expand Down
2 changes: 1 addition & 1 deletion cmake/thundersvmConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

find_dependency(OpenMP)

if (@USE_EIGEN@)
if (NOT @USE_CUDA@)
if (@Eigen3_FOUND@)
find_dependency(Eigen3)
endif ()
Expand Down
12 changes: 6 additions & 6 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mkdir build
cd build
cmake \
-DUSE_CUDA=OFF \
-DUSE_EIGEN=ON \
\
-DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
-DOpenMP_C_LIB_NAMES=omp \
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
Expand All @@ -65,11 +65,11 @@ git clone https://github.com/Xtra-Computing/thundersvm.git
```bash
mkdir build
cd build
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -G "Visual Studio 14 2015 Win64"
cmake .. -DBUILD_SHARED_LIBS=TRUE -G "Visual Studio 14 2015 Win64"
```
You need to change the Visual Studio version if you are using a different version of Visual Studio. Visual Studio can be downloaded from [this link](https://www.visualstudio.com/vs/). The above commands generate some Visual Studio project files, open the Visual Studio project to build ThunderSVM. Please note that CMake should be 3.4 or above for Windows.

After you execute `cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -G "Visual Studio 14 2015 Win64"`, you can find a project "thundersvm.sln" under build directory. You can double click it to open it with Visual Studio. Then you should build the solution inside Visual Studio. You can refer to this [this link](https://docs.microsoft.com/en-us/visualstudio/ide/building-and-cleaning-projects-and-solutions-in-visual-studio?view=vs-2019). After you build the project, you should be able to use the python interface.
After you execute `cmake .. -DBUILD_SHARED_LIBS=TRUE -G "Visual Studio 14 2015 Win64"`, you can find a project "thundersvm.sln" under build directory. You can double click it to open it with Visual Studio. Then you should build the solution inside Visual Studio. You can refer to this [this link](https://docs.microsoft.com/en-us/visualstudio/ide/building-and-cleaning-projects-and-solutions-in-visual-studio?view=vs-2019). After you build the project, you should be able to use the python interface.

#### Working without GPUs<a name="withoutGPU"></a>
If you don't have GPUs, ThunderSVM can run purely on CPUs. The number of CPU cores to use can be specified by the ```-o``` option (e.g., ```-o 10```), and refer to [Parameters](http://thundersvm.readthedocs.io/en/latest/parameters.html) for more information.
Expand All @@ -88,21 +88,21 @@ git submodule init eigen && git submodule update
* Build without GPUs for Linux
```bash
# in thundersvm root directory
mkdir build && cd build && cmake -DUSE_CUDA=OFF -DUSE_EIGEN=ON .. && make -j
mkdir build && cd build && cmake -DUSE_CUDA=OFF .. && make -j
```
If ```make -j``` doesn't work, please simply use ```make```. Now ThunderSVM will work solely on CPUs and does not rely on CUDA.

* Build without GPUs for MacOS
```bash
# in thundersvm root directory
mkdir build && cd build && cmake -DCMAKE_CXX_COMPILER=[path_to_g++] -DCMAKE_C_COMPILER=[path_to_gcc] -DUSE_CUDA=OFF -DUSE_EIGEN=ON .. && make -j
mkdir build && cd build && cmake -DCMAKE_CXX_COMPILER=[path_to_g++] -DCMAKE_C_COMPILER=[path_to_gcc] -DUSE_CUDA=OFF .. && make -j
```

* Build without GPUs for Windows
```bash
mkdir build
cd build
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -DUSE_EIGEN=ON -G "Visual Studio 14 2015 Win64"
cmake .. -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -G "Visual Studio 14 2015 Win64"
```
Then, you can open the generated the Visual Studio project file to build ThunderSVM.

Expand Down
4 changes: 2 additions & 2 deletions docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ git submodule update --init src/test/googletest
```bash
mkdir build
cd build
cmake .. -DCMAKE_CXX_COMPILER=[path_to_g++]/usr/local/bin/g++-7 -DCMAKE_C_COMPILER=[path_to_gcc] -DUSE_CUDA=OFF -DUSE_EIGEN=ON -DBUILD_TESTS=ON
cmake .. -DCMAKE_CXX_COMPILER=[path_to_g++]/usr/local/bin/g++-7 -DCMAKE_C_COMPILER=[path_to_gcc] -DUSE_CUDA=OFF -DBUILD_TESTS=ON
make -j runtest
```
Where ```[path_to_g++]``` and ```[path_to_gcc]``` typically look like ```/usr/local/bin/g++-7``` and ```/usr/local/bin/gcc-7```, respectively.
Expand All @@ -105,7 +105,7 @@ git submodule update --init src/test/googletest
```bash
mkdir build
cd build
cmake .. -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DBUILD_TESTS=ON -G "Visual Studio 14 2015 Win64"
cmake .. -DBUILD_SHARED_LIBS=TRUE -DBUILD_TESTS=ON -G "Visual Studio 14 2015 Win64"
cmake --build . --target runtest
```
You need to change the Visual Studio version if you are using a different version of Visual Studio. Visual Studio can be downloaded from [this link](https://www.visualstudio.com/vs/). The above commands generate some Visual Studio project files, open the Visual Studio project to build ThunderSVM. Please note that CMake should be 3.4 or above for Windows.
Expand Down
1 change: 0 additions & 1 deletion include/thundersvm/config.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#cmakedefine DATASET_DIR "@DATASET_DIR@"
#cmakedefine USE_CUDA
#cmakedefine USE_EIGEN
#cmakedefine USE_DOUBLE
5 changes: 2 additions & 3 deletions scripts/build_cpu_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ cd build

case ${TRAVIS_OS_NAME} in
linux)
cmake -DUSE_CUDA=OFF -DUSE_EIGEN=ON ..
cmake -DUSE_CUDA=OFF ..
;;
osx)
brew install cmake libomp
cmake \
-DUSE_CUDA=OFF \
-DUSE_EIGEN=ON \
-DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
-DOpenMP_C_LIB_NAMES=omp \
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
Expand All @@ -23,7 +22,7 @@ osx)
;;
windows)
export PATH=${MSBUILD_PATH}:$PATH
cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -DUSE_EIGEN=ON -G "Visual Studio 14 2015 Win64" ..
cmake -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -G "Visual Studio 14 2015 Win64" ..
choco install python --version=3.6.3
python -m pip install --upgrade pip
pip install wheel
Expand Down
6 changes: 3 additions & 3 deletions scripts/build_cputest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ cd build_cputest

case ${TRAVIS_OS_NAME} in
linux)
cmake -DBUILD_TESTS=ON -DUSE_CUDA=OFF -DUSE_EIGEN=ON ..
cmake -DBUILD_TESTS=ON -DUSE_CUDA=OFF ..
;;
osx)
brew install cmake libomp
cmake \
-DUSE_CUDA=OFF \
-DUSE_EIGEN=ON \
\
-DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
-DOpenMP_C_LIB_NAMES=omp \
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
Expand All @@ -24,7 +24,7 @@ osx)
;;
windows)
export PATH=${MSBUILD_PATH}:$PATH
cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -DUSE_EIGEN=ON -DBUILD_TESTS=ON -G "Visual Studio 14 2015 Win64" ..
cmake -DBUILD_SHARED_LIBS=TRUE -DUSE_CUDA=OFF -DBUILD_TESTS=ON -G "Visual Studio 14 2015 Win64" ..
;;
esac

Expand Down
2 changes: 1 addition & 1 deletion scripts/build_gpu_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ windows)
wget -q http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_426.00_win10.exe
./cuda_10.1.243_426.00_win10.exe -s nvcc_10.1 cusparse_dev_10.1
export PATH=${MSBUILD_PATH}:$PATH
cmake -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE -DBUILD_SHARED_LIBS=TRUE -DCUDA_TOOLKIT_ROOT_DIR="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1" -G "Visual Studio 14 2015 Win64" ..
cmake -DBUILD_SHARED_LIBS=TRUE -DCUDA_TOOLKIT_ROOT_DIR="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.1" -G "Visual Studio 14 2015 Win64" ..
choco install python --version=3.6.3
python -m pip install --upgrade pip
pip install wheel
Expand Down

0 comments on commit cf708d5

Please sign in to comment.