Commit 91f00a69 authored by Matthieu Dorier's avatar Matthieu Dorier

added prepare-read-op

parent 5e17e1eb
......@@ -5,11 +5,18 @@ src_libmobject_store_la_SOURCES = \
src/read-op-impl.c \
src/proc-write-actions.c \
src/proc-read-actions.c \
src/prepare-write-op.c
src/prepare-write-op.c \
src/prepare-read-op.c
noinst_HEADERS += src/log.h src/completion.h \
src/write-op-impl.h src/write-actions.h \
src/read-op-impl.h src/read-actions.h \
src/utlist.h src/proc-write-actions.h \
src/proc-read-actions.h \
src/prepare-write-op.h
noinst_HEADERS += \
src/log.h \
src/completion.h \
src/write-op-impl.h \
src/write-actions.h \
src/read-op-impl.h \
src/read-actions.h \
src/utlist.h \
src/proc-write-actions.h \
src/proc-read-actions.h \
src/prepare-write-op.h \
src/prepare-read-op.h
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include "prepare-read-op.h"
#include "read-op-impl.h"
#include "utlist.h"
#include "log.h"
static void prepare_read(uint64_t* cur_offset,
rd_action_read_t action,
void** ptr,
size_t* len)
{
uint64_t pos = *cur_offset;
*cur_offset += action->len;
*ptr = (void*)action->buffer.as_pointer;
*len = action->len;
action->buffer.as_offset = pos;
}
void prepare_read_op(margo_instance_id mid, mobject_store_read_op_t read_op)
{
if(read_op->use_local_pointers == 0) return;
if(read_op->num_actions == 0) return;
rd_action_base_t action;
void** pointers = (void**)calloc(read_op->num_actions, sizeof(void*));
size_t* lengths = (size_t*)calloc(read_op->num_actions, sizeof(size_t));
uint64_t current_offset = 0;
size_t i = 0;
DL_FOREACH(read_op->actions, action) {
switch(action->type) {
case READ_OPCODE_READ:
prepare_read(&current_offset,
(rd_action_read_t)action, pointers+i, lengths+i);
i += 1;
break;
}
}
uint32_t count = i;
if(count != 0) {
hg_return_t ret = margo_bulk_create(mid, count,
pointers, lengths, HG_BULK_WRITE_ONLY,
&(read_op->bulk_handle));
// TODO handle error
}
read_op->use_local_pointers = 0;
free(pointers);
free(lengths);
}
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_PREPARE_READ_OP_H
#define __MOBJECT_PREPARE_READ_OP_H
#include <margo.h>
#include "libmobject-store.h"
void prepare_read_op(margo_instance_id mid, mobject_store_read_op_t read_op);
#endif
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