1 /* Converted to D from papi.h by htod */
2 
3 module testquark.papi;
4 
5 extern(C):
6 @nogc:
7 
8 
9 
10 
11 //#include <sys/types.h>
12 import core.sys.posix.sys.types;
13 //#include <limits.h>
14 import core.stdc.limits;
15 //C     #include "papiStdEventDefs.h"
16 import testquark.papiStdEventDefs;
17 
18 /* Converted to D from papi.h by htod */
19 
20 /****************************/
21 /* THIS IS OPEN SOURCE CODE */
22 /****************************/
23 
24 /** 
25 * @file    papi.h
26 *
27 * @author  Philip Mucci
28 *          mucci@cs.utk.edu
29 * @author  dan terpstra
30 *          terpstra@cs.utk.edu
31 * @author  Haihang You
32 *	       you@cs.utk.edu
33 * @author  Kevin London
34 *	       london@cs.utk.edu
35 * @author  Maynard Johnson
36 *          maynardj@us.ibm.com
37 *
38 * @brief Return codes and api definitions.
39 */
40 
41 
42 
43 /**
44  * @mainpage PAPI
45  *  
46  * @section papi_intro Introduction
47  * The PAPI Performance Application Programming Interface provides machine and 
48  * operating system independent access to hardware performance counters found 
49  * on most modern processors. 
50  * Any of over 100 preset events can be counted through either a simple high 
51  * level programming interface or a more complete low level interface from 
52  * either C or Fortran. 
53  * A list of the function calls in these interfaces is given below, 
54  * with references to other pages for more complete details. 
55  *
56  * @section papi_high_api High Level Functions
57  * A simple interface for instrumenting end-user applications. 
58  * Fully supported on both C and Fortran. 
59  * See individual functions for details on usage.
60  * 
61  *	@ref high_api
62  * 
63  * Note that the high-level interface is self-initializing. 
64  * You can mix high and low level calls, but you @b must call either 
65  * @ref PAPI_library_init() or a high level routine before calling a low level routine.
66  *
67  * @section papi_low_api Low Level Functions
68  * Advanced interface for all applications and performance tools.
69  * Some functions may be implemented only for C or Fortran.
70  * See individual functions for details on usage and support.
71  * 
72  * @ref low_api
73  *
74  * @section papi_Fortran Fortran API
75  * The Fortran interface has some unique features and entry points.
76  * See individual functions for details.
77  * 
78  * @ref PAPIF
79  *
80  * @section Components 
81  *
82  *	Components provide access to hardware information on specific subsystems.
83  *
84  *	Components can be found under the conponents directory or @ref papi_components "here". 
85  *	and included in a build as an argument to configure, 
86  *	'--with-components=< comma_seperated_list_of_components_to_build >'
87  * 
88  * @section papi_util PAPI Utility Commands
89  * <ul> 
90  *		<li> @ref papi_avail - provides availability and detail information for PAPI preset events
91  *		<li> @ref papi_clockres - provides availability and detail information for PAPI preset events
92  *		<li> @ref papi_cost - provides availability and detail information for PAPI preset events
93  *		<li> @ref papi_command_line - executes PAPI preset or native events from the command line
94  *		<li> @ref papi_decode -	decodes PAPI preset events into a csv format suitable for 
95  *							PAPI_encode_events
96  *		<li> @ref papi_event_chooser -	given a list of named events, lists other events 
97  *										that can be counted with them
98  *		<li> @ref papi_mem_info -	provides information on the memory architecture 
99 									of the current processor
100  *		<li> @ref papi_native_avail - provides detailed information for PAPI native events 
101  * </ul>
102  * @see The PAPI Website http://icl.cs.utk.edu/papi
103  */
104 
105 /** \htmlonly
106   * @page CDI PAPI Component Development Interface
107   * @par \em Introduction
108   *		PAPI-C consists of a Framework and between 1 and 16 Components. 
109   *		The Framework is platform independent and exposes the PAPI API to end users. 
110   *		The Components provide access to hardware information on specific subsystems. 
111   *		By convention, Component 0 is always a CPU Component. 
112   *		This allows default behavior for legacy code, and provides a universal 
113   *		place to define system-wide operations and parameters, 
114   *		like clock rates and interrupt structures. 
115   *		Currently only a single CPU Component can exist at a time. 
116   *
117   * @par No CPU
118   *		In certain cases it can be desirable to use a generic CPU component for 
119   *		testing instrumentation or for operation on systems that don't provide 
120   *		the proper patches for accessing cpu counters. 
121   *		For such a case, the configure option: 
122   *	@code
123   *		configure --with-no-cpu-counters = yes
124   *	@endcode 
125   *	is provided to build PAPI with an "empty" cpu component.
126   *
127   *	@par Exposed Interface
128   *		A Component for PAPI-C typically consists of a single header file and a 
129   *		single (or small number of) source file(s). 
130   *		All of the information for a Component needed by PAPI-C is exposed through 
131   *		a single data structure that is declared and initialized at the bottom 
132   *		of the main source file. 
133   *		This structure, @ref papi_vector_t , is defined in @ref papi_vector.h .
134   *	
135   *	@par Compiling With an Existing Component 
136   *		Components provided with the PAPI source distribution all appear in the 
137   *		src/components directory. 
138   *		Each component exists in its own directory, named the same as the component itself. 
139   *		To include a component in a PAPI build, use the configure command line as shown:
140   *	
141   *	@code
142   *		configure --with-components="component list"
143   *	@endcode
144   *	
145   * Replace the "component list" argument with either the name of a specific 
146   *	component directory or multiple component names separated by spaces and 
147   *	enclosed in quotes as shown below:
148   *
149   *	\c configure --with-components="acpi lustre infiniband"
150   *
151   *	In some cases components themselves require additional configuration. 
152   *	In these cases an error message will be produced when you run @code make @endcode . 
153   *	To fix this, run the configure script found in the component directory.
154   * 
155   *	@par Adding a New Component 
156   *	The mechanics of adding a new component to the PAPI 4.1 build are relatively straight-forward.
157   *	Add a directory to the papi/src/components directory that is named with 
158   *	the base name of the component. 
159   *	This directory will contain the source files and build files for the new component. 
160   *	If configuration of the component is necessary, 
161   *	additional configure and make files will be needed. 
162   *	The /example directory can be cloned and renamed as a starting point. 
163   *	Other components can be used as examples. 
164   *	This is described in more detail in /components/README.
165   *
166   *	@par Developing a New Component 
167   *		A PAPI-C component generally consists of a header file and one or a 
168   *		small number of source files. 
169   *		The source file must contain a @ref papi_vector_t structure that 
170   *		exposes the internal data and entry points of the component to the PAPI-C Framework. 
171   *		This structure must have a unique name that is exposed externally and 
172   *		contains the name of the directory containing the component source code.
173   *
174   *	Three types of information are exposed in the @ref papi_vector_t structure:
175   *		Configuration parameters are contained in the @ref PAPI_component_info_t structure;
176   *		Sizes of opaque data structures necessary for memory management are in the @ref cmp_struct_sizes_t structure;
177   *		An array of function entry points which, if implemented, provide access to the functionality of the component.
178   *
179   *	If a function is not implemented in a given component its value in the structure can be left unset. 
180   *	In this case it will be initialized to NULL, and result (generally) in benign, although unproductive, behavior.
181   *
182   *	During the development of a component, functions can be implemented and tested in blocks. 
183   *	Further information about an appropriate order for developing these functions 
184   *	can be found in the Component Development Cookbook .
185   *
186   * @par PAPI-C Open Research Issues:
187   *	<ul>
188   *	<li> Support for non-standard data types: 
189   *		Currently PAPI supports returned data values expressed as unsigned 64-bit integers. 
190   *		This is appropriate for counting events, but may not be as appropriate 
191   *		for expressing other values. 
192   *		Examples of some other possible data types are shown below. 
193   *		Data type might be expressed as a flag in the event definition.
194   *	<li> Signed Integer
195   *		<ul>
196   *		<li>Float: 64-bit IEEE double precision
197   *		<li>Fixed Point: 32-bit integer and 32-bit fraction
198   *		<li>Ratios: 32 bit numerator and 32 bit denominator
199   *		</ul>
200   *	<li> Synchronization:
201   *		Components might report values with widely different time scales and 
202   *		remote measurements may be significantly skewed in time from local measurements. 
203   *		It would be desirable to have a mechanism to synchronize these values in time.
204   *	<li> Dynamic Component Discovery:
205   *		Components currently must be included statically in the PAPI library build. 
206   *		This minimizes startup disruption and time lag, particularly for large parallel systems. 
207   *		In some instances it would also be desirable to support a run-time 
208   *		discovery process for components, possibly by searching a specific 
209   *		location for dynamic libraries.
210   *	<li> Component Repository:
211   *		A small collection of components are currently maintained and 
212   *		supported inside the PAPI source distribution. 
213   *		It would be desirable to create a public component repository where 3rd 
214   *		parties could submit components for the use and benefit of the larger community.
215   *	<li> Multiple CPU Components:
216   *		With the rise in popularity of heterogeneous computing systems, it may 
217   *		become desirable to have more than one CPU component. 
218   *		Issues must then be resolved relating to which cpu time-base is used, 
219   *		how are interrupts handled, etc. 
220   *	</ul>
221   * \endhtmlonly
222   */
223 
224 /* Definition of PAPI_VERSION format.  Note that each of the four 
225  * components _must_ be less than 256.  Also, the PAPI_VER_CURRENT
226  * masks out the revision and increment.  Any revision change is supposed 
227  * to be binary compatible between the user application code and the 
228  * run-time library. Any modification that breaks this compatibility 
229  * _should_ modify the minor version number as to force user applications 
230  * to re-compile.
231  */
232 //C     #define PAPI_VERSION_NUMBER(maj,min,rev,inc) (((maj)<<24) | ((min)<<16) | ((rev)<<8) | (inc))
233 //C     #define PAPI_VERSION_MAJOR(x)   	(((x)>>24)    & 0xff)
234 //C     #define PAPI_VERSION_MINOR(x)		(((x)>>16)    & 0xff)
235 //C     #define PAPI_VERSION_REVISION(x)	(((x)>>8)     & 0xff)
236 //C     #define PAPI_VERSION_INCREMENT(x)((x)          & 0xff)
237 
238 /* This is the official PAPI version */
239 /* The final digit represents the patch count */
240 //C     #define PAPI_VERSION  			PAPI_VERSION_NUMBER(5,6,0,0)
241 //C     #define PAPI_VER_CURRENT 		(PAPI_VERSION & 0xffff0000)
242 
243   /* Tests for checking event code type */
244 //C     #define IS_NATIVE( EventCode ) ( ( EventCode & PAPI_NATIVE_MASK ) && !(EventCode & PAPI_PRESET_MASK) )
245 //C     #define IS_PRESET( EventCode ) ( ( EventCode & PAPI_PRESET_MASK ) && !(EventCode & PAPI_NATIVE_MASK) )
246 //C     #define IS_USER_DEFINED( EventCode ) ( ( EventCode & PAPI_PRESET_MASK ) && (EventCode & PAPI_NATIVE_MASK) )
247 
248 //C     #ifdef __cplusplus
249 //C     extern "C"
250 //C     {
251 //C     #endif
252 
253 /* Include files */
254 
255 
256 //C     #include "papiStdEventDefs.h"
257 
258 
259 /** \internal 
260 @defgroup ret_codes Return Codes
261 Return Codes
262 All of the functions contained in the PerfAPI return standardized error codes.
263 Values greater than or equal to zero indicate success, less than zero indicates
264 failure. 
265 @{
266 */
267 
268 //C     #define PAPI_OK          0     /**< No error */
269 //C     #define PAPI_EINVAL     -1     /**< Invalid argument */
270 const PAPI_OK = 0;
271 //C     #define PAPI_ENOMEM     -2     /**< Insufficient memory */
272 const PAPI_EINVAL = -1;
273 //C     #define PAPI_ESYS       -3     /**< A System/C library call failed */
274 const PAPI_ENOMEM = -2;
275 //C     #define PAPI_ECMP       -4     /**< Not supported by component */
276 const PAPI_ESYS = -3;
277 //C     #define PAPI_ESBSTR     -4     /**< Backwards compatibility */
278 const PAPI_ECMP = -4;
279 //C     #define PAPI_ECLOST     -5     /**< Access to the counters was lost or interrupted */
280 const PAPI_ESBSTR = -4;
281 //C     #define PAPI_EBUG       -6     /**< Internal error, please send mail to the developers */
282 const PAPI_ECLOST = -5;
283 //C     #define PAPI_ENOEVNT    -7     /**< Event does not exist */
284 const PAPI_EBUG = -6;
285 //C     #define PAPI_ECNFLCT    -8     /**< Event exists, but cannot be counted due to counter resource limitations */
286 const PAPI_ENOEVNT = -7;
287 //C     #define PAPI_ENOTRUN    -9     /**< EventSet is currently not running */
288 const PAPI_ECNFLCT = -8;
289 //C     #define PAPI_EISRUN     -10    /**< EventSet is currently counting */
290 const PAPI_ENOTRUN = -9;
291 //C     #define PAPI_ENOEVST    -11    /**< No such EventSet Available */
292 const PAPI_EISRUN = -10;
293 //C     #define PAPI_ENOTPRESET -12    /**< Event in argument is not a valid preset */
294 const PAPI_ENOEVST = -11;
295 //C     #define PAPI_ENOCNTR    -13    /**< Hardware does not support performance counters */
296 const PAPI_ENOTPRESET = -12;
297 //C     #define PAPI_EMISC      -14    /**< Unknown error code */
298 const PAPI_ENOCNTR = -13;
299 //C     #define PAPI_EPERM      -15    /**< Permission level does not permit operation */
300 const PAPI_EMISC = -14;
301 //C     #define PAPI_ENOINIT    -16    /**< PAPI hasn't been initialized yet */
302 const PAPI_EPERM = -15;
303 //C     #define PAPI_ENOCMP     -17    /**< Component Index isn't set */
304 const PAPI_ENOINIT = -16;
305 //C     #define PAPI_ENOSUPP    -18    /**< Not supported */
306 const PAPI_ENOCMP = -17;
307 //C     #define PAPI_ENOIMPL    -19    /**< Not implemented */
308 const PAPI_ENOSUPP = -18;
309 //C     #define PAPI_EBUF       -20    /**< Buffer size exceeded */
310 const PAPI_ENOIMPL = -19;
311 //C     #define PAPI_EINVAL_DOM -21    /**< EventSet domain is not supported for the operation */
312 const PAPI_EBUF = -20;
313 //C     #define PAPI_EATTR		-22    /**< Invalid or missing event attributes */
314 const PAPI_EINVAL_DOM = -21;
315 //C     #define PAPI_ECOUNT		-23    /**< Too many events or attributes */
316 const PAPI_EATTR = -22;
317 //C     #define PAPI_ECOMBO		-24    /**< Bad combination of features */
318 const PAPI_ECOUNT = -23;
319 //C     #define PAPI_NUM_ERRORS	 25    /**< Number of error messages specified in this API */
320 const PAPI_ECOMBO = -24;
321 
322 const PAPI_NUM_ERRORS = 25;
323 //C     #define PAPI_NOT_INITED		0
324 //C     #define PAPI_LOW_LEVEL_INITED 	1       /* Low level has called library init */
325 const PAPI_NOT_INITED = 0;
326 //C     #define PAPI_HIGH_LEVEL_INITED 	2       /* High level has called library init */
327 const PAPI_LOW_LEVEL_INITED = 1;
328 //C     #define PAPI_THREAD_LEVEL_INITED 4      /* Threads have been inited */
329 const PAPI_HIGH_LEVEL_INITED = 2;
330 /** @} */
331 const PAPI_THREAD_LEVEL_INITED = 4;
332 
333 /** @internal 
334 @defgroup consts Constants
335 All of the functions in the PerfAPI should use the following set of constants.
336 @{
337 */
338 
339 //C     #define PAPI_NULL       -1      /**<A nonexistent hardware event used as a placeholder */
340 
341 const PAPI_NULL = -1;
342 /** @internal  
343 	@defgroup domain_defns Domain definitions 
344  	@{ */
345 
346 //C     #define PAPI_DOM_USER    0x1    /**< User context counted */
347 //C     #define PAPI_DOM_MIN     PAPI_DOM_USER
348 const PAPI_DOM_USER = 0x1;
349 //C     #define PAPI_DOM_KERNEL	 0x2    /**< Kernel/OS context counted */
350 alias PAPI_DOM_USER PAPI_DOM_MIN;
351 //C     #define PAPI_DOM_OTHER	 0x4    /**< Exception/transient mode (like user TLB misses ) */
352 const PAPI_DOM_KERNEL = 0x2;
353 //C     #define PAPI_DOM_SUPERVISOR 0x8 /**< Supervisor/hypervisor context counted */
354 const PAPI_DOM_OTHER = 0x4;
355 //C     #define PAPI_DOM_ALL	 (PAPI_DOM_USER|PAPI_DOM_KERNEL|PAPI_DOM_OTHER|PAPI_DOM_SUPERVISOR) /**< All contexts counted */
356 const PAPI_DOM_SUPERVISOR = 0x8;
357 /* #define PAPI_DOM_DEFAULT PAPI_DOM_USER NOW DEFINED BY COMPONENT */
358 //C     #define PAPI_DOM_MAX     PAPI_DOM_ALL
359 //C     #define PAPI_DOM_HWSPEC  0x80000000     
360 /**< Flag that indicates we are not reading CPU like stuff.
361 alias PAPI_DOM_ALL PAPI_DOM_MAX;
362                                            The lower 31 bits can be decoded by the component into something
363                                            meaningful. i.e. SGI HUB counters */
364 /** @} */
365 const PAPI_DOM_HWSPEC = 0x80000000;
366 
367 /** @internal 
368  *	@defgroup thread_defns Thread Definitions 
369  *		We define other levels in papi_internal.h
370  *		for internal PAPI use, so if you change anything
371  *		make sure to look at both places -KSL
372  *	@{ */
373 //C     #define PAPI_USR1_TLS		0x0
374 //C     #define PAPI_USR2_TLS		0x1
375 const PAPI_USR1_TLS = 0x0;
376 //C     #define PAPI_HIGH_LEVEL_TLS     0x2
377 const PAPI_USR2_TLS = 0x1;
378 //C     #define PAPI_NUM_TLS		0x3
379 const PAPI_HIGH_LEVEL_TLS = 0x2;
380 //C     #define PAPI_TLS_USR1		PAPI_USR1_TLS
381 const PAPI_NUM_TLS = 0x3;
382 //C     #define PAPI_TLS_USR2		PAPI_USR2_TLS
383 alias PAPI_USR1_TLS PAPI_TLS_USR1;
384 //C     #define PAPI_TLS_HIGH_LEVEL     PAPI_HIGH_LEVEL_TLS
385 alias PAPI_USR2_TLS PAPI_TLS_USR2;
386 //C     #define PAPI_TLS_NUM		PAPI_NUM_TLS
387 alias PAPI_HIGH_LEVEL_TLS PAPI_TLS_HIGH_LEVEL;
388 //C     #define PAPI_TLS_ALL_THREADS	0x10
389 alias PAPI_NUM_TLS PAPI_TLS_NUM;
390 /** @} */
391 const PAPI_TLS_ALL_THREADS = 0x10;
392 
393 /** @internal 
394  *	@defgroup locking_defns Locking Mechanisms defines 
395  *	@{ */
396 //C     #define PAPI_USR1_LOCK          	0x0    /**< User controlled locks */
397 //C     #define PAPI_USR2_LOCK          	0x1    /**< User controlled locks */
398 const PAPI_USR1_LOCK = 0x0;
399 //C     #define PAPI_NUM_LOCK           	0x2    /**< Used with setting up array */
400 const PAPI_USR2_LOCK = 0x1;
401 //C     #define PAPI_LOCK_USR1          	PAPI_USR1_LOCK
402 const PAPI_NUM_LOCK = 0x2;
403 //C     #define PAPI_LOCK_USR2          	PAPI_USR2_LOCK
404 alias PAPI_USR1_LOCK PAPI_LOCK_USR1;
405 //C     #define PAPI_LOCK_NUM			PAPI_NUM_LOCK
406 alias PAPI_USR2_LOCK PAPI_LOCK_USR2;
407 /** @} */
408 alias PAPI_NUM_LOCK PAPI_LOCK_NUM;
409 
410 /* Remove this!  If it breaks userspace we might have to add it back :( */
411 /* #define PAPI_MPX_DEF_DEG 32			                        */
412 
413 /**	@internal 
414 	@defgroup papi_vendors  Vendor definitions 
415 	@{ */
416 //C     #define PAPI_VENDOR_UNKNOWN 0
417 //C     #define PAPI_VENDOR_INTEL   1
418 const PAPI_VENDOR_UNKNOWN = 0;
419 //C     #define PAPI_VENDOR_AMD     2
420 const PAPI_VENDOR_INTEL = 1;
421 //C     #define PAPI_VENDOR_IBM     3
422 const PAPI_VENDOR_AMD = 2;
423 //C     #define PAPI_VENDOR_CRAY    4
424 const PAPI_VENDOR_IBM = 3;
425 //C     #define PAPI_VENDOR_SUN     5
426 const PAPI_VENDOR_CRAY = 4;
427 //C     #define PAPI_VENDOR_FREESCALE 6
428 const PAPI_VENDOR_SUN = 5;
429 //C     #define PAPI_VENDOR_ARM     7
430 const PAPI_VENDOR_FREESCALE = 6;
431 //C     #define PAPI_VENDOR_MIPS    8
432 const PAPI_VENDOR_ARM = 7;
433 /** @} */
434 const PAPI_VENDOR_MIPS = 8;
435 
436 /** @internal 
437  *	@defgroup granularity_defns Granularity definitions 
438  *	@{ */
439 
440 //C     #define PAPI_GRN_THR     0x1    /**< PAPI counters for each individual thread */
441 //C     #define PAPI_GRN_MIN     PAPI_GRN_THR
442 const PAPI_GRN_THR = 0x1;
443 //C     #define PAPI_GRN_PROC    0x2    /**< PAPI counters for each individual process */
444 alias PAPI_GRN_THR PAPI_GRN_MIN;
445 //C     #define PAPI_GRN_PROCG   0x4    /**< PAPI counters for each individual process group */
446 const PAPI_GRN_PROC = 0x2;
447 //C     #define PAPI_GRN_SYS     0x8    /**< PAPI counters for the current CPU, are you bound? */
448 const PAPI_GRN_PROCG = 0x4;
449 //C     #define PAPI_GRN_SYS_CPU 0x10   /**< PAPI counters for all CPUs individually */
450 const PAPI_GRN_SYS = 0x8;
451 //C     #define PAPI_GRN_MAX     PAPI_GRN_SYS_CPU
452 const PAPI_GRN_SYS_CPU = 0x10;
453 /** @} */
454 alias PAPI_GRN_SYS_CPU PAPI_GRN_MAX;
455 
456 /** @internal 
457 	@defgroup evt_states States of an EventSet 
458 	@{ */
459 //C     #define PAPI_STOPPED      0x01  /**< EventSet stopped */
460 //C     #define PAPI_RUNNING      0x02  /**< EventSet running */
461 const PAPI_STOPPED = 0x01;
462 //C     #define PAPI_PAUSED       0x04  /**< EventSet temp. disabled by the library */
463 const PAPI_RUNNING = 0x02;
464 //C     #define PAPI_NOT_INIT     0x08  /**< EventSet defined, but not initialized */
465 const PAPI_PAUSED = 0x04;
466 //C     #define PAPI_OVERFLOWING  0x10  /**< EventSet has overflowing enabled */
467 const PAPI_NOT_INIT = 0x08;
468 //C     #define PAPI_PROFILING    0x20  /**< EventSet has profiling enabled */
469 const PAPI_OVERFLOWING = 0x10;
470 //C     #define PAPI_MULTIPLEXING 0x40  /**< EventSet has multiplexing enabled */
471 const PAPI_PROFILING = 0x20;
472 //C     #define PAPI_ATTACHED	  0x80  /**< EventSet is attached to another thread/process */
473 const PAPI_MULTIPLEXING = 0x40;
474 //C     #define PAPI_CPU_ATTACHED 0x100 /**< EventSet is attached to a specific cpu (not counting thread of execution) */
475 const PAPI_ATTACHED = 0x80;
476 /** @} */
477 const PAPI_CPU_ATTACHED = 0x100;
478 
479 /** @internal 
480 	@defgroup error_predef Error predefines 
481 	@{ */
482 //C     #define PAPI_QUIET       0      /**< Option to turn off automatic reporting of return codes < 0 to stderr. */
483 //C     #define PAPI_VERB_ECONT  1      /**< Option to automatically report any return codes < 0 to stderr and continue. */
484 const PAPI_QUIET = 0;
485 //C     #define PAPI_VERB_ESTOP  2      /**< Option to automatically report any return codes < 0 to stderr and exit. */
486 const PAPI_VERB_ECONT = 1;
487 /** @} */
488 const PAPI_VERB_ESTOP = 2;
489 
490 /** @internal 
491 	@defgroup profile_defns Profile definitions 
492 	@{ */
493 //C     #define PAPI_PROFIL_POSIX     0x0        /**< Default type of profiling, similar to 'man profil'. */
494 //C     #define PAPI_PROFIL_RANDOM    0x1        /**< Drop a random 25% of the samples. */
495 const PAPI_PROFIL_POSIX = 0x0;
496 //C     #define PAPI_PROFIL_WEIGHTED  0x2        /**< Weight the samples by their value. */
497 const PAPI_PROFIL_RANDOM = 0x1;
498 //C     #define PAPI_PROFIL_COMPRESS  0x4        /**< Ignore samples if hash buckets get big. */
499 const PAPI_PROFIL_WEIGHTED = 0x2;
500 //C     #define PAPI_PROFIL_BUCKET_16 0x8        /**< Use 16 bit buckets to accumulate profile info (default) */
501 const PAPI_PROFIL_COMPRESS = 0x4;
502 //C     #define PAPI_PROFIL_BUCKET_32 0x10       /**< Use 32 bit buckets to accumulate profile info */
503 const PAPI_PROFIL_BUCKET_16 = 0x8;
504 //C     #define PAPI_PROFIL_BUCKET_64 0x20       /**< Use 64 bit buckets to accumulate profile info */
505 const PAPI_PROFIL_BUCKET_32 = 0x10;
506 //C     #define PAPI_PROFIL_FORCE_SW  0x40       /**< Force Software overflow in profiling */
507 const PAPI_PROFIL_BUCKET_64 = 0x20;
508 //C     #define PAPI_PROFIL_DATA_EAR  0x80       /**< Use data address register profiling */
509 const PAPI_PROFIL_FORCE_SW = 0x40;
510 //C     #define PAPI_PROFIL_INST_EAR  0x100      /**< Use instruction address register profiling */
511 const PAPI_PROFIL_DATA_EAR = 0x80;
512 //C     #define PAPI_PROFIL_BUCKETS   (PAPI_PROFIL_BUCKET_16 | PAPI_PROFIL_BUCKET_32 | PAPI_PROFIL_BUCKET_64)
513 const PAPI_PROFIL_INST_EAR = 0x100;
514 /** @} */
515 
516 /* @defgroup overflow_defns Overflow definitions 
517    @{ */
518 //C     #define PAPI_OVERFLOW_FORCE_SW 0x40	/**< Force using Software */
519 //C     #define PAPI_OVERFLOW_HARDWARE 0x80	/**< Using Hardware */
520 const PAPI_OVERFLOW_FORCE_SW = 0x40;
521 /** @} */
522 const PAPI_OVERFLOW_HARDWARE = 0x80;
523 
524 /** @internal 
525   *	@defgroup mpx_defns Multiplex flags definitions 
526   * @{ */
527 //C     #define PAPI_MULTIPLEX_DEFAULT	0x0	/**< Use whatever method is available, prefer kernel of course. */
528 //C     #define PAPI_MULTIPLEX_FORCE_SW 0x1	/**< Force PAPI multiplexing instead of kernel */
529 const PAPI_MULTIPLEX_DEFAULT = 0x0;
530 /** @} */
531 const PAPI_MULTIPLEX_FORCE_SW = 0x1;
532 
533 /** @internal 
534 	@defgroup option_defns Option definitions 
535 	@{ */
536 //C     #define PAPI_INHERIT_ALL  1     /**< The flag to this to inherit all children's counters */
537 //C     #define PAPI_INHERIT_NONE 0     /**< The flag to this to inherit none of the children's counters */
538 const PAPI_INHERIT_ALL = 1;
539 
540 const PAPI_INHERIT_NONE = 0;
541 
542 //C     #define PAPI_DETACH			1		/**< Detach */
543 //C     #define PAPI_DEBUG          2       /**< Option to turn on  debugging features of the PAPI library */
544 const PAPI_DETACH = 1;
545 //C     #define PAPI_MULTIPLEX 		3       /**< Turn on/off or multiplexing for an eventset */
546 const PAPI_DEBUG = 2;
547 //C     #define PAPI_DEFDOM  		4       /**< Domain for all new eventsets. Takes non-NULL option pointer. */
548 const PAPI_MULTIPLEX = 3;
549 //C     #define PAPI_DOMAIN  		5       /**< Domain for an eventset */
550 const PAPI_DEFDOM = 4;
551 //C     #define PAPI_DEFGRN  		6       /**< Granularity for all new eventsets */
552 const PAPI_DOMAIN = 5;
553 //C     #define PAPI_GRANUL  		7       /**< Granularity for an eventset */
554 const PAPI_DEFGRN = 6;
555 //C     #define PAPI_DEF_MPX_NS     8       /**< Multiplexing/overflowing interval in ns, same as PAPI_DEF_ITIMER_NS */
556 const PAPI_GRANUL = 7;
557   //#define PAPI_EDGE_DETECT    9       /**< Count cycles of events if supported [not implemented] */
558 const PAPI_DEF_MPX_NS = 8;
559   //#define PAPI_INVERT         10		/**< Invert count detect if supported [not implemented] */
560 //C     #define PAPI_MAX_MPX_CTRS	11      /**< Maximum number of counters we can multiplex */
561 //C     #define PAPI_PROFIL  		12      /**< Option to turn on the overflow/profil reporting software [not implemented] */
562 const PAPI_MAX_MPX_CTRS = 11;
563 //C     #define PAPI_PRELOAD 		13      /**< Option to find out the environment variable that can preload libraries */
564 const PAPI_PROFIL = 12;
565 //C     #define PAPI_CLOCKRATE  	14      /**< Clock rate in MHz */
566 const PAPI_PRELOAD = 13;
567 //C     #define PAPI_MAX_HWCTRS 	15      /**< Number of physical hardware counters */
568 const PAPI_CLOCKRATE = 14;
569 //C     #define PAPI_HWINFO  		16      /**< Hardware information */
570 const PAPI_MAX_HWCTRS = 15;
571 //C     #define PAPI_EXEINFO  		17      /**< Executable information */
572 const PAPI_HWINFO = 16;
573 //C     #define PAPI_MAX_CPUS 		18      /**< Number of ncpus we can talk to from here */
574 const PAPI_EXEINFO = 17;
575 //C     #define PAPI_ATTACH			19      /**< Attach to a another tid/pid instead of ourself */
576 const PAPI_MAX_CPUS = 18;
577 //C     #define PAPI_SHLIBINFO      20      /**< Shared Library information */
578 const PAPI_ATTACH = 19;
579 //C     #define PAPI_LIB_VERSION    21      /**< Option to find out the complete version number of the PAPI library */
580 const PAPI_SHLIBINFO = 20;
581 //C     #define PAPI_COMPONENTINFO  22      /**< Find out what the component supports */
582 const PAPI_LIB_VERSION = 21;
583 /* Currently the following options are only available on Itanium; they may be supported elsewhere in the future */
584 const PAPI_COMPONENTINFO = 22;
585 //C     #define PAPI_DATA_ADDRESS   23      /**< Option to set data address range restriction */
586 //C     #define PAPI_INSTR_ADDRESS  24      /**< Option to set instruction address range restriction */
587 const PAPI_DATA_ADDRESS = 23;
588 //C     #define PAPI_DEF_ITIMER		25		/**< Option to set the type of itimer used in both software multiplexing, overflowing and profiling */
589 const PAPI_INSTR_ADDRESS = 24;
590 //C     #define PAPI_DEF_ITIMER_NS	26		/**< Multiplexing/overflowing interval in ns, same as PAPI_DEF_MPX_NS */
591 const PAPI_DEF_ITIMER = 25;
592 /* Currently the following options are only available on systems using the perf_events component within papi */
593 const PAPI_DEF_ITIMER_NS = 26;
594 //C     #define PAPI_CPU_ATTACH		27      /**< Specify a cpu number the event set should be tied to */
595 //C     #define PAPI_INHERIT		28      /**< Option to set counter inheritance flag */
596 const PAPI_CPU_ATTACH = 27;
597 //C     #define PAPI_USER_EVENTS_FILE 29	/**< Option to set file from where to parse user defined events */
598 const PAPI_INHERIT = 28;
599 
600 const PAPI_USER_EVENTS_FILE = 29;
601 //C     #define PAPI_INIT_SLOTS    64     
602 /*Number of initialized slots in
603                                    DynamicArray of EventSets */
604 
605 const PAPI_INIT_SLOTS = 64;
606 //C     #define PAPI_MIN_STR_LEN        64      /* For small strings, like names & stuff */
607 //C     #define PAPI_MAX_STR_LEN       128      /* For average run-of-the-mill strings */
608 const PAPI_MIN_STR_LEN = 64;
609 //C     #define PAPI_2MAX_STR_LEN      256      /* For somewhat longer run-of-the-mill strings */
610 const PAPI_MAX_STR_LEN = 128;
611 //C     #define PAPI_HUGE_STR_LEN     1024      /* This should be defined in terms of a system parameter */
612 const PAPI_2MAX_STR_LEN = 256;
613 
614 const PAPI_HUGE_STR_LEN = 1024;
615 //C     #define PAPI_PMU_MAX           40      /* maximum number of pmu's supported by one component */
616 //C     #define PAPI_DERIVED           0x1      /* Flag to indicate that the event is derived */
617 const PAPI_PMU_MAX = 40;
618 /** @} */
619 const PAPI_DERIVED = 0x1;
620 
621 /** Possible values for the 'modifier' parameter of the PAPI_enum_event call.
622    A value of 0 (PAPI_ENUM_EVENTS) is always assumed to enumerate ALL 
623    events on every platform.
624    PAPI PRESET events are broken into related event categories.
625    Each supported component can have optional values to determine how 
626    native events on that component are enumerated.
627 */
628 //C     enum {
629 //C        PAPI_ENUM_EVENTS = 0,		/**< Always enumerate all events */
630 //C        PAPI_ENUM_FIRST,				/**< Enumerate first event (preset or native) */
631 //C        PAPI_PRESET_ENUM_AVAIL, 		/**< Enumerate events that exist here */
632 
633    /* PAPI PRESET section */
634 //C        PAPI_PRESET_ENUM_MSC,		/**< Miscellaneous preset events */
635 //C        PAPI_PRESET_ENUM_INS,		/**< Instruction related preset events */
636 //C        PAPI_PRESET_ENUM_IDL,		/**< Stalled or Idle preset events */
637 //C        PAPI_PRESET_ENUM_BR,			/**< Branch related preset events */
638 //C        PAPI_PRESET_ENUM_CND,		/**< Conditional preset events */
639 //C        PAPI_PRESET_ENUM_MEM,		/**< Memory related preset events */
640 //C        PAPI_PRESET_ENUM_CACH,		/**< Cache related preset events */
641 //C        PAPI_PRESET_ENUM_L1,			/**< L1 cache related preset events */
642 //C        PAPI_PRESET_ENUM_L2,			/**< L2 cache related preset events */
643 //C        PAPI_PRESET_ENUM_L3,			/**< L3 cache related preset events */
644 //C        PAPI_PRESET_ENUM_TLB,		/**< Translation Lookaside Buffer events */
645 //C        PAPI_PRESET_ENUM_FP,			/**< Floating Point related preset events */
646 
647    /* PAPI native event related section */
648 //C        PAPI_NTV_ENUM_UMASKS,		/**< all individual bits for given group */
649 //C        PAPI_NTV_ENUM_UMASK_COMBOS,	/**< all combinations of mask bits for given group */
650 //C        PAPI_NTV_ENUM_IARR,			/**< Enumerate events that support IAR (instruction address ranging) */
651 //C        PAPI_NTV_ENUM_DARR,			/**< Enumerate events that support DAR (data address ranging) */
652 //C        PAPI_NTV_ENUM_OPCM,			/**< Enumerate events that support OPC (opcode matching) */
653 //C        PAPI_NTV_ENUM_IEAR,			/**< Enumerate IEAR (instruction event address register) events */
654 //C        PAPI_NTV_ENUM_DEAR,			/**< Enumerate DEAR (data event address register) events */
655 //C        PAPI_NTV_ENUM_GROUPS			/**< Enumerate groups an event belongs to (e.g. POWER5) */
656 //C     };
657 enum
658 {
659     PAPI_ENUM_EVENTS,
660     PAPI_ENUM_FIRST,
661     PAPI_PRESET_ENUM_AVAIL,
662     PAPI_PRESET_ENUM_MSC,
663     PAPI_PRESET_ENUM_INS,
664     PAPI_PRESET_ENUM_IDL,
665     PAPI_PRESET_ENUM_BR,
666     PAPI_PRESET_ENUM_CND,
667     PAPI_PRESET_ENUM_MEM,
668     PAPI_PRESET_ENUM_CACH,
669     PAPI_PRESET_ENUM_L1,
670     PAPI_PRESET_ENUM_L2,
671     PAPI_PRESET_ENUM_L3,
672     PAPI_PRESET_ENUM_TLB,
673     PAPI_PRESET_ENUM_FP,
674     PAPI_NTV_ENUM_UMASKS,
675     PAPI_NTV_ENUM_UMASK_COMBOS,
676     PAPI_NTV_ENUM_IARR,
677     PAPI_NTV_ENUM_DARR,
678     PAPI_NTV_ENUM_OPCM,
679     PAPI_NTV_ENUM_IEAR,
680     PAPI_NTV_ENUM_DEAR,
681     PAPI_NTV_ENUM_GROUPS,
682 }
683 
684 //C     #define PAPI_ENUM_ALL PAPI_ENUM_EVENTS
685 
686 alias PAPI_ENUM_EVENTS PAPI_ENUM_ALL;
687 //C     #define PAPI_PRESET_BIT_MSC		(1 << PAPI_PRESET_ENUM_MSC)	/* Miscellaneous preset event bit */
688 //C     #define PAPI_PRESET_BIT_INS		(1 << PAPI_PRESET_ENUM_INS)	/* Instruction related preset event bit */
689 //C     #define PAPI_PRESET_BIT_IDL		(1 << PAPI_PRESET_ENUM_IDL)	/* Stalled or Idle preset event bit */
690 //C     #define PAPI_PRESET_BIT_BR		(1 << PAPI_PRESET_ENUM_BR)	/* branch related preset events */
691 //C     #define PAPI_PRESET_BIT_CND		(1 << PAPI_PRESET_ENUM_CND)	/* conditional preset events */
692 //C     #define PAPI_PRESET_BIT_MEM		(1 << PAPI_PRESET_ENUM_MEM)	/* memory related preset events */
693 //C     #define PAPI_PRESET_BIT_CACH	(1 << PAPI_PRESET_ENUM_CACH)	/* cache related preset events */
694 //C     #define PAPI_PRESET_BIT_L1		(1 << PAPI_PRESET_ENUM_L1)	/* L1 cache related preset events */
695 //C     #define PAPI_PRESET_BIT_L2		(1 << PAPI_PRESET_ENUM_L2)	/* L2 cache related preset events */
696 //C     #define PAPI_PRESET_BIT_L3		(1 << PAPI_PRESET_ENUM_L3)	/* L3 cache related preset events */
697 //C     #define PAPI_PRESET_BIT_TLB		(1 << PAPI_PRESET_ENUM_TLB)	/* Translation Lookaside Buffer events */
698 //C     #define PAPI_PRESET_BIT_FP		(1 << PAPI_PRESET_ENUM_FP)	/* Floating Point related preset events */
699 
700 //C     #define PAPI_NTV_GROUP_AND_MASK		0x00FF0000	/* bits occupied by group number */
701 //C     #define PAPI_NTV_GROUP_SHIFT		16			/* bit shift to encode group number */
702 const PAPI_NTV_GROUP_AND_MASK = 0x00FF0000;
703 /** @} */
704 const PAPI_NTV_GROUP_SHIFT = 16;
705 
706 /* 
707 The Low Level API
708 
709 The following functions represent the low level portion of the
710 PerfAPI. These functions provide greatly increased efficiency and
711 functionality over the high level API presented in the next
712 section. All of the following functions are callable from both C and
713 Fortran except where noted. As mentioned in the introduction, the low
714 level API is only as powerful as the component upon which it is
715 built. Thus some features may not be available on every platform. The
716 converse may also be true, that more advanced features may be
717 available and defined in the header file.  The user is encouraged to
718 read the documentation carefully.  */
719 
720 
721 //#include <signal.h>
722 
723 /*  Earlier versions of PAPI define a special long_long type to mask
724 	an incompatibility between the Windows compiler and gcc-style compilers.
725 	That problem no longer exists, so long_long has been purged from the source.
726 	The defines below preserve backward compatibility. Their use is deprecated,
727 	but will continue to be supported in the near term.
728 */
729 //C     #define long_long long long
730 //C     #define u_long_long unsigned long long
731 
732 /** @defgroup papi_data_structures PAPI Data Structures */
733 
734 //C     	typedef unsigned long PAPI_thread_id_t;
735 extern (C):
736 alias uint PAPI_thread_id_t;
737 
738 	/** @ingroup papi_data_structures */
739 //C     	typedef struct _papi_all_thr_spec {
740 //C          int num;
741 //C          PAPI_thread_id_t *id;
742 //C          void **data;
743 //C        } PAPI_all_thr_spec_t;
744 struct _papi_all_thr_spec
745 {
746     int num;
747     PAPI_thread_id_t *id;
748     void **data;
749 }
750 alias _papi_all_thr_spec PAPI_all_thr_spec_t;
751 
752 //C       typedef void (*PAPI_overflow_handler_t) (int EventSet, void *address,
753 //C                                     long long overflow_vector, void *context);
754 alias void  function(int EventSet, void *address, long overflow_vector, void *context)PAPI_overflow_handler_t;
755 
756         /* Handle C99 and more recent compilation */
757 	/* caddr_t was never approved by POSIX and is obsolete */
758 	/* We should probably switch all caddr_t to void * or long */
759 //C     #ifdef __STDC_VERSION__
760 //C       #if (__STDC_VERSION__ >= 199901L)
761 //C     	typedef char *caddr_t;
762 alias char *caddr_t;
763 //C       #else
764 
765 //C       #endif
766 //C     #endif
767 
768 	/** @ingroup papi_data_structures */
769 //C        typedef struct _papi_sprofil {
770 //C           void *pr_base;          /**< buffer base */
771 //C           unsigned pr_size;       /**< buffer size */
772 //C           caddr_t pr_off;         /**< pc start address (offset) */
773 //C           unsigned pr_scale;      
774 /**< pc scaling factor: 
775                                  fixed point fraction
776                                  0xffff ~= 1, 0x8000 == .5, 0x4000 == .25, etc.
777                                  also, two extensions 0x1000 == 1, 0x2000 == 2 */
778 //C        } PAPI_sprofil_t;
779 struct _papi_sprofil
780 {
781     void *pr_base;
782     uint pr_size;
783     caddr_t pr_off;
784     uint pr_scale;
785 }
786 alias _papi_sprofil PAPI_sprofil_t;
787 
788 /** @ingroup papi_data_structures */
789 //C        typedef struct _papi_itimer_option {
790 //C          int itimer_num;
791 //C          int itimer_sig;
792 //C          int ns;
793 //C          int flags;
794 //C        } PAPI_itimer_option_t;
795 struct _papi_itimer_option
796 {
797     int itimer_num;
798     int itimer_sig;
799     int ns;
800     int flags;
801 }
802 alias _papi_itimer_option PAPI_itimer_option_t;
803 
804 /** @ingroup papi_data_structures */
805 //C        typedef struct _papi_inherit_option {
806 //C           int eventset;
807 //C           int inherit;
808 //C        } PAPI_inherit_option_t;
809 struct _papi_inherit_option
810 {
811     int eventset;
812     int inherit;
813 }
814 alias _papi_inherit_option PAPI_inherit_option_t;
815 
816 /** @ingroup papi_data_structures */
817 //C        typedef struct _papi_domain_option {
818 //C           int def_cidx; /**< this structure requires a component index to set default domains */
819 //C           int eventset;
820 //C           int domain;
821 //C        } PAPI_domain_option_t;
822 struct _papi_domain_option
823 {
824     int def_cidx;
825     int eventset;
826     int domain;
827 }
828 alias _papi_domain_option PAPI_domain_option_t;
829 
830 /**  @ingroup papi_data_structures*/
831 //C        typedef struct _papi_granularity_option {
832 //C           int def_cidx; /**< this structure requires a component index to set default granularity */
833 //C           int eventset;
834 //C           int granularity;
835 //C        } PAPI_granularity_option_t;
836 struct _papi_granularity_option
837 {
838     int def_cidx;
839     int eventset;
840     int granularity;
841 }
842 alias _papi_granularity_option PAPI_granularity_option_t;
843 
844 /** @ingroup papi_data_structures */
845 //C        typedef struct _papi_preload_option {
846 //C           char lib_preload_env[PAPI_MAX_STR_LEN];   
847 //C           char lib_preload_sep;
848 //C           char lib_dir_env[PAPI_MAX_STR_LEN];
849 //C           char lib_dir_sep;
850 //C        } PAPI_preload_info_t;
851 struct _papi_preload_option
852 {
853     char [128]lib_preload_env;
854     char lib_preload_sep;
855     char [128]lib_dir_env;
856     char lib_dir_sep;
857 }
858 alias _papi_preload_option PAPI_preload_info_t;
859 
860 /** @ingroup papi_data_structures */
861 //C        typedef struct _papi_component_option {
862 //C          char name[PAPI_MAX_STR_LEN];            /**< Name of the component we're using */
863 //C          char short_name[PAPI_MIN_STR_LEN];      
864 /**< Short name of component,
865 						to be prepended to event names */
866 //C          char description[PAPI_MAX_STR_LEN];     /**< Description of the component */
867 //C          char version[PAPI_MIN_STR_LEN];         /**< Version of this component */
868 //C          char support_version[PAPI_MIN_STR_LEN]; /**< Version of the support library */
869 //C          char kernel_version[PAPI_MIN_STR_LEN];  /**< Version of the kernel PMC support driver */
870 //C          char disabled_reason[PAPI_MAX_STR_LEN]; /**< Reason for failure of initialization */
871 //C          int disabled;   /**< 0 if enabled, otherwise error code from initialization */
872 //C          int CmpIdx;				/**< Index into the vector array for this component; set at init time */
873 //C          int num_cntrs;               /**< Number of hardware counters the component supports */
874 //C          int num_mpx_cntrs;           /**< Number of hardware counters the component or PAPI can multiplex supports */
875 //C          int num_preset_events;       /**< Number of preset events the component supports */
876 //C          int num_native_events;       /**< Number of native events the component supports */
877 //C          int default_domain;          /**< The default domain when this component is used */
878 //C          int available_domains;       /**< Available domains */ 
879 //C          int default_granularity;     /**< The default granularity when this component is used */
880 //C          int available_granularities; /**< Available granularities */
881 //C          int hardware_intr_sig;       /**< Signal used by hardware to deliver PMC events */
882 //   int opcode_match_width;      /**< Width of opcode matcher if exists, 0 if not */
883 //C          int component_type;          /**< Type of component */
884 //C          char *pmu_names[PAPI_PMU_MAX];         /**< list of pmu names supported by this component */
885 //C          int reserved[8];             /* */
886 //C          unsigned int hardware_intr:1;         /**< hw overflow intr, does not need to be emulated in software*/
887 //C          unsigned int precise_intr:1;          /**< Performance interrupts happen precisely */
888 //C          unsigned int posix1b_timers:1;        /**< Using POSIX 1b interval timers (timer_create) instead of setitimer */
889 //C          unsigned int kernel_profile:1;        /**< Has kernel profiling support (buffered interrupts or sprofil-like) */
890 //C          unsigned int kernel_multiplex:1;      /**< In kernel multiplexing */
891 //   unsigned int data_address_range:1;    /**< Supports data address range limiting */
892 //   unsigned int instr_address_range:1;   /**< Supports instruction address range limiting */
893 //C          unsigned int fast_counter_read:1;     /**< Supports a user level PMC read instruction */
894 //C          unsigned int fast_real_timer:1;       /**< Supports a fast real timer */
895 //C          unsigned int fast_virtual_timer:1;    /**< Supports a fast virtual timer */
896 //C          unsigned int attach:1;                /**< Supports attach */
897 //C          unsigned int attach_must_ptrace:1;	   /**< Attach must first ptrace and stop the thread/process*/
898 //   unsigned int edge_detect:1;           /**< Supports edge detection on events */
899 //   unsigned int invert:1;                /**< Supports invert detection on events */
900 //   unsigned int profile_ear:1;      	   /**< Supports data/instr/tlb miss address sampling */
901 //     unsigned int cntr_groups:1;           /**< Underlying hardware uses counter groups (e.g. POWER5)*/
902 //C          unsigned int cntr_umasks:1;           /**< counters have unit masks */
903 //   unsigned int cntr_IEAR_events:1;      /**< counters support instr event addr register */
904 //   unsigned int cntr_DEAR_events:1;      /**< counters support data event addr register */
905 //   unsigned int cntr_OPCM_events:1;      /**< counter events support opcode matching */
906      /* This should be a granularity option */
907 //C          unsigned int cpu:1;                   /**< Supports specifying cpu number to use with event set */
908 //C          unsigned int inherit:1;               /**< Supports child processes inheriting parents counters */
909 //C          unsigned int reserved_bits:12;
910 //C        } PAPI_component_info_t;
911 struct _papi_component_option
912 {
913     char [128] name;
914     char [64] short_name;
915     char [128] description;
916     char [64] version_;
917     char [64] support_version;
918     char [64] kernel_version;
919     char [128] disabled_reason;
920     int disabled;
921     int CmpIdx;
922     int num_cntrs;
923     int num_mpx_cntrs;
924     int num_preset_events;
925     int num_native_events;
926     int default_domain;
927     int available_domains;
928     int default_granularity;
929     int available_granularities;
930     int hardware_intr_sig;
931     int component_type;
932     char *[40] pmu_names;
933     int [8] reserved;
934     uint __bitfield1;
935     uint hardware_intr() { return (__bitfield1 >> 0) & 0x1; }
936     uint hardware_intr(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffffffe) | (value << 0); return value; }
937     uint precise_intr() { return (__bitfield1 >> 1) & 0x1; }
938     uint precise_intr(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffffffd) | (value << 1); return value; }
939     uint posix1b_timers() { return (__bitfield1 >> 2) & 0x1; }
940     uint posix1b_timers(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffffffb) | (value << 2); return value; }
941     uint kernel_profile() { return (__bitfield1 >> 3) & 0x1; }
942     uint kernel_profile(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffffff7) | (value << 3); return value; }
943     uint kernel_multiplex() { return (__bitfield1 >> 4) & 0x1; }
944     uint kernel_multiplex(uint value) { __bitfield1 = (__bitfield1 & 0xffffffffffffffef) | (value << 4); return value; }
945     uint fast_counter_read() { return (__bitfield1 >> 5) & 0x1; }
946     uint fast_counter_read(uint value) { __bitfield1 = (__bitfield1 & 0xffffffffffffffdf) | (value << 5); return value; }
947     uint fast_real_timer() { return (__bitfield1 >> 6) & 0x1; }
948     uint fast_real_timer(uint value) { __bitfield1 = (__bitfield1 & 0xffffffffffffffbf) | (value << 6); return value; }
949     uint fast_virtual_timer() { return (__bitfield1 >> 7) & 0x1; }
950     uint fast_virtual_timer(uint value) { __bitfield1 = (__bitfield1 & 0xffffffffffffff7f) | (value << 7); return value; }
951     uint attach() { return (__bitfield1 >> 8) & 0x1; }
952     uint attach(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffffeff) | (value << 8); return value; }
953     uint attach_must_ptrace() { return (__bitfield1 >> 9) & 0x1; }
954     uint attach_must_ptrace(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffffdff) | (value << 9); return value; }
955     uint cntr_umasks() { return (__bitfield1 >> 10) & 0x1; }
956     uint cntr_umasks(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffffbff) | (value << 10); return value; }
957     uint cpu() { return (__bitfield1 >> 11) & 0x1; }
958     uint cpu(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffffff7ff) | (value << 11); return value; }
959     uint inherit() { return (__bitfield1 >> 12) & 0x1; }
960     uint inherit(uint value) { __bitfield1 = (__bitfield1 & 0xffffffffffffefff) | (value << 12); return value; }
961     uint reserved_bits() { return (__bitfield1 >> 13) & 0xfff; }
962     uint reserved_bits(uint value) { __bitfield1 = (__bitfield1 & 0xfffffffffe001fff) | (value << 13); return value; }
963 }
964 alias _papi_component_option PAPI_component_info_t;
965 
966 /**  @ingroup papi_data_structures*/
967 //C        typedef struct _papi_mpx_info {
968 //C          int timer_sig;				/**< Signal number used by the multiplex timer, 0 if not: PAPI_SIGNAL */
969 //C          int timer_num;				/**< Number of the itimer or POSIX 1 timer used by the multiplex timer: PAPI_ITIMER */
970 //C          int timer_us;				/**< uS between switching of sets: PAPI_MPX_DEF_US */
971 //C        } PAPI_mpx_info_t;
972 struct _papi_mpx_info
973 {
974     int timer_sig;
975     int timer_num;
976     int timer_us;
977 }
978 alias _papi_mpx_info PAPI_mpx_info_t;
979 
980 //C        typedef int (*PAPI_debug_handler_t) (int code);
981 alias int  function(int code)PAPI_debug_handler_t;
982 
983    /** @ingroup papi_data_structures */
984 //C        typedef struct _papi_debug_option {
985 //C           int level;
986 //C           PAPI_debug_handler_t handler;
987 //C        } PAPI_debug_option_t;
988 struct _papi_debug_option
989 {
990     int level;
991     PAPI_debug_handler_t handler;
992 }
993 alias _papi_debug_option PAPI_debug_option_t;
994 
995 /** @ingroup papi_data_structures
996 	@brief get the executable's address space info */
997 //C        typedef struct _papi_address_map {
998 //C           char name[PAPI_HUGE_STR_LEN];
999 //C           caddr_t text_start;       /**< Start address of program text segment */
1000 //C           caddr_t text_end;         /**< End address of program text segment */
1001 //C           caddr_t data_start;       /**< Start address of program data segment */
1002 //C           caddr_t data_end;         /**< End address of program data segment */
1003 //C           caddr_t bss_start;        /**< Start address of program bss segment */
1004 //C           caddr_t bss_end;          /**< End address of program bss segment */
1005 //C        } PAPI_address_map_t;
1006 struct _papi_address_map
1007 {
1008     char [1024]name;
1009     caddr_t text_start;
1010     caddr_t text_end;
1011     caddr_t data_start;
1012     caddr_t data_end;
1013     caddr_t bss_start;
1014     caddr_t bss_end;
1015 }
1016 alias _papi_address_map PAPI_address_map_t;
1017 
1018 /** @ingroup papi_data_structures
1019 	@brief get the executable's info */
1020 //C        typedef struct _papi_program_info {
1021 //C           char fullname[PAPI_HUGE_STR_LEN];  /**< path + name */
1022 //C           PAPI_address_map_t address_info;	 /**< executable's address space info */
1023 //C        } PAPI_exe_info_t;
1024 struct _papi_program_info
1025 {
1026     char [1024]fullname;
1027     PAPI_address_map_t address_info;
1028 }
1029 alias _papi_program_info PAPI_exe_info_t;
1030 
1031    /** @ingroup papi_data_structures */
1032 //C        typedef struct _papi_shared_lib_info {
1033 //C           PAPI_address_map_t *map;
1034 //C           int count;
1035 //C        } PAPI_shlib_info_t;
1036 struct _papi_shared_lib_info
1037 {
1038     PAPI_address_map_t *map;
1039     int count;
1040 }
1041 alias _papi_shared_lib_info PAPI_shlib_info_t;
1042 
1043 /** Specify the file containing user defined events. */
1044 //C     typedef char* PAPI_user_defined_events_file_t;
1045 alias char *PAPI_user_defined_events_file_t;
1046 
1047    /* The following defines and next for structures define the memory hierarchy */
1048    /* All sizes are in BYTES */
1049    /* Associativity:
1050 		0: Undefined;
1051 		1: Direct Mapped
1052 		SHRT_MAX: Full
1053 		Other values == associativity
1054    */
1055 //C     #define PAPI_MH_TYPE_EMPTY    0x0
1056 //C     #define PAPI_MH_TYPE_INST     0x1
1057 const PAPI_MH_TYPE_EMPTY = 0x0;
1058 //C     #define PAPI_MH_TYPE_DATA     0x2
1059 const PAPI_MH_TYPE_INST = 0x1;
1060 //C     #define PAPI_MH_TYPE_VECTOR   0x4
1061 const PAPI_MH_TYPE_DATA = 0x2;
1062 //C     #define PAPI_MH_TYPE_TRACE    0x8
1063 const PAPI_MH_TYPE_VECTOR = 0x4;
1064 //C     #define PAPI_MH_TYPE_UNIFIED  (PAPI_MH_TYPE_INST|PAPI_MH_TYPE_DATA)
1065 const PAPI_MH_TYPE_TRACE = 0x8;
1066 //C     #define PAPI_MH_CACHE_TYPE(a) (a & 0xf)
1067 //C     #define PAPI_MH_TYPE_WT       0x00	   /* write-through cache */
1068 //C     #define PAPI_MH_TYPE_WB       0x10	   /* write-back cache */
1069 const PAPI_MH_TYPE_WT = 0x00;
1070 //C     #define PAPI_MH_CACHE_WRITE_POLICY(a) (a & 0xf0)
1071 const PAPI_MH_TYPE_WB = 0x10;
1072 //C     #define PAPI_MH_TYPE_UNKNOWN  0x000
1073 //C     #define PAPI_MH_TYPE_LRU      0x100
1074 const PAPI_MH_TYPE_UNKNOWN = 0x000;
1075 //C     #define PAPI_MH_TYPE_PSEUDO_LRU 0x200
1076 const PAPI_MH_TYPE_LRU = 0x100;
1077 //C     #define PAPI_MH_CACHE_REPLACEMENT_POLICY(a) (a & 0xf00)
1078 const PAPI_MH_TYPE_PSEUDO_LRU = 0x200;
1079 //C     #define PAPI_MH_TYPE_TLB       0x1000  /* tlb, not memory cache */
1080 //C     #define PAPI_MH_TYPE_PREF      0x2000  /* prefetch buffer */
1081 const PAPI_MH_TYPE_TLB = 0x1000;
1082 //C     #define PAPI_MH_MAX_LEVELS    6		   /* # descriptors for each TLB or cache level */
1083 const PAPI_MH_TYPE_PREF = 0x2000;
1084 //C     #define PAPI_MAX_MEM_HIERARCHY_LEVELS 	  4
1085 const PAPI_MH_MAX_LEVELS = 6;
1086 
1087 const PAPI_MAX_MEM_HIERARCHY_LEVELS = 4;
1088 /** @ingroup papi_data_structures */
1089 //C        typedef struct _papi_mh_tlb_info {
1090 //C           int type; /**< Empty, instr, data, vector, unified */
1091 //C           int num_entries;
1092 //C           int page_size;
1093 //C           int associativity;
1094 //C        } PAPI_mh_tlb_info_t;
1095 struct _papi_mh_tlb_info
1096 {
1097     int type;
1098     int num_entries;
1099     int page_size;
1100     int associativity;
1101 }
1102 alias _papi_mh_tlb_info PAPI_mh_tlb_info_t;
1103 
1104 /** @ingroup papi_data_structures */
1105 //C        typedef struct _papi_mh_cache_info {
1106 //C           int type; /**< Empty, instr, data, vector, trace, unified */
1107 //C           int size;
1108 //C           int line_size;
1109 //C           int num_lines;
1110 //C           int associativity;
1111 //C        } PAPI_mh_cache_info_t;
1112 struct _papi_mh_cache_info
1113 {
1114     int type;
1115     int size;
1116     int line_size;
1117     int num_lines;
1118     int associativity;
1119 }
1120 alias _papi_mh_cache_info PAPI_mh_cache_info_t;
1121 
1122 /** @ingroup papi_data_structures */
1123 //C        typedef struct _papi_mh_level_info {
1124 //C           PAPI_mh_tlb_info_t   tlb[PAPI_MH_MAX_LEVELS];
1125 //C           PAPI_mh_cache_info_t cache[PAPI_MH_MAX_LEVELS];
1126 //C        } PAPI_mh_level_t;
1127 struct _papi_mh_level_info
1128 {
1129     PAPI_mh_tlb_info_t [6]tlb;
1130     PAPI_mh_cache_info_t [6]cache;
1131 }
1132 alias _papi_mh_level_info PAPI_mh_level_t;
1133 
1134 /**  @ingroup papi_data_structures
1135   *	 @brief mh for mem hierarchy maybe? */
1136 //C        typedef struct _papi_mh_info { 
1137 //C           int levels;
1138 //C           PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS];
1139 //C        } PAPI_mh_info_t;
1140 struct _papi_mh_info
1141 {
1142     int levels;
1143     PAPI_mh_level_t [4]level;
1144 }
1145 alias _papi_mh_info PAPI_mh_info_t;
1146 
1147 /**  @ingroup papi_data_structures
1148   *  @brief Hardware info structure */
1149 //C        typedef struct _papi_hw_info {
1150 //C           int ncpu;                     /**< Number of CPUs per NUMA Node */
1151 //C           int threads;                  /**< Number of hdw threads per core */
1152 //C           int cores;                    /**< Number of cores per socket */
1153 //C           int sockets;                  /**< Number of sockets */
1154 //C           int nnodes;                   /**< Total Number of NUMA Nodes */
1155 //C           int totalcpus;                /**< Total number of CPUs in the entire system */
1156 //C           int vendor;                   /**< Vendor number of CPU */
1157 //C           char vendor_string[PAPI_MAX_STR_LEN];     /**< Vendor string of CPU */
1158 //C           int model;                    /**< Model number of CPU */
1159 //C           char model_string[PAPI_MAX_STR_LEN];      /**< Model string of CPU */
1160 //C           float revision;               /**< Revision of CPU */
1161 //C           int cpuid_family;             /**< cpuid family */
1162 //C           int cpuid_model;              /**< cpuid model */
1163 //C           int cpuid_stepping;           /**< cpuid stepping */
1164 
1165 //C           int cpu_max_mhz;              /**< Maximum supported CPU speed */
1166 //C           int cpu_min_mhz;              /**< Minimum supported CPU speed */
1167 
1168 //C           PAPI_mh_info_t mem_hierarchy; /**< PAPI memory hierarchy description */
1169 //C           int virtualized;              /**< Running in virtual machine */
1170 //C           char virtual_vendor_string[PAPI_MAX_STR_LEN]; 
1171                                     /**< Vendor for virtual machine */
1172 //C           char virtual_vendor_version[PAPI_MAX_STR_LEN];
1173                                     /**< Version of virtual machine */
1174 
1175       /* Legacy Values, do not use */
1176 //C           float mhz;                    /**< Deprecated */
1177 //C           int clock_mhz;                /**< Deprecated */
1178 
1179       /* For future expansion */
1180 //C           int reserved[8];
1181 
1182 //C        } PAPI_hw_info_t;
1183 struct _papi_hw_info
1184 {
1185     int ncpu;
1186     int threads;
1187     int cores;
1188     int sockets;
1189     int nnodes;
1190     int totalcpus;
1191     int vendor;
1192     char [128]vendor_string;
1193     int model;
1194     char [128]model_string;
1195     float revision;
1196     int cpuid_family;
1197     int cpuid_model;
1198     int cpuid_stepping;
1199     int cpu_max_mhz;
1200     int cpu_min_mhz;
1201     PAPI_mh_info_t mem_hierarchy;
1202     int virtualized;
1203     char [128]virtual_vendor_string;
1204     char [128]virtual_vendor_version;
1205     float mhz;
1206     int clock_mhz;
1207     int [8]reserved;
1208 }
1209 alias _papi_hw_info PAPI_hw_info_t;
1210 
1211 /** @ingroup papi_data_structures */
1212 //C        typedef struct _papi_attach_option {
1213 //C           int eventset;
1214 //C           unsigned long tid;
1215 //C        } PAPI_attach_option_t;
1216 struct _papi_attach_option
1217 {
1218     int eventset;
1219     uint tid;
1220 }
1221 alias _papi_attach_option PAPI_attach_option_t;
1222 
1223 /**  @ingroup papi_data_structures*/
1224 //C           typedef struct _papi_cpu_option {
1225 //C              int eventset;
1226 //C              unsigned int cpu_num;
1227 //C           } PAPI_cpu_option_t;
1228 struct _papi_cpu_option
1229 {
1230     int eventset;
1231     uint cpu_num;
1232 }
1233 alias _papi_cpu_option PAPI_cpu_option_t;
1234 
1235 /** @ingroup papi_data_structures */
1236 //C        typedef struct _papi_multiplex_option {
1237 //C           int eventset;
1238 //C           int ns;
1239 //C           int flags;
1240 //C        } PAPI_multiplex_option_t;
1241 struct _papi_multiplex_option
1242 {
1243     int eventset;
1244     int ns;
1245     int flags;
1246 }
1247 alias _papi_multiplex_option PAPI_multiplex_option_t;
1248 
1249    /** @ingroup papi_data_structures 
1250 	 *  @brief address range specification for range restricted counting if both are zero, range is disabled  */
1251 //C        typedef struct _papi_addr_range_option { 
1252 //C           int eventset;           /**< eventset to restrict */
1253 //C           caddr_t start;          /**< user requested start address of an address range */
1254 //C           caddr_t end;            /**< user requested end address of an address range */
1255 //C           int start_off;          /**< hardware specified offset from start address */
1256 //C           int end_off;            /**< hardware specified offset from end address */
1257 //C        } PAPI_addr_range_option_t;
1258 struct _papi_addr_range_option
1259 {
1260     int eventset;
1261     caddr_t start;
1262     caddr_t end;
1263     int start_off;
1264     int end_off;
1265 }
1266 alias _papi_addr_range_option PAPI_addr_range_option_t;
1267 
1268 /** @ingroup papi_data_structures 
1269   *	@union PAPI_option_t
1270   *	@brief A pointer to the following is passed to PAPI_set/get_opt() */
1271 
1272 //C     	typedef union
1273 //C     	{
1274 //C     		PAPI_preload_info_t preload;
1275 //C     		PAPI_debug_option_t debug;
1276 //C     		PAPI_inherit_option_t inherit;
1277 //C     		PAPI_granularity_option_t granularity;
1278 //C     		PAPI_granularity_option_t defgranularity;
1279 //C     		PAPI_domain_option_t domain;
1280 //C     		PAPI_domain_option_t defdomain;
1281 //C     		PAPI_attach_option_t attach;
1282 //C     		PAPI_cpu_option_t cpu;
1283 //C     		PAPI_multiplex_option_t multiplex;
1284 //C     		PAPI_itimer_option_t itimer;
1285 //C     		PAPI_hw_info_t *hw_info;
1286 //C     		PAPI_shlib_info_t *shlib_info;
1287 //C     		PAPI_exe_info_t *exe_info;
1288 //C     		PAPI_component_info_t *cmp_info;
1289 //C     		PAPI_addr_range_option_t addr;
1290 //C     		PAPI_user_defined_events_file_t events_file;
1291 //C     	} PAPI_option_t;
1292 union _N3
1293 {
1294     PAPI_preload_info_t preload;
1295     PAPI_debug_option_t debug_;
1296     PAPI_inherit_option_t inherit;
1297     PAPI_granularity_option_t granularity;
1298     PAPI_granularity_option_t defgranularity;
1299     PAPI_domain_option_t domain;
1300     PAPI_domain_option_t defdomain;
1301     PAPI_attach_option_t attach;
1302     PAPI_cpu_option_t cpu;
1303     PAPI_multiplex_option_t multiplex;
1304     PAPI_itimer_option_t itimer;
1305     PAPI_hw_info_t *hw_info;
1306     PAPI_shlib_info_t *shlib_info;
1307     PAPI_exe_info_t *exe_info;
1308     PAPI_component_info_t *cmp_info;
1309     PAPI_addr_range_option_t addr;
1310     PAPI_user_defined_events_file_t events_file;
1311 }
1312 alias _N3 PAPI_option_t;
1313 
1314 /** @ingroup papi_data_structures
1315   *	@brief A pointer to the following is passed to PAPI_get_dmem_info() */
1316 //C     	typedef struct _dmem_t {
1317 //C     	  long long peak;
1318 //C     	  long long size;
1319 //C     	  long long resident;
1320 //C     	  long long high_water_mark;
1321 //C     	  long long shared;
1322 //C     	  long long text;
1323 //C     	  long long library;
1324 //C     	  long long heap;
1325 //C     	  long long locked;
1326 //C     	  long long stack;
1327 //C     	  long long pagesize;
1328 //C     	  long long pte;
1329 //C     	} PAPI_dmem_info_t;
1330 struct _dmem_t
1331 {
1332     long peak;
1333     long size;
1334     long resident;
1335     long high_water_mark;
1336     long shared_;
1337     long text;
1338     long library;
1339     long heap;
1340     long locked;
1341     long stack;
1342     long pagesize;
1343     long pte;
1344 }
1345 alias _dmem_t PAPI_dmem_info_t;
1346 
1347 /* Fortran offsets into PAPI_dmem_info_t structure. */
1348 
1349 //C     #define PAPIF_DMEM_VMPEAK     1
1350 //C     #define PAPIF_DMEM_VMSIZE     2
1351 const PAPIF_DMEM_VMPEAK = 1;
1352 //C     #define PAPIF_DMEM_RESIDENT   3
1353 const PAPIF_DMEM_VMSIZE = 2;
1354 //C     #define PAPIF_DMEM_HIGH_WATER 4
1355 const PAPIF_DMEM_RESIDENT = 3;
1356 //C     #define PAPIF_DMEM_SHARED     5
1357 const PAPIF_DMEM_HIGH_WATER = 4;
1358 //C     #define PAPIF_DMEM_TEXT       6
1359 const PAPIF_DMEM_SHARED = 5;
1360 //C     #define PAPIF_DMEM_LIBRARY    7
1361 const PAPIF_DMEM_TEXT = 6;
1362 //C     #define PAPIF_DMEM_HEAP       8
1363 const PAPIF_DMEM_LIBRARY = 7;
1364 //C     #define PAPIF_DMEM_LOCKED     9
1365 const PAPIF_DMEM_HEAP = 8;
1366 //C     #define PAPIF_DMEM_STACK      10
1367 const PAPIF_DMEM_LOCKED = 9;
1368 //C     #define PAPIF_DMEM_PAGESIZE   11
1369 const PAPIF_DMEM_STACK = 10;
1370 //C     #define PAPIF_DMEM_PTE        12
1371 const PAPIF_DMEM_PAGESIZE = 11;
1372 //C     #define PAPIF_DMEM_MAXVAL     12
1373 const PAPIF_DMEM_PTE = 12;
1374 
1375 const PAPIF_DMEM_MAXVAL = 12;
1376 //C     #define PAPI_MAX_INFO_TERMS  12		   /* should match PAPI_EVENTS_IN_DERIVED_EVENT defined in papi_internal.h */
1377 
1378 const PAPI_MAX_INFO_TERMS = 12;
1379 
1380 /** @ingroup papi_data_structures 
1381   *	@brief This structure is the event information that is exposed to the user through the API.
1382 
1383    The same structure is used to describe both preset and native events.
1384    WARNING: This structure is very large. With current definitions, it is about 2660 bytes.
1385    Unlike previous versions of PAPI, which allocated an array of these structures within
1386    the library, this structure is carved from user space. It does not exist inside the library,
1387    and only one copy need ever exist.
1388    The basic philosophy is this:
1389    - each preset consists of a code, some descriptors, and an array of native events;
1390    - each native event consists of a code, and an array of register values;
1391    - fields are shared between preset and native events, and unused where not applicable;
1392    - To completely describe a preset event, the code must present all available
1393       information for that preset, and then walk the list of native events, retrieving
1394       and presenting information for each native event in turn.
1395    The various fields and their usage is discussed below.
1396 */
1397 
1398 
1399 /** Enum values for event_info location field */
1400 //C     enum {
1401 //C        PAPI_LOCATION_CORE = 0,			/**< Measures local to core      */
1402 //C        PAPI_LOCATION_CPU,				/**< Measures local to CPU (HT?) */
1403 //C        PAPI_LOCATION_PACKAGE,			/**< Measures local to package   */
1404 //C        PAPI_LOCATION_UNCORE,			/**< Measures uncore             */
1405 //C     };
1406 enum
1407 {
1408     PAPI_LOCATION_CORE,
1409     PAPI_LOCATION_CPU,
1410     PAPI_LOCATION_PACKAGE,
1411     PAPI_LOCATION_UNCORE,
1412 }
1413 
1414 /** Enum values for event_info data_type field */
1415 //C     enum {
1416 //C        PAPI_DATATYPE_INT64 = 0,			/**< Default: Data is a signed 64-bit int   */
1417 //C        PAPI_DATATYPE_UINT64,			/**< Data is a unsigned 64-bit int */
1418 //C        PAPI_DATATYPE_FP64,				/**< Data is 64-bit floating point */
1419 //C        PAPI_DATATYPE_BIT64,				/**< Data is 64-bit binary */
1420 //C     };
1421 enum
1422 {
1423     PAPI_DATATYPE_INT64,
1424     PAPI_DATATYPE_UINT64,
1425     PAPI_DATATYPE_FP64,
1426     PAPI_DATATYPE_BIT64,
1427 }
1428 
1429 /** Enum values for event_info value_type field */
1430 //C     enum {
1431 //C        PAPI_VALUETYPE_RUNNING_SUM = 0,	/**< Data is running sum from start */
1432 //C        PAPI_VALUETYPE_ABSOLUTE,	        /**< Data is from last read */
1433 //C     };
1434 enum
1435 {
1436     PAPI_VALUETYPE_RUNNING_SUM,
1437     PAPI_VALUETYPE_ABSOLUTE,
1438 }
1439 
1440 /** Enum values for event_info timescope field */
1441 //C     enum {
1442 //C        PAPI_TIMESCOPE_SINCE_START = 0,	/**< Data is cumulative from start */
1443 //C        PAPI_TIMESCOPE_SINCE_LAST,		/**< Data is from last read */
1444 //C        PAPI_TIMESCOPE_UNTIL_NEXT,		/**< Data is until next read */
1445 //C        PAPI_TIMESCOPE_POINT,			/**< Data is an instantaneous value */
1446 //C     };
1447 enum
1448 {
1449     PAPI_TIMESCOPE_SINCE_START,
1450     PAPI_TIMESCOPE_SINCE_LAST,
1451     PAPI_TIMESCOPE_UNTIL_NEXT,
1452     PAPI_TIMESCOPE_POINT,
1453 }
1454 
1455 /** Enum values for event_info update_type field */
1456 //C     enum {
1457 //C        PAPI_UPDATETYPE_ARBITRARY = 0,	/**< Data is cumulative from start */
1458 //C        PAPI_UPDATETYPE_PUSH,	        /**< Data is pushed */
1459 //C        PAPI_UPDATETYPE_PULL,	        /**< Data is pulled */
1460 //C        PAPI_UPDATETYPE_FIXEDFREQ,	    /**< Data is read periodically */
1461 //C     };
1462 enum
1463 {
1464     PAPI_UPDATETYPE_ARBITRARY,
1465     PAPI_UPDATETYPE_PUSH,
1466     PAPI_UPDATETYPE_PULL,
1467     PAPI_UPDATETYPE_FIXEDFREQ,
1468 }
1469 
1470 
1471 //C        typedef struct event_info {
1472 //C           unsigned int event_code;             
1473 /**< preset (0x8xxxxxxx) or 
1474                                                 native (0x4xxxxxxx) event code */
1475 //C           char symbol[PAPI_HUGE_STR_LEN];      /**< name of the event */
1476 //C           char short_descr[PAPI_MIN_STR_LEN];  
1477 /**< a short description suitable for 
1478                                                 use as a label */
1479 //C           char long_descr[PAPI_HUGE_STR_LEN];  
1480 /**< a longer description:
1481                                                 typically a sentence for presets,
1482                                                 possibly a paragraph from vendor
1483                                                 docs for native events */
1484 
1485 //C           int component_index;           /**< component this event belongs to */
1486 //C           char units[PAPI_MIN_STR_LEN];  /**< units event is measured in */
1487 //C           int location;                  /**< location event applies to */
1488 //C           int data_type;                 /**< data type returned by PAPI */
1489 //C           int value_type;                /**< sum or absolute */
1490 //C           int timescope;                 /**< from start, etc. */
1491 //C           int update_type;               /**< how event is updated */
1492 //C           int update_freq;               /**< how frequently event is updated */
1493 
1494      /* PRESET SPECIFIC FIELDS FOLLOW */
1495 
1496 
1497 
1498 //C           unsigned int count;                
1499 /**< number of terms (usually 1) 
1500                                               in the code and name fields 
1501                                               - presets: these are native events
1502                                               - native: these are unused */
1503 
1504 //C           unsigned int event_type;           
1505 /**< event type or category 
1506                                               for preset events only */
1507 
1508 //C           char derived[PAPI_MIN_STR_LEN];    
1509 /**< name of the derived type
1510                                               - presets: usually NOT_DERIVED
1511                                               - native: empty string */
1512 //C           char postfix[PAPI_2MAX_STR_LEN];   
1513 /**< string containing postfix 
1514                                               operations; only defined for 
1515                                               preset events of derived type 
1516                                               DERIVED_POSTFIX */
1517 
1518 //C           unsigned int code[PAPI_MAX_INFO_TERMS]; 
1519 /**< array of values that further 
1520                                               describe the event:
1521                                               - presets: native event_code values
1522                                               - native:, register values(?) */
1523 
1524 //C           char name[PAPI_MAX_INFO_TERMS]         /**< names of code terms: */
1525 //C                    [PAPI_2MAX_STR_LEN];          
1526 /**< - presets: native event names,
1527                                                   - native: descriptive strings 
1528 						  for each register value(?) */
1529 
1530 //C          char note[PAPI_HUGE_STR_LEN];          
1531 /**< an optional developer note 
1532                                                 supplied with a preset event
1533                                                 to delineate platform specific 
1534 						anomalies or restrictions */
1535 
1536 //C        } PAPI_event_info_t;
1537 struct event_info
1538 {
1539     uint event_code;
1540     char [1024]symbol;
1541     char [64]short_descr;
1542     char [1024]long_descr;
1543     int component_index;
1544     char [64]units;
1545     int location;
1546     int data_type;
1547     int value_type;
1548     int timescope;
1549     int update_type;
1550     int update_freq;
1551     uint count;
1552     uint event_type;
1553     char [64]derived;
1554     char [256]postfix;
1555     uint [12]code;
1556     char [256][12]name;
1557     char [1024]note;
1558 }
1559 alias event_info PAPI_event_info_t;
1560 
1561 
1562 
1563 
1564 /** \internal
1565   * @defgroup low_api The Low Level API 
1566   @{ */
1567 //C        int   PAPI_accum(int EventSet, long long * values); /**< accumulate and reset hardware events from an event set */
1568 int  PAPI_accum(int EventSet, long *values);
1569 //C        int   PAPI_add_event(int EventSet, int Event); /**< add single PAPI preset or native hardware event to an event set */
1570 int  PAPI_add_event(int EventSet, int Event);
1571 //C        int   PAPI_add_named_event(int EventSet, const char *EventName); /**< add an event by name to a PAPI event set */
1572 int  PAPI_add_named_event(int EventSet, char *EventName);
1573 //C        int   PAPI_add_events(int EventSet, int *Events, int number); /**< add array of PAPI preset or native hardware events to an event set */
1574 int  PAPI_add_events(int EventSet, int *Events, int number);
1575 //C        int   PAPI_assign_eventset_component(int EventSet, int cidx); /**< assign a component index to an existing but empty eventset */
1576 int  PAPI_assign_eventset_component(int EventSet, int cidx);
1577 //C        int   PAPI_attach(int EventSet, unsigned long tid); /**< attach specified event set to a specific process or thread id */
1578 int  PAPI_attach(int EventSet, uint tid);
1579 //C        int   PAPI_cleanup_eventset(int EventSet); /**< remove all PAPI events from an event set */
1580 int  PAPI_cleanup_eventset(int EventSet);
1581 //C        int   PAPI_create_eventset(int *EventSet); /**< create a new empty PAPI event set */
1582 int  PAPI_create_eventset(int *EventSet);
1583 //C        int   PAPI_detach(int EventSet); /**< detach specified event set from a previously specified process or thread id */
1584 int  PAPI_detach(int EventSet);
1585 //C        int   PAPI_destroy_eventset(int *EventSet); /**< deallocates memory associated with an empty PAPI event set */
1586 int  PAPI_destroy_eventset(int *EventSet);
1587 //C        int   PAPI_enum_event(int *EventCode, int modifier); /**< return the event code for the next available preset or natvie event */
1588 int  PAPI_enum_event(int *EventCode, int modifier);
1589 //C        int   PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx); /**< return the event code for the next available component event */
1590 int  PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx);
1591 //C        int   PAPI_event_code_to_name(int EventCode, char *out); /**< translate an integer PAPI event code into an ASCII PAPI preset or native name */
1592 int  PAPI_event_code_to_name(int EventCode, char * out_);
1593 //C        int   PAPI_event_name_to_code(const char *in, int *out); /**< translate an ASCII PAPI preset or native name into an integer PAPI event code */
1594 int  PAPI_event_name_to_code(char * in_, int *out_);
1595 //C        int  PAPI_get_dmem_info(PAPI_dmem_info_t *dest); /**< get dynamic memory usage information */
1596 int  PAPI_get_dmem_info(PAPI_dmem_info_t *dest);
1597 //C        int   PAPI_get_event_info(int EventCode, PAPI_event_info_t * info); /**< get the name and descriptions for a given preset or native event code */
1598 int  PAPI_get_event_info(int EventCode, PAPI_event_info_t *info);
1599 //C        const PAPI_exe_info_t *PAPI_get_executable_info(void); /**< get the executable's address space information */
1600 PAPI_exe_info_t * PAPI_get_executable_info();
1601 //C        const PAPI_hw_info_t *PAPI_get_hardware_info(void); /**< get information about the system hardware */
1602 PAPI_hw_info_t * PAPI_get_hardware_info();
1603 //C        const PAPI_component_info_t *PAPI_get_component_info(int cidx); /**< get information about the component features */
1604 PAPI_component_info_t * PAPI_get_component_info(int cidx);
1605 //C        int   PAPI_get_multiplex(int EventSet); /**< get the multiplexing status of specified event set */
1606 int  PAPI_get_multiplex(int EventSet);
1607 //C        int   PAPI_get_opt(int option, PAPI_option_t * ptr); /**< query the option settings of the PAPI library or a specific event set */
1608 int  PAPI_get_opt(int option, PAPI_option_t *ptr);
1609 //C        int   PAPI_get_cmp_opt(int option, PAPI_option_t * ptr,int cidx); /**< query the component specific option settings of a specific event set */
1610 int  PAPI_get_cmp_opt(int option, PAPI_option_t *ptr, int cidx);
1611 //C        long long PAPI_get_real_cyc(void); /**< return the total number of cycles since some arbitrary starting point */
1612 long  PAPI_get_real_cyc();
1613 //C        long long PAPI_get_real_nsec(void); /**< return the total number of nanoseconds since some arbitrary starting point */
1614 long  PAPI_get_real_nsec();
1615 //C        long long PAPI_get_real_usec(void); /**< return the total number of microseconds since some arbitrary starting point */
1616 long  PAPI_get_real_usec();
1617 //C        const PAPI_shlib_info_t *PAPI_get_shared_lib_info(void); /**< get information about the shared libraries used by the process */
1618 PAPI_shlib_info_t * PAPI_get_shared_lib_info();
1619 //C        int   PAPI_get_thr_specific(int tag, void **ptr); /**< return a pointer to a thread specific stored data structure */
1620 int  PAPI_get_thr_specific(int tag, void **ptr);
1621 //C        int   PAPI_get_overflow_event_index(int Eventset, long long overflow_vector, int *array, int *number); /**< # decomposes an overflow_vector into an event index array */
1622 int  PAPI_get_overflow_event_index(int Eventset, long overflow_vector, int *array, int *number);
1623 //C        long long PAPI_get_virt_cyc(void); /**< return the process cycles since some arbitrary starting point */
1624 long  PAPI_get_virt_cyc();
1625 //C        long long PAPI_get_virt_nsec(void); /**< return the process nanoseconds since some arbitrary starting point */
1626 long  PAPI_get_virt_nsec();
1627 //C        long long PAPI_get_virt_usec(void); /**< return the process microseconds since some arbitrary starting point */
1628 long  PAPI_get_virt_usec();
1629 //C        int   PAPI_is_initialized(void); /**< return the initialized state of the PAPI library */
1630 int  PAPI_is_initialized();
1631 //C        int   PAPI_library_init(int version); /**< initialize the PAPI library */
1632 int  PAPI_library_init(int version_);
1633 //C        int   PAPI_list_events(int EventSet, int *Events, int *number); /**< list the events that are members of an event set */
1634 int  PAPI_list_events(int EventSet, int *Events, int *number);
1635 //C        int   PAPI_list_threads(unsigned long *tids, int *number); /**< list the thread ids currently known to PAPI */
1636 int  PAPI_list_threads(uint *tids, int *number);
1637 //C        int   PAPI_lock(int); /**< lock one of two PAPI internal user mutex variables */
1638 int  PAPI_lock(int );
1639 //C        int   PAPI_multiplex_init(void); /**< initialize multiplex support in the PAPI library */
1640 int  PAPI_multiplex_init();
1641 //C        int   PAPI_num_cmp_hwctrs(int cidx); /**< return the number of hardware counters for a specified component */
1642 int  PAPI_num_cmp_hwctrs(int cidx);
1643 //C        int   PAPI_num_events(int EventSet); /**< return the number of events in an event set */
1644 int  PAPI_num_events(int EventSet);
1645 //C        int   PAPI_overflow(int EventSet, int EventCode, int threshold,
1646 //C                          int flags, PAPI_overflow_handler_t handler); /**< set up an event set to begin registering overflows */
1647 int  PAPI_overflow(int EventSet, int EventCode, int threshold, int flags, PAPI_overflow_handler_t handler);
1648 //C        void  PAPI_perror(const char *msg ); /**< Print a PAPI error message */
1649 void  PAPI_perror(char *msg);
1650 //C        int   PAPI_profil(void *buf, unsigned bufsiz, caddr_t offset, 
1651 //C     					 unsigned scale, int EventSet, int EventCode, 
1652 //C     					 int threshold, int flags); /**< generate PC histogram data where hardware counter overflow occurs */
1653 int  PAPI_profil(void *buf, uint bufsiz, caddr_t offset, uint scale, int EventSet, int EventCode, int threshold, int flags);
1654 //C        int   PAPI_query_event(int EventCode); /**< query if a PAPI event exists */
1655 int  PAPI_query_event(int EventCode);
1656 //C        int   PAPI_query_named_event(const char *EventName); /**< query if a named PAPI event exists */
1657 int  PAPI_query_named_event(char *EventName);
1658 //C        int   PAPI_read(int EventSet, long long * values); /**< read hardware events from an event set with no reset */
1659 int  PAPI_read(int EventSet, long *values);
1660 //C        int   PAPI_read_ts(int EventSet, long long * values, long long *cyc); /**< read from an eventset with a real-time cycle timestamp */
1661 int  PAPI_read_ts(int EventSet, long *values, long *cyc);
1662 //C        int   PAPI_register_thread(void); /**< inform PAPI of the existence of a new thread */
1663 int  PAPI_register_thread();
1664 //C        int   PAPI_remove_event(int EventSet, int EventCode); /**< remove a hardware event from a PAPI event set */
1665 int  PAPI_remove_event(int EventSet, int EventCode);
1666 //C        int   PAPI_remove_named_event(int EventSet, const char *EventName); /**< remove a named event from a PAPI event set */
1667 int  PAPI_remove_named_event(int EventSet, char *EventName);
1668 //C        int   PAPI_remove_events(int EventSet, int *Events, int number); /**< remove an array of hardware events from a PAPI event set */
1669 int  PAPI_remove_events(int EventSet, int *Events, int number);
1670 //C        int   PAPI_reset(int EventSet); /**< reset the hardware event counts in an event set */
1671 int  PAPI_reset(int EventSet);
1672 //C        int   PAPI_set_debug(int level); /**< set the current debug level for PAPI */
1673 int  PAPI_set_debug(int level);
1674 //C        int   PAPI_set_cmp_domain(int domain, int cidx); /**< set the component specific default execution domain for new event sets */
1675 int  PAPI_set_cmp_domain(int domain, int cidx);
1676 //C        int   PAPI_set_domain(int domain); /**< set the default execution domain for new event sets  */
1677 int  PAPI_set_domain(int domain);
1678 //C        int   PAPI_set_cmp_granularity(int granularity, int cidx); /**< set the component specific default granularity for new event sets */
1679 int  PAPI_set_cmp_granularity(int granularity, int cidx);
1680 //C        int   PAPI_set_granularity(int granularity); /**<set the default granularity for new event sets */
1681 int  PAPI_set_granularity(int granularity);
1682 //C        int   PAPI_set_multiplex(int EventSet); /**< convert a standard event set to a multiplexed event set */
1683 int  PAPI_set_multiplex(int EventSet);
1684 //C        int   PAPI_set_opt(int option, PAPI_option_t * ptr); /**< change the option settings of the PAPI library or a specific event set */
1685 int  PAPI_set_opt(int option, PAPI_option_t *ptr);
1686 //C        int   PAPI_set_thr_specific(int tag, void *ptr); /**< save a pointer as a thread specific stored data structure */
1687 int  PAPI_set_thr_specific(int tag, void *ptr);
1688 //C        void  PAPI_shutdown(void); /**< finish using PAPI and free all related resources */
1689 void  PAPI_shutdown();
1690 //C        int   PAPI_sprofil(PAPI_sprofil_t * prof, int profcnt, int EventSet, int EventCode, int threshold, int flags); /**< generate hardware counter profiles from multiple code regions */
1691 int  PAPI_sprofil(PAPI_sprofil_t *prof, int profcnt, int EventSet, int EventCode, int threshold, int flags);
1692 //C        int   PAPI_start(int EventSet); /**< start counting hardware events in an event set */
1693 int  PAPI_start(int EventSet);
1694 //C        int   PAPI_state(int EventSet, int *status); /**< return the counting state of an event set */
1695 int  PAPI_state(int EventSet, int *status);
1696 //C        int   PAPI_stop(int EventSet, long long * values); /**< stop counting hardware events in an event set and return current events */
1697 int  PAPI_stop(int EventSet, long *values);
1698 //C        char *PAPI_strerror(int); /**< return a pointer to the error name corresponding to a specified error code */
1699 char * PAPI_strerror(int );
1700 //C        unsigned long PAPI_thread_id(void); /**< get the thread identifier of the current thread */
1701 uint  PAPI_thread_id();
1702 //C        int   PAPI_thread_init(unsigned long (*id_fn) (void)); /**< initialize thread support in the PAPI library */
1703 int  PAPI_thread_init(uint  function()id_fn);
1704 //C        int   PAPI_unlock(int); /**< unlock one of two PAPI internal user mutex variables */
1705 int  PAPI_unlock(int );
1706 //C        int   PAPI_unregister_thread(void); /**< inform PAPI that a previously registered thread is disappearing */
1707 int  PAPI_unregister_thread();
1708 //C        int   PAPI_write(int EventSet, long long * values); /**< write counter values into counters */
1709 int  PAPI_write(int EventSet, long *values);
1710 //C        int   PAPI_get_event_component(int EventCode);  /**< return which component an EventCode belongs to */
1711 int  PAPI_get_event_component(int EventCode);
1712 //C        int   PAPI_get_eventset_component(int EventSet);  /**< return which component an EventSet is assigned to */
1713 int  PAPI_get_eventset_component(int EventSet);
1714 //C        int   PAPI_get_component_index(const char *name); /**< Return component index for component with matching name */
1715 int  PAPI_get_component_index(char *name);
1716 //C        int   PAPI_disable_component(int cidx); /**< Disables a component before init */
1717 int  PAPI_disable_component(int cidx);
1718 //C        int	 PAPI_disable_component_by_name(const char *name ); /**< Disable, before library init, a component by name. */
1719 int  PAPI_disable_component_by_name(char *name);
1720 
1721 
1722    /** @} */
1723 
1724 /** \internal
1725   @defgroup high_api  The High Level API 
1726 
1727    The simple interface implemented by the following eight routines
1728    allows the user to access and count specific hardware events from
1729    both C and Fortran. It should be noted that this API can be used in
1730    conjunction with the low level API. 
1731 	@{ */
1732 
1733 //C        int PAPI_accum_counters(long long * values, int array_len); /**< add current counts to array and reset counters */
1734 int  PAPI_accum_counters(long *values, int array_len);
1735 //C        int PAPI_num_counters(void); /**< get the number of hardware counters available on the system */
1736 int  PAPI_num_counters();
1737 //C        int PAPI_num_components(void); /**< get the number of components available on the system */
1738 int  PAPI_num_components();
1739 //C        int PAPI_read_counters(long long * values, int array_len); /**< copy current counts to array and reset counters */
1740 int  PAPI_read_counters(long *values, int array_len);
1741 //C        int PAPI_start_counters(int *events, int array_len); /**< start counting hardware events */
1742 int  PAPI_start_counters(int *events, int array_len);
1743 //C        int PAPI_stop_counters(long long * values, int array_len); /**< stop counters and return current counts */
1744 int  PAPI_stop_counters(long *values, int array_len);
1745 //C        int PAPI_flips(float *rtime, float *ptime, long long * flpins, float *mflips); /**< simplified call to get Mflips/s (floating point instruction rate), real and processor time */
1746 int  PAPI_flips(float *rtime, float *ptime, long *flpins, float *mflips);
1747 //C        int PAPI_flops(float *rtime, float *ptime, long long * flpops, float *mflops); /**< simplified call to get Mflops/s (floating point operation rate), real and processor time */
1748 int  PAPI_flops(float *rtime, float *ptime, long *flpops, float *mflops);
1749 //C        int PAPI_ipc(float *rtime, float *ptime, long long * ins, float *ipc); /**< gets instructions per cycle, real and processor time */
1750 int  PAPI_ipc(float *rtime, float *ptime, long *ins, float *ipc);
1751 //C        int PAPI_epc(int event, float *rtime, float *ptime, long long *ref, long long *core, long long *evt, float *epc); /**< gets (named) events per cycle, real and processor time, reference and core cycles */
1752 int  PAPI_epc(int event, float *rtime, float *ptime, long * ref_, long *core, long *evt, float *epc);
1753 /** @} */
1754 
1755 
1756 
1757 /* Backwards compatibility hacks.  Remove eventually? */
1758 //C     int   PAPI_num_hwctrs(void); /**< return the number of hardware counters for the cpu. for backward compatibility. Don't use! */
1759 int  PAPI_num_hwctrs();
1760 //C     #define PAPI_COMPONENT_INDEX(a) PAPI_get_event_component(a)
1761 //C     #define PAPI_descr_error(a) PAPI_strerror(a)
1762 
1763 //C     #ifdef __cplusplus
1764 //C     }
1765 //C     #endif
1766 
1767 
1768 
1769 
1770 
1771