Commit 2e7b25cc authored by Jonathan Jenkins's avatar Jonathan Jenkins

Relative path support for codes config, io kernel lang

parent c96fae7a
......@@ -62,7 +62,7 @@ int codes_kernel_helper_parse_input(CodesIOKernel_pstate * ps,
CodesIOKernelContext * c, codeslang_inst * inst);
int codes_kernel_helper_bootstrap(char * io_kernel_path, char * def_io_kernel_path,
char * io_kernel_meta_path, int rank, CodesIOKernelContext * c,
char * io_kernel_meta_path, int rank, int use_relpath, CodesIOKernelContext * c,
CodesIOKernel_pstate ** ps, codes_workload_info * task_info,
codeslang_inst * next_event);
......
......@@ -26,6 +26,8 @@ struct bgp_params
* the I/O lang workloads have no information about the number of ranks.
* Only the bg/p config file knows the number of ranks. */
int num_cns;
/* flag - use path to find kernel files relative to the metafile */
int use_relpath;
char io_kernel_meta_path[MAX_NAME_LENGTH_WKLD];
char bgp_config_file[MAX_NAME_LENGTH_WKLD];
char io_kernel_path[MAX_NAME_LENGTH_WKLD];
......
......@@ -41,6 +41,10 @@ typedef struct
typedef struct
{
/* File path of the configuration file. Used in computing the relative path
* of file fields */
char * config_dir;
/* Returns number of characters in key or < 0 if an error occured
* (such as key is missing)
*
......
......@@ -72,6 +72,24 @@ int configuration_get_value(ConfigHandle *handle,
char *value,
size_t length);
/*
* Gets the value for a given section/key pair, and interprets it as a path
* relative to the location of the configuration file.
* Assumes the key name is a KEY configuration type.
* Assumes unix path conventions.
*
* handle - configuration handle
* section_name - name of the section the key is in
* key_name - name of the key
* value - pointer to string
* length - maximum length of string */
int configuration_get_value_relpath(
ConfigHandle *handle,
const char * section_name,
const char * key_name,
char *value,
size_t length);
/*
* Get's the values for a give section/key pair which has multiple values.
......
......@@ -12,6 +12,7 @@
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
#include <libgen.h>
#define CK_LINE_LIMIT 8192
#define CL_DEFAULT_GID 0
......@@ -110,7 +111,7 @@ static int convertKLInstToEvent(int inst)
}
static void codes_kernel_helper_parse_cf(char * io_kernel_path, char *
io_kernel_def_path, char * io_kernel_meta_path, int task_rank, codes_workload_info * task_info)
io_kernel_def_path, char * io_kernel_meta_path, int task_rank, codes_workload_info * task_info, int use_relpath)
{
int foundit = 0;
char line[CK_LINE_LIMIT];
......@@ -159,8 +160,14 @@ static void codes_kernel_helper_parse_cf(char * io_kernel_path, char *
/* parse the last element... kernel path */
token = strtok_r(NULL, " \n", &ctx);
if(token)
strcpy(io_kernel_path, token);
if(token) {
if (use_relpath){
sprintf(io_kernel_path, "%s/%s", dirname(io_kernel_meta_path), token);
}
else{
strcpy(io_kernel_path, token);
}
}
/* if our rank is on this range... end processing of the config
* file */
......@@ -292,7 +299,7 @@ int codes_kernel_helper_parse_input(CodesIOKernel_pstate * ps, CodesIOKernelCont
int codes_kernel_helper_bootstrap(char * io_kernel_path, char *
io_kernel_def_path, char * io_kernel_meta_path,
int rank, CodesIOKernelContext * c,
int rank, int use_relpath, CodesIOKernelContext * c,
CodesIOKernel_pstate ** ps, codes_workload_info * task_info,
codeslang_inst * next_event)
{
......@@ -306,7 +313,7 @@ int codes_kernel_helper_bootstrap(char * io_kernel_path, char *
temp_group_rank = rank;
/* get the kernel from the file */
codes_kernel_helper_parse_cf(io_kernel_path, io_kernel_def_path,
io_kernel_meta_path, rank, task_info);
io_kernel_meta_path, rank, task_info, use_relpath);
/* stat the kernel file */
ret = stat(io_kernel_path, &info);
......
......@@ -9,6 +9,7 @@
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <libgen.h>
#include "codes/configuration.h"
/*
......@@ -64,6 +65,8 @@ int configuration_load (const char *filepath,
fclose(f);
(*handle)->config_dir = strdup(dirname(filepath));
return rc;
}
......@@ -87,6 +90,23 @@ int configuration_get_value(ConfigHandle *handle,
return rc;
}
int configuration_get_value_relpath(
ConfigHandle *handle,
const char * section_name,
const char * key_name,
char *value,
size_t length){
char *tmp = malloc(length);
configuration_get_value(handle, section_name, key_name, tmp, length);
/* concat the configuration value with the directory */
int w = snprintf(value, length, "%s/%s", (*handle)->config_dir, tmp);
free(tmp);
return w;
}
int configuration_get_multivalue(ConfigHandle *handle,
const char *section_name,
const char *key_name,
......
......@@ -86,6 +86,7 @@ int bgp_io_workload_load(const char* params, int rank)
b_param->io_kernel_def_path,
b_param->io_kernel_meta_path,
rank,
b_param->use_relpath,
&(wrkld_per_rank->codes_context),
&(wrkld_per_rank->codes_pstate),
&(wrkld_per_rank->task_info),
......
......@@ -12,7 +12,7 @@
static char type[128] = {'\0'};
static darshan_params d_params = {NULL, "", 0};
static bgp_params b_params = {0, "", "", "", ""};
static bgp_params b_params = {0, 0, "", "", "", ""};
static int n = -1;
static struct option long_opts[] =
......@@ -24,6 +24,7 @@ static struct option long_opts[] =
{"i-meta", required_argument, NULL, 'm'},
{"i-bgp-config", required_argument, NULL, 'b'},
{"i-rank-cnt", required_argument, NULL, 'r'},
{"i-use-relpath", no_argument, NULL, 'p'},
{NULL, 0, NULL, 0}
};
......@@ -38,6 +39,7 @@ void usage(){
"--i-meta: i/o language kernel meta file path\n"
"--i-bgp-config: i/o language bgp config file\n"
"--i-rank-cnt: i/o language rank count\n"
"--i-use-relpath: use i/o kernel path relative meta file path\n"
"-s: print final workload stats\n");
}
......@@ -53,7 +55,7 @@ int main(int argc, char *argv[])
int64_t write_size = 0;
char ch;
while ((ch = getopt_long(argc, argv, "t:n:l:a:m:b:r:s", long_opts, NULL)) != -1){
while ((ch = getopt_long(argc, argv, "t:n:l:a:m:b:r:sp", long_opts, NULL)) != -1){
switch (ch){
case 't':
strcpy(type, optarg);
......@@ -80,6 +82,9 @@ int main(int argc, char *argv[])
case 's':
print_stats = 1;
break;
case 'p':
b_params.use_relpath = 1;
break;
}
}
......
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