source: proiecte/hpl/openmpi_compiled/include/vampirtrace/OTF_WStream.h @ 97

Last change on this file since 97 was 97, checked in by (none), 14 years ago

Adding compiled files

File size: 17.6 KB
Line 
1/*
2 This is part of the OTF library. Copyright by ZIH, TU Dresden 2005-2008.
3 Authors: Andreas Knuepfer, Holger Brunst, Ronny Brendel, Thomas Kriebitzsch
4*/
5
6/**
7 *  @file OTF_WStream.h
8 *
9 *  @brief Provides write access to trace streams, which consist of multiple
10 *  buffers.
11 *
12 *  \ingroup wstream
13 */
14
15/** \defgroup wstream Stream Writer Interface
16 *
17 * This interface provides functions for writing trace at stream level.
18 * A stream is part of a trace and consists of up to four buffers
19 * (event buffer, definition buffer, snapshots buffer, statistics buffer).
20 *
21 * wstream is structured similarly to writer.
22 *
23 * Use this interface, if you want to a specific stream and the writer
24 * interface does not provide the desired access.
25 *
26 * \section wstream_example A short Example
27 *
28 *  \code
29 *  #include <assert.h>
30 *  #include "otf.h"
31 *
32 *  int main( int argc, char** argv ) {
33 *  \endcode
34 *
35 *      Declare a file manager and a writer.
36 *      \code
37 *          OTF_FileManager* manager;
38 *          OTF_WStream* wstream;
39 *          \endcode
40 *
41 *      Initialize the file manager. Open at most 100 OS files.
42 *      \code
43 *      manager= OTF_FileManager_open( 100 );
44 *          assert( manager );
45 *          \endcode
46 *
47 *          Initialize the wstream object. Open file "test", writing the first stream.
48 *          \code
49 *          wstream = OTF_WStream_open( "test", 0, manager );
50 *      assert( wstream );
51 *      \endcode
52 *     
53 *      Write some definition records.
54 *      \code
55 *      OTF_WStream_writeDefTimerResolution( wstream, 0, 1000 );
56 *      OTF_WStream_writeDefProcess( wstream, 0, 1, "proc one", 0 );
57 *      \endcode
58 *
59 *      Clean up before exiting the program.
60 *      \code
61 *      OTF_WStream_close( wstream );
62 *      OTF_FileManager_close( manager );
63 *
64 *              return 0;
65 * }
66 * \endcode
67 *
68 * Compile this using $ gcc -o test test.c `otfconfig --libs`.
69 *
70 * When executing this program it only writes one file (test.0.def),
71 * containg the written records.
72 *
73 */
74
75#ifndef OTF_WSTREAM_H
76#define OTF_WSTREAM_H
77
78
79#include <stdlib.h>
80
81
82#include "OTF_inttypes.h"
83
84
85#include "OTF_Definitions.h"
86#include "OTF_FileManager.h"
87#include "OTF_WBuffer.h"
88#include "OTF_Filenames.h"
89
90
91#ifdef __cplusplus
92extern "C" {
93#endif /* __cplusplus */
94
95struct struct_OTF_WStream {
96
97
98        /**     name stub: all files will begin with this name */
99        char* namestub;
100
101        /**     Unique id for the current stream. */
102        uint32_t id;
103
104        /**     State wether to use long or short format,
105                see OTF_WSTREAM_FORMAT_XXX macros above. */
106        uint32_t format;
107
108
109        /**     Definitions buffer. Definitions buffer carries definition
110                records. */
111        OTF_WBuffer* defBuffer;
112
113        /**     Event buffer. The event buffer carries records for actual
114                events, i.e. records with a time stamp */
115        OTF_WBuffer* eventBuffer;
116
117        /**     Snaps (snapshots) buffer. The snapshots buffer carries
118                snapshots of the whole state at a point in time - as oppossed to
119                events which only show changes in the state. This can be used to
120                start from such a snapshot instead of from the very begining. */
121        OTF_WBuffer* snapsBuffer;
122
123        /**     Statistics buffer. Statistics buffer carries statistical
124                information information about a certain time interval resp.
125                data at points of time that allow to derive statistics without
126                reading through all events of that interval. */
127        OTF_WBuffer* statsBuffer;
128
129        /** Default compression method for all buffers managed by this stream */
130        OTF_FileCompression compression;
131       
132        /** Default size of buffers managed by this WStream. */
133        uint32_t buffersizes;
134
135#ifdef HAVE_ZLIB
136        /** Default size of zbuffers managed by this RStream. */
137        uint32_t zbuffersizes;
138#endif /* HAVE_ZLIB */
139       
140        /** file handle manager */
141        OTF_FileManager* manager;
142};
143/** wstream object \ingroup wstream */
144typedef struct struct_OTF_WStream OTF_WStream;
145
146
147/**     
148 * Create a new OTF_WStream instance.
149 *
150 * @param namestub     File name prefix which is going to be used by
151 *                     all sub-files which belong to the writer stream.
152 * @param id           Abitrary but unique identifier of the writer stream.
153 *                     Cannot be '0'.
154 * @param manager      File handle manager.
155 *
156 * @return             Initialized OTF_WStream instance or 0 if an error
157 *                     occurred.
158 *
159 * \ingroup wstream
160 */
161OTF_WStream* OTF_WStream_open( const char* namestub, uint32_t id, 
162        OTF_FileManager* manager );
163
164
165/**
166 * Close an OTF_WStream instance and all its related files.
167 *
168 * @param wstream  Pointer to an initialized OTF_WStream object. See
169 *                 also OTF_WStream_open().
170 *
171 * @return         1 if instance was closed successfully and 0 otherwise.
172 *
173 * \ingroup wstream
174 */
175int OTF_WStream_close( OTF_WStream* wstream );
176
177                       
178/**
179 * Flush an OTF_WStream instance, i.e. flush all associated buffers if existing.
180 *
181 * @param wstream  Pointer to an initialized OTF_WStream object. See
182 *                 also OTF_WStream_open().
183 *
184 * @return         1 if everything flushed successfully and 0 otherwise.
185 *
186 * \ingroup wstream
187 */
188int OTF_WStream_flush( OTF_WStream* wstream );
189
190
191/**
192 * Returns the definition buffer of the according writer stream.
193 *
194 * @param wstream  Pointer to an initialized OTF_WStream object. See
195 *                 also OTF_WStream_open().
196 *
197 * @return         Initialized OTF_WBuffer instance or 0 if an error occured.
198 *
199 * \ingroup wstream
200 */
201OTF_WBuffer* OTF_WStream_getDefBuffer( OTF_WStream* wstream );
202
203
204/**
205 * Returns the event buffer of the according writer stream.
206 *
207 * @param wstream  Pointer to an initialized OTF_WStream object. See
208 *                 also OTF_WStream_open().
209 *
210 * @return         Initialized OTF_WBuffer instance or 0 if an error occured.
211 *
212 * \ingroup wstream
213 */
214OTF_WBuffer* OTF_WStream_getEventBuffer( OTF_WStream* wstream );
215
216
217/**
218 * Returns the snapshots buffer of the according writer stream.
219 *
220 * @param wstream  Pointer to an initialized OTF_WStream object. See
221 *                 also OTF_WStream_open().
222 *
223 * @return         Initialized OTF_WBuffer instance or 0 if an error occured.
224 *
225 * \ingroup wstream
226 */
227OTF_WBuffer* OTF_WStream_getSnapshotBuffer( OTF_WStream* wstream );
228
229
230/**
231 * Returns the statistics buffer of the according writer stream.
232 *
233 * @param wstream  Pointer to an initialized OTF_WStream object. See
234 *                 also OTF_WStream_open().
235 *
236 * @return         Initialized OTF_WBuffer instance or 0 if an error occured.
237 *
238 * \ingroup wstream
239 */
240OTF_WBuffer* OTF_WStream_getStatsBuffer( OTF_WStream* wstream );
241
242
243/**
244 * Set the standard compression method for all buffers managed by this writer
245 * stream
246 *
247 * @param wstream      Pointer to an initialized OTF_WStream object. See
248 *                     also OTF_WStream_open().
249 *
250 * @param compression  Default compression level.
251 *                     0-9, where 0 means no compression is applied, and 9 is
252 *                     the highest level of compression.
253 *
254 * @return             1 on success, 0 if an error occurs.
255 *
256 * \ingroup wstream
257 */
258int OTF_WStream_setCompression( OTF_WStream* wstream, OTF_FileCompression
259        compression );
260       
261       
262/**
263 * Return the standard compression method for all buffers managed by this writer
264 * stream
265 *
266 * @param wstream      Pointer to an initialized OTF_WStream object. See
267 *                     also OTF_WStream_open().
268 *
269 * @return             Standard compression level for all buffers managed by
270 *                     this writer stream.
271 *
272 * \ingroup wstream
273 */
274OTF_FileCompression OTF_WStream_getCompression( OTF_WStream* wstream );
275
276
277/**
278 * Set the default buffer size for all buffers managed by this writer stream.
279 * This is only effective for future buffers and will not change already
280 * allocated buffers. Those can be changed with the buffers directly.
281 *
282 * @param wstream  Pointer to an initialized OTF_WStream object. See
283 *                 also OTF_WStream_open().
284 *
285 * @param size     Intended buffer size.
286 *
287 * \ingroup wstream
288 */
289void OTF_WStream_setBufferSizes( OTF_WStream* wstream, uint32_t size );
290
291/**
292 * Get the default buffer size for all buffers managed by this writer stream.
293 *
294 * @param wstream  Pointer to an initialized OTF_WStream object. See
295 *                 also OTF_WStream_open().
296 *
297 * @return         Default buffer size for all buffers managed by this writer
298 *                 stream.
299 *
300 * \ingroup wstream
301 */
302uint32_t OTF_WStream_getBufferSizes( OTF_WStream* wstream );
303
304/**
305 * Set the default zbuffer size for all files managed by this writer stream.
306 * This is only effective for future files and will not change already
307 * allocated buffers. Those can be changed with the files directly.
308 *
309 * @param wstream  Pointer to an initialized OTF_WStream object. See
310 *                 also OTF_WStream_open().
311 *
312 * @param size     Intended buffer size.
313 *
314 * \ingroup wstream
315 */
316void OTF_WStream_setZBufferSizes( OTF_WStream* wstream, uint32_t size );
317
318
319/**
320 * Get the default zbuffer size for all files managed by this writer stream.
321 *
322 * @param wstream  Pointer to an initialized OTF_WStream object. See
323 *                 also OTF_WStream_open().
324 *
325 * @return         Default buffer size for all buffers managed by this reader
326 *                 stream.
327 *
328 * \ingroup wstream
329 */
330uint32_t OTF_WStream_getZBufferSizes( OTF_WStream* wstream );
331
332/**
333 * Set the default ouput format.
334 *
335 * @param wstream  Pointer to an initialized OTF_WStream object. See
336 *                 also OTF_WStream_open().
337 *
338 * @param format   Intended output format (OTF_WSTREAM_FORMAT_{LONG,SHORT})
339 *
340 * \ingroup wstream
341 */
342void OTF_WStream_setFormat( OTF_WStream* wstream, uint32_t format );
343
344/**
345 * Get the default output format
346 *
347 * @param wstream  Pointer to an initialized OTF_WStream object. See
348 *                 also OTF_WStream_open().
349 *
350 * @return         Default output format.
351 *
352 * \ingroup wstream
353 */
354uint32_t OTF_WStream_getFormat( OTF_WStream* wstream );
355
356
357/* *** definition record write handlers *** ******************************** */
358
359
360/**     Write a DEFINITIONCOMMENT record to stream 'wstream'. \ingroup wstream */
361int OTF_WStream_writeDefinitionComment( OTF_WStream* wstream,
362        const char* comment );
363
364/**     Write a DEFTIMERRESOLUTION record to stream 'wstream'. \ingroup wstream  */
365int OTF_WStream_writeDefTimerResolution( OTF_WStream* wstream,
366        uint64_t ticksPerSecond );
367
368/**     Write a DEFPROCESS record to stream 'wstream'. \ingroup wstream  */
369int OTF_WStream_writeDefProcess( OTF_WStream* wstream, uint32_t deftoken,
370        const char* name, uint32_t parent );
371
372/**     Write a DEFPROCESSGROUP record to stream 'wstream'. \ingroup wstream  */
373int OTF_WStream_writeDefProcessGroup( OTF_WStream* wstream, uint32_t deftoken,
374        const char* name, uint32_t n, const uint32_t* array );
375
376/**     Write a DEFFUNCTION record to stream 'wstream'. \ingroup wstream  */
377int OTF_WStream_writeDefFunction( OTF_WStream* wstream, uint32_t deftoken,
378        const char* name, uint32_t group, uint32_t scltoken );
379
380/**     Write a DEFFUNCTIONGROUP record to stream 'wstream'. \ingroup wstream  */
381int OTF_WStream_writeDefFunctionGroup( OTF_WStream* wstream,
382        uint32_t deftoken, const char* name );
383
384/** Write a DEFCOLLECTIVEOPERATION record to stream 'wstream'. \ingroup wstream  */
385int OTF_WStream_writeDefCollectiveOperation( OTF_WStream* wstream, 
386        uint32_t collOp, const char* name, uint32_t type );
387
388/**     Write a DEFCOUNTER record to stream 'wstream'. \ingroup wstream  */
389int OTF_WStream_writeDefCounter( OTF_WStream* wstream, uint32_t deftoken,
390        const char* name, uint32_t properties, uint32_t countergroup, 
391        const char* unit );
392
393/**     Write a DEFCOUNTERGROUP record to stream 'wstream'. \ingroup wstream  */
394int OTF_WStream_writeDefCounterGroup( OTF_WStream* wstream,
395        uint32_t deftoken, const char* name );
396
397/**     Write a DEFSCL record to stream 'wstream'. \ingroup wstream  */
398int OTF_WStream_writeDefScl( OTF_WStream* wstream, uint32_t deftoken,
399        uint32_t sclfile, uint32_t sclline );
400
401/**     Write a DEFSCLFILE record to stream 'wstream'. \ingroup wstream  */
402int OTF_WStream_writeDefSclFile( OTF_WStream* wstream,
403        uint32_t deftoken, const char* filename );
404
405/**     Write a DEFCREATOR record to stream 'wstream'. \ingroup wstream  */
406int OTF_WStream_writeDefCreator( OTF_WStream* wstream, const char* creator );
407
408/** Write a DEFVERSION record to stream 'wstream'. \ingroup wstream  */
409int OTF_WStream_writeOtfVersion( OTF_WStream* wstream );
410
411/** Write a DEFFILE record to stream 'wstream'. \ingroup wstream  */
412int OTF_WStream_writeDefFile( OTF_WStream* wstream, uint32_t token,
413        const char* name, uint32_t group );
414
415/** Write a DEFFILEGROUP record to stream 'wstream'. \ingroup wstream  */
416int OTF_WStream_writeDefFileGroup( OTF_WStream* wstream, uint32_t token,
417        const char* name );
418
419
420/* *** event record write handlers *** ************************************* */
421
422
423/**     Write a ENTER record to stream 'wstream'. \ingroup wstream  */
424int OTF_WStream_writeEnter( OTF_WStream* wstream, uint64_t time,
425    uint32_t statetoken, uint32_t cpuid, uint32_t scltoken );
426
427/**     Write a RECEIVE record to stream 'wstream'. \ingroup wstream  */
428int OTF_WStream_writeRecvMsg( OTF_WStream* wstream, uint64_t time,
429    uint32_t receiver, uint32_t sender, uint32_t communicator,
430    uint32_t msgtype, uint32_t msglength, uint32_t scltoken );
431
432/**     Write a SEND record to stream 'wstream'. \ingroup wstream  */
433int OTF_WStream_writeSendMsg( OTF_WStream* wstream, uint64_t time, 
434    uint32_t sender, uint32_t receiver, uint32_t communicator, 
435    uint32_t msgtype, uint32_t msglength, uint32_t scltoken );
436
437/**     Write a LEAVE record to stream 'wstream'. \ingroup wstream  */
438int OTF_WStream_writeLeave( OTF_WStream* wstream, uint64_t time,
439    uint32_t statetoken, uint32_t cpuid, uint32_t scltoken );
440
441/**     Write a COUNTER record to stream 'wstream'. \ingroup wstream  */
442int OTF_WStream_writeCounter( OTF_WStream* wstream, uint64_t time, 
443    uint32_t process, uint32_t counter_token, uint64_t value );
444
445/** Write a COLLOP record to stream 'wstream'. \ingroup wstream  */
446int OTF_WStream_writeCollectiveOperation( OTF_WStream* wstream, uint64_t time, 
447    uint32_t process, uint32_t functionToken, uint32_t communicator, 
448    uint32_t rootprocess, uint32_t sent, uint32_t received, 
449    uint64_t duration, uint32_t scltoken );
450
451/** Write a #EVTCOMMENT record to stream 'wstream'. \ingroup wstream  */
452int OTF_WStream_writeEventComment( OTF_WStream* wstream, uint64_t time, 
453    uint32_t process, const char* comment );
454
455/** Write a PROCESSBEGIN record to stream 'wstream'. \ingroup wstream  */
456int OTF_WStream_writeBeginProcess( OTF_WStream* wstream, uint64_t time,
457    uint32_t process );
458
459/** Write a PROCESSEND record to stream 'wstream'. \ingroup wstream  */
460int OTF_WStream_writeEndProcess( OTF_WStream* wstream, uint64_t time,
461    uint32_t process );
462
463int OTF_WStream_writeFileOperation( OTF_WStream* wstream, uint64_t time,
464        uint32_t fileid, uint32_t process, uint64_t handleid, uint32_t operation,
465        uint64_t bytes, uint64_t duration, uint32_t source );
466
467
468/* *** public snapshot record write handlers *** */
469
470
471/** Write a #TCOMMENT record to stream 'wstream'. \ingroup wstream  */
472int OTF_WStream_writeSnapshotComment( OTF_WStream* wstream, uint64_t time, 
473    uint32_t process, const char* comment );
474
475/** Write a TENTER record to stream 'wstream'. \ingroup wstream  */
476int OTF_WStream_writeEnterSnapshot( OTF_WStream* wstream, uint64_t time,
477    uint64_t originaltime, uint32_t statetoken, uint32_t cpuid, uint32_t scltoken );
478
479/** Write a TSEND record to stream 'wstream'. \ingroup wstream  */
480int OTF_WStream_writeSendSnapshot( OTF_WStream* wstream, uint64_t time,
481                uint64_t originaltime, uint32_t sender, uint32_t receiver,
482                uint32_t procGroup, uint32_t type, uint32_t source );
483
484/** Write a TOPENFILE record to stream 'wstream'. \ingroup wstream  */
485int OTF_WStream_writeOpenFileSnapshot( OTF_WStream* wstream,uint64_t time,
486        uint64_t originaltime, uint32_t fileid, uint32_t process, uint64_t handleid,
487        uint32_t source );
488
489               
490/* *** public statistics record write handlers *** */
491
492
493/** Write a SUMCOMMENT record to stream 'wstream'. \ingroup wstream  */
494int OTF_WStream_writeSummaryComment( OTF_WStream* wstream, uint64_t time, 
495    uint32_t process, const char* comment );
496
497/** Write a SUMFUNCTION record to stream 'wstream'. \ingroup wstream  */
498int OTF_WStream_writeFunctionSummary( OTF_WStream* wstream, 
499        uint64_t time, uint32_t function, uint32_t process, 
500        uint64_t count, uint64_t excltime, uint64_t incltime );
501
502/** Write a SUMFUNCTIONGROUP record to stream 'wstream'. \ingroup wstream  */
503int OTF_WStream_writeFunctionGroupSummary( OTF_WStream* wstream, 
504        uint64_t time,  uint32_t functiongroup,  uint32_t process, 
505        uint64_t count,  uint64_t excltime,  uint64_t incltime );
506
507/** Write a SUMMESSAGE record to stream 'wstream'. \ingroup wstream  */
508int OTF_WStream_writeMessageSummary( OTF_WStream* wstream, 
509        uint64_t time, uint32_t process, uint32_t peer, 
510        uint32_t comm,  uint32_t tag, uint64_t number_sent, uint64_t number_recved,
511        uint64_t bytes_sent,  uint64_t bytes_recved );
512
513/** Write a SUMFILEOPERATION record to stream 'wstream'. \ingroup wstream  */
514int OTF_WStream_writeFileOperationSummary( OTF_WStream* wstream, uint64_t time,
515        uint32_t fileid, uint32_t process, uint64_t nopen, uint64_t nclose,
516        uint64_t nread, uint64_t nwrite, uint64_t nseek, uint64_t bytesread,
517        uint64_t byteswrite );
518
519/** Write a SUMFILEGROUPOPERATION record to stream 'wstream'. \ingroup wstream  */
520int OTF_WStream_writeFileGroupOperationSummary( OTF_WStream* wstream, uint64_t time,
521        uint32_t groupid, uint32_t process, uint64_t nopen, uint64_t nclose,
522        uint64_t nread, uint64_t nwrite, uint64_t nseek, uint64_t bytesread,
523        uint64_t byteswrite );
524
525/*
526int OTF_WStream_writeCounterSummary( OTF_WStream* wstream,
527        uint64_t time,  uint32_t process, 
528        uint32_t counter,  uint64_t value );
529
530int OTF_WStream_writeCollOpSummary( OTF_WStream* wstream,
531        uint64_t time, uint32_t process,  uint32_t root, 
532        uint64_t bytes_sent, uint64_t bytes_recved );
533*/
534
535#ifdef __cplusplus
536}
537#endif /* __cplusplus */
538
539#endif /* OTF_WSTREAM_H */
540
Note: See TracBrowser for help on using the repository browser.