"I am a person who works hard and plays hard."

Yuan Wei
Second Year Graduate Student Department of Computer Science
University of Virginia Charlottesville, VA 22903
Email: yw3f@cs.virginia.edu


Source Code Analysis

Main Page   Compound List   File List   Compound Members   File Members  

ppopt.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include "../host.h"
#include "../misc.h"
#include "../machine.h"
#include "libcheetah.h"

Include dependency graph for ppopt.c:

Include dependency graph

Go to the source code of this file.

Compounds

Defines

Functions

Variables


Define Documentation

#define HASHNO   7211
 

Definition at line 15 of file ppopt.c.

Referenced by ft_hash(), and ft_hash_del().

#define LA_DIST   100000
 

Definition at line 14 of file ppopt.c.

Referenced by init_optpp(), optpp(), and term_optpp().

#define toggle      if(i==1)i=0;else{i=1;}
 

Definition at line 12 of file ppopt.c.


Function Documentation

int ft_hash md_addr_t    addr
 

Definition at line 76 of file ppopt.c.

References ft_hash_table::addr, fatal(), ft_slot, ft_slot_flag, HASHNO, LA_Get_from_free_list(), ft_hash_table::nxt, p_inum, and ft_hash_table::pt.

Referenced by optpp().

00077 {
00078   int loc;
00079   int prev_time = 0;
00080   struct ft_hash_table *ptr, *oldptr;
00081 
00082   loc = addr % HASHNO;
00083   if (ft_slot_flag[loc] == 0)
00084     {
00085       /* ++tot_addrs;*/
00086       ft_slot_flag[loc] = 1;
00087       ft_slot[loc].addr = addr;
00088       ft_slot[loc].nxt = NULL;
00089       ft_slot[loc].pt = p_inum;
00090       return -1;
00091     }
00092   else
00093     {
00094       ptr = &ft_slot[loc];
00095       while (ptr)
00096         {
00097           oldptr = ptr;
00098           if (ptr->addr == addr)
00099             break;
00100           ptr = ptr->nxt;
00101         }
00102       if (ptr)
00103         {
00104           prev_time = ptr->pt;
00105           ptr->pt = p_inum;
00106           return(prev_time);
00107         }
00108       else
00109         {
00110           /*++tot_addrs;*/
00111           if ((oldptr->nxt = LA_Get_from_free_list()) == NULL)
00112             {
00113               oldptr->nxt = calloc(1, sizeof(struct ft_hash_table));
00114               if (!oldptr->nxt)
00115                 fatal("out of virtual memory");
00116             }
00117           oldptr->nxt->addr = addr;
00118           oldptr->nxt->nxt = NULL;
00119           oldptr->nxt->pt = p_inum;
00120           return -1;
00121         }
00122     }
00123 }

void ft_hash_del md_addr_t    addr
 

Definition at line 138 of file ppopt.c.

References ft_hash_table::addr, ft_slot, ft_slot_flag, HASHNO, LA_Add_to_free_list(), ft_hash_table::nxt, and ft_hash_table::pt.

Referenced by gfsoptls(), and process_groups().

00139 {
00140   int loc;             /* Scratch variables */
00141   struct ft_hash_table *ptr, *oldptr;
00142 
00143   loc = addr % HASHNO;
00144   if (ft_slot_flag[loc] == 0)
00145     printf ("Error: addr not found in hash_table\n");
00146   else if (ft_slot[loc].addr == addr)
00147     {
00148       if (ft_slot[loc].nxt == NULL)
00149         ft_slot_flag[loc] = 0;
00150       else
00151         {
00152           ft_slot[loc].addr = ft_slot[loc].nxt->addr;
00153           ft_slot[loc].pt = ft_slot[loc].nxt->pt;
00154           ptr = ft_slot[loc].nxt;
00155           ft_slot[loc].nxt = ft_slot[loc].nxt->nxt;
00156           LA_Add_to_free_list(ptr);
00157         }
00158     }
00159   else
00160     {
00161       ptr = &ft_slot[loc];
00162       while (ptr)
00163         {
00164           if (ptr->addr == addr)
00165             break;
00166           oldptr = ptr;
00167           ptr = ptr->nxt;
00168         }
00169       if (ptr)
00170         {
00171           oldptr->nxt = ptr->nxt;
00172           LA_Add_to_free_list(ptr);
00173         }
00174       else
00175         printf("Error: addr not found in hash_table\n");
00176     }
00177 }

void init_optpp void   
 

Definition at line 198 of file ppopt.c.

References base, LA_DIST, and la_limit.

Referenced by cheetah_init().

