<commit_before>/* 
* File:    papi_internal.h
* CVS:     $Id$
* Author:  <NAME>
*          <EMAIL>
* Mods:    dan terpstra
*          terpstra.utk.edu
* Mods:    <NAME>
*	   <EMAIL>
* Mods:    <your name here>
*          <your email address>
*/  

#ifdef DEBUG
/* add Win32 to the debug list */
#if (defined(sgi) && defined(mips)) || defined(_CRAYT3E) || (defined(__digital__) \
	|| defined(__osf__)) || (defined(sun) && defined(sparc)) || defined(_WIN32)
#define DBG(a) { extern int papi_debug; if (papi_debug) { fprintf(stderr,"DEBUG:%s:%d: ",__FILE__,__LINE__); fprintf a; } }
#else /* SV2,SV1 ? */
#define DBG(a) { extern int papi_debug; if (papi_debug) { fprintf(stderr,"DEBUG:%s:%s:%d: ",__FILE__,__FUNCTION__,__LINE__); fprintf a; } }
#endif
#else
#define DBG(a)
#endif

/* some members of structs and/or function parameters may or may not be
   necessary, but at this point, we have included anything that might 
   possibly be useful later, and will remove them as we progress */

/* Signal used for overflow delivery */

#ifdef ITIMER_REALPROF
#define PAPI_ITIMER ITIMER_REALPROF
#else
#define PAPI_ITIMER ITIMER_PROF
#endif
#define PAPI_SIGNAL SIGPROF
#define PAPI_ITIMER_MS 1

/* Mask which indicates the event is a preset- the presets will have 
   the high bit set to one, as the vendors probably won't use the 
   higher numbers for the native events */
/* This causes a problem for signed ints on 64 bit systems, since the
   'high bit' is no longer the high bit. An alternative is to AND
   with PRESET_AND_MASK instead of XOR with PRESET_MASK to isolate
   the event bits. */

#define PRESET_MASK 0x80000000
#define PRESET_AND_MASK 0x7FFFFFFF

/* Commands used to compute derived events */

#define NOT_DERIVED      0x0  /* Do nothing */
#define DERIVED_ADD      0x1  /* Add counters */
#define DERIVED_PS       0x2  /* Divide by the cycle counter and convert to seconds */
#define DERIVED_ADD_PS   0x4  /* Add 2 counters then divide by the cycle counter and xl8 to secs. */
#define DERIVED_CMPD     0x8  /* Event lives in operand index but takes 2 or more codes */
#define DERIVED_SUB      0x10 /* Sub all counters from counter with operand_index */

typedef struct _EventSetMultistartInfo {
  int num_runners;
  int *SharedDepth; } EventSetMultistartInfo_t;

typedef struct _EventSetDomainInfo {
  int domain; } EventSetDomainInfo_t;

typedef struct _EventSetGranularityInfo {
  int granularity; } EventSetGranularityInfo_t;

typedef struct _EventSetOverflowInfo {
  long_long deadline;
  int count;
  int threshold;
  int EventIndex;
  int EventCode;
  int flags;
  int timer_ms;
  PAPI_overflow_handler_t handler;
} EventSetOverflowInfo_t;

#if 0
typedef struct _EventSetInheritInfo {
  int inherit; } EventSetInheritInfo_t;
#endif

typedef struct _EventSetProfileInfo {
  PAPI_sprofil_t *prof;
  int count; /* Number of buffers */
  int flags;
} EventSetProfileInfo_t;

/* PAPI supports derived events that are made up of at most 2 counters. */

typedef struct _EventInfo {
  int code;          /* Preset or native code for this event as passed to PAPI_add_event() */
  unsigned int selector;      /* Counter select bits used in the lower level */
  int command;       /* Counter derivation command used in the lower level */
  int operand_index; /* Counter derivation data used in the lower level */
} EventInfo_t;

/* Multiplex definitions */

/* This contains only the information about an event that
 * would cause two events to be counted separately.  Options
 * that don't affect an event aren't included here.
 */

typedef struct _papi_info {
	int event_type;
	int domain;
	int granularity;
} PapiInfo;

typedef struct _masterevent {
        int uses;
        int active;
	int is_a_rate;
	int papi_event;
	PapiInfo pi;
        long_long count;
        long_long cycles;
	long_long handler_count;
 	long_long prev_total_c;
 	long_long count_estimate;
 	double rate_estimate;
	struct _threadlist * mythr;
        struct _masterevent * next;
} MasterEvent;

typedef struct _threadlist {
#ifdef PTHREADS
	pthread_t thr;
#else
        pid_t pid;
#endif
        /* Total cycles for this thread */
	long_long total_c;
        /* Pointer to event in use */
	MasterEvent * cur_event;
        /* List of multiplexing events for this thread */
	MasterEvent * head;
        /* Pointer to next thread */
	struct _threadlist * next;
} Threadlist;

/* Structure contained in the EventSet structure that
   holds information about multiplexing. */

