Skip to content

WIP: extract clonable feature from LinOp#2005

Open
yhmtsai wants to merge 18 commits into
developfrom
executorholder
Open

WIP: extract clonable feature from LinOp#2005
yhmtsai wants to merge 18 commits into
developfrom
executorholder

Conversation

@yhmtsai
Copy link
Copy Markdown
Member

@yhmtsai yhmtsai commented Apr 17, 2026

This PR is still under process but I will collect some potential issues to users or developers when we move this direction.

Idea: we usually only need to clone the matrix to generate new preconditioner or solver, but we do not need that for solver or preconditioner. It will remove the clone/copy_from out of LinOp.

We plan to have several prs to reach that, but need to have this to check whether we will have trouble having that.

Clonable: only Matrix now, but maybe also need stop criterion?
Note. Partition is also clonable.
I also include one test to show when user defines a custom class inherit from ginkgo class, which is already inherited from ClonableObject.
ExecutorHolder is unnecessary. will move back in the end.

clear is relying on the operator=.
I feel create_default and clear not need other than clone. we might be able to make LinOp without any mixin.

Issue:

  • We use clone to keep executor consistent in LinOp generation.
    • gko::clone throw exception when they can not do it. (current in this branch)
    • turn .on(exec) strictly on user behalf. -> need to make it optional such that awareness of the cost and behavior.
    • How do we have two same set of factory to generate solver? (we use clone to test reference and backend on the same solver settings). It will require to manually set two same set factory and corresponding LinOp
  • clone/copy_from usage is a bit harder now because LinOp is not holding clone/copy_from.
    • free function gko::clone() takes care of that.
    • member function will leads as<LinOp>(as<ClonableObject>(linop)->clone()). copy_from is worse because we might also need to use as<> in the input. Note. if they are concrete type, we can directly call the function.

TODO:

  • check the clone when the base class also have clone

@yhmtsai yhmtsai added this to the Ginkgo 2.0 milestone Apr 17, 2026
@yhmtsai yhmtsai self-assigned this Apr 17, 2026
@yhmtsai yhmtsai added 1:ST:WIP This PR is a work in progress. Not ready for review. is:interface-breaking This change may break interface compatibility. Can only be done through a major release. 1:ST:need-feedback The PR is somewhat ready but feedback on a blocking topic is required before a proper review. labels Apr 17, 2026
@ginkgo-bot ginkgo-bot added reg:build This is related to the build system. reg:testing This is related to testing. mod:core This is related to the core module. mod:reference This is related to the reference module. type:solver This is related to the solvers type:preconditioner This is related to the preconditioners type:matrix-format This is related to the Matrix formats type:factorization This is related to the Factorizations type:reordering This is related to the matrix(LinOp) reordering type:multigrid This is related to multigrid type:stopping-criteria This is related to the stopping criteria labels Apr 17, 2026
@ginkgo-bot
Copy link
Copy Markdown
Member

Error: The following files need to be formatted:

accessor/hip_helper.hpp
benchmark/utils/preconditioners.hpp
common/cuda_hip/base/bf16_alias.hpp
common/cuda_hip/base/math.hpp
common/unified/components/fill_array_kernels.cpp
common/unified/components/precision_conversion_kernels.cpp
core/config/preconditioner_config.cpp
core/config/preconditioner_ic_config.cpp
core/config/preconditioner_ilu_config.cpp
core/preconditioner/ic.cpp
core/preconditioner/ilu.cpp
core/test/config/preconditioner.cpp
core/test/config/solver.cpp
core/test/matrix/sellp.cpp
core/test/preconditioner/ic.cpp
core/test/preconditioner/ilu.cpp
core/test/solver/direct.cpp
cuda/base/types.hpp
examples/ilu-preconditioned-solver/ilu-preconditioned-solver.cpp
examples/ir-ilu-preconditioned-solver/ir-ilu-preconditioned-solver.cpp
examples/multigrid-preconditioned-solver-customized/multigrid-preconditioned-solver-customized.cpp
examples/preconditioner-export/preconditioner-export.cpp
examples/reordered-preconditioned-solver/reordered-preconditioned-solver.cpp
hip/base/exception.hip.cpp
hip/base/hipblas_bindings.hip.hpp
hip/base/hipblas_handle.hpp
hip/base/hiprand_bindings.hip.hpp
hip/base/hipsparse_bindings.hip.hpp
hip/base/hipsparse_block_bindings.hip.hpp
hip/base/hipsparse_handle.hpp
hip/base/memory.hip.cpp
hip/base/pointer_mode_guard.hip.hpp
hip/base/roctx.hip.cpp
hip/base/types.hip.hpp
hip/components/memory.hip.hpp
hip/test/base/exception_helpers.hip.cpp
hip/test/matrix/fft_kernels.hip.cpp
test/mpi/distributed/row_gatherer.cpp
test/mpi/solver/solver.cpp
test/solver/direct.cpp

You can find a formatting patch under Artifacts here or run format! if you have write access to Ginkgo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1:ST:need-feedback The PR is somewhat ready but feedback on a blocking topic is required before a proper review. 1:ST:WIP This PR is a work in progress. Not ready for review. is:interface-breaking This change may break interface compatibility. Can only be done through a major release. mod:core This is related to the core module. mod:reference This is related to the reference module. reg:build This is related to the build system. reg:testing This is related to testing. type:factorization This is related to the Factorizations type:matrix-format This is related to the Matrix formats type:multigrid This is related to multigrid type:preconditioner This is related to the preconditioners type:reordering This is related to the matrix(LinOp) reordering type:solver This is related to the solvers type:stopping-criteria This is related to the stopping criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants