1 # ifndef CPPAD_LOCAL_OP_CODE_HPP
2 # define CPPAD_LOCAL_OP_CODE_HPP
25 namespace CppAD {
namespace local {
179 static const size_t NumArgTable[] = {
250 static bool first =
true;
253 sizeof(NumArgTable) /
sizeof(NumArgTable[0])
261 return NumArgTable[op];
285 static const size_t NumResTable[] = {
356 sizeof(NumResTable) /
sizeof(NumResTable[0])
361 return NumResTable[op];
376 static const char *OpNameTable[] = {
447 size_t(
NumberOp) + 1 ==
sizeof(OpNameTable)/
sizeof(OpNameTable[0])
452 return OpNameTable[op];
478 template <
class Type>
481 const char * leader ,
485 std::ostringstream buffer;
492 buffer << std::setw(
int(width) ) << value;
496 size_t len = str.size();
499 for(i = 0; i < width-1; i++)
507 while(str[nspace] ==
' ' && nspace < len)
515 i = width - len + nspace;
546 template <
class Base>
557 "cannot print trace of AD operations in parallel mode"
559 static const char *CompareOpName[] =
560 {
"Lt",
"Le",
"Eq",
"Ge",
"Gt",
"Ne" };
598 if(
size_t(ind[4]) < 3 )
599 {
for(i = 0; i < size_t(ind[4]); i++)
604 for(i = 1; i < size_t(ind[4]); i++)
607 if(
size_t(ind[5]) < 3 )
608 {
for(i = 0; i < size_t(ind[5]); i++)
613 {
for(i = 1; i < size_t(ind[5]); i++)
630 for(i = 0; i < size_t(ind[0]); i++)
632 for(i = 0; i < size_t(ind[1]); i++)
770 os <<
"before=\"" << play->
GetTxt(ind[2]) <<
"\"";
774 os <<
"after=\"" << play->
GetTxt(ind[4]) <<
"\"";
851 template <
class Value>
860 for(k = 0; k < nfz; k++)
861 os <<
"| fz[" << k <<
"]=" << fz[k];
862 for(k = 0; k < nrz; k++)
863 os <<
"| rz[" << k <<
"]=" << rz[k];
915 {
size_t num_arg =
NumArg(op);
916 if( is_variable.
size() < num_arg )
917 is_variable.
extend( num_arg - is_variable.
size() );
953 is_variable[0] =
true;
961 is_variable[0] =
false;
980 is_variable[0] =
false;
981 is_variable[1] =
true;
991 is_variable[0] =
true;
992 is_variable[1] =
false;
1006 is_variable[0] =
true;
1007 is_variable[1] =
true;
1012 is_variable[0] =
false;
1013 is_variable[1] =
false;
1014 is_variable[2] =
true;
1023 is_variable[0] =
false;
1024 is_variable[1] =
false;
1025 is_variable[2] =
false;
1031 is_variable[0] =
false;
1032 is_variable[1] =
true;
1033 is_variable[2] =
false;
1038 is_variable[0] =
false;
1039 is_variable[1] =
false;
1040 is_variable[2] =
true;
1045 is_variable[0] =
false;
1046 is_variable[1] =
true;
1047 is_variable[2] =
true;
1054 for(
size_t i = 0; i < 4; i++)
1055 is_variable[i] =
false;
1062 is_variable[0] =
false;
1063 is_variable[1] = (arg[0] & 1) != 0;
1064 is_variable[2] =
false;
1065 is_variable[3] = (arg[0] & 2) != 0;
1066 is_variable[4] =
false;
1073 is_variable[0] =
false;
1074 is_variable[1] =
false;
1075 is_variable[2] = (arg[0] & 1) != 0;
1076 is_variable[3] = (arg[0] & 2) != 0;
1077 is_variable[4] = (arg[0] & 4) != 0;
1078 is_variable[5] = (arg[0] & 8) != 0;
1087 num_arg = 7 + arg[4] + arg[5];
1088 if( is_variable.
size() < num_arg )
1089 is_variable.
extend( num_arg - is_variable.
size() );
1090 is_variable[0] =
false;
1091 is_variable[1] =
false;
1092 is_variable[2] = (arg[1] & 1) != 0;
1093 is_variable[3] = (arg[1] & 2) != 0;
1094 for(
size_t i = 4; i < num_arg; ++i)
1095 is_variable[i] =
false;
1104 num_arg = 4 + arg[0] + arg[1];
1105 if( is_variable.
size() < num_arg )
1106 is_variable.
extend( num_arg - is_variable.
size() );
1107 is_variable[0] =
false;
1108 is_variable[1] =
false;
1109 is_variable[2] =
false;
1110 for(
size_t i = 3; i < num_arg - 1; ++i)
1111 is_variable[i] =
true;
1112 is_variable[num_arg - 1] =
false;
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
Define processor symbols and macros that are used by CppAD.
size_t extend(size_t n)
Increase the number of elements the end of this vector (existing elements are always preserved)...
size_t arg_is_variable(OpCode op, const addr_t *arg, pod_vector< bool > &is_variable)
Determines which arguments are variaibles for an operator.
void printOpResult(std::ostream &os, size_t nfz, const Value *fz, size_t nrz, const Value *rz)
Prints the result values correspnding to an operator.
CPPAD_TAPE_ADDR_TYPE addr_t
static bool in_parallel(void)
Are we in a parallel execution state; i.e., is it possible that other threads are currently executing...
static const char * name(size_t index)
Name corresponding to a discrete object.
const char * GetTxt(size_t i) const
Fetch a '\0' terminated string from the recording.
size_t NumArg(OpCode op)
Number of arguments for a specified operator.
Class used to store and play back an operation sequence recording.
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
const char * OpName(OpCode op)
Fetch the name for a specified operation.
#define CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL
Check that the first call to a routine is not during parallel execution mode.
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION Base Value(const AD< Base > &x)
size_t NumRes(OpCode op)
Number of variables resulting from the specified operation.
File used to define pod_vector class.
static std::vector< std::string > & class_name(void)
List of names for each object in this class.
OpCode
Type used to distinguish different AD< Base > atomic operations.
size_t size(void) const
current number of elements in this vector.
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
bool is_pod< OpCode >(void)
specialize is_pod<OpCode> to be true
void printOp(std::ostream &os, const local::player< Base > *play, size_t i_op, size_t i_var, OpCode op, const addr_t *ind)
Prints a single operator and its operands.
#define CPPAD_ASSERT_NARG_NRES(op, n_arg, n_res)
Check that operator op has the specified number of of arguments and results.
File used to define the CppAD multi-threading allocator class.
void printOpField(std::ostream &os, const char *leader, const Type &value, size_t width)
Prints a single field corresponding to an operator.
Base GetPar(size_t i) const
Fetch a parameter from the recording.