Skip to content

Commit 2125fed

Browse files
committed
Derive the device_task_t from a parsec_object_t
Introduce the parsec_gpu_flow_info_s info structure to combine the flow information needed by the GPU code. Allow the standard device tasks (aka. parsec_gpu_dsl_task_t) to contain the flow_info array inside the task, while allowing other DSL to have their own type of device task (derived from parsec_gpu_task_t) Enhance the mechanism to release the device tasks via the release_device_task function pointer. The device code will call this function to let the DSL decide how to device task release should be handled. Some DSL (PTG and DTD as of now) will call OBJ_RELEASE on it (and the free is automatic), while others (TTG as an example) will have its own handling. Signed-off-by: George Bosilca <gbosilca@nvidia.com>
1 parent 14b823a commit 2125fed

12 files changed

Lines changed: 193 additions & 143 deletions

File tree

parsec/arena.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ int parsec_arena_allocate_device_private(parsec_data_copy_t *copy,
223223
assert(0 == (((ptrdiff_t)chunk->data) % arena->alignment));
224224
assert((arena->elem_size + (ptrdiff_t)chunk->data) <= (size + (ptrdiff_t)chunk));
225225

226-
data->nb_elts = count * arena->elem_size;
226+
data->span = count * arena->elem_size;
227227

228228
copy->flags = PARSEC_DATA_FLAG_ARENA |
229229
PARSEC_DATA_FLAG_PARSEC_OWNED |

parsec/data.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static void parsec_data_construct(parsec_data_t* obj )
7070
obj->owner_device = -1;
7171
obj->preferred_device = -1;
7272
obj->key = 0;
73-
obj->nb_elts = 0;
73+
obj->span = 0;
7474
for( uint32_t i = 0; i < parsec_nb_devices;
7575
obj->device_copies[i] = NULL, i++ );
7676
obj->dc = NULL;
@@ -511,7 +511,7 @@ parsec_data_create( parsec_data_t **holder,
511511
data->owner_device = 0;
512512
data->key = key;
513513
data->dc = desc;
514-
data->nb_elts = size;
514+
data->span = size;
515515
parsec_data_copy_attach(data, data_copy, 0);
516516

517517
if( !parsec_atomic_cas_ptr(holder, NULL, data) ) {
@@ -548,7 +548,7 @@ parsec_data_create_with_type( parsec_data_collection_t *desc,
548548
clone->owner_device = 0;
549549
clone->key = key;
550550
clone->dc = desc;
551-
clone->nb_elts = size;
551+
clone->span = size;
552552
parsec_data_copy_attach(clone, data_copy, 0);
553553

554554
return clone;

parsec/data_dist/matrix/broadcast.jdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static parsec_data_t* data_of(parsec_data_collection_t *desc, ...)
5959
data->owner_device = 0;
6060
data->key = k;
6161
data->dc = (parsec_data_collection_t*)desc;
62-
data->nb_elts = 1;
62+
data->span = 1;
6363
parsec_data_copy_t* data_copy = (parsec_data_copy_t*)PARSEC_OBJ_NEW(parsec_data_copy_t);
6464
parsec_data_copy_attach(data, data_copy, 0);
6565
data_copy->device_private = NULL;

parsec/data_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct parsec_data_s {
3636
* which device this data should be modified RW when there
3737
* are multiple choices. -1 means no preference. */
3838
struct parsec_data_collection_s* dc;
39-
size_t nb_elts; /* size in bytes of the memory layout */
39+
size_t span; /* size in bytes of the memory layout */
4040
struct parsec_data_copy_s *device_copies[]; /* this array allocated according to the number of devices
4141
* (parsec_nb_devices). It points to the most recent
4242
* version of the data.

parsec/interfaces/dtd/insert_function.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,20 +2398,18 @@ static parsec_hook_return_t parsec_dtd_gpu_task_submit(parsec_execution_stream_t
23982398
#if defined(PARSEC_HAVE_DEV_CUDA_SUPPORT) || defined(PARSEC_HAVE_DEV_HIP_SUPPORT) || defined(PARSEC_HAVE_DEV_LEVEL_ZERO_SUPPORT)
23992399
parsec_dtd_task_t *dtd_task = (parsec_dtd_task_t *)this_task;
24002400
parsec_dtd_task_class_t *dtd_tc = (parsec_dtd_task_class_t*)this_task->task_class;
2401-
parsec_gpu_task_t *gpu_task = (parsec_gpu_task_t *) calloc(1, sizeof(parsec_gpu_task_t));
2402-
PARSEC_OBJ_CONSTRUCT(gpu_task, parsec_list_item_t);
2403-
gpu_task->release_device_task = free; /* by default free the device task */
2401+
parsec_gpu_task_t *gpu_task = (parsec_gpu_task_t*)PARSEC_OBJ_NEW(parsec_gpu_dsl_task_t);
24042402
gpu_task->ec = (parsec_task_t *) this_task;
24052403
gpu_task->submit = dtd_tc->gpu_func_ptr;
2406-
gpu_task->task_type = 0;
2407-
gpu_task->last_data_check_epoch = -1; /* force at least one validation for the task */
2404+
gpu_task->task_type = PARSEC_GPU_TASK_TYPE_KERNEL;
24082405
gpu_task->pushout = 0;
2406+
gpu_task->nb_flows = dtd_tc->super.nb_flows; /* inherit the flows from the task class */
24092407
for(int i = 0; i < dtd_tc->super.nb_flows; i++) {
24102408
parsec_dtd_flow_info_t *flow = FLOW_OF(dtd_task, i);
24112409
if(flow->op_type & PARSEC_PUSHOUT)
24122410
gpu_task->pushout |= 1<<i;
2413-
gpu_task->flow[i] = dtd_tc->super.in[i];
2414-
gpu_task->flow_nb_elts[i] = this_task->data[i].data_in->original->nb_elts;
2411+
gpu_task->flow_info[i].flow = dtd_tc->super.in[i];
2412+
gpu_task->flow_info[i].flow_span = this_task->data[i].data_in->original->span;
24152413
}
24162414

24172415
parsec_device_module_t *device = this_task->selected_device;

parsec/interfaces/ptg/ptg-compiler/jdf2c.c

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2009-2024 The University of Tennessee and The University
2+
* Copyright (c) 2009-2025 The University of Tennessee and The University
33
* of Tennessee Research Foundation. All rights
44
* reserved.
55
* Copyright (c) 2024-2026 NVIDIA Corporation. All rights reserved.
@@ -6828,66 +6828,56 @@ static void jdf_generate_code_hook_gpu(const jdf_t *jdf,
68286828
" assert(NULL != dev);\n"
68296829
" assert(PARSEC_DEV_IS_GPU(dev->type));\n"
68306830
"\n"
6831-
" gpu_task = (parsec_gpu_task_t*)calloc(1, sizeof(parsec_gpu_task_t));\n"
6832-
" PARSEC_OBJ_CONSTRUCT(gpu_task, parsec_list_item_t);\n"
6833-
" gpu_task->release_device_task = free; /* by default free the device task */\n"
6831+
" gpu_task = (parsec_gpu_task_t*)PARSEC_OBJ_NEW(parsec_gpu_dsl_task_t);"
68346832
" gpu_task->ec = (parsec_task_t*)this_task;\n"
68356833
" gpu_task->submit = &%s_kernel_submit_%s_%s;\n"
6836-
" gpu_task->task_type = 0;\n"
6837-
" gpu_task->last_data_check_epoch = -1; /* force at least one validation for the task */\n",
6834+
" gpu_task->task_type = PARSEC_GPU_TASK_TYPE_KERNEL;\n",
68386835
dev_lower, jdf_basename, f->fname);
68396836

68406837
/* Set up stage in/out callbacks */
68416838
jdf_find_property(body->properties, "stage_in", &stage_in_property);
6842-
jdf_find_property(body->properties, "stage_out", &stage_out_property);
6843-
6844-
if(stage_in_property == NULL) {
6845-
coutput(" gpu_task->stage_in = parsec_default_gpu_stage_in;\n");
6846-
}else{
6847-
coutput(" gpu_task->stage_in = %s;\n", dump_expr((void**)stage_in_property->expr, &info));
6848-
}
6839+
coutput(" gpu_task->stage_in = %s;\n", (NULL == stage_in_property) ? "parsec_default_gpu_stage_in"
6840+
: dump_expr((void **)stage_in_property->expr, &info));
68496841

6850-
if(stage_out_property == NULL) {
6851-
coutput(" gpu_task->stage_out = parsec_default_gpu_stage_out;\n");
6852-
}else{
6853-
coutput(" gpu_task->stage_out = %s;\n", dump_expr((void**)stage_out_property->expr, &info));
6854-
}
6842+
jdf_find_property(body->properties, "stage_out", &stage_out_property);
6843+
coutput(" gpu_task->stage_out = %s;\n", (NULL == stage_out_property) ? "parsec_default_gpu_stage_out"
6844+
: dump_expr((void **)stage_out_property->expr, &info));
68556845

68566846
/* Dump the dataflow */
68576847
coutput(" gpu_task->pushout = 0;\n");
68586848
for(fl = f->dataflow, di = 0; fl != NULL; fl = fl->next, di++) {
6859-
coutput(" gpu_task->flow[%d] = &%s;\n",
6849+
coutput(" gpu_task->flow_info[%d].flow = &%s;\n",
68606850
di, JDF_OBJECT_ONAME( fl ));
68616851

68626852
sprintf(sa->ptr, "%s.dc", fl->varname);
68636853
jdf_find_property(body->properties, sa->ptr, &desc_property);
6864-
if(desc_property == NULL){
6865-
coutput(" gpu_task->flow_dc[%d] = NULL;\n", di);
6854+
if(desc_property == NULL) {
6855+
coutput(" gpu_task->flow_info[%d].flow_dc = NULL;\n", di);
68666856
}else{
6867-
coutput(" gpu_task->flow_dc[%d] = (parsec_data_collection_t *)%s;\n", di,
6857+
coutput(" gpu_task->flow_info[%d].flow_dc = (parsec_data_collection_t *)%s;\n", di,
68686858
dump_expr((void**)desc_property->expr, &info));
68696859
}
68706860

68716861
sprintf(sa->ptr, "%s.size", fl->varname);
68726862
jdf_find_property(body->properties, sa->ptr, &size_property);
68736863

68746864
if(fl->flow_flags & JDF_FLOW_TYPE_CTL) {
6875-
if(size_property != NULL){
6865+
if(size_property != NULL) {
68766866
fprintf(stderr, "Error: specifying GPU buffer size for CTL flow %s at line %d\n",
68776867
fl->varname, JDF_OBJECT_LINENO(fl));
68786868
exit(-1);
68796869
}
6880-
coutput(" gpu_task->flow_nb_elts[%d] = 0;\n", di);
6881-
}else{
6870+
coutput(" gpu_task->flow_info[%d].flow_span = 0;\n", di);
6871+
} else {
68826872
coutput(" // A shortcut to check if the flow exists\n");
68836873
coutput(" if (gpu_task->ec->data[%d].data_in != NULL) {\n", di);
68846874
if(size_property == NULL){
6885-
coutput(" gpu_task->flow_nb_elts[%d] = gpu_task->ec->data[%d].data_in->original->nb_elts;\n", di, di);
6886-
}else{
6887-
coutput(" gpu_task->flow_nb_elts[%d] = %s;\n",
6888-
di, dump_expr((void**)size_property->expr, &info));
6875+
coutput(" gpu_task->flow_info[%d].flow_span = gpu_task->ec->data[%d].data_in->original->span;\n", di, di);
6876+
} else {
6877+
coutput(" gpu_task->flow_info[%d].flow_span = %s;\n",
6878+
di, dump_expr((void **)size_property->expr, &info));
68896879
if( (stage_in_property == NULL) || ( stage_out_property == NULL )){
6890-
coutput(" assert(gpu_task->ec->data[%d].data_in->original->nb_elts <= %s);\n",
6880+
coutput(" assert(gpu_task->ec->data[%d].data_in->original->span <= %s);\n",
68916881
di, dump_expr((void**)size_property->expr, &info));
68926882
}
68936883

@@ -6955,6 +6945,7 @@ static void jdf_generate_code_hook_gpu(const jdf_t *jdf,
69556945
}
69566946
}
69576947
string_arena_free(info.sa);
6948+
coutput(" gpu_task->nb_flows = %d; /* inherit the flows from the task_class */\n", di);
69586949

69596950
coutput("\n"
69606951
" return dev->kernel_scheduler(dev, es, gpu_task);\n"

0 commit comments

Comments
 (0)