Commit 73c5f0c9 authored by Shane Snyder's avatar Shane Snyder

cleanup bgq up-convert code

parent e1ad9514
......@@ -30,14 +30,7 @@ char *bgq_f_counter_names[] = {
};
#undef X
/* old definitions for enforcing backwards compatibility */
struct darshan_bgq_record_1
{
struct darshan_base_record base_rec;
int alignment;
int64_t counters[BGQ_NUM_INDICES];
double fcounters[BGQ_F_NUM_INDICES];
};
#define DARSHAN_BGQ_FILE_SIZE_1 (112 + sizeof(int))
static int darshan_log_get_bgq_rec(darshan_fd fd, void* bgq_buf);
static int darshan_log_put_bgq_rec(darshan_fd fd, void* bgq_buf, int ver);
......@@ -60,9 +53,9 @@ struct darshan_mod_logutil_funcs bgq_logutils =
static int darshan_log_get_bgq_rec(darshan_fd fd, void* bgq_buf)
{
int log_rec_len;
struct darshan_bgq_record *rec =
(struct darshan_bgq_record *)bgq_buf;
struct darshan_bgq_record *rec = (struct darshan_bgq_record *)bgq_buf;
int rec_len;
char *buffer, *p;
int i;
int ret = -1;
......@@ -71,32 +64,34 @@ static int darshan_log_get_bgq_rec(darshan_fd fd, void* bgq_buf)
*/
if(fd->mod_ver[DARSHAN_BGQ_MOD] == 1)
{
struct darshan_bgq_record_1 bgq_rec_1;
log_rec_len = sizeof(struct darshan_bgq_record_1);
buffer = malloc(DARSHAN_BGQ_FILE_SIZE_1);
if(!buffer)
return(-1);
ret = darshan_log_get_mod(fd, DARSHAN_BGQ_MOD, &bgq_rec_1,
log_rec_len);
if(ret == log_rec_len)
rec_len = DARSHAN_BGQ_FILE_SIZE_1;
ret = darshan_log_get_mod(fd, DARSHAN_BGQ_MOD, buffer, rec_len);
if(ret == rec_len)
{
/* up-convert old BGQ format to new format */
rec->base_rec = bgq_rec_1.base_rec;
memcpy(rec->counters, bgq_rec_1.counters,
BGQ_NUM_INDICES * sizeof(int64_t));
memcpy(rec->fcounters, bgq_rec_1.fcounters,
BGQ_F_NUM_INDICES * sizeof(double));
p = buffer;
memcpy(&(rec->base_rec), p, sizeof(struct darshan_base_record));
p += sizeof(struct darshan_base_record);
p += sizeof(int);
memcpy(&(rec->counters[0]), p, BGQ_NUM_INDICES * sizeof(int64_t));
p += (BGQ_NUM_INDICES * sizeof(int64_t));
memcpy(&(rec->fcounters[0]), p, BGQ_F_NUM_INDICES * sizeof(double));
}
free(buffer);
}
else if(fd->mod_ver[DARSHAN_BGQ_MOD] == 2)
{
log_rec_len = sizeof(struct darshan_bgq_record);
ret = darshan_log_get_mod(fd, DARSHAN_BGQ_MOD, rec,
log_rec_len);
rec_len = sizeof(struct darshan_bgq_record);
ret = darshan_log_get_mod(fd, DARSHAN_BGQ_MOD, rec, rec_len);
}
if(ret < 0)
return(-1);
else if(ret < log_rec_len)
else if(ret < rec_len)
return(0);
else
{
......
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