aboutsummaryrefslogtreecommitdiff
path: root/liboffloadmic/runtime/offload_target.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'liboffloadmic/runtime/offload_target.cpp')
-rw-r--r--liboffloadmic/runtime/offload_target.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/liboffloadmic/runtime/offload_target.cpp b/liboffloadmic/runtime/offload_target.cpp
index 2e5f91e..e3c1374 100644
--- a/liboffloadmic/runtime/offload_target.cpp
+++ b/liboffloadmic/runtime/offload_target.cpp
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2014 Intel Corporation. All Rights Reserved.
+ Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -114,6 +114,8 @@ static void BufReleaseRef(void * buf)
if (info) {
--info->count;
if (info->count == 0 && info->is_added) {
+ OFFLOAD_TRACE(1, "Calling COIBufferReleaseRef AddRef count = %d\n",
+ ((RefInfo *) ref_data[buf])->count);
BufferReleaseRef(buf);
info->is_added = 0;
}
@@ -360,7 +362,6 @@ void OffloadDescriptor::scatter_copyin_data()
if (m_vars[i].flags.alloc_disp) {
int64_t offset = 0;
m_in.receive_data(&offset, sizeof(offset));
- m_vars[i].offset = -offset;
}
if (VAR_TYPE_IS_DV_DATA_SLICE(type) ||
VAR_TYPE_IS_DV_DATA(type)) {
@@ -369,7 +370,6 @@ void OffloadDescriptor::scatter_copyin_data()
*reinterpret_cast<ArrDesc**>(ptr_addr);
ptr_addr = reinterpret_cast<void**>(&dvp->Base);
}
-
// Set pointer values
switch (type) {
case c_data_ptr_array:
@@ -380,6 +380,9 @@ void OffloadDescriptor::scatter_copyin_data()
*(reinterpret_cast<char**>(m_vars[i].ptr)) :
reinterpret_cast<char*>(m_vars[i].into);
+ if (m_vars[i].flags.is_pointer) {
+ dst_arr_ptr = *((char**)dst_arr_ptr);
+ }
for (; j < max_el; j++) {
if (src_is_for_mic) {
m_vars[j].ptr =
@@ -402,8 +405,8 @@ void OffloadDescriptor::scatter_copyin_data()
case c_data_ptr:
case c_cean_var_ptr:
case c_dv_ptr:
- if (m_vars[i].alloc_if) {
- void *buf;
+ if (m_vars[i].alloc_if && !m_vars[i].flags.preallocated) {
+ void *buf = NULL;
if (m_vars[i].flags.sink_addr) {
m_in.receive_data(&buf, sizeof(buf));
}
@@ -417,9 +420,12 @@ void OffloadDescriptor::scatter_copyin_data()
// increment buffer reference
OFFLOAD_TIMER_START(c_offload_target_add_buffer_refs);
BufferAddRef(buf);
+ OFFLOAD_TRACE(1, "Calling COIBufferAddRef %p\n", buf);
OFFLOAD_TIMER_STOP(c_offload_target_add_buffer_refs);
}
add_ref_count(buf, 0 == m_vars[i].flags.sink_addr);
+ OFFLOAD_TRACE(1, " AddRef count = %d\n",
+ ((RefInfo *) ref_data[buf])->count);
}
ptr = static_cast<char*>(buf) +
m_vars[i].mic_offset +
@@ -597,6 +603,7 @@ void OffloadDescriptor::gather_copyout_data()
case c_dv_ptr:
if (m_vars[i].free_if &&
src_is_for_mic &&
+ !m_vars[i].flags.preallocated &&
!m_vars[i].flags.is_static) {
void *buf = *static_cast<char**>(m_vars[i].ptr) -
m_vars[i].mic_offset -
@@ -610,6 +617,9 @@ void OffloadDescriptor::gather_copyout_data()
BufReleaseRef(buf);
OFFLOAD_TIMER_STOP(c_offload_target_release_buffer_refs);
}
+ if (m_vars[i].flags.preallocated && m_vars[i].alloc_if) {
+ m_out.send_data((void*) m_vars[i].ptr, sizeof(void*));
+ }
break;
case c_func_ptr: