Skip to content

Commit

Permalink
Merge branch 'release/1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
emfomy committed Sep 8, 2017
2 parents 7ce116f + d31a8b7 commit f0b1835
Show file tree
Hide file tree
Showing 113 changed files with 4,491 additions and 1,544 deletions.
24 changes: 13 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
# The main CMake setting

# Set project
project(ISVD)
# cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8.12)
set(ISVD_NAME "Integrated Singular Value Decomposition")

# Set version number
# Set project
set(ISVD_NAME "Integrated Singular Value Decomposition")
set(ISVD_MAJOR_VERSION 1)
set(ISVD_MINOR_VERSION 1)
set(ISVD_PATCH_VERSION 1)
set(ISVD_MINOR_VERSION 2)
set(ISVD_PATCH_VERSION 0)
set(ISVD_VERSION "${ISVD_MAJOR_VERSION}.${ISVD_MINOR_VERSION}.${ISVD_PATCH_VERSION}")

# Set cache options
include(cmake/cache.cmake)

# Initialize project
cmake_policy(SET CMP0048 OLD)
project(ISVD)

# Set Makefile
set(CMAKE_COLOR_MAKEFILE ON)
# set(CMAKE_VERBOSE_MAKEFILE ON)

# Set module path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

# Include utilities
include(cmake/utilities.cmake)
# Variables
string(ASCII 27 Esc)

# Set the options
include(cmake/options.cmake)
Expand All @@ -43,8 +48,5 @@ add_subdirectory(share)
add_subdirectory(check)
add_subdirectory(doxygen)

# Set flags
include(cmake/flags.cmake)

# Display message
include(cmake/display.cmake)
52 changes: 42 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Integrated Singular Value Decomposition (iSVD)
### Author
* Mu Yang <<emfomy@gmail.com>>

### Tutorial
* @ref tutorial_main

