Skip to content

Commit 1713077

Browse files
committed
Adjustments to new PaRSEC device interface
Recent changes require minor adaptations. Signed-off-by: Joseph Schuchart <joseph.schuchart@stonybrook.edu>
1 parent a24ed04 commit 1713077

6 files changed

Lines changed: 41 additions & 35 deletions

File tree

cmake/modules/ExternalDependenciesVersions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set(TTG_TRACKED_VG_CMAKE_KIT_TAG 256d9462bb765787f5acb69be154b26d6efba8b6) # provides FindOrFetchLinalgPP and "real" FindOrFetchBoost
66
set(TTG_TRACKED_CATCH2_VERSION 3.5.0)
77
set(TTG_TRACKED_MADNESS_TAG a50e8d440fc2a1718a1ba0140af6866f49813d14)
8-
set(TTG_TRACKED_PARSEC_TAG parsec-for-ttg)
8+
set(TTG_TRACKED_PARSEC_TAG parsec-for-ttg-merge-with-master)
99
set(TTG_TRACKED_UMPIRE_CXX_ALLOCATOR_TAG a48ad360e20b9733263768b54aa24afe5894faa4)
1010
set(TTG_TRACKED_BTAS_TAG c25b0a11d2a76190bfb13fa72f9e9dc3e57c3c2f)
1111
set(TTG_TRACKED_TILEDARRAY_TAG 42e0d65df9400469d29ebeb929b045be1caaf3d6)

ttg/ttg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "ttg/util/dot.h"
3232
#include "ttg/util/macro.h"
3333
#include "ttg/util/print.h"
34+
#include "ttg/util/multiindex.h"
3435
#include "ttg/world.h"
3536

3637
#include "ttg/constraint.h"

