Commit 5becf802 authored by Philip Carns's avatar Philip Carns

Merge branch 'bake-server-daemon-to-lib' into 'master'

refactor bake-bulk to include a server library

See merge request !1
parents 1e31e3a7 7dca03eb
......@@ -13,7 +13,7 @@ CLEANFILES = $(bin_SCRIPTS)
MAINTAINERCLEANFILES =
EXTRA_DIST =
BUILT_SOURCES =
include_HEADERS = include/bake-bulk.h
include_HEADERS = include/bake-bulk.h include/bake-bulk-client.h include/bake-bulk-server.h
EXTRA_DIST += \
prepare.sh
......@@ -26,10 +26,11 @@ AM_LIBS =
AM_CXXFLAGS = $(AM_CFLAGS)
lib_LTLIBRARIES = src/libbake-bulk.la
src_libbake_bulk_la_SOURCES =
lib_LTLIBRARIES = src/libbake-bulk-client.la src/libbake-bulk-server.la
src_libbake_bulk_client_la_SOURCES =
src_libbake_bulk_server_la_SOURCES =
LDADD = src/libbake-bulk.la
LDADD = src/libbake-bulk-client.la src/libbake-bulk-server.la
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = maint/bake-bulk.pc
......
/*
* (C) 2016 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __BAKE_BULK_CLIENT_H
#define __BAKE_BULK_CLIENT_H
#include <stdint.h>
#include "bake-bulk.h"
/**
* Obtain identifying information for a bake target through the provided
* remote mercury address.
*
* @param [in] mecury_dest Mercury address in string form
* @param [out] bti BAKE target identifier
* @returns 0 on success, -1 on failure
*/
int bake_probe_instance(
const char *mercury_dest,
bake_target_id_t *bti);
/**
* Create a bounded-size bulk data region. The resulting region can be
* written using bulk write operations, and can be persisted (once writes are
* complete) with a a bulk persist operation. The region is not valid for
* read access until persisted.
*
* @param [in] bti BAKE target identifier
* @param [in] region_size size of region to be created
* @param [out] rid identifier for new region
* @returns 0 on success, -1 on failure
*/
int bake_bulk_create(
bake_target_id_t bti,
uint64_t region_size,
bake_bulk_region_id_t *rid);
/**
* Writes into a region that was previously created with bake_bulk_create().
* Result is not guaranteed to be persistent until explicit
* bake_bulk_persist() call.
*
* Results are undefined if multiple writers (from same process or different
* processes) perform overlapping writes.
*
* @param [in] bti BAKE target identifier
* @param [in] rid identifier for region
* @param [in] region_offset offset into the target region to write
* @param [in] buf local memory buffer to write
* @param [in] buf_size size of local memory buffer to write
* @returns 0 on success, -1 on failure
*/
int bake_bulk_write(
bake_target_id_t bti,
bake_bulk_region_id_t rid,
uint64_t region_offset,
void const *buf,
uint64_t buf_size);
/**
* Persist a bulk region. The region is considered immutable at this point
* and reads may be performed on the region.
*
* @param [in] bti BAKE target identifier
* @param [in] rid identifier for region
* @returns 0 on success, -1 on failure
*/
int bake_bulk_persist(
bake_target_id_t bti,
bake_bulk_region_id_t rid);
/**
* Check the size of an existing region.
*
* @param [in] bti BAKE target identifier
* @param [in] rid identifier for region
* @param [out] size sizes of region
* @returns 0 on success, -1 on failure
*/
int bake_bulk_get_size(
bake_target_id_t bti,
bake_bulk_region_id_t rid,
uint64_t *region_size);
/**
* Reads from a region that was previously persisted with bake_bulk_persist().
*
* NOTE: for now at least, this call does not support "short" reads. It
* either succeeds in reading the requested size or not.
*
* @param [in] bti BAKE target identifier
* @param [in] rid region identifier
* @param [in] region_offset offset into the target region to read from
* @param [in] buf local memory buffer read into
* @param [in] buf_size size of local memory buffer to read into
* @returns 0 on success, -1 on failure
*/
int bake_bulk_read(
bake_target_id_t bti,
bake_bulk_region_id_t rid,
uint64_t region_offset,
void *buf,
uint64_t buf_size);
/**
* Release local resources associated with access to a target; does not
* modify the target in any way.
*
* @param [in] bti BAKE target_identifier
*/
void bake_release_instance(
bake_target_id_t bti);
/**
* Utility function to shut down a remote service
*
* @param [in] bti Bake target identifier
* @returns 0 on success, -1 on fialure
*/
int bake_shutdown_service(bake_target_id_t bti);
/* NOTE: code below is a copy of the bulk portion of the proposed BAKE API.
* Commented out for now but leaving it in place for reference
*/
/**
* Issue a no-op
*
* @param [in] bti BAKE target identifier
* @returns 0 on success, -1 on failure
*/
int bake_bulk_noop(
bake_target_id_t bti);
#endif /* __BAKE_BULK__CLIENT_H */
/*
* (C) 2016 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __BAKE_BULK_SERVER_H
#define __BAKE_BULK_SERVER_H
#include <margo.h>
#include <libpmemobj.h>
#include "bake-bulk.h"
struct bake_bulk_root
{
bake_target_id_t target_id;
};
/**
* Register a bake server instance for a given Margo instance.
*
* @param[in] mid Margo instance identifier
* @param[in] bb_pmem_pool libpmem pool to use for the bake storage service
* @param[in] bb_pmem_root libpmem root for the bake pool
*/
void bake_server_register(
margo_instance_id mid,
PMEMobjpool *bb_pmem_pool,
struct bake_bulk_root *bb_pmem_root);
#endif /* __BAKE_BULK_SERVER_H */
......@@ -27,131 +27,6 @@ typedef struct {
char data[BAKE_BULK_REGION_ID_DATA_SIZE];
} bake_bulk_region_id_t;
/**
* Obtain identifying information for a bake target through the provided
* remote mercury address.
*
* @param [in] mecury_dest Mercury address in string form
* @param [out] bti BAKE target identifier
* @returns 0 on success, -1 on failure
*/
int bake_probe_instance(
const char *mercury_dest,
bake_target_id_t *bti);
/**
* Create a bounded-size bulk data region. The resulting region can be
* written using bulk write operations, and can be persisted (once writes are
* complete) with a a bulk persist operation. The region is not valid for
* read access until persisted.
*
* @param [in] bti BAKE target identifier
* @param [in] region_size size of region to be created
* @param [out] rid identifier for new region
* @returns 0 on success, -1 on failure
*/
int bake_bulk_create(
bake_target_id_t bti,
uint64_t region_size,
bake_bulk_region_id_t *rid);
/**
* Writes into a region that was previously created with bake_bulk_create().
* Result is not guaranteed to be persistent until explicit
* bake_bulk_persist() call.
*
* Results are undefined if multiple writers (from same process or different
* processes) perform overlapping writes.
*
* @param [in] bti BAKE target identifier
* @param [in] rid identifier for region
* @param [in] region_offset offset into the target region to write
* @param [in] buf local memory buffer to write
* @param [in] buf_size size of local memory buffer to write
* @returns 0 on success, -1 on failure
*/
int bake_bulk_write(
bake_target_id_t bti,
bake_bulk_region_id_t rid,
uint64_t region_offset,
void const *buf,
uint64_t buf_size);
/**
* Persist a bulk region. The region is considered immutable at this point
* and reads may be performed on the region.
*
* @param [in] bti BAKE target identifier
* @param [in] rid identifier for region
* @returns 0 on success, -1 on failure
*/
int bake_bulk_persist(
bake_target_id_t bti,
bake_bulk_region_id_t rid);
/**
* Check the size of an existing region.
*
* @param [in] bti BAKE target identifier
* @param [in] rid identifier for region
* @param [out] size sizes of region
* @returns 0 on success, -1 on failure
*/
int bake_bulk_get_size(
bake_target_id_t bti,
bake_bulk_region_id_t rid,
uint64_t *region_size);
/**
* Reads from a region that was previously persisted with bake_bulk_persist().
*
* NOTE: for now at least, this call does not support "short" reads. It
* either succeeds in reading the requested size or not.
*
* @param [in] bti BAKE target identifier
* @param [in] rid region identifier
* @param [in] region_offset offset into the target region to read from
* @param [in] buf local memory buffer read into
* @param [in] buf_size size of local memory buffer to read into
* @returns 0 on success, -1 on failure
*/
int bake_bulk_read(
bake_target_id_t bti,
bake_bulk_region_id_t rid,
uint64_t region_offset,
void *buf,
uint64_t buf_size);
/**
* Release local resources associated with access to a target; does not
* modify the target in any way.
*
* @param [in] bti BAKE target_identifier
*/
void bake_release_instance(
bake_target_id_t bti);
/**
* Utility function to shut down a remote service
*
* @param [in] bti Bake target identifier
* @returns 0 on success, -1 on fialure
*/
int bake_shutdown_service(bake_target_id_t bti);
/* NOTE: code below is a copy of the bulk portion of the proposed BAKE API.
* Commented out for now but leaving it in place for reference
*/
/**
* Issue a no-op
*
* @param [in] bti BAKE target identifier
* @returns 0 on success, -1 on failure
*/
int bake_bulk_noop(
bake_target_id_t bti);
#if 0
/// ==== Some high-level goals ====
......
src_libbake_bulk_la_SOURCES += \
src/bake-bulk.c
src_libbake_bulk_client_la_SOURCES += \
src/bake-bulk-client.c
src_libbake_bulk_server_la_SOURCES += \
src/bake-bulk-server.c
bin_PROGRAMS += \
src/bake-bulk-server \
src/bake-bulk-server-daemon \
src/bb-shutdown \
src/bb-copy-to \
src/bb-copy-from \
src/bb-latency-bench
src_bake_bulk_server_SOURCES = \
src/bake-bulk-server.c \
src/bake-bulk-rpc.c
......@@ -5,7 +5,7 @@
*/
#include <assert.h>
#include <bake-bulk.h>
#include <bake-bulk-client.h>
#include <margo.h>
#include "uthash.h"
#include "bake-bulk-rpc.h"
......
This diff is collapsed.
......@@ -101,15 +101,6 @@ DECLARE_MARGO_RPC_HANDLER(bake_bulk_probe_ult)
/* noop */
DECLARE_MARGO_RPC_HANDLER(bake_bulk_noop_ult)
/* TODO: this should be somewhere else, just putting in this header for
* convenience right now. The type should only be visible to the server
* daemon and the rpc handlers.
*/
struct bake_bulk_root
{
bake_target_id_t target_id;
};
/* TODO: where should the encoder defs live? Not in bake-bulk-rpc.c because
* we don't really need the rpc handlers to be linked into clients...
......
/*
* (C) 2015 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <uuid/uuid.h>
#include <abt.h>
#include <abt-snoozer.h>
#include <margo.h>
#include <libpmemobj.h>
#include <bake-bulk-server.h>
int main(int argc, char **argv)
{
int ret;
margo_instance_id mid;
ABT_xstream handler_xstream;
ABT_pool handler_pool;
hg_context_t *hg_context;
hg_class_t *hg_class;
char target_string[64];
PMEMoid root_oid;
PMEMobjpool *bb_pmem_pool = NULL;
struct bake_bulk_root *bb_pmem_root = NULL;
if(argc != 3)
{
fprintf(stderr, "Usage: bake-bulk-server <HG listening addr> <pmem pool>\n");
fprintf(stderr, " Example: ./bake-bulk-server tcp://localhost:1234 /dev/shm/foo.dat\n");
return(-1);
}
/* open pmem pool */
bb_pmem_pool = pmemobj_open(argv[2], NULL);
if(!bb_pmem_pool)
{
fprintf(stderr, "pmemobj_open: %s\n", pmemobj_errormsg());
return(-1);
}
/* find root */
root_oid = pmemobj_root(bb_pmem_pool, sizeof(*bb_pmem_root));
bb_pmem_root = pmemobj_direct(root_oid);
if(uuid_is_null(bb_pmem_root->target_id.id))
{
uuid_generate(bb_pmem_root->target_id.id);
pmemobj_persist(bb_pmem_pool, bb_pmem_root, sizeof(*bb_pmem_root));
}
uuid_unparse(bb_pmem_root->target_id.id, target_string);
fprintf(stderr, "BAKE target ID: %s\n", target_string);
/* boilerplate HG initialization steps */
/***************************************/
hg_class = HG_Init(argv[1], HG_TRUE);
if(!hg_class)
{
fprintf(stderr, "Error: HG_Init()\n");
return(-1);
}
hg_context = HG_Context_create(hg_class);
if(!hg_context)
{
fprintf(stderr, "Error: HG_Context_create()\n");
HG_Finalize(hg_class);
return(-1);
}
/* set up argobots */
/***************************************/
ret = ABT_init(argc, argv);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_init()\n");
return(-1);
}
/* set primary ES to idle without polling */
ret = ABT_snoozer_xstream_self_set();
if(ret != 0)
{
fprintf(stderr, "Error: ABT_snoozer_xstream_self_set()\n");
return(-1);
}
/* Find primary pool to use for running rpc handlers */
ret = ABT_xstream_self(&handler_xstream);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_xstream_self()\n");
return(-1);
}
ret = ABT_xstream_get_main_pools(handler_xstream, 1, &handler_pool);
if(ret != 0)
{
fprintf(stderr, "Error: ABT_xstream_get_main_pools()\n");
return(-1);
}
/* actually start margo */
/* provide argobots pools for driving communication progress and
* executing rpc handlers as well as class and context for Mercury
* communication.
*/
/***************************************/
mid = margo_init_pool(handler_pool, handler_pool, hg_context);
assert(mid);
/* register the bake bulk server */
bake_server_register(mid, bb_pmem_pool, bb_pmem_root);
/* NOTE: at this point this server ULT has two options. It can wait on
* whatever mechanism it wants to (however long the daemon should run and
* then call margo_finalize(). Otherwise, it can call
* margo_wait_for_finalize() on the assumption that it should block until
* some other entity calls margo_finalize().
*
* This example does the latter. Margo will be finalized by a special
* RPC from the client.
*
* This approach will allow the server to idle gracefully even when
* executed in "single" mode, in which the main thread of the server
* daemon and the progress thread for Mercury are executing in the same
* ABT pool.
*/
margo_wait_for_finalize(mid);
ABT_finalize();
HG_Context_destroy(hg_context);
HG_Finalize(hg_class);
pmemobj_close(bb_pmem_pool);
return(0);
}
This diff is collapsed.
......@@ -15,7 +15,7 @@
#include "abt.h"
#include "abt-snoozer.h"
#include "bake-bulk.h"
#include "bake-bulk-client.h"
/* client program that will copy a bake bulk region out to a POSIX file */
......
......@@ -15,7 +15,7 @@
#include "abt.h"
#include "abt-snoozer.h"
#include "bake-bulk.h"
#include "bake-bulk-client.h"
/* client program that will copy a POSIX file into a bake bulk region */
......
......@@ -15,7 +15,7 @@
#include "abt.h"
#include "abt-snoozer.h"
#include "bake-bulk.h"
#include "bake-bulk-client.h"
static void bench_routine_write(bake_target_id_t bti, int iterations, double* measurement_array, int size);
static void bench_routine_read(bake_target_id_t bti, int iterations, double* measurement_array, int size);
......
......@@ -10,7 +10,7 @@
#include "abt.h"
#include "abt-snoozer.h"
#include "bake-bulk.h"
#include "bake-bulk-client.h"
/* client program that will shut down a BAKE bulk server. */
......
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