Skip to content

Commit

Permalink
Create semi-structured Hypre solver interface for multi-variate syste…
Browse files Browse the repository at this point in the history
…ms (ECP-copa#632)

Also adds calls to HYPRE_Init and HYPRE_Finalize to the hypre structured solver
Does not support PFMG or Jacobi preconditioner options
  • Loading branch information
lebuller authored and brtnfld committed Jan 8, 2024
1 parent 9ebf220 commit 263efc9
Show file tree
Hide file tree
Showing 12 changed files with 2,109 additions and 54 deletions.
2 changes: 2 additions & 0 deletions cajita/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ set(HEADERS_PUBLIC

if(Cabana_ENABLE_HYPRE)
list(APPEND HEADERS_PUBLIC
Cajita_Hypre.hpp
Cajita_HypreStructuredSolver.hpp
Cajita_HypreSemiStructuredSolver.hpp
)
endif()

Expand Down
2 changes: 2 additions & 0 deletions cajita/src/Cajita.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include <Cajita_UniformDimPartitioner.hpp>

#ifdef Cabana_ENABLE_HYPRE
#include <Cajita_Hypre.hpp>
#include <Cajita_HypreSemiStructuredSolver.hpp>
#include <Cajita_HypreStructuredSolver.hpp>
#endif

Expand Down
85 changes: 85 additions & 0 deletions cajita/src/Cajita_Hypre.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/****************************************************************************
* Copyright (c) 2018-2022 by the Cabana authors *
* All rights reserved. *
* *
* This file is part of the Cabana library. Cabana is distributed under a *
* BSD 3-clause license. For the licensing terms see the LICENSE file in *
* the top-level directory. *
* *
* SPDX-License-Identifier: BSD-3-Clause *
****************************************************************************/

/*!
\file Cajita_Hypre.hpp
\brief HYPRE memory space handling
*/
#ifndef CAJITA_HYPRE_HPP
#define CAJITA_HYPRE_HPP

#include <HYPRE_config.h>
#include <HYPRE_struct_ls.h>
#include <HYPRE_struct_mv.h>

#include <Kokkos_Core.hpp>

#include <memory>

namespace Cajita
{
//---------------------------------------------------------------------------//
// Hypre memory space selection. Don't compile if HYPRE wasn't configured to
// use the device.
// ---------------------------------------------------------------------------//

//! Hypre device compatibility check.
template <class MemorySpace>
struct HypreIsCompatibleWithMemorySpace : std::false_type
{
};

// FIXME: This is currently written in this structure because HYPRE only has
// compile-time switches for backends and hence only one can be used at a
// time. Once they have a run-time switch we can use that instead.
#ifdef HYPRE_USING_CUDA
#ifdef KOKKOS_ENABLE_CUDA
#ifdef HYPRE_USING_DEVICE_MEMORY
//! Hypre device compatibility check - CUDA memory.
template <>
struct HypreIsCompatibleWithMemorySpace<Kokkos::CudaSpace> : std::true_type
{
};
#endif // end HYPRE_USING_DEVICE_MEMORY

//! Hypre device compatibility check - CUDA UVM memory.
#ifdef HYPRE_USING_UNIFIED_MEMORY
template <>
struct HypreIsCompatibleWithMemorySpace<Kokkos::CudaUVMSpace> : std::true_type
{
};
#endif // end HYPRE_USING_UNIFIED_MEMORY
#endif // end KOKKOS_ENABLE_CUDA
#endif // end HYPRE_USING_CUDA

#ifdef HYPRE_USING_HIP
#ifdef KOKKOS_ENABLE_HIP
//! Hypre device compatibility check - HIP memory. FIXME - make this true when
//! the HYPRE CMake includes HIP
template <>
struct HypreIsCompatibleWithMemorySpace<Kokkos::ExperimentalHIPSpace>
: std::false_type
{
};
#endif // end KOKKOS_ENABLE_HIP
#endif // end HYPRE_USING_HIP

#ifndef HYPRE_USING_GPU
//! Hypre device compatibility check - host memory.
template <>
struct HypreIsCompatibleWithMemorySpace<Kokkos::HostSpace> : std::true_type
{
};
#endif // end HYPRE_USING_GPU

} // namespace Cajita

#endif // end HYPRE_HPP
Loading

0 comments on commit 263efc9

Please sign in to comment.