Panzer: Default Tangent Dimension
Created by: jmgate
I was debugging a memory issue with @etphipp yesterday. The problem was in the panzer::Traits::Tangent
instantiation of an Evaluator
most of the PHX::MDField
s I was dealing with had a single derivative, while one field had the correct number of derivatives (matching the number of "Active Parameters" I'd added). Any AD operations between fields with mismatching numbers of derivatives was causing the memory issues (invalid read of size 8, 0 bytes past block...).
@etphipp ran into this sometime last year and coded up a fix such that if the user manually specifies "Tangent Dimension" in the "User Data" ParameterList
, then all of my fields that didn't have enough derivatives now do, through panzer::ModelEvaluator::setupModel()
, which eventually calls PHX::FieldManager::setKokkosExtendedDataTypeDimensions()
, which does the trick.
It seems like there should be some check here to ensure that all our fields have the correct tangent dimension. It defaults to one, but then if you're trying to work with more derivatives there are no complaints—you just wind up accessing whatever random junk is in the memory location specified. Defaulting to zero wouldn't be much better, because everything would be treated as a constant as far as AD is concerned, and you might not notice. Can we somehow throw an exception if we wind up doing AD with fields with different tangent dimensions? Or can we cook up some way to determine the tangent dimension automatically so the user doesn't have to specify it in "User Data"? Seems like one fewer place for user error would be a good thing.
@trilinos/panzer