## Requirements
* [CMake](https://cmake.org) 2.8+ (CMake 3+ recommended).
* C/C++ compiler with C99/C++98 standard support ([GCC](https://gcc.gnu.org) 4.4+ recommended).
Expand All @@ -20,7 +23,7 @@ Integrated Singular Value Decomposition (iSVD)

### Optional
* [Intel&reg; Math Kernel Library](https://software.intel.com/en-us/intel-mkl) (**Recommended** for better performance, used for BLAS & LAPACK).
<!-- * [MAGMA](http://icl.cs.utk.edu/magma/) 2+ (Used for BLAS & LAPACK with GPU support). -->
* [MAGMA](http://icl.cs.utk.edu/magma/) 2+ (Used for BLAS & LAPACK with GPU support).
* [OpenMP](http://openmp.org) Library (**Recommended** for better performance, used for multi-thread parallelization).
* [Google Test Library](https://github.com/google/googletest) (Used for code testing).
* [DOxygen](http://www.stack.nl/~dimitri/doxygen/) (Used for documentation).
Expand Down Expand Up @@ -50,33 +53,57 @@ The following table are the main options
| `ISVD_BLAS` | the selection BLAS/LAPACK library. | Options: `BLAS/MKL` |
| `ISVD_BUILD_DEMO` | build demo codes. | |
| `ISVD_BUILD_DOC` | build documentation. | |
| `ISVD_BUILD_LIB` | build libraries. | |
| `ISVD_BUILD_TEST` | build unit tests. | |
| `ISVD_INDEX_TYPE` | the selection index type. | Options: `32/64` |
| `ISVD_OMP` | the selection OpenMP library. | Options: `OFF/GOMP/IOMP` |
| `ISVD_USE_GPU` | enable GPU support. | |
| `ISVD_VERBOSE_TEST` | enable verbose unit tests. | |
| `GTEST_ROOT` | the root path of Google Test. | Require `ISVD_BUILD_TEST` |
| `INTEL_ROOT` | the root path of Intel libraries. | Require `ISVD_BLAS = MKL` |
| `MKL_ROOT` | the root path of Intel MKL. | Require `ISVD_BLAS = MKL` |
| `MPI_PROCS` | the number of MPI processes. | Only used in demo codes. |
| `OMP_THRDS` | the number of OpenMP threads. | Only used in demo/check codes. |
<!-- | `ISVD_USE_GPU` | enable GPU support. | | -->

### Makefile

The following table are the main make rules

| Command | Detail |
|----------------|--------------------------------|
| `make all` | build all binaries |
| `make all` | build all libraries |
| `make install` | install package |
| `make check` | build and run unit tests |
| `make doc` | build documentation |
| `make help` | display make-rules |

### Definitions
## Usage

* Define `ISVD_USE_ILP64` before include `isvd.h` to use 64-bit integer.
* All 64bit libraries and executables are named with suffix "`_64`".

### Libraries

Please link exact one library of each kind.

* Define `ISVD_USE_ILP64` to use 64-bit integer.
* Define `ISVD_USE_MKL` to enable Intel MKL.
<!-- * Define `ISVD_USE_GPU` to enable GPU support. -->
* Correct
* `gcc test.c -I<include-path> -L<library-path> -Wl,-rpath <library-path> -lisvd_core -lisvd_la_mkl_iomp -lisvd_gpu_magma`
* `gcc test.c -I<include-path> -L<library-path> -Wl,-rpath <library-path> -lisvd_core -lisvd_la_blas -lisvd_gpu_none`
* Wrong
* `gcc test.c -I<include-path> -L<library-path> -Wl,-rpath <library-path> -lisvd_core`
* (Some kind of libraries are not linked)
* `gcc test.c -I<include-path> -L<library-path> -Wl,-rpath <library-path> -lisvd_core -lisvd_la_blas -lisvd_gpu_magma -lisvd_gpu_none`
* (Some kind of libraries are linked multiple times)

| Name | Kind | Detail |
|------------------------|----------------|----------------------------------------|
| `isvd_core` | Core | Core routines |
| `isvd_la_blas` | Linear Algebra | Sequential Plain BLAS |
| `isvd_la_mkl` | Linear Algebra | Sequential Intel MKL |
| `isvd_la_mkl_gomp` | Linear Algebra | Parallel Intel MKL using GNU OpenMP |
| `isvd_la_mkl_iomp` | Linear Algebra | Parallel Intel MKL using Intel OpenMP |
| `isvd_gpu_none` | GPU | No GPU |
| `isvd_gpu_magma` | GPU | MAGMA GPU |

## Q&amp;A

Expand All @@ -95,11 +122,16 @@ The following table are the main make rules

* Set `GTEST_ROOT` to a folder containing `include` and `lib` of Google Test.

### How to enable multithread support?

* Set `ISVD_OMP` with `ccmake` before building libraries.
* Make sure your LAPACK&amp;BLAS / Intel MKL uses supports multithreading.

### How to use 64-bit integer?

* Set `ISVD_USE_ILP64` with `ccmake`.
* If you want to compile directly, add `-DISVD_USE_ILP64` to compiler flag.
* Make sure your LAPACK&amp;BLAS / Intel MKL uses 64bit integer. Make sure you uses the correct library and flags of Intel MKL.
* Set `ISVD_USE_ILP64` with `ccmake` before building libraries.
* Add `-DISVD_USE_ILP64` to compile flag.
* Make sure your LAPACK&amp;BLAS / Intel MKL uses 64bit integer.

## Reference
* [Ting-Li Chen, Dawei D. Chang, Su-Yun Huang, Hung Chen, Chienyao Lin, Weichung Wang, “Integrating Multiple Random Sketches for Singular Value Decomposition”](https://arxiv.org/abs/1608.08285)
Expand Down
63 changes: 35 additions & 28 deletions check/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,39 @@ if(NOT ISVD_BUILD_TEST)
return()
endif()

# GTest
if(GTEST_FOUND)
list(APPEND INCS "${GTEST_INCLUDE_DIRS}")
list(APPEND LIBS "${GTEST_BOTH_LIBRARIES}")
list(APPEND DEFS "ISVD_USE_GTEST")
endif()
# Target rule
function(ISVD_SET_TARGET_CHECK_CPU target)
isvd_set_target_omp(${target} CXX)
isvd_set_target_mpi(${target})
isvd_set_target_blas(${target})
isvd_set_target_gtest(${target})
target_link_libraries(${target} checkisvd extmmio)
target_compile_definitions(${target} PUBLIC "-DISVD_DATA_PATH=\"${PROJECT_SOURCE_DIR}/data\"")
endfunction()

function(ISVD_SET_TARGET_CHECK_GPU target)
isvd_set_target_omp(${target} CXX)
isvd_set_target_mpi(${target})
isvd_set_target_blas(${target})
isvd_set_target_gtest(${target})
isvd_set_target_gpu(${target})
target_link_libraries(${target} checkisvd_gpu extmmio)
target_compile_definitions(${target} PUBLIC "-DISVD_DATA_PATH=\"${PROJECT_SOURCE_DIR}/data\"")
endfunction()

# Set include paths
include_directories("${PROJECT_CONFIG_DIR}/include/c"
"${CMAKE_CURRENT_CONFIG_DIR}/src"
"${PROJECT_CONFIG_DIR}/src"
SYSTEM "${PROJECT_SOURCE_DIR}/ext")

# Add subdirectories
add_subdirectory(src)

# Set libraries
list(APPEND LIBS checkisvd)
list(APPEND LIBS extmmio)

# Set definitions
list(APPEND DEFS "-DISVD_DATA_PATH=\"${PROJECT_SOURCE_DIR}/data\"")

# Configure files
isvd_configure_x_fn("${CMAKE_CURRENT_SOURCE_DIR}/check" "${CMAKE_CURRENT_CONFIG_DIR}/check" "${ISVD_S_TYPES}")
isvd_configure_x_fn("${CMAKE_CURRENT_SOURCE_DIR}/check" "${CMAKE_CURRENT_CONFIG_DIR}/check" "${ISVD_D_TYPES}")
isvd_configure_in_fn("${CMAKE_CURRENT_SOURCE_DIR}/check" "${CMAKE_CURRENT_CONFIG_DIR}/check")
isvd_configure_fn("${CMAKE_CURRENT_SOURCE_DIR}/check" "${CMAKE_CURRENT_CONFIG_DIR}/check")

# Include macros
include(check.cmake)
Expand All @@ -50,30 +57,30 @@ macro(ISVD_CHECK_FN xtypes)

isvd_set_types(${xtypes})

# CPU unit tests
set(DEFS_TMP "${DEFS}")
list(REMOVE_ITEM DEFS "ISVD_USE_GPU")

# Sketching
add_mpi_check(libisvd/core/stage/${x}_sketch_gaussian_projection "${XName} Precision Gaussian Projection Sketching check" "1;2;3;4;6;12")
add_mpi_check_cpu(libisvd/core/stage/${x}_sketch_gaussian_projection "${XName} Precision Gaussian Projection Sketching" "1;2;3;4;6;12")

# Orthogonalization
add_mpi_check(libisvd/core/stage/${x}_orthogonalize_gramian "${XName} Precision Gramian Orthogonalization check" "1;2;3;4;6;12")
add_mpi_check_cpu(libisvd/core/stage/${x}_orthogonalize_gramian "${XName} Precision Gramian Orthogonalization" "1;2;3;4;6;12")

# Integration
add_mpi_check(libisvd/core/stage/${x}_integrate_kolmogorov_nagumo "${XName} Precision Kolmogorov Nagumo Integration check" "1;2;3;4;6;12")
add_mpi_check(libisvd/core/stage/${x}_integrate_wen_yin "${XName} Precision Wen Yin Integration check" "1;2;3;4;6;12")
add_mpi_check(libisvd/core/stage/${x}_integrate_hierarchical_reduction "${XName} Precision Hierarchical Reduction Integration check" "1;2;3;4;6;12")
add_mpi_check_cpu(libisvd/core/stage/${x}_integrate_kolmogorov_nagumo "${XName} Precision Kolmogorov Nagumo Integration" "1;2;3;4;6;12")
add_mpi_check_cpu(libisvd/core/stage/${x}_integrate_wen_yin "${XName} Precision Wen Yin Integration" "1;2;3;4;6;12")
add_mpi_check_cpu(libisvd/core/stage/${x}_integrate_hierarchical_reduction "${XName} Precision Hierarchical Reduction Integration" "1;2;3;4;6;12")

# Postprocessing
add_mpi_check(libisvd/core/stage/${x}_postprocess_gramian "${XName} Precision Gramian Postprocessing check" "1;2;3;4;6;12")
add_mpi_check(libisvd/core/stage/${x}_postprocess_symmetric "${XName} Precision Symmetric Postprocessing check" "1;2;3;4;6;12")

set(DEFS "${DEFS_TMP}")
unset(DEFS_TMP)
add_mpi_check_cpu(libisvd/core/stage/${x}_postprocess_gramian "${XName} Precision Gramian Postprocessing" "1;2;3;4;6;12")
add_mpi_check_cpu(libisvd/core/stage/${x}_postprocess_symmetric "${XName} Precision Symmetric Postprocessing" "1;2;3;4;6;12")

# GPU unit tests
if(ISVD_USE_GPU)

# Sketching
add_mpi_check_gpu(libisvd/gpu/stage/${x}_sketch_gaussian_projection_gpu "${XName} Precision GPU Gaussian Projection Sketching" "1;2")

# Postprocessing
add_mpi_check_gpu(libisvd/gpu/stage/${x}_postprocess_gramian_gpu "${XName} Precision GPU Gramian Postprocessing" "1;2")
add_mpi_check_gpu(libisvd/gpu/stage/${x}_postprocess_symmetric_gpu "${XName} Precision GPU Symmetric Postprocessing" "1;2")
endif()
endmacro()

Expand Down
42 changes: 29 additions & 13 deletions check/check.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ macro(_ADD_CHECK_PREDO checktype)
list(SORT files)
list(REVERSE files)
add_executable(${checktarget} EXCLUDE_FROM_ALL ${checkmain} ${files})
isvd_set_target(${checktarget} "")
isvd_set_target(${checktarget})
target_compile_definitions(${checktarget} PUBLIC "ISVD_CHECK_NAME=\"${checkcomment}\"")
set(CMAKE_CHECK_TARGETS ${CMAKE_CHECK_TARGETS} ${checktarget} PARENT_SCOPE)
list(REVERSE files)
Expand All @@ -26,7 +26,13 @@ endmacro()
macro(_ADD_CHECK checktype)
set(checkmain check.cxx)
_add_check_predo("${checktype}" "")
gtest_add_tests($<TARGET_FILE:${checktarget}> "" ${checkmain} ${files})

# Add test
if(ISVD_VERBOSE_TEST)
gtest_add_tests($<TARGET_FILE:${checktarget}> "" ${checkmain} ${files})
else()
add_test(NAME ${checkname} COMMAND $<TARGET_FILE:${checktarget}>)
endif()

# Add rule
add_custom_target(
Expand All @@ -42,13 +48,20 @@ macro(_ADD_MPI_CHECK checktype listprocs)
set(checkmain check_mpi.cxx)
_add_check_predo("${checktype}")

gtest_add_mpi_tests($<TARGET_FILE:${checktarget}> "${listprocs}" "" ${checkmain} ${files})
# Add test
if(ISVD_VERBOSE_TEST)
gtest_add_mpi_tests($<TARGET_FILE:${checktarget}> "${listprocs}" "" ${checkmain} ${files})
else()
foreach(procs ${listprocs})
add_test(NAME ${checkname}_${procs} COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${procs} ${CMAKE_COMMAND} -E env ${ENVS} $<TARGET_FILE:${checktarget}>)
endforeach()
endif()

# Add rule
foreach(procs ${listprocs})
add_custom_target(
check_${checkname}_${procs}
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${procs} ${CMAKE_ENV} OMP_NUM_THREADS=${OMP_THRDS} $<TARGET_FILE:${checktarget}>
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${procs} ${CMAKE_COMMAND} -E env ${ENVS} $<TARGET_FILE:${checktarget}>
DEPENDS ${checktarget}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Run check ${checkpath}"
Expand All @@ -58,21 +71,24 @@ endmacro()

################################################################################

function(ADD_CHECK checkpath checkcomment)
function(ADD_CHECK_CPU checkpath checkcomment)
_add_check("")
isvd_set_target_check_cpu(${checktarget})
endfunction()

function(ADD_CHECK_TEST checkpath checkcomment)
_add_check("test")
endfunction()

function(ADD_CHECK_DEATH checkpath checkcomment)
list(REMOVE_ITEM DEFS "ISVD_USE_GTEST")
_add_check("death_test")
function(ADD_CHECK_GPU checkpath checkcomment)
_add_check("")
isvd_set_target_check_gpu(${checktarget})
endfunction()

################################################################################

function(ADD_MPI_CHECK checkpath checkcomment listprocs)
function(ADD_MPI_CHECK_CPU checkpath checkcomment listprocs)
_add_mpi_check("" "${listprocs}")
isvd_set_target_check_cpu(${checktarget})
endfunction()

function(ADD_MPI_CHECK_GPU checkpath checkcomment listprocs)
_add_mpi_check("" "${listprocs}")
isvd_set_target_check_gpu(${checktarget})
endfunction()
7 changes: 2 additions & 5 deletions check/check.cxx
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#include <iostream>
#include <gtest/gtest.h>
#include <isvd.h>
#include <libisvd.h>

int main( int argc, char **argv ) {

mpi_int_t mpi_size = 1;
omp_int_t omp_size = isvd_getOmpSize();
printf("iSVD " ISVD_VERSION " " ISVD_CHECK_NAME " test\n");
printf("%d nodes, %d threads per node\n\n", mpi_size, omp_size);
printf("iSVD " ISVD_CHECK_NAME " unit test\n");
isvd_printEnvironment(MPI_COMM_WORLD);

testing::InitGoogleTest(&argc, argv);
int retval = RUN_ALL_TESTS();
Expand Down
Loading

0 comments on commit f0b1835

Please sign in to comment.