Skip to content

Commit fda0a2c

Browse files
authored
Merge pull request #230 from ValeevGroup/asadchev/refactor/math
Asadchev/refactor/math
2 parents 2b9ac27 + 11daf44 commit fda0a2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+971
-1181
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@ build:
3737
- CXX: [ clang++-9 ]
3838
IMAGE : [ "ubuntu:20.04" ]
3939
TA_PYTHON : [ "TA_PYTHON=OFF" ]
40-
41-

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ include(FeatureSummary)
9696
# Preload versions/tags of all dependencies ====================================
9797
include(external/versions.cmake)
9898

99+
set(MPI_CXX_SKIP_MPICXX TRUE CACHE BOOL "MPI_CXX_SKIP_MPICXX")
100+
99101
# Configure options =======================================================
100102
option(ENABLE_MPI "Enable MPI" ON)
101103
add_feature_info(MPI ENABLE_MPI "Message-Passing Interface supports distributed-memory parallel programs")

cmake/gitlab-ci.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
set(TA_BUILD_UNITTEST TRUE)
2-
2+
set(ENABLE_SCALAPACK ON)
3+
set(blacs_LIBRARIES "scalapack-openmpi")
4+
set(scalapack_LIBRARIES "scalapack-openmpi")
5+
set(lapack_LIBRARIES "lapack")

cmake/toolchains/travis.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -Wall" CACHE STRING "Inital C++ relea
1717
set(BLAS_LINKER_FLAGS "-L/usr/lib/libblas" "-lblas" "-L/usr/lib/lapack" "-llapack" "-L/usr/lib" "-llapacke" CACHE STRING "BLAS linker flags")
1818
set(LAPACK_LIBRARIES ${BLAS_LINKER_FLAGS} CACHE STRING "LAPACK linker flags")
1919
set(LAPACK_INCLUDE_DIRS "/usr/include" CACHE STRING "LAPACK include directories")
20-
set(
21-
LAPACK_COMPILE_DEFINITIONS
22-
MADNESS_LINALG_USE_LAPACKE
23-
TILEDARRAY_EIGEN_USE_LAPACKE
24-
CACHE STRING "LAPACK preprocessor definitions"
25-
)
2620
set(INTEGER4 TRUE CACHE BOOL "Set Fortran integer size to 4 bytes")
2721
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
2822

examples/scalapack/conversion.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
*/
2626

2727
#include <tiledarray.h>
28+
#include <TiledArray/math/linalg/scalapack/block_cyclic.h>
2829
#include <random>
2930

