121int main(
int argc,
char* argv[]) {
130 Teuchos::CommandLineProcessor clp;
131 clp.setDocString(
"This program tests the speed of various forward mode AD implementations for a single multiplication operation");
133 clp.setOption(
"nderiv", &nderiv,
"Number of derivative components");
135 clp.setOption(
"nloop", &nloop,
"Number of loops");
138 Teuchos::CommandLineProcessor::EParseCommandLineReturn
139 parseReturn= clp.parse(argc, argv);
140 if(parseReturn != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL)
143 std::cout.setf(std::ios::scientific);
144 std::cout.precision(
p);
145 std::cout <<
"Times (sec) for nderiv = " << nderiv
146 <<
" nloop = " << nloop <<
": " << std::endl;
149 std::cout <<
"Analytic: " << std::setw(w) << ta << std::endl;
151 t = do_time< Sacado::Fad::SimpleFad<double> >(nderiv, nloop);
152 std::cout <<
"SimpleFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
154 t = do_time< FAD::TFad<10,double> >(nderiv, nloop);
155 std::cout <<
"TFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
157 t = do_time< FAD::Fad<double> >(nderiv, nloop);
158 std::cout <<
"Fad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
160 t = do_time< Sacado::Fad::SFad<double,10> >(nderiv, nloop);
161 std::cout <<
"SFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
163 t = do_time< Sacado::Fad::SLFad<double,10> >(nderiv, nloop);
164 std::cout <<
"SLFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
166 t = do_time< Sacado::Fad::DFad<double> >(nderiv, nloop);
167 std::cout <<
"DFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
169 t = do_time< Sacado::ELRFad::SFad<double,10> >(nderiv, nloop);
170 std::cout <<
"ELRSFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
172 t = do_time< Sacado::ELRFad::SLFad<double,10> >(nderiv, nloop);
173 std::cout <<
"ELRSLFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
175 t = do_time< Sacado::ELRFad::DFad<double> >(nderiv, nloop);
176 std::cout <<
"ELRDFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
178 t = do_time< Sacado::CacheFad::DFad<double> >(nderiv, nloop);
179 std::cout <<
"CacheFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
181 t = do_time< Sacado::Fad::DVFad<double> >(nderiv, nloop);
182 std::cout <<
"DVFad: " << std::setw(w) << t <<
"\t" << std::setw(w) << t/ta << std::endl;
185 catch (std::exception& e) {
186 std::cout << e.what() << std::endl;
189 catch (
const char *s) {
190 std::cout << s << std::endl;
194 std::cout <<
"Caught unknown exception!" << std::endl;
void func1_and_deriv(int n, double x1, double x2, double *x1dot, double *x2dot, double &y, double *ydot)