Browse Source

fix code format

Nathalie Furmento 4 years ago
parent
commit
f4cede33d3

+ 26 - 24
src/core/perfmodel/energy_model.c

@@ -57,8 +57,7 @@ static const int N_EVTS = 2;
 static int nsockets;
 
 static const char* event_names[] = { "rapl::RAPL_ENERGY_PKG:cpu=%d",
-
-                              "rapl::RAPL_ENERGY_DRAM:cpu=%d"};
+				     "rapl::RAPL_ENERGY_DRAM:cpu=%d"};
 
 static int add_event(int EventSet, int socket);
 
@@ -85,7 +84,8 @@ int starpu_energy_start(int workerid, enum starpu_worker_archtype archi)
 {
 	t1 = starpu_timing_now();
 
-	switch (archi) {
+	switch (archi)
+	{
 #ifdef STARPU_PAPI
 #ifdef STARPU_HAVE_HWLOC
 	case STARPU_CPU_WORKER:
@@ -102,15 +102,14 @@ int starpu_energy_start(int workerid, enum starpu_worker_archtype archi)
 		values=calloc(nsockets * N_EVTS,sizeof(long long));
 		STARPU_ASSERT(values);
 
-		if((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT )
+		if ((retval = PAPI_library_init(PAPI_VER_CURRENT)) != PAPI_VER_CURRENT)
 			ERROR_RETURN(retval);
 
 		/* Creating the eventset */
-		if ( (retval = PAPI_create_eventset(&EventSet)) != PAPI_OK)
+		if ((retval = PAPI_create_eventset(&EventSet)) != PAPI_OK)
 			ERROR_RETURN(retval);
 
 		int i;
-
 		for (i = 0 ; i < nsockets ; i ++ )
 		{
 			/* return the index of socket */
@@ -134,19 +133,20 @@ int starpu_energy_start(int workerid, enum starpu_worker_archtype archi)
 #endif
 #endif
 
-
 #ifdef HAVE_NVMLDEVICEGETTOTALENERGYCONSUMPTION
 	case STARPU_CUDA_WORKER:
 	{
 		STARPU_ASSERT_MSG(workerid != -1, "For CUDA GPUs we measure each GPU separately, please specify a worker\n");
 		int devid = starpu_worker_get_devid(workerid);
 		int ret = nvmlDeviceGetHandleByIndex_v2 (devid,  &device);
-		if (ret != NVML_SUCCESS) {
+		if (ret != NVML_SUCCESS)
+		{
 			_STARPU_DISP("Could not get CUDA device %d from nvml\n", devid);
 			return -1;
 		}
 		ret = nvmlDeviceGetTotalEnergyConsumption ( device, &energy_begin );
-		if (ret != NVML_SUCCESS) {
+		if (ret != NVML_SUCCESS)
+		{
 			_STARPU_DISP("Could not measure energy used by CUDA device %d\n", devid);
 			return -1;
 		}
@@ -164,14 +164,13 @@ int starpu_energy_start(int workerid, enum starpu_worker_archtype archi)
 int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task, unsigned nimpl, unsigned ntasks, int workerid, enum starpu_worker_archtype archi)
 {
 	double energy = 0.;
-
 	int retval;
 	unsigned cpuid = 0;
-
 	double t2 = starpu_timing_now();
 	double t STARPU_ATTRIBUTE_UNUSED = t2 - t1;
 
-	switch (archi) {
+	switch (archi)
+	{
 #ifdef STARPU_PAPI
 #ifdef STARPU_HAVE_HWLOC
 	case STARPU_CPU_WORKER:
@@ -184,15 +183,16 @@ int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task,
 
 		int k,s;
 
-		for( s = 0 ; s < nsockets ; s ++){
-			for(k = 0 ; k < N_EVTS; k++) {
+		for( s = 0 ; s < nsockets ; s ++)
+		{
+			for(k = 0 ; k < N_EVTS; k++)
+			{
 				double delta = values[s * N_EVTS + k]*0.23/1.0e9;
 				energy += delta;
 
 				debug("%-40s%12.6f J\t(for %f us, Average Power %.1fW)\n",
-					event_names[k],
-					delta, t, delta/(t*1.0E-6)
-				);
+				      event_names[k],
+				      delta, t, delta/(t*1.0E-6));
 			}
 		}
 
@@ -215,7 +215,7 @@ int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task,
 	case STARPU_CUDA_WORKER:
 	{
 		STARPU_ASSERT_MSG(workerid != -1, "For CUDA GPUs we measure each GPU separately, please specify a worker\n");
-		int ret = nvmlDeviceGetTotalEnergyConsumption ( device, &energy_end );
+		int ret = nvmlDeviceGetTotalEnergyConsumption(device, &energy_end );
 		if (ret != NVML_SUCCESS)
 			return -1;
 		energy = (energy_end - energy_begin) / 1000.;
@@ -225,10 +225,11 @@ int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task,
 #endif
 
 	default:
+	{
 		printf("Error: worker type %d is not supported! \n", archi);
 		return -1;
 		break;
-
+	}
 	}
 
 
@@ -242,7 +243,6 @@ int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task,
 	starpu_perfmodel_update_history(model, task, arch, cpuid, nimpl, energy);
 
 	return retval;
-
 }
 
 #ifdef STARPU_PAPI
@@ -250,17 +250,18 @@ int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task,
 static int add_event(int eventSet, int socket)
 {
 	int retval, i;
-	for (i = 0; i < N_EVTS; i++) {
+	for (i = 0; i < N_EVTS; i++)
+	{
 		char buf[255];
 		int code;
-
 		PAPI_event_info_t info;
 		sprintf(buf,  event_names[i], socket);
 		retval = PAPI_event_name_to_code( buf, &code);
 
 		retval = PAPI_get_event_info(code, &info);
 		retval = PAPI_add_event(eventSet, code);
-		if (retval != PAPI_OK) {
+		if (retval != PAPI_OK)
+		{
 			/* printf("Activating multiplex\n"); */
 			/* retval = PAPI_set_multiplex(eventSet); */
 			/* if(retval != PAPI_OK) { */
@@ -268,7 +269,8 @@ static int add_event(int eventSet, int socket)
 			/*      exit (0); */
 			/* } */
 			retval = PAPI_add_named_event(eventSet, buf);
-			if(retval != PAPI_OK) {
+			if(retval != PAPI_OK)
+			{
 				printf("cannot add event\n");
 				exit (1);
 			}

+ 5 - 10
src/core/perfmodel/perfmodel.h

@@ -74,14 +74,10 @@ void _starpu_initialize_registered_performance_models(void);
 void _starpu_deinitialize_registered_performance_models(void);
 void _starpu_deinitialize_performance_model(struct starpu_perfmodel *model);
 
-double _starpu_regression_based_job_expected_perf(struct starpu_perfmodel *model,
-					struct starpu_perfmodel_arch* arch, struct _starpu_job *j, unsigned nimpl);
-double _starpu_non_linear_regression_based_job_expected_perf(struct starpu_perfmodel *model,
-					struct starpu_perfmodel_arch* arch, struct _starpu_job *j, unsigned nimpl);
-double _starpu_multiple_regression_based_job_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch,
-					struct _starpu_job *j, unsigned nimpl);
-void _starpu_update_perfmodel_history(struct _starpu_job *j, struct starpu_perfmodel *model, struct starpu_perfmodel_arch * arch,
-					unsigned cpuid, double measured, unsigned nimpl, unsigned number);
+double _starpu_regression_based_job_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, struct _starpu_job *j, unsigned nimpl);
+double _starpu_non_linear_regression_based_job_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, struct _starpu_job *j, unsigned nimpl);
+double _starpu_multiple_regression_based_job_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, struct _starpu_job *j, unsigned nimpl);
+void _starpu_update_perfmodel_history(struct _starpu_job *j, struct starpu_perfmodel *model, struct starpu_perfmodel_arch * arch, unsigned cpuid, double measured, unsigned nimpl, unsigned number);
 int _starpu_perfmodel_create_comb_if_needed(struct starpu_perfmodel_arch* arch);
 
 void _starpu_create_sampling_directory_if_needed(void);
@@ -98,8 +94,7 @@ unsigned *_starpu_get_cuda_affinity_vector(unsigned gpuid);
 unsigned *_starpu_get_opencl_affinity_vector(unsigned gpuid);
 #endif
 
-void _starpu_save_bandwidth_and_latency_disk(double bandwidth_write, double bandwidth_read,
-					     double latency_write, double latency_read, unsigned node, const char *name);
+void _starpu_save_bandwidth_and_latency_disk(double bandwidth_write, double bandwidth_read, double latency_write, double latency_read, unsigned node, const char *name);
 
 void _starpu_write_double(FILE *f, const char *format, double val);
 int _starpu_read_double(FILE *f, char *format, double *val);

+ 30 - 33
src/profiling/profiling.c

@@ -146,43 +146,42 @@ void _starpu_profiling_init(void)
 	}
 
 #ifdef STARPU_PAPI
-		STARPU_PTHREAD_MUTEX_LOCK(&papi_mutex);
-		int retval = PAPI_library_init(PAPI_VER_CURRENT);
-		if (retval != PAPI_VER_CURRENT)
-		{
-			 _STARPU_MSG("Failed init PAPI, error: %s.\n", PAPI_strerror(retval));
-		}
-		retval = PAPI_thread_init(pthread_self);
-		if (retval != PAPI_OK)
-		{
-			 _STARPU_MSG("Failed init PAPI thread, error: %s.\n", PAPI_strerror(retval));
-		}
+	STARPU_PTHREAD_MUTEX_LOCK(&papi_mutex);
+	int retval = PAPI_library_init(PAPI_VER_CURRENT);
+	if (retval != PAPI_VER_CURRENT)
+	{
+		_STARPU_MSG("Failed init PAPI, error: %s.\n", PAPI_strerror(retval));
+	}
+	retval = PAPI_thread_init(pthread_self);
+	if (retval != PAPI_OK)
+	{
+		_STARPU_MSG("Failed init PAPI thread, error: %s.\n", PAPI_strerror(retval));
+	}
 
-		char *conf_papi_events;
-		char *papi_event_name;
-		conf_papi_events = starpu_getenv("STARPU_PROF_PAPI_EVENTS");
-		papi_nevents = 0;
-		if (conf_papi_events != NULL)
+	char *conf_papi_events;
+	char *papi_event_name;
+	conf_papi_events = starpu_getenv("STARPU_PROF_PAPI_EVENTS");
+	papi_nevents = 0;
+	if (conf_papi_events != NULL)
+	{
+		while ((papi_event_name = strtok_r(conf_papi_events, " ,", &conf_papi_events)))
 		{
-			while ((papi_event_name = strtok_r(conf_papi_events, " ,", &conf_papi_events)))
+			if (papi_nevents == PAPI_MAX_HWCTRS)
 			{
-				if (papi_nevents == PAPI_MAX_HWCTRS)
-				{
-				      _STARPU_MSG("Too many requested papi counters, ignoring %s\n", papi_event_name);
-				      continue;
-				}
-
-				_STARPU_DEBUG("Loading PAPI Event: %s\n", papi_event_name);
-				retval = PAPI_event_name_to_code ((char*)papi_event_name, &papi_events[papi_nevents]);
-				if (retval != PAPI_OK)
-				      _STARPU_MSG("Failed to codify papi event [%s], error: %s.\n", papi_event_name, PAPI_strerror(retval));
-				else
-					papi_nevents++;
+				_STARPU_MSG("Too many requested papi counters, ignoring %s\n", papi_event_name);
+				continue;
 			}
+
+			_STARPU_DEBUG("Loading PAPI Event: %s\n", papi_event_name);
+			retval = PAPI_event_name_to_code ((char*)papi_event_name, &papi_events[papi_nevents]);
+			if (retval != PAPI_OK)
+				_STARPU_MSG("Failed to codify papi event [%s], error: %s.\n", papi_event_name, PAPI_strerror(retval));
+			else
+				papi_nevents++;
 		}
-		STARPU_PTHREAD_MUTEX_UNLOCK(&papi_mutex);
+	}
+	STARPU_PTHREAD_MUTEX_UNLOCK(&papi_mutex);
 #endif
-
 }
 
 #ifdef STARPU_PAPI
@@ -268,7 +267,6 @@ void _starpu_profiling_terminate(void)
 /*
  *	Task profiling
  */
-
 struct starpu_profiling_task_info *_starpu_allocate_profiling_info_if_needed(struct starpu_task *task)
 {
 	struct starpu_profiling_task_info *info = NULL;
@@ -285,7 +283,6 @@ struct starpu_profiling_task_info *_starpu_allocate_profiling_info_if_needed(str
 /*
  *	Worker profiling
  */
-
 static void _starpu_worker_reset_profiling_info_with_lock(int workerid)
 {
 	_starpu_clock_gettime(&worker_info[workerid].start_time);

+ 4 - 3
tests/perfmodels/regression_based_memset.c

@@ -337,7 +337,8 @@ int main(int argc, char **argv)
 	STARPU_CHECK_RETURN_VALUE(ret, "starpu_opencl_load_opencl_from_file");
 #endif
 
-	if (starpu_cpu_worker_get_count() > 0) {
+	if (starpu_cpu_worker_get_count() > 0)
+	{
 		memset_cl.cpu_funcs[1] = NULL;
 		bench_energy(-1, STARPU_CPU, STARPU_CPU_WORKER, 0, &memset_cl);
 		memset_cl.cpu_funcs[1] = memset_cpu;
@@ -351,7 +352,8 @@ int main(int argc, char **argv)
 		bench_energy(-1, STARPU_CPU, STARPU_CPU_WORKER, 1, &nl_memset_cl);
 	}
 
-	for (i = 0; i < starpu_cuda_worker_get_count(); i++) {
+	for (i = 0; i < starpu_cuda_worker_get_count(); i++)
+	{
 		int workerid = starpu_worker_get_by_type(STARPU_CUDA_WORKER, i);
 		bench_energy(workerid, STARPU_CUDA, STARPU_CUDA_WORKER, 0, &memset_cl);
 		bench_energy(workerid, STARPU_CUDA, STARPU_CUDA_WORKER, 0, &nl_memset_cl);
@@ -363,6 +365,5 @@ int main(int argc, char **argv)
 #endif
 	starpu_shutdown();
 
-
 	return EXIT_SUCCESS;
 }