typedef enum { MPX_STOPPED, MPX_RUNNING } MPX_status;

typedef struct _MPX_EventSet {
	MPX_status status;
        /* Pointer to this thread's structure */
	struct _threadlist * mythr;
        /* Pointers to this EventSet's MPX entries in the master list for this thread */
	struct _masterevent *(mev[PAPI_MPX_DEF_DEG]);
        /* Number of entries in above list */
	int	num_events;
        /* Not sure... */
	long_long start_c, stop_c;
	long_long start_values[PAPI_MPX_DEF_DEG];
	long_long start_cycles[PAPI_MPX_DEF_DEG];
	long_long stop_values[PAPI_MPX_DEF_DEG];
	long_long stop_cycles[PAPI_MPX_DEF_DEG];
	long_long start_hc[PAPI_MPX_DEF_DEG];
	long_long stop_hc[PAPI_MPX_DEF_DEG];
} MPX_EventSet;

typedef MPX_EventSet * EventSetMultiplexInfo_t;

typedef struct _EventSetInfo {
  unsigned long int tid;       /* Thread ID, only used if PAPI_thread_init() is called  */

  int EventSetIndex;       /* Index of the EventSet in the array  */

  int NumberOfEvents;    /* Number of counters added to EventSet */

  void *machdep;      /* A pointer to memory of size 
                         _papi_system_info.size_machdep bytes. This 
                         will contain the encoding necessary for the 
                         hardware to set the counters to the appropriate
                         conditions*/

  long_long *hw_start;   /* Array of length _papi_system_info.num_cntrs that contains
			    unprocessed, out of order, long_long counter registers */

  long_long *sw_stop;    /* Array of length ESI->NumberOfCounters that contains
			    processed, in order, PAPI counter values when used or stopped */

  /* long_long *latest;   Array of the same length as above, containing 
				  the values of the counters when last read */ 

  int state;          /* The state of this entire EventSet; can be
			 PAPI_RUNNING or PAPI_STOPPED plus flags */

  EventInfo_t *EventInfoArray;   /* This array contains the mapping from 
                                  events added into the API into hardware 
                                  specific encoding as returned by the 
                                  kernel or the code that directly 
                                  accesses the counters. */

  EventSetMultistartInfo_t multistart;

  EventSetDomainInfo_t domain;
<commit_msg>Change to EventSetInfo structure needed for alpha-dadd<commit_after>/* 
* File:    papi_internal.h
* CVS:     $Id$
* Author:  <NAME>
*          <EMAIL>
* Mods:    dan terpstra
*          terpstra.utk.edu
* Mods:    <NAME>
*	   <EMAIL>
* Mods:    <your name here>
*          <your email address>
*/  

#ifdef DEBUG
/* add Win32 to the debug list */
#if (defined(sgi) && defined(mips)) || defined(_CRAYT3E) || (defined(__digital__) \
	|| defined(__osf__)) || (defined(sun) && defined(sparc)) || defined(_WIN32)
#define DBG(a) { extern int papi_debug; if (papi_debug) { fprintf(stderr,"DEBUG:%s:%d: ",__FILE__,__LINE__); fprintf a; } }
#else /* SV2,SV1 ? */
#define DBG(a) { extern int papi_debug; if (papi_debug) { fprintf(stderr,"DEBUG:%s:%s:%d: ",__FILE__,__FUNCTION__,__LINE__); fprintf a; } }
#endif
#else
#define DBG(a)
#endif

/* some members of structs and/or function parameters may or may not be
   necessary, but at this point, we have included anything that might 
   possibly be useful later, and will remove them as we progress */

/* Signal used for overflow delivery */

#ifdef ITIMER_REALPROF
#define PAPI_ITIMER ITIMER_REALPROF
#else
#define PAPI_ITIMER ITIMER_PROF
#endif
#define PAPI_SIGNAL SIGPROF
#define PAPI_ITIMER_MS 1

/* Mask which indicates the event is a preset- the presets will have 
   the high bit set to one, as the vendors probably won't use the 
   higher numbers for the native events */
/* This causes a problem for signed ints on 64 bit systems, since the
   'high bit' is no longer the high bit. An alternative is to AND
   with PRESET_AND_MASK instead of XOR with PRESET_MASK to isolate
   the event bits. */

#define PRESET_MASK 0x80000000
#define PRESET_AND_MASK 0x7FFFFFFF

/* Commands used to compute derived events */

#define NOT_DERIVED      0x0  /* Do nothing */
#define DERIVED_ADD      0x1  /* Add counters */
#define DERIVED_PS       0x2  /* Divide by the cycle counter and convert to seconds */
#define DERIVED_ADD_PS   0x4  /* Add 2 counters then divide by the cycle counter and xl8 to secs. */
#define DERIVED_CMPD     0x8  /* Event lives in operand index but takes 2 or more codes */
#define DERIVED_SUB      0x10 /* Sub all counters from counter with operand_index */

