Commit a616251c authored by Philip Carns's avatar Philip Carns
Browse files

ability to pass in abt-io instance as dependency

parent 464c619d
......@@ -63,8 +63,7 @@
"targets":[
"./file-target-A.dat"
],
"alignment":4096,
"abtio_nthreads":16
"alignment":4096
},
"pmem_backend":{
"targets":[
......
......@@ -7,6 +7,7 @@
#ifndef __BAKE_SERVER_H
#define __BAKE_SERVER_H
#include <abt-io.h>
#include <margo.h>
#include <libpmemobj.h>
#include <bake.h>
......@@ -26,8 +27,9 @@ typedef struct bake_provider* bake_provider_t;
* can be memset to zero to use default values.
*/
struct bake_provider_init_info {
const char* json_config; /* JSON-formatted string */
ABT_pool rpc_pool; /* pool on which to run RPC handlers */
const char* json_config; /* JSON-formatted string */
ABT_pool rpc_pool; /* pool on which to run RPC handlers */
abt_io_instance_id aid; /* optional abt-io instance, used by file backend */
};
/**
......
......@@ -18,13 +18,13 @@ static int bake_register_provider(bedrock_args_t args,
int ret;
struct bake_provider_init_info bpargs = {0};
margo_instance_id mid = bedrock_args_get_margo_instance(args);
uint16_t provider_id = bedrock_args_get_provider_id(args);
ABT_pool pool = bedrock_args_get_pool(args);
const char* config = bedrock_args_get_config(args);
const char* name = bedrock_args_get_name(args);
abt_io_instance_id abtio = bedrock_args_get_dependency(args, "abt_io", 0);
uint16_t provider_id = bedrock_args_get_provider_id(args);
ABT_pool pool = bedrock_args_get_pool(args);
const char* config = bedrock_args_get_config(args);
const char* name = bedrock_args_get_name(args);
bpargs.aid = bedrock_args_get_dependency(args, "abt_io", 0);
if (abtio)
if (bpargs.aid)
BAKE_DEBUG(mid, "got abt-io instance");
else
BAKE_DEBUG(mid, "did not get abt-io instance");
......@@ -106,8 +106,13 @@ static int bake_destroy_provider_handle(bedrock_module_provider_handle_t ph)
return BEDROCK_SUCCESS;
}
/* an optional abt-io dependency can be specified
* - only used by some backends (the file one, specifically)
* - if needed by not provided as a dependency, then the backend will create
* one of it's own implicitly
*/
struct bedrock_dependency bake_deps[2]
= {{"abt_io", "abt_io", BEDROCK_REQUIRED}, BEDROCK_NO_MORE_DEPENDENCIES};
= {{"abt_io", "abt_io", 0}, BEDROCK_NO_MORE_DEPENDENCIES};
static struct bedrock_module bake
= {.register_provider = bake_register_provider,
......
......@@ -190,11 +190,29 @@ static int bake_file_backend_initialize(bake_provider_t provider,
CONFIG_HAS_OR_CREATE(file_backend_json, int64, "alignment", 4096,
"file_backend.alignment", val);
/* nthreads for abtio */
/* TODO: add ability to pass this in from bedrock and/or report abtio
* json */
CONFIG_HAS_OR_CREATE(file_backend_json, int64, "abtio_nthreads", 16,
"file_backend.abtio_nthreads", val);
/* you can't pass in an existing abt-io instance _and_ request one with
* a particular thread count.
*/
if (provider->aid && CONFIG_HAS(file_backend_json, "abtio_nthreads", val)) {
BAKE_ERROR(provider->mid,
"cannot pass in abt-io instance and also specify explicit "
"\"abtio_nthreads\" setting in json");
ret = BAKE_ERR_INVALID_ARG;
goto error_cleanup;
} else if (provider->aid) {
new_entry->abtioi = provider->aid;
} else {
CONFIG_HAS_OR_CREATE(file_backend_json, int64, "abtio_nthreads", 16,
"file_backend.abtio_nthreads", val);
/* initialize an abt-io instance just for this target */
new_entry->abtioi = abt_io_init(json_object_get_int(
json_object_object_get(file_backend_json, "abtio_nthreads")));
if (!new_entry->abtioi) {
ret = BAKE_ERR_IO;
goto error_cleanup;
}
}
tmp = strrchr(path, '/');
if (!tmp) tmp = path;
......@@ -202,14 +220,6 @@ static int bake_file_backend_initialize(bake_provider_t provider,
d = tmp - path;
new_entry->root = strndup(path, d);
/* initialize an abt-io instance just for this target */
new_entry->abtioi = abt_io_init(json_object_get_int(
json_object_object_get(file_backend_json, "abtio_nthreads")));
if (!new_entry->abtioi) {
ret = BAKE_ERR_IO;
goto error_cleanup;
}
new_entry->log_fd
= abt_io_open(new_entry->abtioi, path, O_RDWR | O_DIRECT, 0);
if (new_entry->log_fd < 0) {
......@@ -285,7 +295,8 @@ error_cleanup:
if (new_entry) {
if (new_entry->file_root) free(new_entry->file_root);
if (new_entry->log_fd > -1) close(new_entry->log_fd);
if (new_entry->abtioi) abt_io_finalize(new_entry->abtioi);
if (new_entry->abtioi && new_entry->abtioi != provider->aid)
abt_io_finalize(new_entry->abtioi);
if (new_entry->filename) free(new_entry->filename);
if (new_entry->root) free(new_entry->root);
free(new_entry);
......@@ -299,7 +310,8 @@ static int bake_file_backend_finalize(backend_context_t context)
bake_file_entry_t* entry = (bake_file_entry_t*)context;
free(entry->file_root);
close(entry->log_fd);
abt_io_finalize(entry->abtioi);
if (entry->abtioi && entry->abtioi != entry->provider->aid)
abt_io_finalize(entry->abtioi);
free(entry->filename);
free(entry->root);
free(entry);
......
......@@ -36,6 +36,8 @@ typedef struct bake_provider {
// but we are going with that for simplicity for now.
uint64_t num_targets;
bake_target_t* targets;
abt_io_instance_id
aid; /* externally provided abt-io instance, if present */
hg_id_t
bake_create_write_persist_id; // <-- this is a client version of the id
......
......@@ -135,6 +135,7 @@ int bake_provider_register(margo_instance_id mid,
}
tmp_provider->json_cfg = config;
tmp_provider->aid = args.aid;
tmp_provider->mid = mid;
if (args.rpc_pool != NULL)
......
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