LCOV - code coverage report
Current view: top level - src/kokkos/functions - KokkosFunction.K (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 329044 Lines: 20 21 95.2 %
Date: 2026-08-03 21:12:22 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "KokkosFunction.h"
      11             : 
      12             : namespace Moose::Kokkos
      13             : {
      14             : 
      15             : InputParameters
      16        8874 : FunctionBase::validParams()
      17             : {
      18        8874 :   InputParameters params = Moose::FunctionBase::validParams();
      19             : 
      20        8874 :   params.addPrivateParam<bool>(MooseBase::kokkos_object_param, true);
      21             : 
      22        8874 :   return params;
      23           0 : }
      24             : 
      25        1242 : FunctionBase::FunctionBase(const InputParameters & parameters) : Moose::FunctionBase(parameters) {}
      26             : 
      27       43264 : FunctionBase::FunctionBase(const FunctionBase & object) : Moose::FunctionBase(object, {}) {}
      28             : 
      29         119 : Function::Function(std::shared_ptr<FunctionWrapperHostBase> wrapper) : _wrapper_host(wrapper)
      30             : {
      31             :   // Allocate device wrapper
      32         119 :   _wrapper_device = _wrapper_host->allocate();
      33         119 : }
      34             : 
      35       20949 : Function::Function(const Function & function)
      36       20945 :   : _wrapper_host(function._wrapper_host), _wrapper_device(function._wrapper_device)
      37             : {
      38             :   // Copy function to device
      39       20949 :   if (_wrapper_host)
      40       20949 :     _wrapper_host->copyFunction();
      41       20949 : }
      42             : 
      43       21068 : Function::~Function()
      44             : {
      45             :   // Free device wrapper
      46       21068 :   if (_wrapper_host && _wrapper_host.use_count() == 1)
      47         119 :     ::Kokkos::kokkos_free<ExecSpace::memory_space>(_wrapper_device);
      48             : 
      49             :   // Free host copy of function
      50       21068 :   if (_wrapper_host)
      51       21068 :     _wrapper_host->freeFunction();
      52       21068 : }
      53             : 
      54             : } // namespace Moose::Kokkos

Generated by: LCOV version 1.14