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 6746 : FunctionBase::validParams() 17 : { 18 6746 : InputParameters params = Moose::FunctionBase::validParams(); 19 : 20 6746 : params.addPrivateParam<bool>(MooseBase::kokkos_object_param, true); 21 : 22 6746 : return params; 23 0 : } 24 : 25 226 : FunctionBase::FunctionBase(const InputParameters & parameters) : Moose::FunctionBase(parameters) {} 26 : 27 25537 : 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 : _wrapper_host->copyFunction(); 40 20949 : } 41 : 42 21068 : Function::~Function() 43 : { 44 : // Free device wrapper 45 21068 : if (_wrapper_host.use_count() == 1) 46 119 : ::Kokkos::kokkos_free<ExecSpace::memory_space>(_wrapper_device); 47 : 48 : // Free host copy of function 49 21068 : _wrapper_host->freeFunction(); 50 21068 : } 51 : 52 : } // namespace Moose::Kokkos