Procházet zdrojové kódy

hypervisor: Convert `sched_ctx_hypervisor.configurations' to <common/uthash.h>.

Ludovic Courtès před 12 roky
rodič
revize
599114d14d

+ 9 - 1
sched_ctx_hypervisor/src/sched_ctx_config.c

@@ -232,8 +232,16 @@ void sched_ctx_hypervisor_ioctl(unsigned sched_ctx, ...)
 	struct policy_config *config = _ioctl(sched_ctx, varg_list, (task_tag > 0));
 	if(config != NULL)
 	{
+		struct configuration_entry *entry;
+
+		entry = malloc(sizeof *entry);
+		STARPU_ASSERT(entry != NULL);
+
+		entry->task_tag = task_tag;
+		entry->configuration = config;
+
 		pthread_mutex_lock(&hypervisor.conf_mut[sched_ctx]);
-//		_starpu_htbl_insert_32(&hypervisor.configurations[sched_ctx], (uint32_t)task_tag, config);
+		HASH_ADD_INT(hypervisor.configurations[sched_ctx], task_tag, entry);
 		pthread_mutex_unlock(&hypervisor.conf_mut[sched_ctx]);
 	}
 

+ 15 - 10
sched_ctx_hypervisor/src/sched_ctx_hypervisor.c

@@ -223,9 +223,9 @@ void sched_ctx_hypervisor_shutdown(void)
 
 /* the hypervisor is in charge only of the contexts registered to it*/
 void sched_ctx_hypervisor_register_ctx(unsigned sched_ctx, double total_flops)
-{	
+{
 	pthread_mutex_lock(&act_hypervisor_mutex);
-/* 	hypervisor.configurations[sched_ctx] = (struct starpu_htbl32_node*)malloc(sizeof(struct starpu_htbl32_node)); */
+	hypervisor.configurations[sched_ctx] = NULL;
 	hypervisor.resize_requests[sched_ctx] = NULL;
 	pthread_mutex_init(&hypervisor.conf_mut[sched_ctx], NULL);
 	pthread_mutex_init(&hypervisor.resize_mut[sched_ctx], NULL);
@@ -718,16 +718,21 @@ static void notify_post_exec_hook(unsigned sched_ctx, int task_tag)
 	
 	for(i = 0; i < ns; i++)
 	{
+		struct configuration_entry *entry;
+
 		conf_sched_ctx = hypervisor.sched_ctxs[i];
 		pthread_mutex_lock(&hypervisor.conf_mut[conf_sched_ctx]);
-/* 		void *_config = _starpu_htbl_search_32(hypervisor.configurations[conf_sched_ctx], (uint32_t)task_tag); */
-
-/* 		if(_config)// && config != hypervisor.configurations[conf_sched_ctx]) */
-/* 		{ */
-/* 			sched_ctx_hypervisor_set_config(conf_sched_ctx, _config); */
-/* 			free(_config); */
-/* 			_starpu_htbl_insert_32(&hypervisor.configurations[sched_ctx], (uint32_t)task_tag, NULL); */
-/* 		} */
+
+		HASH_FIND_INT(hypervisor.configurations[conf_sched_ctx], &task_tag, entry);
+
+		if (entry != NULL)
+		{
+			struct policy_config *config = entry->configuration;
+
+			sched_ctx_hypervisor_set_config(conf_sched_ctx, config);
+			HASH_DEL(hypervisor.configurations[conf_sched_ctx], entry);
+			free(config);
+		}
 		pthread_mutex_unlock(&hypervisor.conf_mut[conf_sched_ctx]);
 	}	
 		

+ 13 - 1
sched_ctx_hypervisor/src/sched_ctx_hypervisor_intern.h

@@ -38,6 +38,17 @@ struct resize_request_entry {
 	UT_hash_handle hh;
 };
 
+struct configuration_entry {
+	/* Key: the tag of tasks concerned by this configuration.  */
+	uint32_t task_tag;
+
+	/* Value: configuration of the scheduling context.  */
+	struct policy_config *configuration;
+
+	/* Bookkeeping.  */
+	UT_hash_handle hh;
+};
+
 struct sched_ctx_hypervisor {
 	struct sched_ctx_wrapper sched_ctx_w[STARPU_NMAX_SCHED_CTXS];
 	int sched_ctxs[STARPU_NMAX_SCHED_CTXS];
@@ -45,7 +56,8 @@ struct sched_ctx_hypervisor {
 	unsigned resize[STARPU_NMAX_SCHED_CTXS];
 	int min_tasks;
 	struct hypervisor_policy policy;
-	struct starpu_htbl32_node *configurations[STARPU_NMAX_SCHED_CTXS];
+
+	struct configuration_entry *configurations[STARPU_NMAX_SCHED_CTXS];
 
 	/* Set of pending resize requests for any context/tag pair.  */
 	struct resize_request_entry *resize_requests[STARPU_NMAX_SCHED_CTXS];