Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify and extend AD tape choices #2107

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions Common/include/code_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,30 @@ FORCEINLINE Out su2staticcast_p(In ptr) {
#if defined(HAVE_OMP)
using su2double = codi::RealReverseIndexOpenMPGen<double, double>;
#else
#if defined(CODI_INDEX_TAPE)
#if defined(CODI_JACOBIAN_LINEAR_TAPE)
using su2double = codi::RealReverse;
#elif defined(CODI_JACOBIAN_REUSE_TAPE)
using su2double = codi::RealReverseIndexGen<double, double, codi::ReuseIndexManager<int> >;
#elif defined(CODI_JACOBIAN_MULTIUSE_TAPE)
using su2double = codi::RealReverseIndex;
// #elif defined(CODI_PRIMAL_TAPE)
// using su2double = codi::RealReversePrimal;
// #elif defined(CODI_PRIMAL_INDEX_TAPE)
// using su2double = codi::RealReversePrimalIndex;
#elif defined(CODI_PRIMAL_LINEAR_TAPE)
using su2double = codi::RealReversePrimal;
#elif defined(CODI_PRIMAL_REUSE_TAPE)
using su2double = codi::RealReversePrimalIndexGen<double, double, codi::ReuseIndexManager<int> >;
#elif defined(CODI_PRIMAL_MULTIUSE_TAPE)
using su2double = codi::RealReversePrimalIndex;
#else
using su2double = codi::RealReverse;
#error "Please define a CoDiPack tape."
#endif
#endif

#if defined(HAVE_OMP) || defined(CODI_JACOBIAN_REUSE_TAPE) || defined(CODI_JACOBIAN_MULTIUSE_TAPE) || \
defined(CODI_PRIMAL_REUSE_TAPE) || defined(CODI_PRIMAL_MULTIUSE_TAPE)
#define CODI_INDEX_REUSE
#endif
#elif defined(CODI_FORWARD_TYPE) // forward mode AD
#include "codi.hpp"
using su2double = codi::RealForward;

#else // primal / direct / no AD
using su2double = double;
#endif
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ void CDiscAdjMultizoneDriver::SetAdjObjFunction() {

void CDiscAdjMultizoneDriver::ComputeAdjoints(unsigned short iZone, bool eval_transfer) {

#if defined(CODI_INDEX_TAPE) || defined(HAVE_OPDI)
#if defined(CODI_INDEX_REUSE)
if (nZone > 1 && rank == MASTER_NODE) {
std::cout << "WARNING: Index AD types do not support multiple zones." << std::endl;
std::cout << "WARNING: AD types that reuse indices do not support multiple zones." << std::endl;
}
#endif

Expand Down
20 changes: 14 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ if get_option('enable-autodiff') or get_option('enable-directdiff')
endif

if get_option('enable-autodiff')
if get_option('codi-tape') == 'JacobianIndex'
codi_rev_args += '-DCODI_INDEX_TAPE'
#elif get_option('codi-tape') == 'PrimalLinear'
# codi_rev_args += '-DCODI_PRIMAL_TAPE'
#elif get_option('codi-tape') == 'PrimalIndex'
# codi_rev_args += '-DCODI_PRIMAL_INDEX_TAPE'
if get_option('codi-tape') == 'JacobianLinear'
codi_rev_args += '-DCODI_JACOBIAN_LINEAR_TAPE'
elif get_option('codi-tape') == 'JacobianReuse'
codi_rev_args += '-DCODI_JACOBIAN_REUSE_TAPE'
elif get_option('codi-tape') == 'JacobianMultiUse'
codi_rev_args += '-DCODI_JACOBIAN_MULTIUSE_TAPE'
elif get_option('codi-tape') == 'PrimalLinear'
codi_rev_args += '-DCODI_PRIMAL_LINEAR_TAPE'
elif get_option('codi-tape') == 'PrimalReuse'
codi_rev_args += '-DCODI_PRIMAL_REUSE_TAPE'
elif get_option('codi-tape') == 'PrimalMultiUse'
codi_rev_args += '-DCODI_PRIMAL_MULTIUSE_TAPE'
else
message('Invalid CoDiPack tape choice @1@'.format(get_option('codi-tape')))
endif
endif

Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ option('enable-mpp', type : 'boolean', value : false, description: 'enable Muta
option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support')
option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable MLPCpp support')
option('opdi-backend', type : 'combo', choices : ['auto', 'macro', 'ompt'], value : 'auto', description: 'OpDiLib backend choice')
option('codi-tape', type : 'combo', choices : ['JacobianLinear', 'JacobianIndex'], value : 'JacobianLinear', description: 'CoDiPack tape choice')
option('codi-tape', type : 'combo', choices : ['JacobianLinear', 'JacobianReuse', 'JacobianMultiUse', 'PrimalLinear', 'PrimalReuse', 'PrimalMultiUse'], value : 'JacobianLinear', description: 'CoDiPack tape choice')
option('opdi-shared-read-opt', type : 'boolean', value : true, description : 'OpDiLib shared reading optimization')
option('librom_root', type : 'string', value : '', description: 'libROM base directory')
option('enable-librom', type : 'boolean', value : false, description: 'enable LLNL libROM support')
Expand Down
2 changes: 1 addition & 1 deletion meson_scripts/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def init_submodules(

# This information of the modules is used if projects was not cloned using git
# The sha tag must be maintained manually to point to the correct commit
sha_version_codi = "17232fed05245dbb8f04a31e274a02d53458c75c"
sha_version_codi = "c30f195eb9d772cadc75e9dbf4c88cb351ee34bb"
github_repo_codi = "https://github.com/scicompkl/CoDiPack"
sha_version_medi = "aafc2d1966ba1233640af737e71c77c1a86183fd"
github_repo_medi = "https://github.com/SciCompKL/MeDiPack"
Expand Down