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 13 : { 14 : namespace Kokkos 15 : { 16 : 17 : InputParameters 18 17644 : FunctionBase::validParams() 19 : { 20 17644 : InputParameters params = Moose::FunctionBase::validParams(); 21 : 22 17644 : params.addPrivateParam<bool>(MooseBase::kokkos_object_param, true); 23 : 24 17644 : return params; 25 0 : } 26 : 27 190 : FunctionBase::FunctionBase(const InputParameters & parameters) : Moose::FunctionBase(parameters) {} 28 : 29 13487 : FunctionBase::FunctionBase(const FunctionBase & object) : Moose::FunctionBase(object, {}) {} 30 : 31 92 : Function::Function(std::shared_ptr<FunctionWrapperHostBase> wrapper) : _wrapper_host(wrapper) 32 : { 33 : // Allocate device wrapper 34 92 : _wrapper_device = _wrapper_host->allocate(); 35 92 : } 36 : 37 11943 : Function::Function(const Function & function) 38 11939 : : _wrapper_host(function._wrapper_host), _wrapper_device(function._wrapper_device) 39 : { 40 : // Copy function to device 41 11943 : _wrapper_host->copyFunction(); 42 11943 : } 43 : 44 12035 : Function::~Function() 45 : { 46 : // Free device wrapper 47 12035 : if (_wrapper_host.use_count() == 1) 48 92 : ::Kokkos::kokkos_free<ExecSpace::memory_space>(_wrapper_device); 49 : 50 : // Free host copy of function 51 12035 : _wrapper_host->freeFunction(); 52 12035 : } 53 : 54 : } // namespace Kokkos 55 : } // namespace Moose