Commit ac0d0f3c authored by Jonathan Jenkins's avatar Jonathan Jenkins

convert resource lp implementation to use codes-callback/map-ctx

parent a5c4512a
......@@ -52,6 +52,23 @@ struct codes_cb_params {
(_cb_info_ptr)->cb_ret_offset = offsetof(_event_type, _cb_ret_field); \
} while (0)
#define CB_HO(_cb_params_ptr) ((_cb_params_ptr)->info.header_offset)
#define CB_TO(_cb_params_ptr) ((_cb_params_ptr)->info.tag_offset)
#define CB_RO(_cb_params_ptr) ((_cb_params_ptr)->info.cb_ret_offset)
/* Declare return variables at the right byte offsets from a codes_cb_params.
* Additionally, set the header and tag vars */
#define GET_INIT_CB_PTRS(_cb_params_ptr, _data_ptr, _sender_gid_val, _header_nm, _tag_nm, _rtn_name, _rtn_type) \
msg_header * _header_nm = \
(msg_header*)((char*)(_data_ptr) + CB_HO(_cb_params_ptr)); \
int * _tag_nm = \
(int*)((char*)(_data_ptr) + CB_TO(_cb_params_ptr));\
_rtn_type * _rtn_name = \
(_rtn_type*)((char*)(_data_ptr) + CB_RO(_cb_params_ptr)); \
msg_set_header((_cb_params_ptr)->h.magic, (_cb_params_ptr)->h.event_type, \
_sender_gid_val, _header_nm); \
*_tag_nm = (_cb_params_ptr)->tag
#define SANITY_CHECK_CB(_cb_info_ptr, _ret_type) \
do { \
int _total_size = sizeof(_ret_type) + sizeof(int) + sizeof(msg_header);\
......
......@@ -11,11 +11,14 @@
#ifndef RESOURCE_LP_H
#define RESOURCE_LP_H
#include "ross.h"
#include "codes/lp-msg.h"
#include "codes/resource.h"
#include <ross.h>
#include <stdint.h>
#include "lp-msg.h"
#include "resource.h"
#include "codes-callback.h"
#include "codes-mapping-context.h"
#define RESOURCE_MAX_CALLBACK_PAYLOAD 64
#define RESOURCE_LP_NM "resource"
......@@ -24,7 +27,7 @@ typedef struct {
int ret;
/* in the case of a reserve, need to return the token */
resource_token_t tok;
} resource_callback;
} resource_return;
/* registers the resource LP with CODES/ROSS */
......@@ -42,57 +45,43 @@ void resource_lp_configure();
*
* block_on_unavail - flag whether to wait to message the requester if
* request cannot be satisfied
* msg_size - size of the requester event structure
* msg_header_offset - offset in the requester event to place the resource's
* msg_header
* msg_callback_offset - offset in the requester event struct to place the
* resource-provided resource_callback data
* msg_callback_misc_size - size of requester-provided callback data
* msg_callback_misc_offset - offset in the requester event struct to place the
* requester-provided callback data
* msg_callback_misc_data - requester-provided callback data
*
* tag, h - set in the return client event, using the offsets in cb
*/
void resource_lp_get(
msg_header *header,
uint64_t req,
uint64_t req,
int block_on_unavail,
int msg_size,
int msg_header_offset,
int msg_callback_offset,
int msg_callback_misc_size,
int msg_callback_misc_offset,
void *msg_callback_misc_data,
tw_lp *sender);
tw_lp *sender,
struct codes_mctx const * map_ctx,
int tag,
msg_header const *h,
struct codes_cb_info const *cb);
/* no callback for frees thus far */
void resource_lp_free(uint64_t req, tw_lp *sender);
void resource_lp_free(
uint64_t req,
tw_lp *sender,
struct codes_mctx const * map_ctx);
void resource_lp_reserve(
msg_header *header,
uint64_t req,
int block_on_unavail,
int msg_size,
int msg_header_offset,
int msg_callback_offset,
int msg_callback_misc_size,
int msg_callback_misc_offset,
void *msg_callback_misc_data,
tw_lp *sender);
tw_lp *sender,
struct codes_mctx const * map_ctx,
int tag,
msg_header const *h,
struct codes_cb_info const *cb);
void resource_lp_get_reserved(
msg_header *header,
uint64_t req,
resource_token_t tok,
int block_on_unavail,
int msg_size,
int msg_header_offset,
int msg_callback_offset,
int msg_callback_misc_size,
int msg_callback_misc_offset,
void *msg_callback_misc_data,
tw_lp *sender);
tw_lp *sender,
struct codes_mctx const * map_ctx,
int tag,
msg_header const *h,
struct codes_cb_info const *cb);
void resource_lp_free_reserved(
uint64_t req,
resource_token_t tok,
tw_lp *sender);
tw_lp *sender,
struct codes_mctx const * map_ctx);
/* rc functions - thankfully, they only use codes-local-latency, so no need
* to pass in any arguments */
......
This diff is collapsed.
......@@ -4,11 +4,13 @@
*
*/
#include "codes/resource.h"
#include "codes/resource-lp.h"
#include "codes/lp-msg.h"
#include "codes/configuration.h"
#include "codes/codes_mapping.h"
#include <codes/resource.h>
#include <codes/resource-lp.h>
#include <codes/lp-msg.h>
#include <codes/configuration.h>
#include <codes/codes_mapping.h>
#include <codes/codes-callback.h>
#include <codes/codes-mapping-context.h>
#include <stdint.h>
static int bsize = 1024;
......@@ -26,17 +28,20 @@ enum s_type {
typedef struct {
int id;
uint64_t mem, mem_max;
struct codes_cb_info cb;
} s_state;
typedef struct {
msg_header h;
resource_callback c;
resource_return c;
int tag;
uint64_t mem_max_prev;
} s_msg;
static void s_init(s_state *ns, tw_lp *lp){
ns->mem = 0;
ns->mem_max = 0;
INIT_CODES_CB_INFO(&ns->cb, s_msg, h, tag, c);
ns->id = codes_mapping_get_lp_relative_id(lp->gid, 0, 0);
tw_event *e = codes_event_new(lp->gid, codes_local_latency(lp), lp);
s_msg *m = tw_event_data(e);
......@@ -53,9 +58,7 @@ static void s_event(s_state *ns, tw_bf *bf, s_msg *m, tw_lp *lp){
case S_KICKOFF: ;
msg_header h;
msg_set_header(s_magic, S_ALLOC_ACK, lp->gid, &h);
resource_lp_get(&h, bsize, 0, sizeof(s_msg),
offsetof(s_msg, h), offsetof(s_msg, c),
0, 0, NULL, lp);
resource_lp_get(bsize, 0, lp, CODES_MCTX_DEFAULT, 0, &h, &ns->cb);
break;
case S_ALLOC_ACK:
if (m->c.ret == 0){
......@@ -64,14 +67,13 @@ static void s_event(s_state *ns, tw_bf *bf, s_msg *m, tw_lp *lp){
ns->mem_max = maxu64(ns->mem, ns->mem_max);
msg_header h;
msg_set_header(s_magic, S_ALLOC_ACK, lp->gid, &h);
resource_lp_get(&h, bsize, 0, sizeof(s_msg),
offsetof(s_msg, h), offsetof(s_msg, c),
0, 0, NULL, lp);
resource_lp_get(bsize, 0, lp, CODES_MCTX_DEFAULT, 0, &h,
&ns->cb);
break;
}
/* else fall into the free stmt */
case S_FREE:
resource_lp_free(bsize, lp);
resource_lp_free(bsize, lp, CODES_MCTX_DEFAULT);
ns->mem -= bsize;
if (ns->mem > 0){
tw_event *e =
......@@ -120,9 +122,9 @@ static tw_lptype s_lp = {
static char conf_file_name[128] = {'\0'};
static const tw_optdef app_opt [] =
{
TWOPT_GROUP("codes-mapping test case" ),
TWOPT_GROUP("codes-mapping test case" ),
TWOPT_CHAR("codes-config", conf_file_name, "name of codes configuration file"),
TWOPT_END()
TWOPT_END()
};
int main(int argc, char *argv[])
{
......
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