116int main(
int argc,
char* argv[]) {
125 Teuchos::CommandLineProcessor clp;
126 clp.setDocString(
"This program tests the speed of various forward mode AD implementations for a finite-element-like Jacobian fill");
127 int work_count = 200000;
128 int num_eqns_begin = 5;
129 int num_eqns_end = 65;
130 int num_eqns_delta = 10;
132 clp.setOption(
"wc", &work_count,
"Work count = num_nodes*num_eqns");
133 clp.setOption(
"p_begin", &num_eqns_begin,
"Intitial number of equations");
134 clp.setOption(
"p_end", &num_eqns_end,
"Final number of equations");
135 clp.setOption(
"p_delta", &num_eqns_delta,
"Step in number of equations");
136 clp.setOption(
"rt", &rt,
"Include ADOL-C retaping test");
139 Teuchos::CommandLineProcessor::EParseCommandLineReturn
140 parseReturn= clp.parse(argc, argv);
141 if(parseReturn != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL)
145 std::cout.setf(std::ios::right);
146 std::cout << std::setw(w_name) <<
"Name" <<
" ";
147 for (
int num_eqns = num_eqns_begin; num_eqns <= num_eqns_end;
148 num_eqns += num_eqns_delta)
149 std::cout << std::setw(w) << num_eqns <<
" ";
150 std::cout << std::endl;
151 for (
int j=0; j<w_name; j++)
154 for (
int num_eqns = num_eqns_begin; num_eqns <= num_eqns_end;
155 num_eqns += num_eqns_delta) {
156 for (
int j=0; j<w; j++)
160 std::cout << std::endl;
163 std::vector<double> times_analytic =
164 do_times(work_count, num_eqns_begin, num_eqns_end, num_eqns_delta,
166 print_times(times_analytic, times_analytic,
"Analytic",
p, w, w_name);
172 std::vector<double> times_adic =
173 do_times(work_count, num_eqns_begin, num_eqns_end, num_eqns_delta,
175 print_times(times_adic, times_analytic,
"ADIC",
p, w, w_name);
179 std::vector<double> times_sfad =
180 do_times_sfad<Sacado::Fad::SFad>(
181 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
182 print_times(times_sfad, times_analytic,
"SFAD",
p, w, w_name);
184 std::vector<double> times_slfad =
185 do_times_sfad<Sacado::Fad::SLFad>(
186 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
187 print_times(times_slfad, times_analytic,
"SLFAD",
p, w, w_name);
189 std::vector<double> times_dfad =
190 do_times_fad<Sacado::Fad::DFad>(
191 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
192 print_times(times_dfad, times_analytic,
"DFAD",
p, w, w_name);
196 std::vector<double> times_elr_sfad =
197 do_times_sfad<Sacado::ELRFad::SFad>(
198 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
199 print_times(times_elr_sfad, times_analytic,
"ELRSFAD",
p, w, w_name);
201 std::vector<double> times_elr_slfad =
202 do_times_sfad<Sacado::ELRFad::SLFad>(
203 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
204 print_times(times_elr_slfad, times_analytic,
"ELRSLFAD",
p, w, w_name);
206 std::vector<double> times_elr_dfad =
207 do_times_fad<Sacado::ELRFad::DFad>(
208 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
209 print_times(times_elr_dfad, times_analytic,
"ELRDFAD",
p, w, w_name);
213 std::vector<double> times_cache_sfad =
214 do_times_sfad<Sacado::CacheFad::SFad>(
215 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
216 print_times(times_cache_sfad, times_analytic,
"CacheSFAD",
p, w, w_name);
218 std::vector<double> times_cache_slfad =
219 do_times_sfad<Sacado::CacheFad::SLFad>(
220 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
221 print_times(times_cache_slfad, times_analytic,
"CacheSLFAD",
p, w, w_name);
223 std::vector<double> times_cache_dfad =
224 do_times_fad<Sacado::CacheFad::DFad>(
225 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
226 print_times(times_cache_dfad, times_analytic,
"CacheDFAD",
p, w, w_name);
229 std::vector<double> times_cache_elr_sfad =
230 do_times_sfad<Sacado::ELRCacheFad::SFad>(
231 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
232 print_times(times_cache_elr_sfad, times_analytic,
"ELRCacheSFAD",
p, w, w_name);
234 std::vector<double> times_cache_elr_slfad =
235 do_times_sfad<Sacado::ELRCacheFad::SLFad>(
236 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
237 print_times(times_cache_elr_slfad, times_analytic,
"ELRCacheSLFAD",
p, w, w_name);
239 std::vector<double> times_cache_elr_dfad =
240 do_times_fad<Sacado::ELRCacheFad::DFad>(
241 work_count, num_eqns_begin, num_eqns_end, num_eqns_delta);
242 print_times(times_cache_elr_dfad, times_analytic,
"ELRCacheDFAD",
p, w, w_name);
245 catch (std::exception& e) {
246 std::cout << e.what() << std::endl;
249 catch (
const char *s) {
250 std::cout << s << std::endl;
254 std::cout <<
"Caught unknown exception!" << std::endl;