ttg/ttg/parsec/buffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ namespace detail {
185185
const allocator_type& allocator = allocator_type()) {
186186
parsec_data_t *data = PARSEC_OBJ_NEW(parsec_data_t);
187187
data->owner_device = 0;
188-
data->nb_elts = size*sizeof(value_type);
188+
data->span = size*sizeof(value_type);
189189

190190
/* create the host copy and allocate host memory */
191191
data_copy_type *copy = PARSEC_OBJ_NEW(data_copy_type);
@@ -209,7 +209,7 @@ namespace detail {
209209
static parsec_data_t * create_data(PtrT& ptr, std::size_t size, ttg::scope scope) {
210210
parsec_data_t *data = PARSEC_OBJ_NEW(parsec_data_t);
211211
data->owner_device = 0;
212-
data->nb_elts = size*sizeof(value_type);
212+
data->span = size*sizeof(value_type);
213213

214214
/* create the host copy and allocate host memory */
215215
data_copy_type *copy = PARSEC_OBJ_NEW(data_copy_type);

ttg/ttg/parsec/devicefunc.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ namespace ttg_parsec {
4444
.flow_index = I,
4545
.flow_datatype_mask = ~0 };
4646

47-
gpu_task->flow_nb_elts[I] = data->nb_elts; // size in bytes
48-
gpu_task->flow[I] = &flows[I];
47+
gpu_task->flow_info[I].flow_span = data->span; // size in bytes
48+
gpu_task->flow_info[I].flow = &flows[I];
4949

5050
/* set the input data copy, parsec will take care of the transfer
5151
* and the buffer will look at the parsec_data_t for the current pointer */
@@ -61,8 +61,8 @@ namespace ttg_parsec {
6161
.flow_flags = 0,
6262
.flow_index = I,
6363
.flow_datatype_mask = ~0 };
64-
gpu_task->flow[I] = &flows[I];
65-
gpu_task->flow_nb_elts[I] = 0; // size in bytes
64+
gpu_task->flow_info[I].flow = &flows[I];
65+
gpu_task->flow_info[I].flow_span = 0; // size in bytes
6666
caller->parsec_task.data[I].data_in = nullptr;
6767
}
6868

@@ -96,8 +96,8 @@ namespace ttg_parsec {
9696
detail::parsec_ttg_caller->parsec_task.data[i].data_in = nullptr;
9797
detail::parsec_ttg_caller->dev_ptr->flows[i].flow_flags = PARSEC_FLOW_ACCESS_NONE;
9898
detail::parsec_ttg_caller->dev_ptr->flows[i].flow_index = i;
99-
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow[i] = &detail::parsec_ttg_caller->dev_ptr->flows[i];
100-
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow_nb_elts[i] = 0;
99+
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow_info[i].flow = &detail::parsec_ttg_caller->dev_ptr->flows[i];
100+
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow_info[i].flow_span = 0;
101101
}
102102

103103
return is_current;
@@ -151,8 +151,8 @@ namespace ttg_parsec {
151151
.flow_index = i,
152152
.flow_datatype_mask = ~0 };
153153

154-
gpu_task->flow_nb_elts[i] = data->nb_elts; // size in bytes
155-
gpu_task->flow[i] = &flows[i];
154+
gpu_task->flow_info[i].flow_span = data->span; // size in bytes
155+
gpu_task->flow_info[i].flow = &flows[i];
156156

157157
/* set the input data copy, parsec will take care of the transfer
158158
* and the buffer will look at the parsec_data_t for the current pointer */
@@ -183,8 +183,8 @@ namespace ttg_parsec {
183183
.flow_flags = 0,
184184
.flow_index = i,
185185
.flow_datatype_mask = ~0 };
186-
gpu_task->flow[i] = &flows[i];
187-
gpu_task->flow_nb_elts[i] = 0; // size in bytes
186+
gpu_task->flow_info[i].flow = &flows[i];
187+
gpu_task->flow_info[i].flow_span = 0; // size in bytes
188188
caller->parsec_task.data[i].data_in = nullptr;
189189
}
190190
}
@@ -194,8 +194,8 @@ namespace ttg_parsec {
194194
detail::parsec_ttg_caller->parsec_task.data[i].data_in = nullptr;
195195
detail::parsec_ttg_caller->dev_ptr->flows[i].flow_flags = PARSEC_FLOW_ACCESS_NONE;
196196
detail::parsec_ttg_caller->dev_ptr->flows[i].flow_index = i;
197-
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow[i] = &detail::parsec_ttg_caller->dev_ptr->flows[i];
198-
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow_nb_elts[i] = 0;
197+
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow_info[i].flow = &detail::parsec_ttg_caller->dev_ptr->flows[i];
198+
detail::parsec_ttg_caller->dev_ptr->gpu_task->flow_info[i].flow_span = 0;
199199
}
200200
// we cannot allow the calling thread to submit kernels so say we're not ready
201201
return is_current;
@@ -223,7 +223,7 @@ namespace ttg_parsec {
223223
int ret = device_module->memcpy_async(device_module, stream,
224224
data->device_copies[0]->device_private,
225225
data->device_copies[data->owner_device]->device_private,
226-
data->nb_elts, parsec_device_gpu_transfer_direction_d2h);
226+
data->span, parsec_device_gpu_transfer_direction_d2h);
227227
if (ret != PARSEC_SUCCESS) throw std::runtime_error("Failed to copy data from device to host!");
228228
}
229229
if constexpr (sizeof...(Is) > 0) {

ttg/ttg/parsec/devicescratch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct devicescratch {
111111
}
112112

113113
std::size_t size() const {
114-
return (m_data->nb_elts / sizeof(element_type));
114+
return (m_data->span / sizeof(element_type));
115115
}
116116

117117
};

