1 #include <madness/madness_config.h>
2 
3 #ifdef HAVE_PARSEC
4 #include "parsec.h"
5 #include <iostream>
6 #include "thread.h"
7 #include <dague/dague_internal.h>
8 
9 // Here we initialize with the right child class
10 namespace madness {
complete_madness_task_execution(dague_execution_unit_t * eu,dague_execution_context_t * exec_context)11     dague_hook_return_t complete_madness_task_execution (dague_execution_unit_t *eu,
12                                                          dague_execution_context_t *exec_context)
13     {
14         (void)eu;
15         dague_atomic_add_32b(&exec_context->dague_handle->nb_tasks, -1);
16         return DAGUE_HOOK_RETURN_DONE;
17     }
18 
release_madness_task(dague_execution_unit_t * eu,dague_execution_context_t * exec_context)19     dague_hook_return_t release_madness_task (dague_execution_unit_t *eu,
20                                               dague_execution_context_t *exec_context)
21     {
22         PoolTaskInterface *c = ((PoolTaskInterface **)exec_context->locals)[0];
23         delete(c);
24         return DAGUE_HOOK_RETURN_DONE;
25     }
26 
27     const dague_function_t* PoolTaskInterface::func = &madness_function;
28 
pointer_call(dague_execution_unit_t * eu,dague_execution_context_t * exec_context)29     dague_hook_return_t pointer_call(dague_execution_unit_t *eu,
30                                      dague_execution_context_t *exec_context)
31     {
32         PoolTaskInterface *c = ((PoolTaskInterface **)exec_context->locals)[0];
33         c->run(TaskThreadEnv(1, 0, 0));
34         return DAGUE_HOOK_RETURN_DONE;
35     }
36 
37 
38   extern "C"{
39 
40 #include <stdio.h>
41 
RUN_hash(const dague_handle_t * handle,const assignment_t * a)42         static uint64_t RUN_hash(const dague_handle_t *handle, const assignment_t *a)
43         {
44             (void)a; (void)handle;
45             return 0;
46         }
47 
empty_hook(dague_execution_unit_t * eu,dague_execution_context_t * context)48         static dague_hook_return_t empty_hook (dague_execution_unit_t *eu,
49                                                dague_execution_context_t *context)
50         {
51             return DAGUE_HOOK_RETURN_DONE;
52         }
53 
54         static const __dague_chore_t __RUN_chores[] = {
55             {.type = DAGUE_DEV_CPU,
56              .evaluate = NULL,
57              .hook = pointer_call},
58             {.type = DAGUE_DEV_NONE,
59              .evaluate = NULL,
60              .hook = (dague_hook_t *) NULL},
61         };
62 
63 
64         const dague_function_t madness_function = {
65             .name = "RUN",
66             .flags = DAGUE_HAS_IN_IN_DEPENDENCIES | DAGUE_USE_DEPS_MASK,
67             .function_id = 0,
68             .nb_flows = 0,
69             .nb_parameters = 0,
70             .nb_locals = 0,
71             .dependencies_goal = 0,
72             .params = {NULL,NULL,NULL, NULL},
73             .locals = {NULL,NULL,NULL, NULL},
74             .in = {NULL, NULL, NULL, NULL},
75             .out = {NULL, NULL, NULL, NULL},
76             .priority = NULL,
77             .initial_data = NULL,
78             .final_data = NULL,
79             .data_affinity = NULL,
80             .key = (dague_functionkey_fn_t *) RUN_hash,
81 #if defined(DAGUE_SIM)
82             .sim_cost_fct = (dague_sim_cost_fct_t*) NULL,
83 #endif
84             .get_datatype = (dague_datatype_lookup_t *) NULL,
85             .prepare_input = empty_hook,
86             .incarnations = __RUN_chores,
87             .prepare_output = (dague_hook_t *) NULL,
88             .find_deps = (dague_find_dependency_fn_t*)NULL,
89             .iterate_successors = (dague_traverse_function_t *) NULL,
90             .iterate_predecessors = (dague_traverse_function_t *) NULL,
91             .release_deps = (dague_release_deps_t *) NULL,
92             .complete_execution = complete_madness_task_execution,
93             .new_task = (dague_new_task_function_t*) NULL,
94             .release_task = release_madness_task, //object delete,
95             .fini = (dague_hook_t *) NULL,
96         };
97 
98         const dague_function_t* madness_function_array[]= {&(madness::madness_function), NULL};
99 
100         dague_handle_t madness_handle = {
101             .super = { 0x0, },
102             .handle_id = 0,
103             .nb_tasks = 0,
104             .nb_functions = 1,
105             .devices_mask = DAGUE_DEVICES_ALL,
106             .initial_number_tasks = 0,
107             .priority = 0,
108             .nb_pending_actions = 1,
109             .context = NULL,
110             .startup_hook = NULL,
111             .functions_array = madness_function_array
112         };
113     }
114 }
115 #endif
116