00199 {
00200   la_limit = 2*LA_DIST;
00201   base = 0;
00202 }

void LA_Add_to_free_list struct ft_hash_table   free_ptr
 

Definition at line 42 of file ppopt.c.

References ft_hash_table::nxt.

Referenced by ft_hash_del().

00043 {
00044   free_ptr->nxt = head_free_list;
00045   head_free_list = free_ptr;
00046 }

struct ft_hash_table* LA_Get_from_free_list void   
 

Definition at line 50 of file ppopt.c.

References ft_hash_table::nxt.

Referenced by ft_hash().

00051 {
00052   struct ft_hash_table *free_ptr;
00053 
00054   if (head_free_list == NULL)
00055     return NULL;
00056   else
00057     {
00058       free_ptr = head_free_list;
00059       head_free_list = head_free_list->nxt;
00060       return free_ptr;
00061     }
00062 }

void optpp md_addr_t    addr,
int    L,
int(*    stack_proc)(int start, int end),
void(*    inf_handler)(md_addr_t addr, int cur_time)
 

Definition at line 205 of file ppopt.c.

References addr_array, base, end, ft_hash(), LA_DIST, la_limit, oe_flag, p_inum, start, time_array, and toggle.

Referenced by cheetah_access().

00208 {
00209   int prev_time, sf;
00210 
00211   if (p_inum > la_limit-1)
00212     {
00213       start = (la_limit % (2*LA_DIST));
00214       end = start + LA_DIST;
00215       if ((sf = (*stack_proc)(start, end))  == 1)
00216         return;
00217       la_limit += LA_DIST;
00218       toggle(oe_flag);          
00219       if (oe_flag)
00220         base += 2*LA_DIST;
00221     }
00222   addr >>= L;
00223   addr_array[(p_inum - base) % (2*LA_DIST)] = addr;
00224   if ((prev_time = ft_hash(addr)) >= 0)
00225     {
00226       if ((la_limit - prev_time) <= 2*LA_DIST)
00227         time_array[(prev_time - base) % (2*LA_DIST)] = p_inum;
00228       else
00229         (*inf_handler)(addr, p_inum);
00230     }
00231   else
00232     (*inf_handler)(addr, p_inum);
00233   ++p_inum;
00234 }

void term_optpp int(*    stack_proc)()
 

Definition at line 239 of file ppopt.c.

References base, end, LA_DIST, la_limit, oe_flag, p_inum, start, and toggle.

Referenced by cheetah_stats().

00240 {
00241   start = la_limit % (2*LA_DIST);
00242   end = start + LA_DIST;
00243   if (p_inum < LA_DIST)
00244     end = p_inum; /* For small traces */
00245   (*stack_proc)(start, end);
00246   if (p_inum >= LA_DIST)
00247     {
00248       toggle(oe_flag);
00249       if (oe_flag)
00250         base += 2*LA_DIST;
00251       la_limit += LA_DIST;
00252       start = la_limit % (2*LA_DIST);
00253       end = start + (((p_inum % LA_DIST) == 0) ? LA_DIST : (p_inum % LA_DIST));
00254       (*stack_proc)(start, end);
00255     }
00256 }


Variable Documentation

unsigned addr_array[2*LA_DIST]
 

Definition at line 25 of file ppopt.c.

Referenced by optpp(), and stack_proc_sa().

int base [static]
 

Definition at line 28 of file ppopt.c.

Referenced by init_optpp(), optpp(), and term_optpp().

int end [static]
 

Definition at line 195 of file ppopt.c.

Referenced by optpp(), and term_optpp().

struct ft_hash_table ft_slot[HASHNO]
 

Referenced by ft_hash(), and ft_hash_del().

short ft_slot_flag[HASHNO]
 

Definition at line 23 of file ppopt.c.

Referenced by ft_hash(), and ft_hash_del().

struct ft_hash_table* head_free_list [static]
 

Definition at line 39 of file ppopt.c.

int la_limit [static]
 

Definition at line 28 of file ppopt.c.

Referenced by init_optpp(), optpp(), and term_optpp().

int oe_flag = 1 [static]
 

Definition at line 30 of file ppopt.c.

Referenced by optpp(), and term_optpp().

int p_inum [static]
 

Definition at line 32 of file ppopt.c.

Referenced by ft_hash(), optpp(), and term_optpp().

int start [static]
 

Definition at line 195 of file ppopt.c.

Referenced by optpp(), and term_optpp().

unsigned time_array[2*LA_DIST]
 

Definition at line 25 of file ppopt.c.

Referenced by optpp(), Priority_sa(), and stack_proc_sa().



UVa CS Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214