31+
namespace scalapack = TiledArray::math::linalg::scalapack;
32+
3033
template <typename Integral1, typename Integral2>
3134
int64_t div_ceil(Integral1 x, Integral2 y) {
3235
int64_t x_ll = x;
@@ -66,7 +69,7 @@ int main(int argc, char** argv) {
6669

6770
// Create Test Matrix
6871
blacspp::Grid grid = blacspp::Grid::square_grid(MPI_COMM_WORLD);
69-
TA::scalapack::BlockCyclicMatrix<double> ref_matrix(world, grid, N, N, NB, NB);
72+
scalapack::BlockCyclicMatrix<double> ref_matrix(world, grid, N, N, NB, NB);
7073

7174
for (size_t i = 0; i < N; ++i)
7275
for (size_t j = 0; j < N; ++j)
@@ -125,7 +128,7 @@ int main(int argc, char** argv) {
125128
TA::make_array<TA::TArray<double> >(world, trange, make_ta_reference);
126129

127130
world.gop.fence();
128-
TA::scalapack::BlockCyclicMatrix<double> test_matrix(ref_ta, grid, NB, NB);
131+
scalapack::BlockCyclicMatrix<double> test_matrix(ref_ta, grid, NB, NB);
129132
world.gop.fence();
130133

131134
double local_norm_diff =
@@ -172,7 +175,7 @@ int main(int argc, char** argv) {
172175
TA::make_array<TA::TArray<double> >(world, trange, make_ta_reference);
173176

174177
world.gop.fence();
175-
TA::scalapack::BlockCyclicMatrix<double> test_matrix(ref_ta, grid, NB, NB);
178+
scalapack::BlockCyclicMatrix<double> test_matrix(ref_ta, grid, NB, NB);
176179
world.gop.fence();
177180

178181
double local_norm_diff =

examples/scalapack/evp.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
#include <scalapackpp/eigenvalue_problem/sevp.hpp>
2929
#include <scalapackpp/pblas/gemm.hpp>
3030

31-
#include <TiledArray/algebra/scalapack/heig.h>
31+
#include <TiledArray/math/linalg/scalapack/heig.h>
3232

3333
using Array = TA::TArray<double>;
3434
// using Array = TA::TSpArray<double>;
35+
namespace scalapack = TiledArray::math::linalg::scalapack;
3536

3637
TA::TiledRange gen_trange(size_t N, const std::vector<size_t>& TA_NBs) {
3738
assert(TA_NBs.size() > 0);
@@ -93,7 +94,7 @@ int main(int argc, char** argv) {
9394
tensor_symm("i,j") = 0.5 * (tensor("i,j") + tensor("j,i"));
9495
tensor("i,j") = tensor_symm("i,j");
9596

96-
auto [evals, evecs_ta] = TA::scalapack::heig(tensor);
97+
auto [evals, evecs_ta] = scalapack::heig(tensor);
9798

9899
//// Check EVP with TA
99100
Array tmp =

examples/vector_tests/vector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ int main(int argc, char** argv) {
391391

392392
start = madness::wall_time();
393393
for (std::size_t r = 0ul; r < repeat; ++r) {
394-
madness::cblas::scal(n, 3.0, c, 1);
394+
TiledArray::blas::scale(n, 3.0, c);
395395
}
396396
stop = madness::wall_time();
397397

external/eigen.cmake

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@ else(ENABLE_CUDA)
1212
set(_tiledarray_required_eigen_version ${TA_TRACKED_EIGEN_VERSION})
1313
endif(ENABLE_CUDA)
1414

15-
set(_tiledarray_eigen_use_lapacke FALSE)
16-
if ("${LAPACK_COMPILE_DEFINITIONS}" MATCHES "TILEDARRAY_EIGEN_USE_LAPACKE")
17-
set(_tiledarray_eigen_use_lapacke TRUE)
18-
if (_tiledarray_required_eigen_version VERSION_LESS 3.3.7)
19-
message(
20-
WARNING
21-
"Eigen3 version => 3.3.7 is required if TILEDARRAY_EIGEN_USE_LAPACKE is set. "
22-
"Prior Eigen3 with LAPACKE enabled may give incorrect eigenvalue results"
23-
)
24-
set(_tiledarray_required_eigen_version 3.3.7)
25-
endif()
26-
endif ()
27-
2815
# Check for existing Eigen
2916
# prefer CMake-configured-and-installed instance
3017
# re:NO_CMAKE_PACKAGE_REGISTRY: eigen3 registers its *build* tree with the user package registry ...
@@ -168,11 +155,8 @@ if (TARGET TiledArray_Eigen)
168155
target_compile_definitions(TiledArray_Eigen INTERFACE EIGEN_USE_MKL_ALL)
169156
else(MADNESS_HAS_MKL)
170157
# Eigen's prototypes for non-MKL (i.e. F77) BLAS interface libraries do not match those in MADNESS (and are not const correct)
171-
# thus can't use non-MKL BLAS, only LAPACK
158+
# thus can't use non-MKL BLAS
172159
# target_compile_definitions(TiledArray_Eigen INTERFACE EIGEN_USE_BLAS)
173-
if (_tiledarray_eigen_use_lapacke)
174-
target_compile_definitions(TiledArray_Eigen INTERFACE EIGEN_USE_LAPACKE EIGEN_USE_LAPACKE_STRICT)
175-
endif ()
176160
endif(MADNESS_HAS_MKL)
177161
install(TARGETS TiledArray_Eigen EXPORT tiledarray COMPONENT tiledarray)
178162
endif(TARGET TiledArray_Eigen)

external/scalapack.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ else()
4343
add_subdirectory( ${blacspp_SOURCE_DIR} ${blacspp_BINARY_DIR} )
4444
add_subdirectory( ${scalapackpp_SOURCE_DIR} ${scalapackpp_BINARY_DIR} )
4545

46+
# propagate MPI_CXX_SKIP_MPICXX=ON
47+
target_compile_definitions( blacspp PRIVATE ${MPI_CXX_COMPILE_DEFINITIONS} )
48+
target_compile_definitions( scalapackpp PRIVATE ${MPI_CXX_COMPILE_DEFINITIONS} )
49+
4650
install( TARGETS blacspp scalapackpp EXPORT tiledarray COMPONENT tiledarray )
4751
# Add these dependencies to External
4852
add_dependencies(External-tiledarray scalapackpp blacspp)

src/CMakeLists.txt

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,20 @@ TiledArray/utility.h
5757
TiledArray/val_array.h
5858
TiledArray/version.h
5959
TiledArray/zero_tensor.h
60-
TiledArray/algebra/conjgrad.h
61-
TiledArray/algebra/diis.h
62-
TiledArray/algebra/utils.h
63-
TiledArray/algebra/cholesky.h
64-
TiledArray/algebra/heig.h
65-
TiledArray/algebra/lu.h
66-
TiledArray/algebra/svd.h
67-
TiledArray/algebra/types.h
68-
TiledArray/algebra/lapack/cholesky.h
69-
TiledArray/algebra/lapack/heig.h
70-
TiledArray/algebra/lapack/util.h
71-
TiledArray/algebra/lapack/lu.h
72-
TiledArray/algebra/lapack/svd.h
73-
TiledArray/algebra/scalapack/cholesky.h
74-
TiledArray/algebra/scalapack/heig.h
75-
TiledArray/algebra/scalapack/lu.h
76-
TiledArray/algebra/scalapack/svd.h
60+
TiledArray/math/linalg/forward.h
61+
TiledArray/math/linalg/conjgrad.h
62+
TiledArray/math/linalg/diis.h
63+
TiledArray/math/linalg/util.h
64+
TiledArray/math/linalg/cholesky.h
65+
TiledArray/math/linalg/heig.h
66+
TiledArray/math/linalg/lu.h
67+
TiledArray/math/linalg/svd.h
68+
TiledArray/math/linalg/scalapack/util.h
69+
TiledArray/math/linalg/scalapack/block_cyclic.h
70+
TiledArray/math/linalg/scalapack/cholesky.h
71+
TiledArray/math/linalg/scalapack/heig.h
72+
TiledArray/math/linalg/scalapack/lu.h
73+
TiledArray/math/linalg/scalapack/svd.h
7774
TiledArray/conversions/btas.h
7875
TiledArray/conversions/clone.h
7976
TiledArray/conversions/dense_to_sparse.h
@@ -82,7 +79,6 @@ TiledArray/conversions/foreach.h
8279
TiledArray/conversions/vector_of_arrays.h
8380
TiledArray/conversions/make_array.h
8481
TiledArray/conversions/sparse_to_dense.h
85-
TiledArray/conversions/block_cyclic.h
8682
TiledArray/conversions/to_new_tile_type.h
8783
TiledArray/conversions/truncate.h
8884
TiledArray/conversions/retile.h
@@ -120,7 +116,6 @@ TiledArray/expressions/unary_expr.h
120116
TiledArray/expressions/index_list.h
121117
TiledArray/external/btas.h
122118
TiledArray/math/blas.h
123-
TiledArray/math/eigen.h
124119
TiledArray/math/gemm_helper.h
125120
TiledArray/math/outer.h
126121
TiledArray/math/parallel_gemm.h
@@ -180,26 +175,30 @@ TiledArray/util/random.h
180175
TiledArray/util/singleton.h
181176
TiledArray/util/time.h
182177
TiledArray/util/vector.h
178+
179+
TiledArray/math/linalg/rank-local.h
180+
TiledArray/math/linalg/rank-local.cpp
181+
183182
)
184183

185184
if(CUDA_FOUND)
186185

187186
list(APPEND TILEDARRAY_HEADER_FILES
188187
TiledArray/external/cuda.h
189188
TiledArray/external/cutt.h
190-
TiledArray/math/cublas.h
191-
TiledArray/cuda/btas_cublas.h
192-
TiledArray/cuda/btas_um_tensor.h
193-
TiledArray/cuda/cpu_cuda_vector.h
194-
TiledArray/cuda/cuda_task_fn.h
195-
TiledArray/cuda/kernel/mult_kernel.h
196-
TiledArray/cuda/kernel/mult_kernel_impl.h
197-
TiledArray/cuda/kernel/reduce_kernel.h
198-
TiledArray/cuda/kernel/reduce_kernel_impl.h
199-
TiledArray/cuda/platform.h
200-
TiledArray/cuda/thrust.h
201-
TiledArray/cuda/um_allocator.h
202-
TiledArray/cuda/um_storage.h)
189+
TiledArray/cuda/cublas.h
190+
TiledArray/cuda/btas_cublas.h
191+
TiledArray/cuda/btas_um_tensor.h
192+
TiledArray/cuda/cpu_cuda_vector.h
193+
TiledArray/cuda/cuda_task_fn.h
194+
TiledArray/cuda/kernel/mult_kernel.h
195+
TiledArray/cuda/kernel/mult_kernel_impl.h
196+
TiledArray/cuda/kernel/reduce_kernel.h
197+
TiledArray/cuda/kernel/reduce_kernel_impl.h
198+
TiledArray/cuda/platform.h
199+
TiledArray/cuda/thrust.h
200+
TiledArray/cuda/um_allocator.h
201+
TiledArray/cuda/um_storage.h)
203202

204203
endif(CUDA_FOUND)
205204

@@ -211,7 +210,7 @@ TiledArray/array_impl.cpp
211210
TiledArray/dist_array.cpp
212211
TiledArray/util/backtrace.cpp
213212
TiledArray/util/bug.cpp
214-
TiledArray/algebra/lapack/lapack.cpp
213+
TiledArray/math/linalg/rank-local.cpp
215214
)
216215

217216
# the list of libraries on which TiledArray depends on, will be cached later

0 commit comments

Comments
 (0)