Commit 33008e39 authored by Shane Snyder's avatar Shane Snyder

Final changes to build/use darshan workload api

parent b073000d
......@@ -36,7 +36,7 @@ include $(top_srcdir)/src/Makefile.subdir
include $(top_srcdir)/tests/Makefile.subdir
if USE_DARSHAN
AM_CPPFLAGS += ${DARSHAN_CFLAGS}
AM_CPPFLAGS += ${DARSHAN_CFLAGS} "-DUSE_DARSHAN=1"
src_libcodes_base_a_SOURCES += src/workload/codes-darshan-io-wrkld.c
tests_workload_codes_workload_test_LDADD += ${DARSHAN_LIBS}
tests_workload_codes_workload_mpi_replay_LDADD += ${DARSHAN_LIBS}
......
......@@ -41,14 +41,6 @@ struct rank_io_context
struct qhash_head hash_link;
};
struct darshan_io_dat_array
{
struct darshan_io_op *op_array;
int64_t op_arr_ndx;
int64_t op_arr_cnt;
};
/* Darshan workload generator's implementation of the CODES workload API */
static int darshan_io_workload_load(const char *params, int rank);
static void darshan_io_workload_get_next(int rank, struct codes_workload_op *op);
......@@ -60,6 +52,7 @@ static void darshan_insert_next_io_op(void *io_op_dat, struct darshan_io_op *io_
static void darshan_remove_next_io_op(void *io_op_dat, struct darshan_io_op *io_op,
double last_op_time);
static void darshan_finalize_io_op_dat(void *io_op_dat);
static void darshan_print_io_ops(void *io_op_dat, int rank, FILE *log_stream);
static int darshan_io_op_compare(const void *p1, const void *p2);
/* Helper functions for implementing the (complex, nonfactored) Darshan workload generator */
......@@ -91,12 +84,6 @@ static void calc_io_delays(struct darshan_file *file, int64_t num_opens, int64_t
double *inter_open_delay, double *inter_io_delay);
static void file_sanity_check(struct darshan_file *file, struct darshan_job *job);
void print_events(struct darshan_io_op *event_list,
int64_t event_list_cnt,
int rank,
FILE *log_stream);
/* workload method name and function pointers for the CODES workload API */
struct codes_workload_method darshan_io_workload_method =
{
......@@ -194,8 +181,11 @@ static int darshan_io_workload_load(const char *params, int rank)
qhash_add(rank_tbl, &(my_ctx->my_rank), &(my_ctx->hash_link));
rank_tbl_pop++;
struct darshan_io_dat_array *arr = (struct darshan_io_dat_array *)my_ctx->io_op_dat;
print_events(arr->op_array, arr->op_arr_cnt, rank, d_params->stream);
/* TODO: do we want this long-term */
if (d_params->stream)
{
darshan_print_io_ops(my_ctx->io_op_dat, rank, d_params->stream);
}
return 0;
}
......@@ -269,7 +259,6 @@ static int darshan_rank_hash_compare(
#define DARSHAN_IO_OP_INC_CNT 100000
#if 0
/* dynamically allocated array data structure for storing darshan i/o events */
struct darshan_io_dat_array
{
......@@ -277,7 +266,6 @@ struct darshan_io_dat_array
int64_t op_arr_ndx;
int64_t op_arr_cnt;
};
#endif
/* initialize the dynamic array data structure */
static void *darshan_init_io_op_dat()
......@@ -371,6 +359,75 @@ static void darshan_finalize_io_op_dat(
return;
}
/* print the events for this rank in order */
void darshan_print_io_ops(void *io_op_dat, int rank, FILE *log_stream)
{
struct darshan_io_dat_array *io_array = (struct darshan_io_dat_array *)io_op_dat;
struct darshan_io_op *event_list = io_array->op_array;
int64_t event_list_cnt = io_array->op_arr_cnt;
int64_t i;
if (!event_list_cnt)
return;
for (i = 0; i < event_list_cnt; i++)
{
if (event_list[i].codes_op.op_type == CODES_WK_OPEN)
{
if (event_list[i].codes_op.u.open.create_flag == 0)
{
fprintf(log_stream, "Rank %d OPEN %"PRIu64" (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.open.file_id,
event_list[i].start_time,
event_list[i].end_time);
}
else
{
fprintf(log_stream, "Rank %d CREATE %"PRIu64" (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.open.file_id,
event_list[i].start_time,
event_list[i].end_time);
}
}
else if (event_list[i].codes_op.op_type == CODES_WK_CLOSE)
{
fprintf(log_stream, "Rank %d CLOSE %"PRIu64" (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.close.file_id,
event_list[i].start_time,
event_list[i].end_time);
}
else if (event_list[i].codes_op.op_type == CODES_WK_READ)
{
fprintf(log_stream, "Rank %d READ %"PRIu64" [sz = %"PRId64", off = %"PRId64"] (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.read.file_id,
(int64_t)event_list[i].codes_op.u.read.size,
(int64_t)event_list[i].codes_op.u.read.offset,
event_list[i].start_time,
event_list[i].end_time);
}
else if (event_list[i].codes_op.op_type == CODES_WK_WRITE)
{
fprintf(log_stream, "Rank %d WRITE %"PRIu64" [sz = %"PRId64", off = %"PRId64"] (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.write.file_id,
(int64_t)event_list[i].codes_op.u.write.size,
(int64_t)event_list[i].codes_op.u.write.offset,
event_list[i].start_time,
event_list[i].end_time);
}
else if (event_list[i].codes_op.op_type == CODES_WK_BARRIER)
{
fprintf(log_stream, "****");
}
}
return;
}
/* comparison function for sorting darshan_io_ops in order of start timestamps */
static int darshan_io_op_compare(
const void *p1, const void *p2)
......@@ -1501,74 +1558,6 @@ static void file_sanity_check(
return;
}
void print_events(struct darshan_io_op *event_list,
int64_t event_list_cnt,
int rank,
FILE *log_stream)
{
int64_t i;
if (!event_list_cnt)
return;
for (i = 0; i < event_list_cnt; i++)
{
if (event_list[i].codes_op.op_type == CODES_WK_OPEN)
{
if (event_list[i].codes_op.u.open.create_flag == 0)
{
fprintf(log_stream, "Rank %d OPEN %"PRIu64" (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.open.file_id,
event_list[i].start_time,
event_list[i].end_time);
}
else
{
fprintf(log_stream, "Rank %d CREATE %"PRIu64" (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.open.file_id,
event_list[i].start_time,
event_list[i].end_time);
}
}
else if (event_list[i].codes_op.op_type == CODES_WK_CLOSE)
{
fprintf(log_stream, "Rank %d CLOSE %"PRIu64" (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.close.file_id,
event_list[i].start_time,
event_list[i].end_time);
}
else if (event_list[i].codes_op.op_type == CODES_WK_READ)
{
fprintf(log_stream, "Rank %d READ %"PRIu64" [sz = %"PRId64", off = %"PRId64"] (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.read.file_id,
(int64_t)event_list[i].codes_op.u.read.size,
(int64_t)event_list[i].codes_op.u.read.offset,
event_list[i].start_time,
event_list[i].end_time);
}
else if (event_list[i].codes_op.op_type == CODES_WK_WRITE)
{
fprintf(log_stream, "Rank %d WRITE %"PRIu64" [sz = %"PRId64", off = %"PRId64"] (%lf - %lf)\n",
rank,
event_list[i].codes_op.u.write.file_id,
(int64_t)event_list[i].codes_op.u.write.size,
(int64_t)event_list[i].codes_op.u.write.offset,
event_list[i].start_time,
event_list[i].end_time);
}
else if (event_list[i].codes_op.op_type == CODES_WK_BARRIER)
{
fprintf(log_stream, "****");
}
}
return;
}
/*
* Local variables:
* c-indent-level: 4
......
......@@ -49,7 +49,7 @@ void usage(char *exename)
{
fprintf(stderr, "Usage: %s [OPTIONS] --conf <conf_file_path>\n "
"--test-dir <workload_test_dir>\n\n", exename);
fprintf(stderr, "\t<conf_file_path> : path to a valid workload configuration file\n");
fprintf(stderr, "\t<conf_file_path> : (absolute) path to a valid workload configuration file\n");
fprintf(stderr, "\t<workload_test_dir> : the directory to replay the workload I/O in\n");
fprintf(stderr, "\n\t[OPTIONS] includes:\n");
fprintf(stderr, "\t\t--noop : do not perform i/o\n");
......@@ -136,7 +136,12 @@ int load_workload(char *conf_path, int rank)
configuration_get_value(&config, "PARAMS", "aggregator_count", aggregator_count, 10);
d_params.aggregator_cnt = atoi(aggregator_count);
d_params.stream = NULL;
#if 0
d_params.stream = log_stream;
opt_verbose = 0;
#endif
return codes_workload_load(workload_type, (char *)&d_params, rank);
}
else if (strcmp(workload_type, "bgp_io_workload") == 0)
......@@ -212,29 +217,6 @@ int main(int argc, char *argv[])
goto error_exit;
}
#if 0
/* change the working directory to be the test directory */
ret = chdir(replay_test_path);
if (ret < 0)
{
fprintf(stderr, "Unable to change to testing directory (%s)\n", strerror(errno));
goto error_exit;
}
/* set the path for logging this rank's events, if verbose is turned on */
if (opt_verbose)
{
mkdir(log_dir, 0755);
snprintf(my_log_path, MAX_NAME_LENGTH_WKLD, "%s/rank-%d.log", log_dir, myrank);
log_stream = fopen(my_log_path, "w");
if (log_stream == NULL)
{
fprintf(stderr, "Unable to open log file %s\n", my_log_path);
goto error_exit;
}
}
/* initialize hash table for storing file descriptors */
fd_table = qhash_init(hash_file_compare, quickhash_64bit_hash, 29);
if (!fd_table)
......@@ -265,13 +247,12 @@ int main(int argc, char *argv[])
}
}
if (opt_verbose)
if (log_stream)
fclose(log_stream);
/* destroy and finalize the file descriptor hash table */
qhash_destroy_and_finalize(fd_table, struct file_info, hash_link, free);
#endif
error_exit:
MPI_Finalize();
......
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