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