typedef struct _EventSetMultistartInfo {
  int num_runners;
  int *SharedDepth; } EventSetMultistartInfo_t;

typedef struct _EventSetDomainInfo {
  int domain; } EventSetDomainInfo_t;

typedef struct _EventSetGranularityInfo {
  int granularity; } EventSetGranularityInfo_t;

typedef struct _EventSetOverflowInfo {
  long_long deadline;
  int count;
  int threshold;
  int EventIndex;
  int EventCode;
  int flags;
  int timer_ms;
  PAPI_overflow_handler_t handler;
} EventSetOverflowInfo_t;

#if 0
typedef struct _EventSetInheritInfo {
  int inherit; } EventSetInheritInfo_t;
#endif

typedef struct _EventSetProfileInfo {
  PAPI_sprofil_t *prof;
  int count; /* Number of buffers */
  int flags;
} EventSetProfileInfo_t;

/* PAPI supports derived events that are made up of at most 2 counters. */

typedef struct _EventInfo {
  int code;          /* Preset or native code for this event as passed to PAPI_add_event() */
  unsigned int selector;      /* Counter select bits used in the lower level */
  int command;       /* Counter derivation command used in the lower level */
  int operand_index; /* Counter derivation data used in the lower level */
} EventInfo_t;

/* Multiplex definitions */

/* This contains only the information about an event that
 * would cause two events to be counted separately.  Options
 * that don't affect an event aren't included here.
 */

typedef struct _papi_info {
	int event_type;
	int domain;
	int granularity;
} PapiInfo;

typedef struct _masterevent {
        int uses;
        int active;
	int is_a_rate;
	int papi_event;
	PapiInfo pi;
        long_long count;
        long_long cycles;
	long_long handler_count;
 	long_long prev_total_c;
 	long_long count_estimate;
 	double rate_estimate;
	struct _threadlist * mythr;
        struct _masterevent * next;
} MasterEvent;

typedef struct _threadlist {
#ifdef PTHREADS
	pthread_t thr;
#else
        pid_t pid;
#endif
        /* Total cycles for this thread */
	long_long total_c;
        /* Pointer to event in use */
	MasterEvent * cur_event;
        /* List of multiplexing events for this thread */
	MasterEvent * head;
        /* Pointer to next thread */
	struct _threadlist * next;
} Threadlist;

/* Structure contained in the EventSet structure that
   holds information about multiplexing. */

typedef enum { MPX_STOPPED, MPX_RUNNING } MPX_status;

typedef struct _MPX_EventSet {
	MPX_status status;
        /* Pointer to this thread's structure */
	struct _threadlist * mythr;
        /* Pointers to this EventSet's MPX entries in the master list for this thread */
	struct _masterevent *(mev[PAPI_MPX_DEF_DEG]);
        /* Number of entries in above list */
	int	num_events;
        /* Not sure... */
	long_long start_c, stop_c;
	long_long start_values[PAPI_MPX_DEF_DEG];
	long_long start_cycles[PAPI_MPX_DEF_DEG];
	long_long stop_values[PAPI_MPX_DEF_DEG];
	long_long stop_cycles[PAPI_MPX_DEF_DEG];
	long_long start_hc[PAPI_MPX_DEF_DEG];
	long_long stop_hc[PAPI_MPX_DEF_DEG];
} MPX_EventSet;

typedef MPX_EventSet * EventSetMultiplexInfo_t;

typedef struct _EventSetInfo {
  unsigned long int tid;       /* Thread ID, only used if PAPI_thread_init() is called  */

  int EventSetIndex;       /* Index of the EventSet in the array  */

  int NumberOfEvents;    /* Number of counters added to EventSet */

  void *machdep;      /* A pointer to memory of size 
                         _papi_system_info.size_machdep bytes. This 
                         will contain the encoding necessary for the 
                         hardware to set the counters to the appropriate
                         conditions*/

  long_long *hw_start;   /* Array of length _papi_system_info.num_cntrs that contains
			    unprocessed, out of order, long_long counter registers */

  long_long *sw_stop;    /* Array of length ESI->NumberOfCounters that contains
			    processed, in order, PAPI counter values when used or stopped */

  long_long *latest;     /* Array of the same length as above, containing 
				  the values of the counters when last read */ 

  int state;          /* The state of this entire EventSet; can be
			 PAPI_RUNNING or PAPI_STOPPED plus flags */

  EventInfo_t *EventInfoArray;   /* This array contains the mapping from 
                                  events added into the API into hardware 
                                  specific encoding as returned by the 
                                  kernel or the code that directly 
                                  accesses the counters. */

  EventSetMultistartInfo_t multistart;

  EventSetDomainInfo_t domain;

{'fraction_non_alphanumeric': 0.07278224319740433, 'fraction_numerical': 0.005751788216208244, 'mean_word_length': 3.0800240673886883, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4470072', 'n_tokens_mistral': 4370, 'n_tokens_neox': 4143, 'n_words': 1474}