ttg/ttg/parsec/ttg.h

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,9 +1492,9 @@ namespace ttg_parsec {
14921492

14931493
auto discard_tmp_flows = [&](){
14941494
for (int i = 0; i < MAX_PARAM_COUNT; ++i) {
1495-
if (gpu_task->flow[i]->flow_flags & TTG_PARSEC_FLOW_ACCESS_TMP) {
1495+
if (gpu_task->flow_info[i].flow->flow_flags & TTG_PARSEC_FLOW_ACCESS_TMP) {
14961496
/* temporary flow, discard by setting it to read-only to avoid evictions */
1497-
const_cast<parsec_flow_t*>(gpu_task->flow[i])->flow_flags = PARSEC_FLOW_ACCESS_READ;
1497+
gpu_task->flow_info[i].flow->flow_flags = PARSEC_FLOW_ACCESS_READ;
14981498
task->parsec_task.data[i].data_out->readers = 1;
14991499
}
15001500
}
@@ -1534,10 +1534,14 @@ namespace ttg_parsec {
15341534
if (task->dev_ptr->gpu_task == nullptr) {
15351535

15361536
/* set up a device task */
1537-
parsec_gpu_task_t *gpu_task;
1537+
/**
1538+
* TODO: don't use gpu_dsl_task here! We store out own set of flows.
1539+
*/
1540+
parsec_gpu_dsl_task_t *dsl_gpu_task;
15381541
/* PaRSEC wants to free the gpu_task, because F***K ownerships */
1539-
gpu_task = static_cast<parsec_gpu_task_t*>(std::calloc(1, sizeof(*gpu_task)));
1540-
PARSEC_OBJ_CONSTRUCT(gpu_task, parsec_list_item_t);
1542+
dsl_gpu_task = static_cast<parsec_gpu_dsl_task_t*>(std::calloc(1, sizeof(*dsl_gpu_task)));
1543+
PARSEC_OBJ_CONSTRUCT(dsl_gpu_task, parsec_gpu_dsl_task_t);
1544+
parsec_gpu_task_t *gpu_task = &dsl_gpu_task->super;
15411545
gpu_task->ec = parsec_task;
15421546
gpu_task->task_type = 0; // user task
15431547
gpu_task->last_data_check_epoch = std::numeric_limits<uint64_t>::max(); // used internally
@@ -1546,7 +1550,7 @@ namespace ttg_parsec {
15461550
parsec_flow_t *flows = task->dev_ptr->flows;
15471551
/* set up flow information so it is available for pushout */
15481552
for (uint8_t i = 0; i < MAX_PARAM_COUNT; ++i) {
1549-
gpu_task->flow[i] = &flows[i]; // will be set in register_device_memory
1553+
gpu_task->flow_info[i].flow = &flows[i]; // will be set in register_device_memory
15501554
/* ignore the flow */
15511555
flows[i] = parsec_flow_t{.name = nullptr,
15521556
.sym_type = PARSEC_FLOW_ACCESS_NONE,
@@ -1579,10 +1583,11 @@ namespace ttg_parsec {
15791583

15801584
// input flows are set up during register_device_memory as part of the first invocation above
15811585
for (int i = 0; i < MAX_PARAM_COUNT; ++i) {
1582-
tc.in[i] = gpu_task->flow[i];
1583-
tc.out[i] = gpu_task->flow[i];
1586+
tc.in[i] = gpu_task->flow_info[i].flow;
1587+
tc.out[i] = gpu_task->flow_info[i].flow;
15841588
}
15851589
tc.nb_flows = MAX_PARAM_COUNT;
1590+
gpu_task->nb_flows = MAX_PARAM_COUNT;
15861591

15871592
/* set the device hint on the data */
15881593
TT *tt = task->tt;
@@ -2262,13 +2267,13 @@ namespace ttg_parsec {
22622267
} else if constexpr (!ttg::has_split_metadata<decvalueT>::value) {
22632268
if (inline_data) {
22642269
detail::foreach_parsec_data(val, [&](parsec_data_t* data){
2265-
read_inline_data(ttg::iovec{data->nb_elts, data->device_copies[data->owner_device]->device_private});
2270+
read_inline_data(ttg::iovec{data->span, data->device_copies[data->owner_device]->device_private});
22662271
});
22672272
} else {
22682273
auto activation = create_activation_fn();
22692274
detail::foreach_parsec_data(val, [&](parsec_data_t* data){
22702275
parsec_atomic_fetch_inc_int32(&data->device_copies[data->owner_device]->readers);
2271-
handle_iovec_fn(ttg::iovec{data->nb_elts, data->device_copies[data->owner_device]->device_private}, activation);
2276+
handle_iovec_fn(ttg::iovec{data->span, data->device_copies[data->owner_device]->device_private}, activation);
22722277
});
22732278
}
22742279
}
@@ -2819,7 +2824,7 @@ namespace ttg_parsec {
28192824
} else {
28202825
/* TODO: how can we query the iovecs of the buffers here without actually packing the data? */
28212826
metadata_size = ttg::default_data_descriptor<ttg::meta::remove_cvr_t<Value>>::payload_size(value_ptr);
2822-
detail::foreach_parsec_data(*value_ptr, [&](parsec_data_t* data){ iov_size += data->nb_elts; });
2827+
detail::foreach_parsec_data(*value_ptr, [&](parsec_data_t* data){ iov_size += data->span; });
28232828
}
28242829
/* key is packed at the end */
28252830
std::size_t key_pack_size = ttg::default_data_descriptor<Key>::payload_size(&key);
@@ -2968,7 +2973,7 @@ namespace ttg_parsec {
29682973
/* Try to find a device that is not the host and has the latest version. */
29692974
std::tie(device, device_copy) = detail::find_device_copy(data);
29702975
}
2971-
handle_iovec_fn(ttg::iovec{data->nb_elts, data->device_copies[device]->device_private},
2976+
handle_iovec_fn(ttg::iovec{data->span, data->device_copies[device]->device_private},
29722977
device_copy);
29732978
});
29742979
}
@@ -3159,7 +3164,7 @@ namespace ttg_parsec {
31593164
/* Try to find a device that is not the host and has the latest version. */
31603165
std::tie(device, device_copy) = detail::find_device_copy(data);
31613166
}
3162-
handle_iov_fn(ttg::iovec{data->nb_elts,
3167+
handle_iov_fn(ttg::iovec{data->span,
31633168
data->device_copies[device]->device_private},
31643169
device_copy);
31653170
});
@@ -3533,8 +3538,8 @@ namespace ttg_parsec {
35333538
/* find the flow */
35343539
int flowidx = 0;
35353540
while (flowidx < MAX_PARAM_COUNT &&
3536-
gpu_task->flow[flowidx] != nullptr &&
3537-
gpu_task->flow[flowidx]->flow_flags != PARSEC_FLOW_ACCESS_NONE) {
3541+
gpu_task->flow_info[flowidx].flow != nullptr &&
3542+
gpu_task->flow_info[flowidx].flow->flow_flags != PARSEC_FLOW_ACCESS_NONE) {
35383543
if (detail::parsec_ttg_caller->parsec_task.data[flowidx].data_in->original == data) {
35393544
/* found the right data, set the corresponding flow as pushout */
35403545
break;
@@ -3544,14 +3549,14 @@ namespace ttg_parsec {
35443549
if (flowidx == MAX_PARAM_COUNT) {
35453550
throw std::runtime_error("Cannot add more than MAX_PARAM_COUNT flows to a task!");
35463551
}
3547-
if (gpu_task->flow[flowidx]->flow_flags == PARSEC_FLOW_ACCESS_NONE) {
3552+
if (gpu_task->flow_info[flowidx].flow->flow_flags == PARSEC_FLOW_ACCESS_NONE) {
35483553
/* no flow found, add one and mark it pushout */
35493554
detail::parsec_ttg_caller->parsec_task.data[flowidx].data_in = data->device_copies[0];
35503555
detail::parsec_ttg_caller->parsec_task.data[flowidx].data_out = data->device_copies[data->owner_device];
3551-
gpu_task->flow_nb_elts[flowidx] = data->nb_elts;
3556+
gpu_task->flow_info[flowidx].flow_span = data->span;
35523557
}
35533558
/* need to mark the flow WRITE, otherwise PaRSEC will not do the pushout */
3554-
((parsec_flow_t *)gpu_task->flow[flowidx])->flow_flags |= PARSEC_FLOW_ACCESS_WRITE;
3559+
const_cast<parsec_flow_t*>(gpu_task->flow_info[flowidx].flow)->flow_flags |= PARSEC_FLOW_ACCESS_WRITE;
35553560
gpu_task->pushout |= 1<<flowidx;
35563561
}
35573562
};

0 commit comments

Comments
 (0)