8000 Distributed matrix and solvers by upsj · Pull Request #760 · ginkgo-project/ginkgo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Distributed matrix and solvers #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ else()
message(STATUS "HWLOC is being forcibly switched off")
endif()

# Automatically find MPI
find_package(MPI)
set(GINKGO_HAVE_MPI 0)
if (MPI_FOUND)
set(GINKGO_HAVE_MPI 1)
endif()

# We keep using NVCC/HCC for consistency with previous releases even if AMD
# updated everything to use NVIDIA/AMD in ROCM 4.1
set(GINKGO_HIP_PLATFORM_NVCC 0)
Expand Down
14 changes: 14 additions & 0 deletions common/matrix/dense_kernels.hpp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ __global__ __launch_bounds__(block_size) void finalize_sqrt_reduce_computation(
}


template <typename ValueType>
__global__ __launch_bounds__(default_block_size) void compute_sqrt(
size_type num_rows, size_type num_cols, size_type stride, ValueType *values)
{
auto idx = thread::get_thread_id_flat();
auto row = idx / num_cols;
auto col = idx % num_cols;
if (row < num_rows) {
auto i = row * stride + col;
values[i] = sqrt(values[i]);
}
}


template <typename ValueType, typename IndexType>
__global__ __launch_bounds__(default_block_size) void fill_in_coo(
size_type num_rows, size_type num_cols, size_type stride,
Expand Down
15 changes: 14 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ target_sources(ginkgo
base/mtx_io.cpp
base/perturbation.cpp
base/version.cpp
distributed/partition.cpp
distributed/errors.cpp
factorization/ic.cpp
factorization/ilu.cpp
factorization/par_ic.cpp
Expand Down Expand Up @@ -56,6 +58,12 @@ if(GINKGO_HAVE_PAPI_SDE)
target_sources(ginkgo PRIVATE log/papi.cpp)
endif()

if(GINKGO_HAVE_MPI)
target_sources(ginkgo PRIVATE
distributed/matrix.cpp
distributed/vector.cpp)
endif()

ginkgo_compile_features(ginkgo)

target_compile_options(ginkgo PRIVATE "${GINKGO_COMPILER_FLAGS}")
Expand All @@ -66,7 +74,7 @@ target_link_libraries(ginkgo
PUBLIC ginkgo_device ginkgo_omp ginkgo_cuda ginkgo_reference ginkgo_hip ginkgo_dpcpp)
# The PAPI dependency needs to be exposed to the user.
set(GKO_RPATH_ADDITIONS "")
if (GINKGO_HAVE_PAPI_SDE)
if(GINKGO_HAVE_PAPI_SDE)
target_link_libraries(ginkgo PUBLIC PAPI::PAPI)
list(GET PAPI_LIBRARIES 0 PAPI_FIRST_LIB)
get_filename_component(GKO_PAPI_LIBDIR "${PAPI_FIRST_LIB}" DIRECTORY)
Expand All @@ -79,9 +87,14 @@ if (GINKGO_BUILD_HIP AND GINKGO_HIP_PLATFORM MATCHES "${HIP_PLATFORM_AMD_REGEX}"
list(APPEND GKO_RPATH_ADDITIONS "${HIP_PATH}/lib")
endif()

if(GINKGO_HAVE_MPI)
target_link_libraries(ginkgo PUBLIC MPI::MPI_CXX)
endif()

ginkgo_default_includes(ginkgo)
ginkgo_install_library(ginkgo "${GKO_RPATH_ADDITIONS}")


if (GINKGO_CHECK_CIRCULAR_DEPS)
ginkgo_check_headers(ginkgo)
endif()
Expand Down
61 changes: 61 additions & 0 deletions core/device_hooks/common_kernels.inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "core/components/fill_array.hpp"
#include "core/components/precision_conversion.hpp"
#include "core/components/prefix_sum.hpp"
#include "core/distributed/matrix_kernels.hpp"
#include "core/distributed/partition_kernels.hpp"
#include "core/distributed/vector_kernels.hpp"
#include "core/factorization/factorization_kernels.hpp"
#include "core/factorization/ic_kernels.hpp"
#include "core/factorization/ilu_kernels.hpp"
Expand Down Expand Up @@ -120,6 +123,54 @@ GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_OUTPLACE_ABSOLUTE_ARRAY_KERNEL);
} // namespace components


namespace partition {


GKO_PARTITION_COUNT_RANGES
GKO_NOT_COMPILED(GKO_HOOK_MODULE);

template <typename LocalIndexType>
GKO_DECLARE_PARTITION_BUILD_FROM_CONTIGUOUS(LocalIndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(
GKO_DECLARE_PARTITION_BUILD_FROM_CONTIGUOUS);

template <typename LocalIndexType>
GKO_DECLARE_PARTITION_BUILD_FROM_MAPPING(LocalIndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(GKO_DECLARE_PARTITION_BUILD_FROM_MAPPING);

template <typename LocalIndexType>
GKO_DECLARE_PARTITION_BUILD_RANKS(LocalIndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(GKO_DECLARE_PARTITION_BUILD_RANKS);


} // namespace partition


namespace distributed_matrix {

template <typename ValueType, typename LocalIndexType>
GKO_DECLARE_BUILD_DIAG_OFFDIAG(ValueType, LocalIndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_BUILD_DIAG_OFFDIAG);


} // namespace distributed_matrix


namespace distributed_vector {

template <typename ValueType, typename LocalIndexType>
GKO_DECLARE_BUILD_LOCAL(ValueType, LocalIndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_BUILD_LOCAL);


} // namespace distributed_vector


namespace dense {


Expand Down Expand Up @@ -168,6 +219,16 @@ GKO_DECLARE_DENSE_COMPUTE_NORM2_KERNEL(ValueType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_DENSE_COMPUTE_NORM2_KERNEL);

template <typename ValueType>
GKO_DECLARE_DENSE_COMPUTE_NORM2_SQR_KERNEL(ValueType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_DENSE_COMPUTE_NORM2_SQR_KERNEL);

template <typename ValueType>
GKO_DECLARE_DENSE_COMPUTE_SQRT_KERNEL(ValueType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(GKO_DECLARE_DENSE_COMPUTE_SQRT_KERNEL);

template <typename ValueType, typename IndexType>
GKO_DECLARE_DENSE_CONVERT_TO_COO_KERNEL(ValueType, IndexType)
GKO_NOT_COMPILED(GKO_HOOK_MODULE);
Expand Down
79 changes: 79 additions & 0 deletions core/distributed/errors.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*******************************<GINKGO LICENSE>******************************
Copyright (c) 2017-2021, the Ginkgo authors
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************<GINKGO LICENSE>*******************************/


#include <ginkgo/config.hpp>


#if GKO_HAVE_MPI


#include <array>


#include <mpi.h>


#include <ginkgo/core/base/exception.hpp>


namespace gko {


std::string MpiError::get_error(int code)
{
std::array<char, MPI_MAX_ERROR_STRING> buffer{};
int resultlen{};
MPI_Error_string(code, buffer.data(), &resultlen);
return std::string{buffer.data(), static_cast<size_type>(resultlen)};
}


} // namespace gko


#else // !GKO_HAVE_MPI


namespace gko {


std::string MpiError::get_error(int)
{
return "ginkgo was compiled without MPI support";
}


} // namespace gko


#endif // !GKO_HAVE_MPI
Loading
0