void update_maximum_tablespace_stats(NodeStats *btn, HashStats *btht, NodeStats *varsf, NodeStats *prodsf, NodeStats *conssf, NodeStats *aln, NodeStats *tstn, HashStats *tstht, NodeStats *tsi,NodeStats *asi) { size_t byte_size; byte_size = CurrentTotalTableSpaceUsed(*btn,*btht,*varsf,*prodsf,*conssf, *aln,*tstn,*tstht,*tsi,*asi); if ( byte_size > maxTableSpaceUsage.total_bytes ) maxTableSpaceUsage.total_bytes = byte_size; if ( NodeStats_NumUsedNodes(*aln) > maxTableSpaceUsage.alns ) maxTableSpaceUsage.alns = NodeStats_NumUsedNodes(*aln); if ( NodeStats_NumUsedNodes(*tsi) > maxTableSpaceUsage.tsi ) maxTableSpaceUsage.tsi = NodeStats_NumUsedNodes(*tsi); }
void print_detailed_tablespace_stats(CTXTdecl) { NodeStats abtn, /* Asserted Basic Trie Nodes */ btn, /* Basic Trie Nodes */ tstn, /* Time Stamp Trie Nodes */ aln, /* Answer List Nodes */ tsi, /* Time Stamp Indices (Index Entries/Nodes) */ varsf, /* Variant Subgoal Frames */ prodsf, /* Subsumptive Producer Subgoal Frames */ conssf, /* Subsumptive Consumer Subgoal Frames */ asi; /* Answer Subst. Info (for conditional answers) */ HashStats abtht, /* Asserted Basic Trie Hash Tables */ btht, /* Basic Trie Hash Tables */ tstht; /* Time Stamp Trie Hash Tables */ size_t trieassert_alloc, trieassert_used, tablespace_alloc, tablespace_used, de_space_alloc, de_space_used, dl_space_alloc, dl_space_used, pnde_space_alloc, pnde_space_used; size_t num_de_blocks, num_dl_blocks, num_pnde_blocks; btn = node_statistics(&smTableBTN); btht = hash_statistics(CTXTc &smTableBTHT); varsf = subgoal_statistics(CTXTc &smVarSF); prodsf = subgoal_statistics(CTXTc &smProdSF); conssf = subgoal_statistics(CTXTc &smConsSF); aln = node_statistics(&smALN); tstn = node_statistics(&smTSTN); tstht = hash_statistics(CTXTc &smTSTHT); tsi = node_statistics(&smTSIN); tsi = node_statistics(&smTSIN); asi = node_statistics(&smASI); de_space_alloc = allocated_de_space(current_de_block_gl,&num_de_blocks); de_space_used = de_space_alloc - unused_de_space(); dl_space_alloc = allocated_dl_space(current_dl_block_gl,& num_dl_blocks); dl_space_used = dl_space_alloc - unused_dl_space(); pnde_space_alloc = allocated_pnde_space(current_pnde_block_gl,&num_pnde_blocks); pnde_space_used = pnde_space_alloc - unused_pnde_space(); tablespace_alloc = CurrentTotalTableSpaceAlloc(btn,btht,varsf,prodsf,conssf,aln, tstn,tstht,tsi,asi); tablespace_used = CurrentTotalTableSpaceUsed(btn,btht,varsf,prodsf,conssf,aln, tstn,tstht,tsi,asi); tablespace_alloc = tablespace_alloc + de_space_alloc + dl_space_alloc + pnde_space_alloc; tablespace_used = tablespace_used + de_space_used + dl_space_used + pnde_space_used; abtn = node_statistics(&smAssertBTN); abtht = hash_statistics(CTXTc &smAssertBTHT); trieassert_alloc = NodeStats_SizeAllocNodes(abtn) + HashStats_SizeAllocTotal(abtht); trieassert_used = NodeStats_SizeUsedNodes(abtn) + HashStats_SizeUsedTotal(abtht); SQUASH_LINUX_COMPILER_WARN(trieassert_used) ; printf("\n" "Table Space Usage (excluding asserted and interned tries) \n"); printf(" Current Total Allocation: %12" UIntfmt" bytes\n" " Current Total Usage: %12" UIntfmt" bytes\n", (UInteger) (pspacesize[TABLE_SPACE]-trieassert_alloc), (UInteger) (pspacesize[TABLE_SPACE]-trieassert_alloc-(tablespace_alloc-tablespace_used))); // Basic Trie Stuff if ( NodeStats_NumBlocks(btn) > 0 || HashStats_NumBlocks(btht) > 0 || NodeStats_NumBlocks(aln) > 0) { printf("\n" " Basic Tries\n"); if ( NodeStats_NumBlocks(btn) > 0) print_NodeStats(btn,"Basic Trie Nodes"); if (HashStats_NumBlocks(btht) > 0) print_HashStats(btht,"Basic Trie Hash Tables"); if ( NodeStats_NumBlocks(aln) > 0) print_NodeStats(aln,"Answer List Nodes (for Incomplete Variant Tables)"); } // Subgoal Frames if (NodeStats_NumBlocks(varsf) > 0 || NodeStats_NumBlocks(prodsf) > 0 || NodeStats_NumBlocks(conssf) > 0) { printf("\n" " Subgoal Frames\n"); if (NodeStats_NumBlocks(varsf) > 0) print_NodeStats(varsf,"Variant Subgoal Frames"); if (NodeStats_NumBlocks(prodsf) > 0) print_NodeStats(prodsf,"Producer Subgoal Frames"); if (NodeStats_NumBlocks(conssf) > 0) print_NodeStats(conssf,"Consumer Subgoal Frames"); } // Subsumptive Tables if (NodeStats_NumBlocks(tstn) > 0 || NodeStats_NumBlocks(tsi) > 0 || HashStats_NumBlocks(tstht) > 0) { printf("\n" " Time Stamp Tries (for Subsumptive Tables) \n"); if (NodeStats_NumBlocks(tstn) > 0) print_NodeStats(tstn,"Time Stamp Trie Nodes"); if (HashStats_NumBlocks(tstht) > 0) print_HashStats(tstht,"Time Stamp Trie Hash Tables"); if (NodeStats_NumBlocks(tsi) > 0) print_NodeStats(tsi,"Time Stamp Trie Index Nodes"); } // Conditional Answers if (dl_space_alloc > 0 || de_space_alloc > 0 || pnde_space_alloc > 0 || NodeStats_NumBlocks(asi) > 0) { printf("\n" " Information for Conditional Answers in Variant Tables \n"); if (dl_space_alloc > 0) print_wfs_usage(dl_space_alloc,dl_space_used,num_dl_blocks,DLS_PER_BLOCK, sizeof(struct delay_list),"Delay Lists"); if (de_space_alloc > 0) print_wfs_usage(de_space_alloc,de_space_used,num_de_blocks,DES_PER_BLOCK, sizeof(struct delay_element),"Delay Elements"); if (pnde_space_alloc > 0) print_wfs_usage(pnde_space_alloc,pnde_space_used,num_pnde_blocks,PNDES_PER_BLOCK, sizeof(struct pos_neg_de_list),"Back-pointer Lists"); if ( NodeStats_NumBlocks(asi) > 0) print_NodeStats(asi,"Answer Substitution Frames"); } if (total_call_node_count_gl) { printf("\nTotal number of incremental subgoals created: %d\n",total_call_node_count_gl); printf(" Current number of incremental call nodesd: %d\n",current_call_node_count_gl); printf(" Total number of incremental call edges created: %d\n",current_call_edge_count_gl); } // Private trie assert space if ( NodeStats_NumBlocks(abtn) > 0 || HashStats_NumBlocks(abtht) > 0) { printf("\n ------------------ Asserted and Interned Tries ----------------\n"); if ( NodeStats_NumBlocks(abtn) > 0) print_NodeStats(abtn,"Basic Trie Nodes (Assert)"); if (HashStats_NumBlocks(abtht) > 0) print_HashStats(abtht,"Basic Trie Hash Tables (Assert)"); } if (flags[MAX_USAGE]) { /* Report Maximum Usages --------------------- */ update_maximum_tablespace_stats(&btn,&btht,&varsf,&prodsf,&conssf, &aln,&tstn,&tstht,&tsi,&asi); printf("\n" "Maximum Total Usage: %12"UIntfmt" bytes\n", maximum_total_tablespace_usage()); printf("Maximum Structure Usage:\n" " ALNs: %10"UIntfmt" (%8"UIntfmt" bytes)\n" " TSINs: %10"UIntfmt" (%8"UIntfmt" bytes)\n", maximum_answer_list_nodes(), maximum_answer_list_nodes() * NodeStats_NodeSize(aln), maximum_timestamp_index_nodes(), maximum_timestamp_index_nodes() * NodeStats_NodeSize(tsi)); } printf("\n"); }
void total_stat(CTXTdeclc double elapstime) { NodeStats tbtn, /* Table Basic Trie Nodes */ abtn, /* Asserted Basic Trie Nodes */ tstn, /* Time Stamp Trie Nodes */ aln, /* Answer List Nodes */ tsi, /* Time Stamp Indices (Index Entries/Nodes) */ varsf, /* Variant Subgoal Frames */ prodsf, /* Subsumptive Producer Subgoal Frames */ conssf, /* Subsumptive Consumer Subgoal Frames */ asi, /* Answer Subst Info for conditional answers */ tot_Key, /* Keys used in incremental tabling */ tot_CallNode, tot_OutEdge, tot_CallList, tot_Call2List; HashStats tbtht, /* Table Basic Trie Hash Tables */ abtht, /* Asserted Basic Trie Hash Tables */ tstht; /* Time Stamp Trie Hash Tables */ size_t pnde_space_alloc, pnde_space_used, num_de_blocks, num_dl_blocks, num_pnde_blocks, i; UInteger de_count, dl_count, de_space_alloc, de_space_used, total_alloc, total_used, dl_space_alloc, dl_space_used, tablespace_sm_alloc, tablespace_sm_used, tablespace_sm_free, pspacetot, incr_tablespace_sm_alloc, // incr_tablespace_sm_used, trieassert_alloc, trieassert_used, tc_avail, gl_avail; UInteger total_table_space; int clref_count = 0; int predref_count = 0; abtn = node_statistics(&smAssertBTN); abtht = hash_statistics(CTXTc &smAssertBTHT); trieassert_alloc = NodeStats_SizeAllocNodes(abtn) + HashStats_SizeAllocTotal(abtht); trieassert_used = NodeStats_SizeUsedNodes(abtn) + HashStats_SizeUsedTotal(abtht); de_space_alloc = allocated_de_space(current_de_block_gl,&num_de_blocks); de_space_used = de_space_alloc - unused_de_space(); de_count = (de_space_used - num_de_blocks * sizeof(Cell)) / sizeof(struct delay_element); dl_space_alloc = allocated_dl_space(current_dl_block_gl,&num_dl_blocks); dl_space_used = dl_space_alloc - unused_dl_space(); dl_count = (dl_space_used - num_dl_blocks * sizeof(Cell)) / sizeof(struct delay_list); pnde_space_alloc = allocated_pnde_space(current_pnde_block_gl,&num_pnde_blocks); pnde_space_used = pnde_space_alloc - unused_pnde_space(); #ifdef DETAILED_STATISTICS tbtn = node_statistics(&smTableBTN); tbtht = hash_statistics(CTXTc &smTableBTHT); varsf = subgoal_statistics(CTXTc &smVarSF); prodsf = subgoal_statistics(CTXTc &smProdSF); conssf = subgoal_statistics(CTXTc &smConsSF); aln = node_statistics(&smALN); tstn = node_statistics(&smTSTN); tstht = hash_statistics(CTXTc &smTSTHT); tsi = node_statistics(&smTSIN); asi = node_statistics(&smASI); tablespace_sm_alloc = CurrentTotalTableSpaceAlloc(tbtn,tbtht,varsf,prodsf,conssf,aln,tstn,tstht,tsi,asi); tablespace_sm_used = CurrentTotalTableSpaceUsed(tbtn,tbtht,varsf,prodsf, conssf,aln,tstn,tstht,tsi,asi); tot_CallNode = node_statistics(&smCallNode); tot_OutEdge = node_statistics(&smOutEdge); tot_CallList = node_statistics(&smCallList); tot_Call2List = node_statistics(&smCall2List); tot_Key = node_statistics(&smKey); incr_tablespace_sm_alloc = CurrentTotalIncrTableSpaceAlloc(tot_CallNode,tot_OutEdge,tot_CallList,tot_Call2List,tot_Key); // incr_tablespace_sm_used = CurrentTotalIncrTableSpaceUsed(tot_CallNode,tot_OutEdge,tot_CallList,tot_Call2List,tot_Key); tablespace_sm_alloc = tablespace_sm_alloc + de_space_alloc + dl_space_alloc + pnde_space_alloc; tablespace_sm_used = tablespace_sm_used + de_space_used + dl_space_used + pnde_space_used; tablespace_sm_free = tablespace_sm_alloc - tablespace_sm_used; #endif /* DETAILED_STATISTICS */ gl_avail = (top_of_localstk - top_of_heap - 1) * sizeof(Cell); tc_avail = (top_of_cpstack - (CPtr)top_of_trail - 1) * sizeof(Cell); pspacetot = 0; for (i=0; i<NUM_CATS_SPACE; i++) if (i != TABLE_SPACE && i != INCR_TABLE_SPACE) pspacetot += pspacesize[i]; total_table_space = pspacesize[TABLE_SPACE]+(pspacesize[INCR_TABLE_SPACE]-trieassert_alloc) +de_space_alloc+dl_space_alloc+pnde_space_alloc; total_alloc = pspacetot + total_table_space + trieassert_alloc + (pdl.size + glstack.size + tcpstack.size + complstack.size) * K ; total_used = pspacetot + total_table_space + trieassert_used - tablespace_sm_free + ((UInteger) ((size_t)(pdlreg+1) - (size_t)pdl.high) + glstack.size*K - gl_avail) + (tcpstack.size * K - tc_avail + complstack.size) ; printf("\n"); // printf("Memory (total) " NIntfmt Intfmt " bytes: %'15" Intfmt " in use, %'15" Intfmt " free\n", printf("Memory (total) " NLoc15Int " bytes: " NLoc15Int " in use, " NLoc15Int " free\n", total_alloc, total_used, total_alloc - total_used); printf(" permanent space " NLoc15Int " bytes: " NLoc15Int " in use, " NLoc15Int " free\n", pspacetot + trieassert_alloc, pspacetot + trieassert_used, trieassert_alloc - trieassert_used); if (trieassert_alloc > 0) printf(" trie-asserted " NLoc15Int " in use, " NLoc15Int "\n", trieassert_used,trieassert_alloc-trieassert_used); for (i=0; i<NUM_CATS_SPACE; i++) if (pspacesize[i] > 0 && i != TABLE_SPACE && i != INCR_TABLE_SPACE) printf(" %s "NLoc15Int "\n",pspace_cat[i],pspacesize[i]); printf(" glob/loc space "NLoc15Int " bytes: "NLoc15Int " in use, "NLoc15Int " free\n", glstack.size * K, glstack.size * K - gl_avail, gl_avail); printf(" global " NLoc15Int "\n", (Integer)((top_of_heap - (CPtr)glstack.low + 1) * sizeof(Cell))); printf(" local " NLoc15Int "\n", (Integer)(((CPtr)glstack.high - top_of_localstk) * sizeof(Cell))); printf(" trail/cp space "NLoc15Int " bytes: " NLoc15Int " in use, " NLoc15Int " free\n", tcpstack.size * K, tcpstack.size * K - tc_avail, tc_avail); printf(" trail " NLoc15Int "\n", (Integer)((top_of_trail - (CPtr *)tcpstack.low + 1) * sizeof(CPtr))); printf(" choice point " NLoc15Int "\n", (Integer)(((CPtr)tcpstack.high - top_of_cpstack) * sizeof(Cell))); printf(" SLG unific. space "NLoc15Int " bytes: "NLoc15Int " in use, "NLoc15Int " free\n", (UInteger) pdl.size * K, (UInteger) ((size_t)(pdlreg+1) - (size_t)pdl.high), (UInteger) (pdl.size * K - ((size_t)(pdlreg+1)-(size_t)pdl.high))); printf(" SLG completion "NLoc15Int " bytes: "NLoc15Int " in use, "NLoc15Int " free\n", (UInteger)complstack.size * K, (UInteger)COMPLSTACKBOTTOM - (UInteger)top_of_complstk, (UInteger)complstack.size * K - (UInteger) ((size_t)COMPLSTACKBOTTOM - (size_t)top_of_complstk)); if (((size_t)COMPLSTACKBOTTOM - (size_t)top_of_complstk) > 0) { printf(" ("NLocInt " Incomplete table(s)", (UInteger) (((UInteger)COMPLSTACKBOTTOM - (UInteger)top_of_complstk)/(COMPLFRAMESIZE*WORD_SIZE))); printf(" in %d SCCs)",count_sccs(CTXT)); printf("\n"); } printf(" SLG table space "NLoc15Int " bytes: " NLoc15Int " in use, " NLoc15Int " free\n", total_table_space, total_table_space - tablespace_sm_free, tablespace_sm_free); if (pspacesize[INCR_TABLE_SPACE]) { printf(" Incr table space " NLoc15Int " allocated\n", pspacesize[INCR_TABLE_SPACE] + incr_tablespace_sm_alloc); printf(" Hash space " NLoc15Int " allocated\n",pspacesize[INCR_TABLE_SPACE]); #ifdef DETAILED_STATISTICS printf(" Callnode spc " NLoc15Int " bytes: " NLoc15Int " in use\n", NodeStats_SizeAllocNodes(tot_CallNode),NodeStats_SizeUsedNodes(tot_CallNode)); printf(" Outedge space " NLoc15Int " bytes: " NLoc15Int " in use\n", NodeStats_SizeAllocNodes(tot_OutEdge),NodeStats_SizeUsedNodes(tot_OutEdge)); printf(" CallList spc " NLoc15Int " bytes: " NLoc15Int " in use\n", NodeStats_SizeAllocNodes(tot_CallList),NodeStats_SizeUsedNodes(tot_CallList)); printf(" Call2List spc " NLoc15Int " bytes: " NLoc15Int " in use\n", NodeStats_SizeAllocNodes(tot_Call2List),NodeStats_SizeUsedNodes(tot_Call2List)); printf(" Key space " NLoc15Int " bytes: " NLoc15Int " in use\n", NodeStats_SizeAllocNodes(tot_Key),NodeStats_SizeUsedNodes(tot_Key)); #endif } printf("\n"); // printf(" Incr tab space %15" Intfmt " bytes: %15" Intfmt " in use, %15" Intfmt " free\n", // incr_tablespace_sm_alloc, incr_tablespace_sm_used, // incr_tablespace_sm_alloc-incr_tablespace_sm_used); //,tot_OutEdge,tot_CallList,tot_Call2List,tot_Key); // if (flags[MAX_USAGE]) { // /* Report Maximum Usages // --------------------- */ // update_maximum_tablespace_stats(&tbtn,&tbtht,&varsf,&prodsf,&conssf, // &aln,&tstn,&tstht,&tsi,&asi); // printf(" Maximum table space used: %'d" Intfmt " bytes\n", // maximum_total_tablespace_usage()); // printf("\n"); // } #if !defined(MULTI_THREAD) || defined(NON_OPT_COMPILE) printf("Tabling Operations\n"); printf(" "NLocUInt" subsumptive call check/insert ops: "NLocUInt" producers, "NLocUInt" variants,\n" " "NLocUInt" properly subsumed ("NLocUInt" table entries), "NLocUInt" used completed table.\n" " "NLocUInt" relevant answer ident ops. "NLocUInt" consumptions via answer list.\n", NumSubOps_CallCheckInsert, NumSubOps_ProducerCall, NumSubOps_VariantCall, NumSubOps_SubsumedCall, NumSubOps_SubsumedCallEntry, NumSubOps_CallToCompletedTable, NumSubOps_IdentifyRelevantAnswers, NumSubOps_AnswerConsumption); { UInteger ttl_ops = ans_chk_ins + NumSubOps_AnswerCheckInsert, ttl_ins = ans_inserts + NumSubOps_AnswerInsert; printf(" "NLocUInt " variant table call check/insert ops: \n",var_subg_chk_ins_gl); printf(" "NLocUInt " checks/inserts for tabled subgoals; "NLocUInt " checks/inserts for IDG leaf nodes \n", var_subg_chk_ins_gl-(dyn_incr_chk_ins_gl+2*incr_table_recomputations_gl),dyn_incr_chk_ins_gl); printf(" "NLocUInt " check/inserts for incremental recomputations\n", (UInteger) 2*incr_table_recomputations_gl); printf(" "NLocUInt " distinct variant subgoals\n",var_subg_inserts_gl); printf(" "NLocUInt" answer check/insert ops: "NLocUInt " unique inserts, "NLocUInt" redundant.\n", ttl_ops, ttl_ins, ttl_ops - ttl_ins); } if (de_count > 0) { printf(" "NLocInt " DEs in the tables (space: "NLocInt " bytes allocated, "NLocInt" in use)\n", de_count, de_space_alloc, de_space_used); printf(" "NLocInt " DLs in the tables (space: "NLocInt " bytes allocated, "NLocInt" in use)\n", dl_count, dl_space_alloc, dl_space_used); printf("\n"); } if (total_call_node_count_gl) { // printf(" Total number of IDG nodes created: %'d\n",total_call_node_count_gl); if (current_call_node_count_gl) { printf(" Currently "NLocint " IDG nodes, "NLocint " dependency edges\n", (long) current_call_node_count_gl,(long) current_call_edge_count_gl); } if (incr_table_recomputations_gl) { printf(" incremental table recomputations "NLocint "\n",(long) incr_table_recomputations_gl); } if (dyn_incr_chk_ins_gl) { printf(" "NLocInt " call check/insert ops for incr dyn IDG nodes; "NLocInt " unique goals\n", dyn_incr_chk_ins_gl,dyn_incr_inserts_gl); } } if (abol_subg_ctr == 1) printf(" 1 tabled subgoal explicitly abolished\n"); else if (abol_subg_ctr > 1) printf(" "NLocUInt " tabled subgoals explicitly abolished\n",abol_subg_ctr); if (abol_pred_ctr == 1) printf(" 1 tabled predicate explicitly abolished\n"); else if (abol_pred_ctr > 1) printf(" "NLocUInt " tabled predicates explicitly abolished\n",abol_pred_ctr); print_abolish_table_statistics(); #endif count_dynamic(&clref_count, &predref_count); printf("\n");printf(" Uncollected clauses %d predrefs %d\n",clref_count,predref_count); print_gc_statistics(); printf("Time: %.3f sec. cputime, %.3f sec. elapsetime\n", cputime_count_gl, elapstime); }
void get_memory_statistics_1(CTXTdeclc double elapstime, int type) { COMMON_MEMSTAT_DECLS; NodeStats tstn, /* Time Stamp Trie Nodes */ \ tsi, /* Time Stamp Indices (Index Entries/Nodes) */ \ prodsf, /* Subsumptive Producer Subgoal Frames */ \ conssf; /* Subsumptive Consumer Subgoal Frames */ \ HashStats tbtht, /* Table Basic Trie Hash Tables */ abtht, /* Asserted Basic Trie Hash Tables */ tstht; /* Time Stamp Trie Hash Tables */ size_t total_alloc, total_used, tablespace_sm_alloc, tablespace_sm_used, trieassert_alloc, trieassert_used, gl_avail, pnde_space_alloc, pnde_space_used, pspacetot; UInteger dl_space_alloc, dl_space_used, de_space_alloc, de_space_used, tc_avail; size_t num_de_blocks, num_dl_blocks, num_pnde_blocks,i; tbtn = node_statistics(&smTableBTN); tbtht = hash_statistics(CTXTc &smTableBTHT); varsf = subgoal_statistics(CTXTc &smVarSF); prodsf = subgoal_statistics(CTXTc &smProdSF); conssf = subgoal_statistics(CTXTc &smConsSF); aln = node_statistics(&smALN); tstn = node_statistics(&smTSTN); tstht = hash_statistics(CTXTc &smTSTHT); tsi = node_statistics(&smTSIN); asi = node_statistics(&smASI); tablespace_sm_alloc = CurrentTotalTableSpaceAlloc(tbtn,tbtht,varsf,prodsf,conssf,aln,tstn,tstht,tsi,asi); tablespace_sm_used = CurrentTotalTableSpaceUsed(tbtn,tbtht,varsf,prodsf,conssf,aln,tstn,tstht,tsi,asi); de_space_alloc = allocated_de_space(current_de_block_gl,&num_de_blocks); de_space_used = de_space_alloc - unused_de_space(); // de_count = (de_space_used - num_de_blocks * sizeof(Cell)) / sizeof(struct delay_element); dl_space_alloc = allocated_dl_space(current_dl_block_gl,&num_dl_blocks); dl_space_used = dl_space_alloc - unused_dl_space(); // dl_count = (dl_space_used - num_dl_blocks * sizeof(Cell)) / sizeof(struct delay_list); pnde_space_alloc = allocated_pnde_space(current_pnde_block_gl,&num_pnde_blocks); pnde_space_used = pnde_space_alloc - unused_pnde_space(); tablespace_sm_alloc = tablespace_sm_alloc + de_space_alloc + dl_space_alloc + pnde_space_alloc; tablespace_sm_used = tablespace_sm_used + de_space_used + dl_space_used + pnde_space_used; abtn = node_statistics(&smAssertBTN); abtht = hash_statistics(CTXTc &smAssertBTHT); trieassert_alloc = NodeStats_SizeAllocNodes(abtn) + HashStats_SizeAllocTotal(abtht); trieassert_used = NodeStats_SizeUsedNodes(abtn) + HashStats_SizeUsedTotal(abtht); gl_avail = (top_of_localstk - top_of_heap - 1) * sizeof(Cell); tc_avail = (top_of_cpstack - (CPtr)top_of_trail - 1) * sizeof(Cell); switch(type) { case TOTALMEMORY: { pspacetot = 0; for (i=0; i<NUM_CATS_SPACE; i++) if (i != TABLE_SPACE && i != INCR_TABLE_SPACE) pspacetot += pspacesize[i]; total_alloc = pspacetot + pspacesize[TABLE_SPACE] + pspacesize[INCR_TABLE_SPACE] + (pdl.size + glstack.size + tcpstack.size + complstack.size) * K + de_space_alloc + dl_space_alloc + pnde_space_alloc; total_used = pspacetot + pspacesize[TABLE_SPACE]-(tablespace_sm_alloc-tablespace_sm_used) - (trieassert_alloc - trieassert_used) + pspacesize[INCR_TABLE_SPACE] + (glstack.size * K - gl_avail) + (tcpstack.size * K - tc_avail) + de_space_used + dl_space_used; ctop_int(CTXTc 4, total_alloc); ctop_int(CTXTc 5, total_used); break; } case GLMEMORY: { ctop_int(CTXTc 4, glstack.size *K); ctop_int(CTXTc 5, (glstack.size * K - gl_avail)); break; } case TCMEMORY: { ctop_int(CTXTc 4, tcpstack.size * K); ctop_int(CTXTc 5, (tcpstack.size * K - tc_avail)); break; } case TABLESPACE: { ctop_int(CTXTc 4, tablespace_sm_alloc); ctop_int(CTXTc 5, tablespace_sm_used); break; } case TRIEASSERTMEM: { ctop_int(CTXTc 4, trieassert_alloc); ctop_int(CTXTc 5, trieassert_used); break; } case HEAPMEM: { ctop_int(CTXTc 4,(Integer)((top_of_heap - (CPtr)glstack.low + 1)* sizeof(Cell))); break; } case CPMEM: { ctop_int(CTXTc 4, (Integer)(((CPtr)tcpstack.high - top_of_cpstack) * sizeof(Cell))); break; } case TRAILMEM: { ctop_int(CTXTc 4, (Integer)((top_of_trail - (CPtr *)tcpstack.low + 1) * sizeof(CPtr))); break; } case LOCALMEM: { ctop_int(CTXTc 4, (Integer)(((CPtr)glstack.high - top_of_localstk) * sizeof(Cell))); break; } case OPENTABLECOUNT: { ctop_int(CTXTc 4, ((size_t)COMPLSTACKBOTTOM - (size_t)top_of_complstk) / sizeof(struct completion_stack_frame)); ctop_int(CTXTc 5, count_sccs(CTXT)); break; } case ATOMMEM: { ctop_int(CTXTc 4, pspacesize[ATOM_SPACE]); break; } } }
void total_stat(CTXTdeclc double elapstime) { NodeStats tbtn, /* Table Basic Trie Nodes */ abtn, /* Asserted Basic Trie Nodes */ tstn, /* Time Stamp Trie Nodes */ aln, /* Answer List Nodes */ tsi, /* Time Stamp Indices (Index Entries/Nodes) */ varsf, /* Variant Subgoal Frames */ prodsf, /* Subsumptive Producer Subgoal Frames */ conssf, /* Subsumptive Consumer Subgoal Frames */ asi; /* Answer Subst Info for conditional answers */ HashStats tbtht, /* Table Basic Trie Hash Tables */ abtht, /* Asserted Basic Trie Hash Tables */ tstht; /* Time Stamp Trie Hash Tables */ unsigned long total_alloc, total_used, tablespace_alloc, tablespace_used, trieassert_alloc, trieassert_used, gl_avail, tc_avail, de_space_alloc, de_space_used, dl_space_alloc, dl_space_used, pnde_space_alloc, pnde_space_used, pspacetot; int num_de_blocks, num_dl_blocks, num_pnde_blocks, de_count, dl_count, i; tbtn = node_statistics(&smTableBTN); tbtht = hash_statistics(&smTableBTHT); varsf = subgoal_statistics(CTXTc &smVarSF); prodsf = subgoal_statistics(CTXTc &smProdSF); conssf = subgoal_statistics(CTXTc &smConsSF); aln = node_statistics(&smALN); tstn = node_statistics(&smTSTN); tstht = hash_statistics(&smTSTHT); tsi = node_statistics(&smTSIN); asi = node_statistics(&smASI); tablespace_alloc = CurrentTotalTableSpaceAlloc(tbtn,tbtht,varsf,prodsf, conssf,aln,tstn,tstht,tsi,asi); tablespace_used = CurrentTotalTableSpaceUsed(tbtn,tbtht,varsf,prodsf, conssf,aln,tstn,tstht,tsi,asi); abtn = node_statistics(&smAssertBTN); abtht = hash_statistics(&smAssertBTHT); trieassert_alloc = NodeStats_SizeAllocNodes(abtn) + HashStats_SizeAllocTotal(abtht); trieassert_used = NodeStats_SizeUsedNodes(abtn) + HashStats_SizeUsedTotal(abtht); de_space_alloc = allocated_de_space(current_de_block_gl,&num_de_blocks); de_space_used = de_space_alloc - unused_de_space(); de_count = (de_space_used - num_de_blocks * sizeof(Cell)) / sizeof(struct delay_element); dl_space_alloc = allocated_dl_space(current_dl_block_gl,&num_dl_blocks); dl_space_used = dl_space_alloc - unused_dl_space(); dl_count = (dl_space_used - num_dl_blocks * sizeof(Cell)) / sizeof(struct delay_list); pnde_space_alloc = allocated_pnde_space(current_pnde_block_gl,&num_pnde_blocks); pnde_space_used = pnde_space_alloc - unused_pnde_space(); tablespace_alloc = tablespace_alloc + de_space_alloc + dl_space_alloc + pnde_space_alloc; tablespace_used = tablespace_used + de_space_used + dl_space_used + pnde_space_used; gl_avail = (top_of_localstk - top_of_heap - 1) * sizeof(Cell); tc_avail = (top_of_cpstack - (CPtr)top_of_trail - 1) * sizeof(Cell); pspacetot = 0; for (i=0; i<NUM_CATS_SPACE; i++) if (i != TABLE_SPACE && i != INCR_TABLE_SPACE) pspacetot += pspacesize[i]; total_alloc = pspacetot + pspacesize[TABLE_SPACE] + pspacesize[INCR_TABLE_SPACE] + (pdl.size + glstack.size + tcpstack.size + complstack.size) * K + de_space_alloc + dl_space_alloc + pnde_space_alloc; total_used = pspacetot + pspacesize[TABLE_SPACE]-(tablespace_alloc-tablespace_used) - (trieassert_alloc - trieassert_used) + pspacesize[INCR_TABLE_SPACE] + (glstack.size * K - gl_avail) + (tcpstack.size * K - tc_avail) + de_space_used + dl_space_used; printf("\n"); printf("Memory (total) %12ld bytes: %12ld in use, %12ld free\n", total_alloc, total_used, total_alloc - total_used); printf(" permanent space %12ld bytes: %12ld in use, %12ld free\n", pspacetot + trieassert_alloc, pspacetot + trieassert_used, trieassert_alloc - trieassert_used); if (trieassert_alloc > 0) printf(" trie-asserted %12ld %12ld\n", trieassert_used,trieassert_alloc-trieassert_used); for (i=0; i<NUM_CATS_SPACE; i++) if (pspacesize[i] > 0 && i != TABLE_SPACE && i != INCR_TABLE_SPACE) printf(" %s %12ld\n",pspace_cat[i],pspacesize[i]); printf(" glob/loc space %12ld bytes: %12ld in use, %12ld free\n", glstack.size * K, glstack.size * K - gl_avail, gl_avail); printf(" global %12ld bytes\n", (long)((top_of_heap - (CPtr)glstack.low + 1) * sizeof(Cell))); printf(" local %12ld bytes\n", (long)(((CPtr)glstack.high - top_of_localstk) * sizeof(Cell))); printf(" trail/cp space %12ld bytes: %12ld in use, %12ld free\n", tcpstack.size * K, tcpstack.size * K - tc_avail, tc_avail); printf(" trail %12ld bytes\n", (long)((top_of_trail - (CPtr *)tcpstack.low + 1) * sizeof(CPtr))); printf(" choice point %12ld bytes\n", (long)(((CPtr)tcpstack.high - top_of_cpstack) * sizeof(Cell))); printf(" SLG unific. space %10ld bytes: %12ld in use, %12ld free\n", pdl.size * K, (unsigned long)(pdlreg+1) - (unsigned long)pdl.high, pdl.size * K - ((unsigned long)(pdlreg+1)-(unsigned long)pdl.high)); printf(" SLG completion %12ld bytes: %12ld in use, %12ld free\n", (unsigned long)complstack.size * K, (unsigned long)COMPLSTACKBOTTOM - (unsigned long)top_of_complstk, (unsigned long)complstack.size * K - ((unsigned long)COMPLSTACKBOTTOM - (unsigned long)top_of_complstk)); if (pspacesize[INCR_TABLE_SPACE] > 0) printf(" Incr table space %12ld in use\n", pspacesize[INCR_TABLE_SPACE]); printf(" SLG table space %12ld bytes: %12ld in use, %12ld free\n", pspacesize[TABLE_SPACE]+pspacesize[INCR_TABLE_SPACE]-trieassert_alloc, pspacesize[TABLE_SPACE]+pspacesize[INCR_TABLE_SPACE]-trieassert_alloc- (tablespace_alloc-tablespace_used), tablespace_alloc - tablespace_used); printf("\n"); if (flags[TRACE_STA]) { /* Report Maximum Usages --------------------- */ printf(" Maximum stack used: global %ld, local %ld, trail %ld, cp %ld,\n", ttt.maxgstack_count, ttt.maxlstack_count, ttt.maxtrail_count, ttt.maxcpstack_count); printf(" SLG completion %ld (%ld subgoals)\n", ttt.maxopenstack_count, (ttt.maxopenstack_count/sizeof(struct completion_stack_frame))); update_maximum_tablespace_stats(&tbtn,&tbtht,&varsf,&prodsf,&conssf, &aln,&tstn,&tstht,&tsi,&asi); printf(" Maximum table space used: %ld bytes\n", maximum_total_tablespace_usage()); printf("\n"); } #if !defined(MULTI_THREAD) || defined(NON_OPT_COMPILE) printf("Tabling Operations\n"); printf(" %lu subsumptive call check/insert ops: %lu producers, %lu variants,\n" " %lu properly subsumed (%lu table entries), %lu used completed table.\n" " %lu relevant answer ident ops. %lu consumptions via answer list.\n", NumSubOps_CallCheckInsert, NumSubOps_ProducerCall, NumSubOps_VariantCall, NumSubOps_SubsumedCall, NumSubOps_SubsumedCallEntry, NumSubOps_CallToCompletedTable, NumSubOps_IdentifyRelevantAnswers, NumSubOps_AnswerConsumption); { unsigned long ttl_ops = ans_chk_ins + NumSubOps_AnswerCheckInsert, ttl_ins = ans_inserts + NumSubOps_AnswerInsert; printf(" %lu variant call check/insert ops: %lu producers, %lu variants.\n" " %lu answer check/insert ops: %lu unique inserts, %lu redundant.\n", subg_chk_ins, subg_inserts, subg_chk_ins - subg_inserts, ttl_ops, ttl_ins, ttl_ops - ttl_ins); } printf("\n"); if (de_count > 0) { printf(" %6d DEs in the tables (space: %5ld bytes allocated, %5ld in use)\n", de_count, de_space_alloc, de_space_used); printf(" %6d DLs in the tables (space: %5ld bytes allocated, %5ld in use)\n", dl_count, dl_space_alloc, dl_space_used); printf("\n"); } #endif #ifdef GC printf("\n"); print_gc_statistics(); #endif printf("Time: %.3f sec. cputime, %.3f sec. elapsetime\n", ttt.time_count, elapstime); }