Skip to content

Commit da0c951

Browse files
authored
Merge pull request #2107 from su2code/codipack_tape_options
Clarify and extend AD tape choices
2 parents 931f367 + fb02214 commit da0c951

File tree

6 files changed

+41
-19
lines changed

6 files changed

+41
-19
lines changed

Common/include/code_config.hpp

+17-7
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,30 @@ FORCEINLINE Out su2staticcast_p(In ptr) {
9898
#if defined(HAVE_OMP)
9999
using su2double = codi::RealReverseIndexOpenMPGen<double, double>;
100100
#else
101-
#if defined(CODI_INDEX_TAPE)
101+
#if defined(CODI_JACOBIAN_LINEAR_TAPE)
102+
using su2double = codi::RealReverse;
103+
#elif defined(CODI_JACOBIAN_REUSE_TAPE)
104+
using su2double = codi::RealReverseIndexGen<double, double, codi::ReuseIndexManager<int> >;
105+
#elif defined(CODI_JACOBIAN_MULTIUSE_TAPE)
102106
using su2double = codi::RealReverseIndex;
103-
// #elif defined(CODI_PRIMAL_TAPE)
104-
// using su2double = codi::RealReversePrimal;
105-
// #elif defined(CODI_PRIMAL_INDEX_TAPE)
106-
// using su2double = codi::RealReversePrimalIndex;
107+
#elif defined(CODI_PRIMAL_LINEAR_TAPE)
108+
using su2double = codi::RealReversePrimal;
109+
#elif defined(CODI_PRIMAL_REUSE_TAPE)
110+
using su2double = codi::RealReversePrimalIndexGen<double, double, codi::ReuseIndexManager<int> >;
111+
#elif defined(CODI_PRIMAL_MULTIUSE_TAPE)
112+
using su2double = codi::RealReversePrimalIndex;
107113
#else
108-
using su2double = codi::RealReverse;
114+
#error "Please define a CoDiPack tape."
109115
#endif
110116
#endif
117+
118+
#if defined(HAVE_OMP) || defined(CODI_JACOBIAN_REUSE_TAPE) || defined(CODI_JACOBIAN_MULTIUSE_TAPE) || \
119+
defined(CODI_PRIMAL_REUSE_TAPE) || defined(CODI_PRIMAL_MULTIUSE_TAPE)
120+
#define CODI_INDEX_REUSE
121+
#endif
111122
#elif defined(CODI_FORWARD_TYPE) // forward mode AD
112123
#include "codi.hpp"
113124
using su2double = codi::RealForward;
114-
115125
#else // primal / direct / no AD
116126
using su2double = double;
117127
#endif

SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -786,9 +786,9 @@ void CDiscAdjMultizoneDriver::SetAdjObjFunction() {
786786

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

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

meson.build

+19-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,25 @@ if get_option('enable-autodiff') or get_option('enable-directdiff')
7777
codi_for_args = ['-DCODI_FORWARD_TYPE']
7878
endif
7979

80-
if get_option('enable-autodiff')
81-
if get_option('codi-tape') == 'JacobianIndex'
82-
codi_rev_args += '-DCODI_INDEX_TAPE'
83-
#elif get_option('codi-tape') == 'PrimalLinear'
84-
# codi_rev_args += '-DCODI_PRIMAL_TAPE'
85-
#elif get_option('codi-tape') == 'PrimalIndex'
86-
# codi_rev_args += '-DCODI_PRIMAL_INDEX_TAPE'
80+
if get_option('enable-autodiff') and not omp
81+
if get_option('codi-tape') == 'JacobianLinear'
82+
codi_rev_args += '-DCODI_JACOBIAN_LINEAR_TAPE'
83+
elif get_option('codi-tape') == 'JacobianReuse'
84+
codi_rev_args += '-DCODI_JACOBIAN_REUSE_TAPE'
85+
elif get_option('codi-tape') == 'JacobianMultiUse'
86+
codi_rev_args += '-DCODI_JACOBIAN_MULTIUSE_TAPE'
87+
elif get_option('codi-tape') == 'PrimalLinear'
88+
codi_rev_args += '-DCODI_PRIMAL_LINEAR_TAPE'
89+
elif get_option('codi-tape') == 'PrimalReuse'
90+
codi_rev_args += '-DCODI_PRIMAL_REUSE_TAPE'
91+
elif get_option('codi-tape') == 'PrimalMultiUse'
92+
codi_rev_args += '-DCODI_PRIMAL_MULTIUSE_TAPE'
93+
else
94+
message('Invalid CoDiPack tape choice @1@'.format(get_option('codi-tape')))
95+
endif
96+
97+
if get_option('codi-tape') != 'JacobianLinear'
98+
warning('The tape choice @1@ is not tested regularly in SU2'.format(get_option('codi-tape')))
8799
endif
88100
endif
89101

meson_options.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ option('enable-mpp', type : 'boolean', value : false, description: 'enable Muta
2121
option('enable-coolprop', type : 'boolean', value : false, description: 'enable CoolProp support')
2222
option('enable-mlpcpp', type : 'boolean', value : false, description: 'enable MLPCpp support')
2323
option('opdi-backend', type : 'combo', choices : ['auto', 'macro', 'ompt'], value : 'auto', description: 'OpDiLib backend choice')
24-
option('codi-tape', type : 'combo', choices : ['JacobianLinear', 'JacobianIndex'], value : 'JacobianLinear', description: 'CoDiPack tape choice')
24+
option('codi-tape', type : 'combo', choices : ['JacobianLinear', 'JacobianReuse', 'JacobianMultiUse', 'PrimalLinear', 'PrimalReuse', 'PrimalMultiUse'], value : 'JacobianLinear', description: 'CoDiPack tape choice')
2525
option('opdi-shared-read-opt', type : 'boolean', value : true, description : 'OpDiLib shared reading optimization')
2626
option('librom_root', type : 'string', value : '', description: 'libROM base directory')
2727
option('enable-librom', type : 'boolean', value : false, description: 'enable LLNL libROM support')

meson_scripts/init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def init_submodules(
5555

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

0 commit comments

Comments
 (0)