Commit 107dcfc1 authored by Shane Snyder's avatar Shane Snyder
Browse files

sync null module with new changes

this includes defining an example logutils function for
aggregating null records into a single shared null record (needed
for darshan-merge utility)
parent c8266822
...@@ -11,18 +11,18 @@ ...@@ -11,18 +11,18 @@
#define DARSHAN_NULL_VER 1 #define DARSHAN_NULL_VER 1
#define NULL_COUNTERS \ #define NULL_COUNTERS \
/* count of number of 'bar' function calls */\ /* number of 'foo' function calls */\
X(NULL_BARS) \ X(NULL_FOOS) \
/* arbitrary data value set by last call to 'bar' */\ /* maximum data value set by calls to 'foo' */\
X(NULL_BAR_DAT) \ X(NULL_FOO_MAX_DAT) \
/* end of counters */\ /* end of counters */\
X(NULL_NUM_INDICES) X(NULL_NUM_INDICES)
#define NULL_F_COUNTERS \ #define NULL_F_COUNTERS \
/* timestamp of the first call to function 'bar' */\ /* timestamp of the first call to function 'foo' */\
X(NULL_F_BAR_TIMESTAMP) \ X(NULL_F_FOO_TIMESTAMP) \
/* timer indicating duration of last call to 'bar' */\ /* timer indicating duration of call to 'foo' with max NULL_FOO_MAX_DAT value */\
X(NULL_F_BAR_DURATION) \ X(NULL_F_FOO_MAX_DURATION) \
/* end of counters */\ /* end of counters */\
X(NULL_F_NUM_INDICES) X(NULL_F_NUM_INDICES)
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* declarations for wrapped funcions, regardless of whether Darshan is used with * declarations for wrapped funcions, regardless of whether Darshan is used with
* statically or dynamically linked executables. * statically or dynamically linked executables.
*/ */
DARSHAN_FORWARD_DECL(foo, int, (const char *name, int arg1, int arg2)); DARSHAN_FORWARD_DECL(foo, int, (const char *name, int arg1));
/* The null_record_ref structure maintains necessary runtime metadata /* The null_record_ref structure maintains necessary runtime metadata
* for the NULL module record (darshan_null_record structure, defined in * for the NULL module record (darshan_null_record structure, defined in
...@@ -132,9 +132,6 @@ static int my_rank = -1; ...@@ -132,9 +132,6 @@ static int my_rank = -1;
} while(0) } while(0)
/* macro for instrumenting the "NULL" module's foo function */ /* macro for instrumenting the "NULL" module's foo function */
/* NOTE: this macro makes use of the DARSHAN_COUNTER_* macros defined
* and documented in darshan.h.
*/
#define NULL_RECORD_FOO(__ret, __name, __dat, __tm1, __tm2) do{ \ #define NULL_RECORD_FOO(__ret, __name, __dat, __tm1, __tm2) do{ \
darshan_record_id rec_id; \ darshan_record_id rec_id; \
struct null_record_ref *rec_ref; \ struct null_record_ref *rec_ref; \
...@@ -149,14 +146,17 @@ static int my_rank = -1; ...@@ -149,14 +146,17 @@ static int my_rank = -1;
if(!rec_ref) null_track_new_record(rec_id, __name); \ if(!rec_ref) null_track_new_record(rec_id, __name); \
/* if we still don't have a valid reference, back out */ \ /* if we still don't have a valid reference, back out */ \
if(!rec_ref) break; \ if(!rec_ref) break; \
/* increment counter indicating number of calls to 'bar' */ \ /* increment counter indicating number of calls to 'foo' */ \
rec_ref->record_p->counters[NULL_BARS] += 1; \ rec_ref->record_p->counters[NULL_FOOS] += 1; \
/* store data value for most recent call to 'bar' */ \ /* store max data value for calls to 'foo', and corresponding time duration */ \
rec_ref->record_p->counters[NULL_BAR_DAT] = __dat; \ if(rec_ref->record_p->counters[NULL_FOO_MAX_DAT] < __dat) { \
/* store timestamp of most recent call to 'bar' */ \ rec_ref->record_p->counters[NULL_FOO_MAX_DAT] = __dat; \
rec_ref->record_p->fcounters[NULL_F_BAR_TIMESTAMP] = __tm1; \ rec_ref->record_p->fcounters[NULL_F_FOO_MAX_DURATION] = __elapsed; \
/* store duration of most recent call to 'bar' */ \ } \
rec_ref->record_p->fcounters[NULL_F_BAR_DURATION] = __elapsed; \ /* store timestamp of first call to 'foo' */ \
if(rec_ref->record_p->fcounters[NULL_F_FOO_TIMESTAMP] == 0 || \
rec_ref->record_p->fcounters[NULL_F_FOO_TIMESTAMP] > __tm1) \
rec_ref->record_p->fcounters[NULL_F_FOO_TIMESTAMP] = __tm1; \
} while(0) } while(0)
/********************************************************** /**********************************************************
...@@ -166,7 +166,7 @@ static int my_rank = -1; ...@@ -166,7 +166,7 @@ static int my_rank = -1;
/* The DARSHAN_DECL macro provides the appropriate wrapper function names, /* The DARSHAN_DECL macro provides the appropriate wrapper function names,
* depending on whether the Darshan library is statically or dynamically linked. * depending on whether the Darshan library is statically or dynamically linked.
*/ */
int DARSHAN_DECL(foo)(const char* name, int arg1, int arg2) int DARSHAN_DECL(foo)(const char* name, int arg1)
{ {
ssize_t ret; ssize_t ret;
double tm1, tm2; double tm1, tm2;
...@@ -182,12 +182,12 @@ int DARSHAN_DECL(foo)(const char* name, int arg1, int arg2) ...@@ -182,12 +182,12 @@ int DARSHAN_DECL(foo)(const char* name, int arg1, int arg2)
* given wrapper function. Timers are used to record the duration of this * given wrapper function. Timers are used to record the duration of this
* operation. */ * operation. */
tm1 = darshan_core_wtime(); tm1 = darshan_core_wtime();
ret = __real_foo(name, arg1, arg2); ret = __real_foo(name, arg1);
tm2 = darshan_core_wtime(); tm2 = darshan_core_wtime();
NULL_PRE_RECORD(); NULL_PRE_RECORD();
/* Call macro for instrumenting data for foo function calls. */ /* Call macro for instrumenting data for foo function calls. */
NULL_RECORD_FOO(ret, name, arg1+arg2, tm1, tm2); NULL_RECORD_FOO(ret, name, arg1, tm1, tm2);
NULL_POST_RECORD(); NULL_POST_RECORD();
return(ret); return(ret);
......
...@@ -56,9 +56,8 @@ struct darshan_mod_logutil_funcs null_logutils = ...@@ -56,9 +56,8 @@ struct darshan_mod_logutil_funcs null_logutils =
}; };
/* retrieve a NULL record from log file descriptor 'fd', storing the /* retrieve a NULL record from log file descriptor 'fd', storing the
* buffer in 'null_buf' and the corresponding Darshan record id in * data in the buffer address pointed to by 'null_buf_p'. Return 1 on
* 'rec_id'. Return 1 on successful record read, 0 on no more data, * successful record read, 0 on no more data, and -1 on error.
* and -1 on error.
*/ */
static int darshan_log_get_null_record(darshan_fd fd, void** null_buf_p) static int darshan_log_get_null_record(darshan_fd fd, void** null_buf_p)
{ {
...@@ -109,8 +108,8 @@ static int darshan_log_get_null_record(darshan_fd fd, void** null_buf_p) ...@@ -109,8 +108,8 @@ static int darshan_log_get_null_record(darshan_fd fd, void** null_buf_p)
} }
} }
/* write the NULL record stored in 'null_buf' to log file descriptor 'fd'. /* write the NULL record stored in 'null_buf' (with version number 'ver')
* Return 0 on success, -1 on failure * to log file descriptor 'fd'. Return 0 on success, -1 on failure
*/ */
static int darshan_log_put_null_record(darshan_fd fd, void* null_buf, int ver) static int darshan_log_put_null_record(darshan_fd fd, void* null_buf, int ver)
{ {
...@@ -160,14 +159,15 @@ static void darshan_log_print_null_record(void *file_rec, char *file_name, ...@@ -160,14 +159,15 @@ static void darshan_log_print_null_record(void *file_rec, char *file_name,
static void darshan_log_print_null_description() static void darshan_log_print_null_description()
{ {
printf("\n# description of NULL counters:\n"); printf("\n# description of NULL counters:\n");
printf("# NULL_BARS: number of 'bar' function calls.\n"); printf("# NULL_FOOS: number of 'foo' function calls.\n");
printf("# NULL_BAR_DAT: value set by last call to function 'bar'.\n"); printf("# NULL_FOO_MAX_DAT: maximum data value set by calls to 'foo'.\n");
printf("# NULL_F_BAR_TIMESTAMP: timestamp of the first call to function 'bar'.\n"); printf("# NULL_F_FOO_TIMESTAMP: timestamp of the first call to function 'foo'.\n");
printf("# NULL_F_BAR_DURATION: duration of the last call to function 'bar'.\n"); printf("# NULL_F_FOO_MAX_DURATION: timer indicating duration of call to 'foo' with max NULL_FOO_MAX_DAT value.\n");
return; return;
} }
/* print a diff of two NULL records (with the same record id) */
static void darshan_log_print_null_record_diff(void *file_rec1, char *file_name1, static void darshan_log_print_null_record_diff(void *file_rec1, char *file_name1,
void *file_rec2, char *file_name2) void *file_rec2, char *file_name2)
{ {
...@@ -240,8 +240,57 @@ static void darshan_log_print_null_record_diff(void *file_rec1, char *file_name1 ...@@ -240,8 +240,57 @@ static void darshan_log_print_null_record_diff(void *file_rec1, char *file_name1
return; return;
} }
/* aggregate the input NULL record 'rec' into the output record 'agg_rec' */
static void darshan_log_agg_null_records(void *rec, void *agg_rec, int init_flag) static void darshan_log_agg_null_records(void *rec, void *agg_rec, int init_flag)
{ {
struct darshan_null_record *null_rec = (struct darshan_null_record *)rec;
struct darshan_null_record *agg_null_rec = (struct darshan_null_record *)agg_rec;
int i;
for(i = 0; i < NULL_NUM_INDICES; i++)
{
switch(i)
{
case NULL_FOOS:
/* sum */
agg_null_rec->counters[i] += null_rec->counters[i];
break;
case NULL_FOO_MAX_DAT:
/* max */
if(null_rec->counters[i] > agg_null_rec->counters[i])
{
agg_null_rec->counters[i] = null_rec->counters[i];
agg_null_rec->fcounters[NULL_F_FOO_MAX_DURATION] =
null_rec->fcounters[NULL_F_FOO_MAX_DURATION];
}
break;
default:
/* if we don't know how to aggregate this counter, just set to -1 */
agg_null_rec->counters[i] = -1;
break;
}
}
for(i = 0; i < NULL_F_NUM_INDICES; i++)
{
switch(i)
{
case NULL_F_FOO_TIMESTAMP:
/* min non-zero */
if((null_rec->fcounters[i] > 0) &&
((agg_null_rec->fcounters[i] == 0) ||
(null_rec->fcounters[i] < agg_null_rec->fcounters[i])))
{
agg_null_rec->fcounters[i] = null_rec->fcounters[i];
}
break;
default:
/* if we don't know how to aggregate this counter, just set to -1 */
agg_null_rec->fcounters[i] = -1;
break;
}
}
return; return;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment