| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | /*************************************************************************
 | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | *	 YAP Prolog 							 * | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | *	Yap Prolog was developed at NCCUP - Universidade do Porto	 * | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997	 * | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | ************************************************************************** | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | * File:		analyst.c						 * | 
					
						
							|  |  |  | * Last rev:								 * | 
					
						
							|  |  |  | * mods:									 * | 
					
						
							|  |  |  | * comments:	Tracing the abstract machine				 * | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | *************************************************************************/ | 
					
						
							|  |  |  | #ifdef SCCS
 | 
					
						
							|  |  |  | static char SccsId[] = "%W% %G%"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Yap.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef ANALYST
 | 
					
						
							|  |  |  | #include "Yatom.h"
 | 
					
						
							|  |  |  | #include "yapio.h"
 | 
					
						
							|  |  |  | #ifdef HAVE_STRING_H
 | 
					
						
							|  |  |  | #include <string.h>
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-25 17:15:04 -05:00
										 |  |  | static Int p_reset_op_counters(void); | 
					
						
							|  |  |  | static Int p_show_op_counters(void); | 
					
						
							|  |  |  | static Int p_show_ops_by_group(void); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static Int  | 
					
						
							|  |  |  | p_reset_op_counters() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for (i = 0; i <= _std_top; ++i) | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[i] = 0; | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   return TRUE; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void  | 
					
						
							|  |  |  | print_instruction(int inst) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int j; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "%s", Yap_op_names[inst]); | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   for (j = strlen(Yap_op_names[inst]); j < 25; j++) | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     putc(' ', GLOBAL_stderr); | 
					
						
							|  |  |  |   j = GLOBAL_opcount[inst]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   if (j < 100000000) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |     if (j < 10000000) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |       putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |       if (j < 1000000) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | 	putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	if (j < 100000) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | 	  putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	  if (j < 10000) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | 	    putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	    if (j < 1000) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | 	      putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	      if (j < 100) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | 		putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 		if (j < 10) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | 		  putc(' ', GLOBAL_stderr); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	      } | 
					
						
							|  |  |  | 	    } | 
					
						
							|  |  |  | 	  } | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "%llu\n", GLOBAL_opcount[inst]); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static Int  | 
					
						
							|  |  |  | p_show_op_counters() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int i; | 
					
						
							|  |  |  |   Term t1 = Deref(ARG1); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   if (IsVarTerm(t1) || !IsAtomTerm(t1)) { | 
					
						
							|  |  |  |     return FALSE; | 
					
						
							|  |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2006-12-13 16:10:26 +00:00
										 |  |  |     Atom at1 = AtomOfTerm(t1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (IsWideAtom(at1)) { | 
					
						
							|  |  |  |       wchar_t *program; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       program = RepAtom(at1)->WStrOfAE; | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |       fprintf(GLOBAL_stderr, "\n Instructions Executed in %S\n", program); | 
					
						
							| 
									
										
										
										
											2006-12-13 16:10:26 +00:00
										 |  |  |     } else { | 
					
						
							|  |  |  |       char *program; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       program = RepAtom(at1)->StrOfAE; | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |       fprintf(GLOBAL_stderr, "\n Instructions Executed in %s\n", program); | 
					
						
							| 
									
										
										
										
											2006-12-13 16:10:26 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   for (i = 0; i <= _std_top; ++i) | 
					
						
							|  |  |  |     print_instruction(i); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Control Instructions \n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_op_fail); | 
					
						
							|  |  |  |   print_instruction(_execute); | 
					
						
							|  |  |  |   print_instruction(_dexecute); | 
					
						
							|  |  |  |   print_instruction(_call); | 
					
						
							|  |  |  |   print_instruction(_fcall); | 
					
						
							|  |  |  |   print_instruction(_call_cpred); | 
					
						
							|  |  |  |   print_instruction(_call_c_wfail); | 
					
						
							|  |  |  |   print_instruction(_procceed); | 
					
						
							|  |  |  |   print_instruction(_allocate); | 
					
						
							|  |  |  |   print_instruction(_deallocate); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Choice Point Manipulation Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_try_me); | 
					
						
							|  |  |  |   print_instruction(_retry_me); | 
					
						
							|  |  |  |   print_instruction(_trust_me); | 
					
						
							|  |  |  |   print_instruction(_try_clause); | 
					
						
							|  |  |  |   print_instruction(_try_in); | 
					
						
							|  |  |  |   print_instruction(_retry); | 
					
						
							|  |  |  |   print_instruction(_trust); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Disjunction Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_either); | 
					
						
							|  |  |  |   print_instruction(_or_else); | 
					
						
							|  |  |  |   print_instruction(_or_last); | 
					
						
							|  |  |  |   print_instruction(_jump); | 
					
						
							|  |  |  |   print_instruction(_move_back); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Dynamic Predicates Choicepoint Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_try_and_mark); | 
					
						
							|  |  |  |   print_instruction(_retry_and_mark); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n C Predicates Choicepoint Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_try_c); | 
					
						
							|  |  |  |   print_instruction(_retry_c); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Indexing Instructions\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "\n  Switch on Type\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_switch_on_type); | 
					
						
							|  |  |  |   print_instruction(_switch_list_nl); | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   print_instruction(_switch_on_arg_type); | 
					
						
							|  |  |  |   print_instruction(_switch_on_sub_arg_type); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n  Switch on Value\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_if_cons); | 
					
						
							|  |  |  |   print_instruction(_go_on_cons); | 
					
						
							|  |  |  |   print_instruction(_switch_on_cons); | 
					
						
							|  |  |  |   print_instruction(_if_func); | 
					
						
							|  |  |  |   print_instruction(_go_on_func); | 
					
						
							|  |  |  |   print_instruction(_switch_on_func); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n  Other Switches\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_if_not_then); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Get Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_get_x_var); | 
					
						
							|  |  |  |   print_instruction(_get_y_var); | 
					
						
							|  |  |  |   print_instruction(_get_x_val); | 
					
						
							|  |  |  |   print_instruction(_get_y_val); | 
					
						
							|  |  |  |   print_instruction(_get_atom); | 
					
						
							| 
									
										
										
										
											2004-09-27 20:45:04 +00:00
										 |  |  |   print_instruction(_get_2atoms); | 
					
						
							|  |  |  |   print_instruction(_get_3atoms); | 
					
						
							|  |  |  |   print_instruction(_get_4atoms); | 
					
						
							|  |  |  |   print_instruction(_get_5atoms); | 
					
						
							|  |  |  |   print_instruction(_get_6atoms); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_get_list); | 
					
						
							|  |  |  |   print_instruction(_get_struct); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n   Optimised Get Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_glist_valx); | 
					
						
							|  |  |  |   print_instruction(_glist_valy); | 
					
						
							|  |  |  |   print_instruction(_gl_void_varx); | 
					
						
							|  |  |  |   print_instruction(_gl_void_vary); | 
					
						
							|  |  |  |   print_instruction(_gl_void_valx); | 
					
						
							|  |  |  |   print_instruction(_gl_void_valy); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Unify Read Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_unify_x_var); | 
					
						
							|  |  |  |   print_instruction(_unify_x_var2); | 
					
						
							|  |  |  |   print_instruction(_unify_y_var); | 
					
						
							|  |  |  |   print_instruction(_unify_x_val); | 
					
						
							|  |  |  |   print_instruction(_unify_y_val); | 
					
						
							|  |  |  |   print_instruction(_unify_x_loc); | 
					
						
							|  |  |  |   print_instruction(_unify_y_loc); | 
					
						
							|  |  |  |   print_instruction(_unify_atom); | 
					
						
							|  |  |  |   print_instruction(_unify_n_atoms); | 
					
						
							|  |  |  |   print_instruction(_unify_n_voids); | 
					
						
							|  |  |  |   print_instruction(_unify_list); | 
					
						
							|  |  |  |   print_instruction(_unify_struct); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n   Unify Last Read Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_unify_l_x_var); | 
					
						
							|  |  |  |   print_instruction(_unify_l_x_var2); | 
					
						
							|  |  |  |   print_instruction(_unify_l_y_var); | 
					
						
							|  |  |  |   print_instruction(_unify_l_x_val); | 
					
						
							|  |  |  |   print_instruction(_unify_l_y_val); | 
					
						
							|  |  |  |   print_instruction(_unify_l_x_loc); | 
					
						
							|  |  |  |   print_instruction(_unify_l_y_loc); | 
					
						
							|  |  |  |   print_instruction(_unify_l_atom); | 
					
						
							|  |  |  |   print_instruction(_unify_l_n_voids); | 
					
						
							|  |  |  |   print_instruction(_unify_l_list); | 
					
						
							|  |  |  |   print_instruction(_unify_l_struc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Unify Write Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_unify_x_var_write); | 
					
						
							|  |  |  |   print_instruction(_unify_x_var2_write); | 
					
						
							|  |  |  |   print_instruction(_unify_y_var_write); | 
					
						
							|  |  |  |   print_instruction(_unify_x_val_write); | 
					
						
							|  |  |  |   print_instruction(_unify_y_val_write); | 
					
						
							|  |  |  |   print_instruction(_unify_x_loc_write); | 
					
						
							|  |  |  |   print_instruction(_unify_y_loc_write); | 
					
						
							|  |  |  |   print_instruction(_unify_atom_write); | 
					
						
							|  |  |  |   print_instruction(_unify_n_atoms_write); | 
					
						
							|  |  |  |   print_instruction(_unify_n_voids_write); | 
					
						
							|  |  |  |   print_instruction(_unify_list_write); | 
					
						
							|  |  |  |   print_instruction(_unify_struct_write); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n   Unify Last Read Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_unify_l_x_var_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_x_var2_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_y_var_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_x_val_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_y_val_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_x_loc_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_y_loc_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_atom_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_n_voids_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_list_write); | 
					
						
							|  |  |  |   print_instruction(_unify_l_struc_write); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Put Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_put_x_var); | 
					
						
							|  |  |  |   print_instruction(_put_y_var); | 
					
						
							|  |  |  |   print_instruction(_put_x_val); | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   print_instruction(_put_xx_val); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_put_y_val); | 
					
						
							|  |  |  |   print_instruction(_put_unsafe); | 
					
						
							|  |  |  |   print_instruction(_put_atom); | 
					
						
							|  |  |  |   print_instruction(_put_list); | 
					
						
							|  |  |  |   print_instruction(_put_struct); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Write Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_write_x_var); | 
					
						
							|  |  |  |   print_instruction(_write_y_var); | 
					
						
							|  |  |  |   print_instruction(_write_x_val); | 
					
						
							|  |  |  |   print_instruction(_write_y_val); | 
					
						
							|  |  |  |   print_instruction(_write_x_loc); | 
					
						
							|  |  |  |   print_instruction(_write_y_loc); | 
					
						
							|  |  |  |   print_instruction(_write_atom); | 
					
						
							|  |  |  |   print_instruction(_write_n_atoms); | 
					
						
							|  |  |  |   print_instruction(_write_n_voids); | 
					
						
							|  |  |  |   print_instruction(_write_list); | 
					
						
							|  |  |  |   print_instruction(_write_struct); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n   Last Write Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_write_l_list); | 
					
						
							|  |  |  |   print_instruction(_write_l_struc); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Miscellaneous Instructions\n"); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_cut); | 
					
						
							|  |  |  |   print_instruction(_cut_t); | 
					
						
							|  |  |  |   print_instruction(_cut_e); | 
					
						
							|  |  |  |   print_instruction(_skip); | 
					
						
							|  |  |  |   print_instruction(_pop); | 
					
						
							|  |  |  |   print_instruction(_pop_n); | 
					
						
							|  |  |  |   print_instruction(_trust_fail); | 
					
						
							|  |  |  |   print_instruction(_index_pred); | 
					
						
							| 
									
										
										
										
											2007-11-26 23:43:10 +00:00
										 |  |  |   print_instruction(_lock_pred); | 
					
						
							| 
									
										
										
										
											2004-02-05 16:57:02 +00:00
										 |  |  | #if THREADS
 | 
					
						
							|  |  |  |   print_instruction(_thread_local); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   print_instruction(_save_b_x); | 
					
						
							|  |  |  |   print_instruction(_save_b_y); | 
					
						
							|  |  |  |   print_instruction(_save_pair_x); | 
					
						
							|  |  |  |   print_instruction(_save_pair_y); | 
					
						
							|  |  |  |   print_instruction(_save_pair_x_write); | 
					
						
							|  |  |  |   print_instruction(_save_pair_y_write); | 
					
						
							|  |  |  |   print_instruction(_save_appl_x); | 
					
						
							|  |  |  |   print_instruction(_save_appl_y); | 
					
						
							|  |  |  |   print_instruction(_save_appl_x_write); | 
					
						
							|  |  |  |   print_instruction(_save_appl_y_write); | 
					
						
							|  |  |  |   print_instruction(_Ystop); | 
					
						
							|  |  |  |   print_instruction(_Nstop); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   return TRUE; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   int nxvar, nxval, nyvar, nyval, ncons, nlist, nstru, nmisc; | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | } uGLOBAL_opcount; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   int ncalls, nexecs, nproceeds, ncallbips, ncuts, nallocs, ndeallocs; | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  | } cGLOBAL_opcount; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |   int ntries, nretries, ntrusts; | 
					
						
							|  |  |  | } ccpcount; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static Int  | 
					
						
							|  |  |  | p_show_ops_by_group(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   uGLOBAL_opcount c_get, c_unify, c_put, c_write; | 
					
						
							|  |  |  |   cGLOBAL_opcount c_control; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   ccpcount c_cp; | 
					
						
							|  |  |  |   int gets, unifies, puts, writes, controls, choice_pts, indexes, misc, | 
					
						
							|  |  |  |     total; | 
					
						
							|  |  |  |   Term t1; | 
					
						
							| 
									
										
										
										
											2006-12-13 16:10:26 +00:00
										 |  |  |   Atom at1; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   t1 = Deref(ARG1); | 
					
						
							|  |  |  |   if (IsVarTerm(t1) || !IsAtomTerm(t1)) | 
					
						
							|  |  |  |     return (FALSE); | 
					
						
							| 
									
										
										
										
											2006-12-13 16:10:26 +00:00
										 |  |  |   at1 = AtomOfTerm(t1); | 
					
						
							|  |  |  |   if (IsWideAtom(at1)) { | 
					
						
							|  |  |  |     wchar_t *program; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     program = RepAtom(at1)->WStrOfAE; | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     fprintf(GLOBAL_stderr, "\n Instructions Executed in %S\n", program); | 
					
						
							| 
									
										
										
										
											2006-12-13 16:10:26 +00:00
										 |  |  |   } else { | 
					
						
							|  |  |  |     char *program; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     program = RepAtom(at1)->StrOfAE; | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     fprintf(GLOBAL_stderr, "\n Instructions Executed in %s\n", program); | 
					
						
							| 
									
										
										
										
											2006-12-13 16:10:26 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_get.nxvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_get_x_var]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_get.nyvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_get_y_var]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_get.nxval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_get_x_val]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_get.nyval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_get_y_val]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_get.ncons = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_get_atom]+ | 
					
						
							|  |  |  |     GLOBAL_opcount[_get_2atoms]+ | 
					
						
							|  |  |  |     GLOBAL_opcount[_get_3atoms]+ | 
					
						
							|  |  |  |     GLOBAL_opcount[_get_4atoms]+ | 
					
						
							|  |  |  |     GLOBAL_opcount[_get_5atoms]+ | 
					
						
							|  |  |  |     GLOBAL_opcount[_get_6atoms]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_get.nlist = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_get_list] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_glist_valx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_glist_valy] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_varx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_vary] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_valx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_valy]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_get.nstru = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_get_struct]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   gets = c_get.nxvar + c_get.nyvar + c_get.nxval + c_get.nyval + | 
					
						
							|  |  |  |     c_get.ncons + c_get.nlist + c_get.nstru; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   c_unify.nxvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_unify_x_var] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_void] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_n_voids] + | 
					
						
							|  |  |  |     2 * GLOBAL_opcount[_unify_x_var2] + | 
					
						
							|  |  |  |     2 * GLOBAL_opcount[_gl_void_varx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_vary] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_valx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_x_var] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_void] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_n_voids] + | 
					
						
							|  |  |  |     2 * GLOBAL_opcount[_unify_l_x_var2] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_x_var_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_void_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_n_voids_write] + | 
					
						
							|  |  |  |     2 * GLOBAL_opcount[_unify_x_var2_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_x_var_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_void_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_n_voids_write] + | 
					
						
							|  |  |  |     2 * GLOBAL_opcount[_unify_l_x_var2_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_unify.nyvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_unify_y_var] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_vary] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_y_var] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_y_var_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_y_var_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_unify.nxval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_unify_x_val] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_x_loc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_glist_valx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_valx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_x_val] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_x_loc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_x_val_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_x_loc_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_x_val_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_x_loc_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_unify.nyval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_unify_y_val] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_y_loc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_glist_valy] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_gl_void_valy] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_y_val] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_y_loc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_y_val_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_y_loc_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_y_val_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_y_loc_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_unify.ncons = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_unify_atom] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_n_atoms] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_atom] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_atom_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_n_atoms_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_atom_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_unify.nlist = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_unify_list] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_list] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_list_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_list_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_unify.nstru = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_unify_struct] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_struc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_struct_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_unify_l_struc_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_unify.nmisc = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_pop] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_pop_n]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   unifies = c_unify.nxvar + c_unify.nyvar + c_unify.nxval + c_unify.nyval + | 
					
						
							|  |  |  |     c_unify.ncons + c_unify.nlist + c_unify.nstru + c_unify.nmisc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   c_put.nxvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_put_x_var]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_put.nyvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_put_y_var]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_put.nxval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_put_x_val]+ | 
					
						
							|  |  |  |     2*GLOBAL_opcount[_put_xx_val]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_put.nyval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_put_y_val]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_put.ncons = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_put_atom]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_put.nlist = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_put_list]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_put.nstru = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_put_struct]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   puts = c_put.nxvar + c_put.nyvar + c_put.nxval + c_put.nyval + | 
					
						
							|  |  |  |     c_put.ncons + c_put.nlist + c_put.nstru; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   c_write.nxvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_write_x_var] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_write_void] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_write_n_voids]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_write.nyvar = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_write_y_var]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_write.nxval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_write_x_val]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_write.nyval = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_write_y_val]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_write.ncons = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_write_atom]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_write.nlist = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_write_list]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   c_write.nstru = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_write_struct]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   writes = c_write.nxvar + c_write.nyvar + c_write.nxval + c_write.nyval + | 
					
						
							|  |  |  |     c_write.ncons + c_write.nlist + c_write.nstru; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   c_control.nexecs = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_execute] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_dexecute]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_control.ncalls = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_call] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_fcall]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_control.nproceeds = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_procceed]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_control.ncallbips = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_call_cpred] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_call_c_wfail] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_try_c] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_retry_c] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_op_fail] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_trust_fail] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_atom_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_atom_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_atomic_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_atomic_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_compound_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_compound_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_float_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_float_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_integer_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_integer_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_nonvar_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_nonvar_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_number_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_number_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_var_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_var_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_db_ref_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_db_ref_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_cut_by_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_cut_by_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_primitive_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_primitive_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_equal] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_plus_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_plus_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_plus_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_plus_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_minus_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_minus_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_minus_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_minus_y_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_times_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_times_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_times_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_times_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_div_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_div_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_div_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_div_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_div_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_div_y_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_or_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_or_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_or_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_or_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_and_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_and_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_and_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_and_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_sll_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_sll_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_sll_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_sll_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_slr_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_slr_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_slr_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_slr_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_dif] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_eq] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_arg_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_arg_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_arg_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_arg_y_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_functor] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2s_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2s_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2s_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2s_y_vv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2s_y_cv] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2s_y_vc] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2f_xx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2f_xy] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2f_yx] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_p_func2f_yy]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_control.ncuts = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_cut] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_cut_t] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_cut_e] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_commit_b_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_commit_b_y]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_control.nallocs = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_allocate] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_fcall]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_control.ndeallocs = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_dexecute] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_deallocate]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   controls = | 
					
						
							|  |  |  |     c_control.nexecs + | 
					
						
							|  |  |  |     c_control.ncalls + | 
					
						
							|  |  |  |     c_control.nproceeds + | 
					
						
							|  |  |  |     c_control.ncuts + | 
					
						
							|  |  |  |     c_control.nallocs + | 
					
						
							|  |  |  |     c_control.ndeallocs + | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_jump] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_move_back] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_try_in]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   c_cp.ntries = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_try_me] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_try_and_mark] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_try_c] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_try_clause] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_either]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_cp.nretries = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_retry_me] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_retry_and_mark] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_retry_c] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_retry] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_or_else]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   c_cp.ntrusts = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_trust_me] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_trust] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_or_last]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   choice_pts = | 
					
						
							|  |  |  |     c_cp.ntries + | 
					
						
							|  |  |  |     c_cp.nretries + | 
					
						
							|  |  |  |     c_cp.ntrusts; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   indexes = | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_jump_if_var] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_switch_on_type] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_switch_list_nl] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_switch_on_arg_type] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_switch_on_sub_arg_type] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_switch_on_cons] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_go_on_cons] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_if_cons] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_switch_on_func] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_go_on_func] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_if_func] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_if_not_then]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   misc = | 
					
						
							|  |  |  |     c_control.ncallbips + | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_Ystop] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_Nstop] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_index_pred] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_lock_pred] + | 
					
						
							| 
									
										
										
										
											2004-02-05 16:57:02 +00:00
										 |  |  | #if THREADS
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_thread_local] + | 
					
						
							| 
									
										
										
										
											2004-02-05 16:57:02 +00:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     GLOBAL_opcount[_save_b_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_b_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_undef_p] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_spy_pred] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_spy_or_trymark] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_pair_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_pair_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_pair_x_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_pair_y_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_appl_x] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_appl_y] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_appl_x_write] + | 
					
						
							|  |  |  |     GLOBAL_opcount[_save_appl_y_write]; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  |   total = gets + unifies + puts + writes + controls + choice_pts + indexes + misc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*  for (i = 0; i <= _std_top; ++i)
 | 
					
						
							|  |  |  |    * print_instruction(i); | 
					
						
							|  |  |  |    */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "Groups are\n\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "  GET               instructions: %8d (%3d%%)\n", gets, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (gets * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  UNIFY             instructions: %8d (%3d%%)\n", unifies, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (unifies * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  PUT               instructions: %8d (%3d%%)\n", puts, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (puts * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  WRITE             instructions: %8d (%3d%%)\n", writes, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (writes * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  CONTROL           instructions: %8d (%3d%%)\n", controls, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (controls * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  CHOICE POINT      instructions: %8d (%3d%%)\n", choice_pts, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (choice_pts * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  INDEXING          instructions: %8d (%3d%%)\n", indexes, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (indexes * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  MISCELLANEOUS     instructions: %8d (%3d%%)\n", misc, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (misc * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "_______________________________________________\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "   TOTAL            instructions: %8d (%3d%%)\n\n", total, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (total * 100) / total); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Analysis of Unification Instructions in %s \n", program); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "           XVAR,   YVAR,    XVAL,    YVAL,     CONS,     LIST,  STRUCT\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "  GET: %8d %8d %8d %8d %8d %8d %8d\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_get.nxvar, | 
					
						
							|  |  |  | 	     c_get.nyvar, | 
					
						
							|  |  |  | 	     c_get.nxval, | 
					
						
							|  |  |  | 	     c_get.nyval, | 
					
						
							|  |  |  | 	     c_get.ncons, | 
					
						
							|  |  |  | 	     c_get.nlist, | 
					
						
							|  |  |  | 	     c_get.nstru); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "UNIFY: %8d %8d %8d %8d %8d %8d %8d\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_unify.nxvar, | 
					
						
							|  |  |  | 	     c_unify.nyvar, | 
					
						
							|  |  |  | 	     c_unify.nxval, | 
					
						
							|  |  |  | 	     c_unify.nyval, | 
					
						
							|  |  |  | 	     c_unify.ncons, | 
					
						
							|  |  |  | 	     c_unify.nlist, | 
					
						
							|  |  |  | 	     c_unify.nstru); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  PUT: %8d %8d %8d %8d %8d %8d %8d\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_put.nxvar, | 
					
						
							|  |  |  | 	     c_put.nyvar, | 
					
						
							|  |  |  | 	     c_put.nxval, | 
					
						
							|  |  |  | 	     c_put.nyval, | 
					
						
							|  |  |  | 	     c_put.ncons, | 
					
						
							|  |  |  | 	     c_put.nlist, | 
					
						
							|  |  |  | 	     c_put.nstru); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "WRITE: %8d %8d %8d %8d %8d %8d %8d\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_write.nxvar, | 
					
						
							|  |  |  | 	     c_write.nyvar, | 
					
						
							|  |  |  | 	     c_write.nxval, | 
					
						
							|  |  |  | 	     c_write.nyval, | 
					
						
							|  |  |  | 	     c_write.ncons, | 
					
						
							|  |  |  | 	     c_write.nlist, | 
					
						
							|  |  |  | 	     c_write.nstru); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "      ___________________________________________________\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "TOTAL: %8d %8d %8d %8d %8d %8d %8d\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_get.nxvar + c_unify.nxvar + c_put.nxvar + c_write.nxvar, | 
					
						
							|  |  |  | 	     c_get.nyvar + c_unify.nyvar + c_put.nyvar + c_write.nyvar, | 
					
						
							|  |  |  | 	     c_get.nxval + c_unify.nxval + c_put.nxval + c_write.nxval, | 
					
						
							|  |  |  | 	     c_get.nyval + c_unify.nyval + c_put.nyval + c_write.nyval, | 
					
						
							|  |  |  | 	     c_get.ncons + c_unify.ncons + c_put.ncons + c_write.ncons, | 
					
						
							|  |  |  | 	     c_get.nlist + c_unify.nlist + c_put.nlist + c_write.nlist, | 
					
						
							|  |  |  | 	     c_get.nstru + c_unify.nstru + c_put.nstru + c_write.nstru | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Analysis of Unification Instructions in %s \n", program); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "           XVAR,   YVAR,    XVAL,    YVAL,     CONS,     LIST,  STRUCT\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "  GET:  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (((double) c_get.nxvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nyvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nxval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nyval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.ncons) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nlist) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nstru) * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "UNIFY:  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (((double) c_unify.nxvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_unify.nyvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_unify.nxval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_unify.nyval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_unify.ncons) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_unify.nlist) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_unify.nstru) * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  PUT:  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (((double) c_put.nxvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_put.nyvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_put.nxval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_put.nyval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_put.ncons) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_put.nlist) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_put.nstru) * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "WRITE:  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (((double) c_write.nxvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_write.nyvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_write.nxval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_write.nyval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_write.ncons) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_write.nlist) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_write.nstru) * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "      ___________________________________________________\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "TOTAL:  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%  %3.2f%%\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (((double) c_get.nxvar + c_unify.nxvar + c_put.nxvar + c_write.nxvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nyvar + c_unify.nyvar + c_put.nyvar + c_write.nyvar) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nxval + c_unify.nxval + c_put.nxval + c_write.nxval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nyval + c_unify.nyval + c_put.nyval + c_write.nyval) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.ncons + c_unify.ncons + c_put.ncons + c_write.ncons) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nlist + c_unify.nlist + c_put.nlist + c_write.nlist) * 100) / total, | 
					
						
							|  |  |  | 	     (((double) c_get.nstru + c_unify.nstru + c_put.nstru + c_write.nstru) * 100) / total | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Control Instructions Executed in %s \n", program); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "Grouped as\n\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "  CALL              instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_control.ncalls, (c_control.ncalls * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  PROCEED           instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_control.nproceeds, (c_control.nproceeds * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  EXECUTE           instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_control.nexecs, (c_control.nexecs * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  CUT               instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_control.ncuts, (c_control.ncuts * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  CALL_BIP          instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_control.ncallbips, (c_control.ncallbips * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  ALLOCATE          instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_control.nallocs, (c_control.nallocs * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  DEALLOCATE        instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_control.ndeallocs, (c_control.ndeallocs * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "_______________________________________________\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "   TOTAL            instructions: %8d (%3d%%)\n\n", total, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (total * 100) / total); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "\n Choice Point Manipulation Instructions Executed in %s \n", program); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "Grouped as\n\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "  TRY              instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_cp.ntries, (c_cp.ntries * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  RETRY            instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_cp.nretries, (c_cp.nretries * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "  TRUST            instructions: %8d (%3d%%)\n", | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     c_cp.ntrusts, (c_cp.ntrusts * 100) / total); | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |   fprintf(GLOBAL_stderr, "_______________________________________________\n"); | 
					
						
							|  |  |  |   fprintf(GLOBAL_stderr, "   TOTAL            instructions: %8d (%3d%%)\n\n", total, | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | 	     (total * 100) / total); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   return TRUE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static Int | 
					
						
							|  |  |  | p_show_sequences(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int i, j; | 
					
						
							|  |  |  |   YAP_ULONG_LONG min; | 
					
						
							|  |  |  |   YAP_ULONG_LONG sum = 0; | 
					
						
							|  |  |  |   Term t = Deref(ARG1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (IsVarTerm(t)) { | 
					
						
							|  |  |  |     Yap_Error(INSTANTIATION_ERROR, t, "shows_sequences/1"); | 
					
						
							|  |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (!IsIntegerTerm(t)) { | 
					
						
							|  |  |  |     Yap_Error(TYPE_ERROR_INTEGER, t, "shows_sequences/1"); | 
					
						
							|  |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   min = (YAP_ULONG_LONG)IntegerOfTerm(t); | 
					
						
							|  |  |  |   if (min <= 0) { | 
					
						
							|  |  |  |     Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t, "shows_sequences/1"); | 
					
						
							|  |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (min <= 0) { | 
					
						
							|  |  |  |     Yap_Error(DOMAIN_ERROR_NOT_LESS_THAN_ZERO, t, "shows_sequences/1"); | 
					
						
							|  |  |  |     return FALSE; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   for (i = 0; i <= _std_top; ++i) { | 
					
						
							| 
									
										
										
										
											2011-05-25 16:40:36 +01:00
										 |  |  |     sum += GLOBAL_opcount[i]; | 
					
						
							| 
									
										
										
										
											2005-07-06 15:10:18 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   for (i = 0; i <= _std_top; ++i) { | 
					
						
							|  |  |  |     for (j = 0; j <= _std_top; ++j) { | 
					
						
							|  |  |  |       YAP_ULONG_LONG seqs = Yap_2opcount[i][j]; | 
					
						
							|  |  |  |       if (seqs && sum/seqs <= min) { | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	Term t[3], t0; | 
					
						
							|  |  |  | 	Functor f =  | 
					
						
							|  |  |  | 	t[0] = Yap_MkFloatTerm(((double)seqs*100.0)/sum); | 
					
						
							|  |  |  | 	t[1] = Yap_LookupAtom(Yap_op_names[i]); | 
					
						
							|  |  |  | 	t[2] = Yap_LookupAtom(Yap_op_names[j]); | 
					
						
							|  |  |  | 	t0 = MkApplTerm( | 
					
						
							|  |  |  | 	Yap_MkPairTerm(Yap_op_names[i] | 
					
						
							|  |  |  | 	*/ | 
					
						
							|  |  |  | 	fprintf(stderr,"%f -> %s,%s\n",((double)seqs*100.0)/sum,Yap_op_names[i],Yap_op_names[j]); | 
					
						
							|  |  |  | 	/* we found one */ | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }   | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return TRUE; | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void  | 
					
						
							| 
									
										
										
										
											2002-11-18 18:18:05 +00:00
										 |  |  | Yap_InitAnalystPreds(void) | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-09-09 23:50:43 -05:00
										 |  |  |   Yap_InitCPred("wam_profiler_reset_op_counters", 0, p_reset_op_counters, SafePredFlag |SyncPredFlag); | 
					
						
							| 
									
										
										
										
											2014-09-11 14:06:57 -05:00
										 |  |  | /** @pred wam_profiler_reset_op_counters 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Reinitialize all counters. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2014-09-09 23:50:43 -05:00
										 |  |  |   Yap_InitCPred("wam_profiler_show_op_counters", 1, p_show_op_counters, SafePredFlag|SyncPredFlag); | 
					
						
							| 
									
										
										
										
											2014-09-11 14:06:57 -05:00
										 |  |  | /** @pred wam_profiler_show_op_counters(+ _A_) 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Display the current value for the counters, using label  _A_. The | 
					
						
							|  |  |  | label must be an atom. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2014-09-09 23:50:43 -05:00
										 |  |  |   Yap_InitCPred("wam_profiler_show_ops_by_group", 1, p_show_ops_by_group, SafePredFlag |SyncPredFlag); | 
					
						
							| 
									
										
										
										
											2014-09-11 14:06:57 -05:00
										 |  |  | /** @pred wam_profiler_show_ops_by_group(+ _A_) 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Display the current value for the counters, organized by groups, using | 
					
						
							|  |  |  | label  _A_. The label must be an atom. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-09-09 23:50:43 -05:00
										 |  |  |   Yap_InitCPred("wam_profiler_show_sequences", 1, p_show_sequences, SafePredFlag |SyncPredFlag); | 
					
						
							| 
									
										
										
										
											2001-04-09 19:54:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* ANALYST */
 |