Skip to content

Vector and supporting classes update#477

Merged
pelesh merged 10 commits into
developfrom
slaven/vector-update
Jul 8, 2026
Merged

Vector and supporting classes update#477
pelesh merged 10 commits into
developfrom
slaven/vector-update

Conversation

@pelesh

@pelesh pelesh commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Description

Implement several enhancements to the Vector and MemoryUtils classes needed to optimize GridKit model evaluation performance and portability.

Proposed changes

This PR provides (partial) support for #452 and includes:

  • Policy-based hardware backend for CPU and placeholders for CUDA and HIP backends implemented in MemoryUtils class.
  • Use C++11 move features (constructors and assignment operators) in DependencyTracking::Variable class to improve performance.
  • Added size guards to multivector methods that lacked them.
  • Default vector constructor is now the constructor that creates a multivector with one 0-length vector.
  • resize method now can resize to a value larger than the original capacity to allow for instantiate now, allocate later.
  • MemoryUtils are moved out of LinearAlgebra directory.

Checklist

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • I have updated CHANGELOG.md to reflect the changes in this PR. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

A few questions that we should probably address in this PR, as well:

  • Should we always allocate host mirror when we allocate data on GPU?
  • When we allocate Vector data should we mark it updated? Should we initialize it?
  • Should we remove setData functions and allow creating vector views only through constructors (and optionally factories)?

@pelesh pelesh self-assigned this Jul 4, 2026
@pelesh pelesh added the enhancement New feature or request label Jul 4, 2026
@pelesh

pelesh commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator Author

@lukelowry lukelowry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me one minor import note for completeness but otherwise seems like an improvment!

Comment thread GridKit/MemoryUtilities/MemoryUtils.hpp
Comment thread GridKit/MemoryUtilities/MemoryUtils.hpp Outdated
Comment thread GridKit/MemoryUtilities/MemoryUtils.hpp Outdated
@lukelowry

Copy link
Copy Markdown
Collaborator

Can I preemptively rebase my other branches onto this?

@alexander-novo

Copy link
Copy Markdown
Collaborator

@lukelowry If it’s for the sake of not having to rebase later, the commits that end up in develop will be different so you’ll still have to rebase against develop later.

@pelesh pelesh merged commit d24c6b4 into develop Jul 8, 2026
6 checks passed

// If no GPU support is present, set device memory manager to a dummy object.
#include <GridKit/MemoryUtilities/cpu/CpuMemory.hpp>
using MemoryHandler = GridKit::MemoryUtils<GridKit::memory::Cpu>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is not namespaced, it will conflict with other definitions of MemorHandler - such as with ReSolve

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants