Browse Source

configurable time sample

Andra Hugo 12 years ago
parent
commit
3e4395d0ba

+ 4 - 1
sc_hypervisor/include/sc_hypervisor_config.h

@@ -38,6 +38,7 @@ extern "C"
 #define SC_HYPERVISOR_NULL -11
 #define	SC_HYPERVISOR_ISPEED_W_SAMPLE -12
 #define SC_HYPERVISOR_ISPEED_CTX_SAMPLE -13
+#define SC_HYPERVISOR_TIME_SAMPLE -14
 
 
 #define MAX_IDLE_TIME 5000000000
@@ -76,7 +77,9 @@ struct sc_hypervisor_policy_config
 
 	/* sample used to compute the instant speed per ctx*/
 	double ispeed_ctx_sample;
-
+	
+        /* sample used to compute the instant speed per ctx (in seconds)*/
+	double time_sample;
 };
 
 /* set a certain configuration to a context */

+ 2 - 15
sc_hypervisor/src/policies_utils/speed.c

@@ -40,13 +40,7 @@ double sc_hypervisor_get_ctx_speed(struct sc_hypervisor_wrapper* sc_w)
 	unsigned can_compute_speed = 0;
 	char *speed_sample_criteria = getenv("SC_HYPERVISOR_SAMPLE_CRITERIA");
 	if(speed_sample_criteria && (strcmp(speed_sample_criteria, "time") == 0))
-	{
-		int n_all_cpus = starpu_cpu_worker_get_count();
-		int n_all_cuda = starpu_cuda_worker_get_count();
-		double th_speed = SC_HYPERVISOR_DEFAULT_CPU_SPEED * n_all_cpus + SC_HYPERVISOR_DEFAULT_CUDA_SPEED * n_all_cuda;
-		double time_sample = 0.1 * ((total_flops/1000000000.0) / th_speed);
-		can_compute_speed = elapsed_time > 1.0;//time_sample;
-	}
+		can_compute_speed = elapsed_time > config->time_sample;
 	else
 		can_compute_speed = elapsed_flops >= redim_sample;
 
@@ -121,14 +115,7 @@ double sc_hypervisor_get_speed_per_worker_type(struct sc_hypervisor_wrapper* sc_
 	unsigned can_compute_speed = 0;
 	char *speed_sample_criteria = getenv("SC_HYPERVISOR_SAMPLE_CRITERIA");
 	if(speed_sample_criteria && (strcmp(speed_sample_criteria, "time") == 0))
-	{
-		int n_all_cpus = starpu_cpu_worker_get_count();
-		int n_all_cuda = starpu_cuda_worker_get_count();
-		double th_speed = SC_HYPERVISOR_DEFAULT_CPU_SPEED * n_all_cpus + SC_HYPERVISOR_DEFAULT_CUDA_SPEED * n_all_cuda;
-		double total_flops = sc_w->total_flops;
-		double time_sample = 0.1 * ((total_flops/1000000000.0) / th_speed);
-		can_compute_speed = elapsed_time > 1.0;
-	}
+		can_compute_speed = elapsed_time > config->time_sample;
 	else
 		can_compute_speed = ctx_elapsed_flops > ctx_sample;
 

+ 6 - 0
sc_hypervisor/src/sc_config.c

@@ -23,6 +23,7 @@ static struct sc_hypervisor_policy_config* _create_config(void)
 	config->max_nworkers = -1;
 	config->new_workers_max_idle = -1.0;
 	config->ispeed_ctx_sample = 0.0;
+	config->time_sample = 0.5;
 
 	int i;
 	for(i = 0; i < STARPU_NMAXWORKERS; i++)
@@ -184,6 +185,11 @@ static struct sc_hypervisor_policy_config* _ctl(unsigned sched_ctx, va_list varg
 			config->ispeed_ctx_sample = va_arg(varg_list, double);
 			break;
 
+		case SC_HYPERVISOR_TIME_SAMPLE:
+			config->time_sample = va_arg(varg_list, double);
+			break;
+
+
 /* not important for the strateg, needed just to jump these args in the iteration of the args */
 		case SC_HYPERVISOR_TIME_TO_APPLY:
 			va_arg(varg_list, int);