Commit 1e3760b2 authored by Jonathan Jenkins's avatar Jonathan Jenkins

add default workload config reading

parent f41acfe5
......@@ -12,7 +12,9 @@
#ifndef CODES_WORKLOAD_H
#define CODES_WORKLOAD_H
#include "ross.h"
#include <ross.h>
#include "configuration.h"
#define MAX_NAME_LENGTH_WKLD 512
typedef struct iolang_params iolang_params;
......@@ -20,7 +22,6 @@ typedef struct darshan_params darshan_params;
typedef struct recorder_params recorder_params;
/* struct to hold the actual data from a single MPI event*/
typedef struct scala_trace_params scala_trace_params;
typedef struct dumpi_trace_params dumpi_trace_params;
typedef struct checkpoint_wrkld_params checkpoint_wrkld_params;
......@@ -47,12 +48,6 @@ struct recorder_params
int64_t nprocs;
};
struct scala_trace_params {
char offset_file_name[MAX_NAME_LENGTH_WKLD];
char nw_wrkld_file_name[MAX_NAME_LENGTH_WKLD];
};
struct dumpi_trace_params {
char file_name[MAX_NAME_LENGTH_WKLD];
int num_net_traces;
......@@ -204,6 +199,21 @@ struct codes_workload_op
}u;
};
/* read workload configuration from a CODES configuration file and return the
* workload name and parameters, which can then be passed to
* codes_workload_load */
typedef struct
{
char const * type;
void * params;
} codes_workload_config_return;
codes_workload_config_return codes_workload_read_config(
ConfigHandle * handle,
char const * section_name);
void codes_workload_free_config_return(codes_workload_config_return *c);
/* load and initialize workload of of type "type" with parameters specified by
* "params". The rank is the caller's relative rank within the collection
* of processes that will participate in this workload. The app_id is the
......
......@@ -25,6 +25,8 @@
struct codes_workload_method
{
char *method_name; /* name of the generator */
void * (*codes_workload_read_config) (
ConfigHandle *handle, char const * section_name);
int (*codes_workload_load)(const char* params, int app_id, int rank);
void (*codes_workload_get_next)(int app_id, int rank, struct codes_workload_op *op);
int (*codes_workload_get_rank_cnt)(const char* params, int app_id);
......
......@@ -70,6 +70,41 @@ struct rank_queue
static struct rank_queue *ranks = NULL;
codes_workload_config_return codes_workload_read_config(
ConfigHandle * handle,
char const * section_name)
{
char type[MAX_NAME_LENGTH_WKLD];
codes_workload_config_return r;
r.type = NULL;
r.params = NULL;
int rc = configuration_get_value(handle, section_name, "type",
NULL, type, MAX_NAME_LENGTH_WKLD);
if (rc <= 0)
return r;
for (int i = 0; method_array[i] != NULL; i++){
struct codes_workload_method const * m = method_array[i];
if (strcmp(m->method_name, type) == 0) {
r.type = m->method_name;
if (m->codes_workload_read_config == NULL)
r.params = NULL;
else
r.params = m->codes_workload_read_config(handle, section_name);
}
}
return r;
}
void codes_workload_free_config_return(codes_workload_config_return *c)
{
free(c->params);
c->type = NULL;
c->params = NULL;
}
int codes_workload_load(
const char* type,
const char* params,
......
......@@ -43,6 +43,9 @@ struct rank_io_context
struct qhash_head hash_link;
};
static void * darshan_io_workload_read_config(
ConfigHandle * handle,
char const * section_name);
/* Darshan workload generator's implementation of the CODES workload API */
static int darshan_io_workload_load(const char *params, int app_id, int rank);
static void darshan_io_workload_get_next(int app_id, int rank, struct codes_workload_op *op);
......@@ -93,6 +96,7 @@ static void file_sanity_check(struct darshan_file *file, struct darshan_job *job
struct codes_workload_method darshan_io_workload_method =
{
.method_name = "darshan_io_workload",
.codes_workload_read_config = darshan_io_workload_read_config,
.codes_workload_load = darshan_io_workload_load,
.codes_workload_get_next = darshan_io_workload_get_next,
.codes_workload_get_rank_cnt = darshan_io_workload_get_rank_cnt,
......@@ -104,6 +108,26 @@ static int total_rank_cnt = 0;
static struct qhash_table *rank_tbl = NULL;
static int rank_tbl_pop = 0;
static void * darshan_io_workload_read_config(
ConfigHandle * handle,
char const * section_name)
{
darshan_params *d = malloc(sizeof(*d));
assert(d);
d->log_file_path[0] = '\0';
d->aggregator_cnt = -1;
int rc = configuration_get_value_relpath(handle, section_name,
"darshan_log_file", NULL, d->log_file_path,
MAX_NAME_LENGTH_WKLD);
assert(rc > 0);
int tmp;
rc = configuration_get_value_int(&config, "workload",
"darshan_aggregator_count", NULL, &tmp);
assert(rc == 0);
d->aggregator_cnt = tmp;
return d;
}
/* load the workload generator for this rank, given input params */
static int darshan_io_workload_load(const char *params, int app_id, int rank)
{
......
......@@ -756,6 +756,7 @@ void dumpi_trace_nw_workload_get_next(int app_id, int rank, struct codes_workloa
struct codes_workload_method dumpi_trace_workload_method =
{
.method_name = "dumpi-trace-workload",
.codes_workload_read_config = NULL,
.codes_workload_load = dumpi_trace_nw_workload_load,
.codes_workload_get_next = dumpi_trace_nw_workload_get_next,
};
......
......@@ -3,6 +3,7 @@
* See COPYRIGHT notice in top-level directory.
*
*/
#include <assert.h>
#include <ross.h>
#include "src/iokernellang/CodesIOKernelTypes.h"
#include "src/iokernellang/CodesIOKernelParser.h"
......@@ -20,11 +21,15 @@
/* This file implements the CODES workload API for the I/O kernel language of
the BG/P storage model */
static void * iolang_io_workload_read_config(
ConfigHandle * handle,
char const * section_name);
/* load the workload file */
int iolang_io_workload_load(const char* params, int app_id, int rank);
static int iolang_io_workload_load(const char* params, int app_id, int rank);
/* get next operation */
void iolang_io_workload_get_next(int app_id, int rank, struct codes_workload_op *op);
static void iolang_io_workload_get_next(int app_id, int rank, struct codes_workload_op *op);
/* mapping from bg/p operation enums to CODES workload operations enum */
static int convertTypes(int inst);
......@@ -39,6 +44,7 @@ int num_ranks = -1;
struct codes_workload_method iolang_workload_method =
{
.method_name = "iolang_workload",
.codes_workload_read_config = iolang_io_workload_read_config,
.codes_workload_load = iolang_io_workload_load,
.codes_workload_get_next = iolang_io_workload_get_next,
};
......@@ -54,6 +60,29 @@ struct codes_iolang_wrkld_state_per_rank
iolang_workload_info task_info;
};
static void * iolang_io_workload_read_config(
ConfigHandle * handle,
char const * section_name)
{
iolang_params *p = malloc(sizeof(*p));
assert(p);
p->num_cns = -1;
p->use_relpath = 1;
p->io_kernel_meta_path[0] = '\0';
p->io_kernel_path[0] = '\0';
int rc = configuration_get_value_relpath(handle, section_name,
"io_kernel_meta_path", NULL, p->io_kernel_meta_path,
MAX_NAME_LENGTH_WKLD);
assert(rc > 0);
rc = configuration_get_value_int(handle, section_name, "num_ranks", NULL,
&p->num_cns);
if (rc != 0)
p->num_cns = -1;
return p;
}
/* loads the workload file for each simulated MPI rank/ compute node LP */
int iolang_io_workload_load(const char* params, int app_id, int rank)
{
......
......@@ -65,6 +65,7 @@ static int hash_file_compare(void *key, struct qhash_head *link);
struct codes_workload_method recorder_io_workload_method =
{
.method_name = "recorder_io_workload",
.codes_workload_read_config = NULL,
.codes_workload_load = recorder_io_workload_load,
.codes_workload_get_next = recorder_io_workload_get_next,
};
......
......@@ -34,6 +34,7 @@ struct wkload_stream_state* wkload_streams = NULL;
struct codes_workload_method test_workload_method =
{
.method_name = "test",
.codes_workload_read_config = NULL,
.codes_workload_load = test_workload_load,
.codes_workload_get_next = test_workload_get_next,
};
......
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