Skip to content

Commit

Permalink
refs #6: Now GPU version (IPv4) works.
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Dec 27, 2015
1 parent cb43048 commit daec371
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions include/nba/element/element.hh
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public:
offload_compute_handlers.insert({{"dummy", ch},});
}
finished_batches.init(MAX_FINBATCH_QLEN, -1, finished_batches_arrbuf);
memset(tasks, 0, sizeof(OffloadTask *) * NBA_MAX_COPROCESSOR_TYPES);
}
virtual ~OffloadableElement() {}
int get_type() const { return ELEMTYPE_OFFLOADABLE | ELEMTYPE_SCHEDULABLE; }
Expand Down
6 changes: 3 additions & 3 deletions include/nba/engines/cuda/mempool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public:

virtual bool init(size_t max_size)
{
max_size = max_size;
this->max_size = max_size;
cutilSafeCall(cudaMalloc((void **) &base, max_size));
return true;
}
Expand Down Expand Up @@ -66,15 +66,15 @@ public:

virtual bool init(unsigned long size)
{
max_size = size;
this->max_size = size;
cutilSafeCall(cudaHostAlloc((void **) &base, size,
this->flags));
return true;
}

bool init_with_flags(unsigned long size, int flags)
{
max_size = size;
this->max_size = size;
cutilSafeCall(cudaHostAlloc((void **) &base, size,
flags));
return true;
Expand Down
2 changes: 1 addition & 1 deletion include/nba/engines/dummy/mempool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public:

virtual bool init(unsigned long size)
{
max_size = size;
this->max_size = size;
base = malloc(size);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions include/nba/engines/phi/mempool.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public:

virtual bool init(unsigned long max_size)
{
max_size = max_size;
this->max_size = max_size;
cl_int err_ret;
clbuf = clCreateBuffer(clctx, CL_MEM_HOST_NO_ACCESS |
(direction_hint == HOST_TO_DEVICE ? CL_MEM_READ_ONLY : CL_MEM_WRITE_ONLY),
Expand Down Expand Up @@ -85,7 +85,7 @@ public:
virtual bool init(size_t max_size)
{
void *ret = NULL;
max_size = max_size;
this->max_size = max_size;
base = (uint8_t*) malloc(max_size);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engines/cuda/computecontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ size_t CUDAComputeContext::get_input_size(io_base_t io_base) const
size_t CUDAComputeContext::get_output_size(io_base_t io_base) const
{
unsigned i = io_base;
return _cpu_mempool_in[i].get_alloc_size();
return _cpu_mempool_out[i].get_alloc_size();
}

int CUDAComputeContext::alloc_input_buffer(io_base_t io_base, size_t size, void **host_ptr, memory_t *dev_mem)
Expand Down
2 changes: 1 addition & 1 deletion src/engines/dummy/computecontext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ size_t DummyComputeContext::get_input_size(io_base_t io_base) const
size_t DummyComputeContext::get_output_size(io_base_t io_base) const
{
unsigned i = io_base;
return _cpu_mempool_in[i].get_alloc_size();
return _cpu_mempool_out[i].get_alloc_size();
}

int DummyComputeContext::alloc_input_buffer(io_base_t io_base, size_t size, void **host_ptr, memory_t *dev_mem)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ int io_loop(void *arg)

snprintf(temp, RTE_MEMPOOL_NAMESIZE,
"comp.dbstate.%u:%u@%u", ctx->loc.node_id, ctx->loc.local_thread_idx, ctx->loc.core_id);
size_t dbstate_pool_size = NBA_MAX_COPROC_PPDEPTH;
size_t dbstate_pool_size = NBA_MAX_COPROC_PPDEPTH * 16;
size_t dbstate_item_size = sizeof(struct datablock_tracker) * NBA_MAX_DATABLOCKS;
ctx->comp_ctx->dbstate_pool = rte_mempool_create(temp, dbstate_pool_size + 1,
dbstate_item_size, 32,
Expand Down
4 changes: 0 additions & 4 deletions src/lib/offloadtask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,9 @@ void OffloadTask::prepare_read_buffer()
for (PacketBatch *batch : batches) {
struct datablock_tracker *t = &batch->datablock_states[dbid];
tie(t->in_size, t->in_count) = db->calc_read_buffer_size(batch);
t->host_in_ptr = nullptr;
t->dev_in_ptr.ptr = nullptr;
if (t->in_size > 0 && t->in_count > 0) {
cctx->alloc_input_buffer(io_base, t->in_size,
(void **) &t->host_in_ptr, &t->dev_in_ptr);
assert(t->host_in_ptr != nullptr);
db->preprocess(batch, t->host_in_ptr);
}
}
Expand Down Expand Up @@ -148,7 +145,6 @@ void OffloadTask::prepare_write_buffer()
cctx->alloc_output_buffer(io_base, t->out_size,
(void **) &t->host_out_ptr,
&t->dev_out_ptr);
assert(t->host_out_ptr != nullptr);
}
}
}
Expand Down

0 comments on commit daec371

Please sign in to comment.