|
@@ -15,6 +15,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include <sched_ctx_hypervisor_intern.h>
|
|
#include <sched_ctx_hypervisor_intern.h>
|
|
|
|
+#include <common/uthash.h>
|
|
|
|
|
|
unsigned imposed_resize = 0;
|
|
unsigned imposed_resize = 0;
|
|
struct starpu_performance_counters* perf_counters = NULL;
|
|
struct starpu_performance_counters* perf_counters = NULL;
|
|
@@ -34,6 +35,7 @@ extern struct hypervisor_policy lp_policy;
|
|
extern struct hypervisor_policy lp2_policy;
|
|
extern struct hypervisor_policy lp2_policy;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+
|
|
static struct hypervisor_policy *predefined_policies[] = {
|
|
static struct hypervisor_policy *predefined_policies[] = {
|
|
&idle_policy,
|
|
&idle_policy,
|
|
&app_driven_policy,
|
|
&app_driven_policy,
|
|
@@ -60,7 +62,7 @@ static void _load_hypervisor_policy(struct hypervisor_policy *policy)
|
|
hypervisor.policy.handle_pushed_task = policy->handle_pushed_task;
|
|
hypervisor.policy.handle_pushed_task = policy->handle_pushed_task;
|
|
hypervisor.policy.handle_idle_cycle = policy->handle_idle_cycle;
|
|
hypervisor.policy.handle_idle_cycle = policy->handle_idle_cycle;
|
|
hypervisor.policy.handle_idle_end = policy->handle_idle_end;
|
|
hypervisor.policy.handle_idle_end = policy->handle_idle_end;
|
|
-// hypervisor.policy.handle_post_exec_hook = policy->handle_post_exec_hook;
|
|
|
|
|
|
+ hypervisor.policy.handle_post_exec_hook = policy->handle_post_exec_hook;
|
|
hypervisor.policy.handle_submitted_job = policy->handle_submitted_job;
|
|
hypervisor.policy.handle_submitted_job = policy->handle_submitted_job;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -224,7 +226,7 @@ void sched_ctx_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
|
|
{
|
|
{
|
|
pthread_mutex_lock(&act_hypervisor_mutex);
|
|
pthread_mutex_lock(&act_hypervisor_mutex);
|
|
/* hypervisor.configurations[sched_ctx] = (struct starpu_htbl32_node*)malloc(sizeof(struct starpu_htbl32_node)); */
|
|
/* hypervisor.configurations[sched_ctx] = (struct starpu_htbl32_node*)malloc(sizeof(struct starpu_htbl32_node)); */
|
|
-/* hypervisor.resize_requests[sched_ctx] = (struct starpu_htbl32_node*)malloc(sizeof(struct starpu_htbl32_node)); */
|
|
|
|
|
|
+ hypervisor.resize_requests[sched_ctx] = NULL;
|
|
pthread_mutex_init(&hypervisor.conf_mut[sched_ctx], NULL);
|
|
pthread_mutex_init(&hypervisor.conf_mut[sched_ctx], NULL);
|
|
pthread_mutex_init(&hypervisor.resize_mut[sched_ctx], NULL);
|
|
pthread_mutex_init(&hypervisor.resize_mut[sched_ctx], NULL);
|
|
|
|
|
|
@@ -624,10 +626,20 @@ static unsigned _ack_resize_completed(unsigned sched_ctx, int worker)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/* Enqueue a resize request for 'sched_ctx', to be executed when the
|
|
|
|
+ * 'task_tag' tasks of 'sched_ctx' complete. */
|
|
void sched_ctx_hypervisor_resize(unsigned sched_ctx, int task_tag)
|
|
void sched_ctx_hypervisor_resize(unsigned sched_ctx, int task_tag)
|
|
{
|
|
{
|
|
|
|
+ struct resize_request_entry *entry;
|
|
|
|
+
|
|
|
|
+ entry = malloc(sizeof *entry);
|
|
|
|
+ STARPU_ASSERT(entry != NULL);
|
|
|
|
+
|
|
|
|
+ entry->sched_ctx = sched_ctx;
|
|
|
|
+ entry->task_tag = task_tag;
|
|
|
|
+
|
|
pthread_mutex_lock(&hypervisor.resize_mut[sched_ctx]);
|
|
pthread_mutex_lock(&hypervisor.resize_mut[sched_ctx]);
|
|
-// _starpu_htbl_insert_32(&hypervisor.resize_requests[sched_ctx], (uint32_t)task_tag, (void*)sched_ctx);
|
|
|
|
|
|
+ HASH_ADD_INT(hypervisor.resize_requests[sched_ctx], task_tag, entry);
|
|
pthread_mutex_unlock(&hypervisor.resize_mut[sched_ctx]);
|
|
pthread_mutex_unlock(&hypervisor.resize_mut[sched_ctx]);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -721,11 +733,15 @@ static void notify_post_exec_hook(unsigned sched_ctx, int task_tag)
|
|
|
|
|
|
if(hypervisor.resize[sched_ctx])
|
|
if(hypervisor.resize[sched_ctx])
|
|
{
|
|
{
|
|
|
|
+ struct resize_request_entry* resize_requests;
|
|
|
|
+
|
|
pthread_mutex_lock(&hypervisor.resize_mut[sched_ctx]);
|
|
pthread_mutex_lock(&hypervisor.resize_mut[sched_ctx]);
|
|
-/* struct starpu_htbl32_node* resize_requests = hypervisor.resize_requests[sched_ctx]; */
|
|
|
|
-
|
|
|
|
-/* if(hypervisor.policy.handle_post_exec_hook) */
|
|
|
|
-/* hypervisor.policy.handle_post_exec_hook(sched_ctx, resize_requests, task_tag); */
|
|
|
|
|
|
+ resize_requests = hypervisor.resize_requests[sched_ctx];
|
|
|
|
+
|
|
|
|
+ /* TODO: Move the lookup of 'task_tag' in 'resize_requests'
|
|
|
|
+ * here, and remove + free the entry here. */
|
|
|
|
+ if(hypervisor.policy.handle_post_exec_hook)
|
|
|
|
+ hypervisor.policy.handle_post_exec_hook(sched_ctx, resize_requests, task_tag);
|
|
pthread_mutex_unlock(&hypervisor.resize_mut[sched_ctx]);
|
|
pthread_mutex_unlock(&hypervisor.resize_mut[sched_ctx]);
|
|
}
|
|
}
|
|
return;
|
|
return;
|