Skip to content

Add examples related to Tao and MATLMVM

Toby Isaac requested to merge tisaac/feature-rosenbrock4 into main

tao/unconstrained/tutorials/rosenbrock4

This MR adds rosenbrock4 and rosenbrock4cu. These examples share all of their code in a common header file. A familiar optimization example, the multidimensional Rosenbrock problem, is implemented with callbacks that can execute either on the host or on the device.

One of the main patterns that this example illustrates is Hessian and gradient assembly with one thread per term that contributes to the objective, rather than one thread per row of the Hessian (or one thread per entry of the gradient).

I noticed a few ergonomic issues while writing this:

  • VecGhostGetLocalForm() would be very natural for this problem, but I don't think it works with Vec_CUPM, so I had to create a scatter from scratch.
  • VecSetValuesCOO() isn't very useful when the assembly vector changes (see discussion in !6865)
  • I was surprised that cupmStream_t isn't in a public header and I had to define it for myself
  • Likewise, I was surprised there wasn't a VecCUPMCheckLaunch() alias for VecCUDACheckLaunch() / VecHIPCheckLaunch(). Also, I didn't want to sacrifice on performance, and VecCUDACheckLaunch() synchronizes the device, so I made VecCUPMLaunch() that only calls cupmGetLastError().

ksp/ksp/utils/lmvm/tests/solve_perfomance

We want to profile the performance of LMVM methods in solvers. When using the GPU, the core LMVM methods -- MatLMVMUpdate() and MatSolve() -- are difficult to time in isolation. But the performance of TaoSolve() on a problem like the rosenbrock4cu also includes objective and gradients evaluation, particularly in a linesearch. So we add this supplementary example that simulates an optimization iteration, but by simply calling MatLMVMUpdate() and MatSolve() in a loop.

tao/unconstrained/impls/lmvm/tests/ex1

With exact line search on a quadratic problem, BFGS is equivalent to GMRES, so we add a test solving a linear least-squares problem with TAOLMVM. This test is a good smoke test for errors in the implementation of BFGS.

Edited by Toby Isaac

Merge request reports