Commit 04063da7 authored by Shane Snyder's avatar Shane Snyder

common access counters are now sorted in logs

common value counters are sorted first by decreasing counts,
and then by decreasing size.
parent d4a3d112
......@@ -66,7 +66,10 @@
} while(0)
/* potentially set or increment a common value counter, depending on the __count
* for the given __value
* for the given __value. This macro ensures common values are stored first in
* decreasing order of their total count, and second by decreasing order of
* their value.
*
* NOTE: This macro is hardcoded to expect that Darshan will only track the 4
* most common (i.e., frequently occuring) values. __val_p is a pointer to the
......@@ -78,32 +81,50 @@
*/
#define DARSHAN_COMMON_VAL_COUNTER_INC(__val_p, __cnt_p, __value, __count, __online_flag) do {\
int i; \
int set = 0; \
int64_t min = *(__cnt_p); \
int min_index = 0; \
int inc_count; \
int inc_count, total_count; \
int64_t tmp_val[4] = {0}; \
int64_t tmp_cnt[4] = {0}; \
int tmp_ndx = 0; \
if(__value == 0) break; \
if(__online_flag) \
inc_count = 1; \
else \
inc_count = __count; \
for(i=0; i<4; i++) { \
/* increment bucket if already exists */ \
if(*(__val_p + i) == __value) { \
*(__cnt_p + i) += inc_count; \
set = 1; \
total_count = *(__cnt_p + i) + inc_count; \
break; \
} \
/* otherwise find the least frequently used bucket */ \
else if(*(__cnt_p + i) < min) { \
min = *(__cnt_p + i); \
min_index = i; \
} \
if(i == 4) total_count = __count; \
/* first, copy over any counters that should be sorted above this one \
* (counters with higher counts or equal counts and larger values) \
*/ \
for(i=0;i < 4; i++) { \
if((*(__cnt_p + i) > total_count) || \
((*(__cnt_p + i) == total_count) && (*(__val_p + i) > __value))) { \
tmp_val[tmp_ndx] = *(__val_p + i); \
tmp_cnt[tmp_ndx] = *(__cnt_p + i); \
tmp_ndx++; \
} \
else break; \
} \
if(!set && (__count > min)) { \
*(__cnt_p + min_index) = __count; \
*(__val_p + min_index) = __value; \
if(tmp_ndx == 4) break; /* all done, updated counter is not added */ \
/* next, add the updated counter */ \
tmp_val[tmp_ndx] = __value; \
tmp_cnt[tmp_ndx] = total_count; \
tmp_ndx++; \
/* last, copy over any remaining counters to make sure we have 4 sets total */ \
while(tmp_ndx != 4) { \
if(*(__val_p + i) != __value) { \
tmp_val[tmp_ndx] = *(__val_p + i); \
tmp_cnt[tmp_ndx] = *(__cnt_p + i); \
tmp_ndx++; \
} \
i++; \
} \
memcpy(__val_p, tmp_val, 4*sizeof(int64_t)); \
memcpy(__cnt_p, tmp_cnt, 4*sizeof(int64_t)); \
} while(0)
/* maximum number of common values that darshan will track per file at
......
......@@ -237,9 +237,10 @@ static void darshan_log_agg_mpiio_files(void *rec, void *agg_rec, int init_flag)
struct darshan_mpiio_file *mpi_rec = (struct darshan_mpiio_file *)rec;
struct darshan_mpiio_file *agg_mpi_rec = (struct darshan_mpiio_file *)agg_rec;
int i, j, k;
int set;
int min_ndx;
int64_t min;
int total_count;
int64_t tmp_val[4];
int64_t tmp_cnt[4];
int tmp_ndx;
double old_M;
double mpi_time = mpi_rec->fcounters[MPIIO_F_READ_TIME] +
mpi_rec->fcounters[MPIIO_F_WRITE_TIME] +
......@@ -308,30 +309,69 @@ static void darshan_log_agg_mpiio_files(void *rec, void *agg_rec, int init_flag)
break;
case MPIIO_ACCESS1_ACCESS:
/* increment common value counters */
if(mpi_rec->counters[i] == 0) break;
/* first, collapse duplicates */
for(j = i; j < i + 4; j++)
{
min = agg_mpi_rec->counters[i + 4];
min_ndx = 0;
set = 0;
for(k = 0; k < 4; k++)
{
if(agg_mpi_rec->counters[i + k] == mpi_rec->counters[j])
{
agg_mpi_rec->counters[i + k + 4] += mpi_rec->counters[j + 4];
set = 1;
mpi_rec->counters[j] = mpi_rec->counters[j + 4] = 0;
}
}
}
/* second, add new counters */
for(j = i; j < i + 4; j++)
{
tmp_ndx = 0;
memset(tmp_val, 0, 4 * sizeof(int64_t));
memset(tmp_cnt, 0, 4 * sizeof(int64_t));
for(k = 0; k < 4; k++)
{
if(agg_mpi_rec->counters[i + k] == mpi_rec->counters[j])
{
total_count = agg_mpi_rec->counters[i + k + 4] +
mpi_rec->counters[j + 4];
break;
}
else if(agg_mpi_rec->counters[i + k + 4] < min)
}
if(k == 4) total_count = mpi_rec->counters[j + 4];
for(k = 0; k < 4; k++)
{
if((agg_mpi_rec->counters[i + k + 4] > total_count) ||
((agg_mpi_rec->counters[i + k + 4] == total_count) &&
(agg_mpi_rec->counters[i + k] > mpi_rec->counters[j])))
{
min = agg_mpi_rec->counters[i + k + 4];
min_ndx = k;
tmp_val[tmp_ndx] = agg_mpi_rec->counters[i + k];
tmp_cnt[tmp_ndx] = agg_mpi_rec->counters[i + k + 4];
tmp_ndx++;
}
else break;
}
if(!set && (mpi_rec->counters[j + 4] > min))
if(tmp_ndx == 4) break;
tmp_val[tmp_ndx] = mpi_rec->counters[j];
tmp_cnt[tmp_ndx] = mpi_rec->counters[j + 4];
tmp_ndx++;
while(tmp_ndx != 4)
{
agg_mpi_rec->counters[i + min_ndx] = mpi_rec->counters[j];
agg_mpi_rec->counters[i + min_ndx + 4] = mpi_rec->counters[j + 4];
if(agg_mpi_rec->counters[i + k] != mpi_rec->counters[j])
{
tmp_val[tmp_ndx] = agg_mpi_rec->counters[i + k];
tmp_cnt[tmp_ndx] = agg_mpi_rec->counters[i + k + 4];
tmp_ndx++;
}
k++;
}
memcpy(&(agg_mpi_rec->counters[i]), tmp_val, 4 * sizeof(int64_t));
memcpy(&(agg_mpi_rec->counters[i + 4]), tmp_cnt, 4 * sizeof(int64_t));
}
break;
case MPIIO_ACCESS2_ACCESS:
......
......@@ -238,9 +238,10 @@ static void darshan_log_agg_posix_files(void *rec, void *agg_rec, int init_flag)
struct darshan_posix_file *psx_rec = (struct darshan_posix_file *)rec;
struct darshan_posix_file *agg_psx_rec = (struct darshan_posix_file *)agg_rec;
int i, j, k;
int set;
int min_ndx;
int64_t min;
int total_count;
int64_t tmp_val[4];
int64_t tmp_cnt[4];
int tmp_ndx;
double old_M;
double psx_time = psx_rec->fcounters[POSIX_F_READ_TIME] +
psx_rec->fcounters[POSIX_F_WRITE_TIME] +
......@@ -325,30 +326,69 @@ static void darshan_log_agg_posix_files(void *rec, void *agg_rec, int init_flag)
case POSIX_STRIDE1_STRIDE:
case POSIX_ACCESS1_ACCESS:
/* increment common value counters */
if(psx_rec->counters[i] == 0) break;
/* first, collapse duplicates */
for(j = i; j < i + 4; j++)
{
min = agg_psx_rec->counters[i + 4];
min_ndx = 0;
set = 0;
for(k = 0; k < 4; k++)
{
if(agg_psx_rec->counters[i + k] == psx_rec->counters[j])
{
agg_psx_rec->counters[i + k + 4] += psx_rec->counters[j + 4];
set = 1;
psx_rec->counters[j] = psx_rec->counters[j + 4] = 0;
}
}
}
/* second, add new counters */
for(j = i; j < i + 4; j++)
{
tmp_ndx = 0;
memset(tmp_val, 0, 4 * sizeof(int64_t));
memset(tmp_cnt, 0, 4 * sizeof(int64_t));
for(k = 0; k < 4; k++)
{
if(agg_psx_rec->counters[i + k] == psx_rec->counters[j])
{
total_count = agg_psx_rec->counters[i + k + 4] +
psx_rec->counters[j + 4];
break;
}
else if(agg_psx_rec->counters[i + k + 4] < min)
}
if(k == 4) total_count = psx_rec->counters[j + 4];
for(k = 0; k < 4; k++)
{
if((agg_psx_rec->counters[i + k + 4] > total_count) ||
((agg_psx_rec->counters[i + k + 4] == total_count) &&
(agg_psx_rec->counters[i + k] > psx_rec->counters[j])))
{
min = agg_psx_rec->counters[i + k + 4];
min_ndx = k;
tmp_val[tmp_ndx] = agg_psx_rec->counters[i + k];
tmp_cnt[tmp_ndx] = agg_psx_rec->counters[i + k + 4];
tmp_ndx++;
}
else break;
}
if(!set && (psx_rec->counters[j + 4] > min))
if(tmp_ndx == 4) break;
tmp_val[tmp_ndx] = psx_rec->counters[j];
tmp_cnt[tmp_ndx] = psx_rec->counters[j + 4];
tmp_ndx++;
while(tmp_ndx != 4)
{
agg_psx_rec->counters[i + min_ndx] = psx_rec->counters[j];
agg_psx_rec->counters[i + min_ndx + 4] = psx_rec->counters[j + 4];
if(agg_psx_rec->counters[i + k] != psx_rec->counters[j])
{
tmp_val[tmp_ndx] = agg_psx_rec->counters[i + k];
tmp_cnt[tmp_ndx] = agg_psx_rec->counters[i + k + 4];
tmp_ndx++;
}
k++;
}
memcpy(&(agg_psx_rec->counters[i]), tmp_val, 4 * sizeof(int64_t));
memcpy(&(agg_psx_rec->counters[i + 4]), tmp_cnt, 4 * sizeof(int64_t));
}
break;
case POSIX_STRIDE2_STRIDE:
......
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