Browse Source

Small improvements for Papi counters

* accept comma as separator of events to monitor
* warn is event registration failed because of unavailable component
* doc: explain how to get available counters (the given link isn't
  online anymore)
* doc: tell about the perf_event_paranoid kernel parameter
Philippe SWARTVAGHER 4 years ago
parent
commit
400eeb4659

+ 19 - 7
doc/doxygen/chapters/380_offline_performance_tools.doxy

@@ -586,19 +586,31 @@ $ starpu_paje_sort paje.trace
 \section PapiCounters PAPI counters
 \section PapiCounters PAPI counters
 
 
 Performance counter values could be obtained from the PAPI framework if
 Performance counter values could be obtained from the PAPI framework if
-<c>./configure</c> detected the libpapi. One has to set the \ref STARPU_PROFILING
-environment variable to 1 and then specify which events to record with the
-\ref STARPU_PROF_PAPI_EVENTS environment variable. For instance:
+<c>./configure</c> detected the libpapi.
+
+In Debian, packages <c>libpapi-dev</c> and <c>libpapi5.7</c> provide required
+files.  Package <c>papi-tools</c> contains a set of useful tools, for example
+<c>papi_avail</c> to see which counters are available.
+
+To be able to use Papi counters, one may need to reduce the level of the kernel
+parameter <c>kernel.perf_event_paranoid</c> to at least 2. See
+https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html for the
+security impact of this parameter.
+
+Then one has to set the \ref STARPU_PROFILING environment variable to 1 and
+specify which events to record with the \ref STARPU_PROF_PAPI_EVENTS
+environment variable. For instance:
 
 
 \verbatim
 \verbatim
 export STARPU_PROFILING=1 STARPU_PROF_PAPI_EVENTS="PAPI_TOT_INS PAPI_TOT_CYC"
 export STARPU_PROFILING=1 STARPU_PROF_PAPI_EVENTS="PAPI_TOT_INS PAPI_TOT_CYC"
 \endverbatim
 \endverbatim
 
 
+The comma can also be used to separate events to monitor.
+
 In the current simple implementation, only CPU tasks have their events measured
 In the current simple implementation, only CPU tasks have their events measured
-and require CPUs that support the PAPI events. All events that PAPI support are
-available from their documentation (https://icl.cs.utk.edu/projects/papi/wiki/PAPIC:Preset_Event_Definitions).
-It is important to note that not all events are available on all systems, and
-general PAPI recommendations should be followed.
+and require CPUs that support the PAPI events. It is important to note that not
+all events are available on all systems, and general PAPI recommendations
+should be followed.
 
 
 The counter values can be accessed using the profiling interface:
 The counter values can be accessed using the profiling interface:
 \code{.c}
 \code{.c}

+ 8 - 2
src/profiling/profiling.c

@@ -46,6 +46,7 @@ static struct timespec executing_start_date[STARPU_NMAXWORKERS];
 #ifdef STARPU_PAPI
 #ifdef STARPU_PAPI
 static int papi_events[PAPI_MAX_HWCTRS];
 static int papi_events[PAPI_MAX_HWCTRS];
 static int papi_nevents = 0;
 static int papi_nevents = 0;
+static int warned_component_unavailable = 0;
 #endif
 #endif
 
 
 /* Store the busid of the different (src, dst) pairs. busid_matrix[src][dst]
 /* Store the busid of the different (src, dst) pairs. busid_matrix[src][dst]
@@ -160,7 +161,7 @@ void _starpu_profiling_init(void)
 		conf_papi_events = starpu_getenv("STARPU_PROF_PAPI_EVENTS");
 		conf_papi_events = starpu_getenv("STARPU_PROF_PAPI_EVENTS");
 		if (conf_papi_events != NULL)
 		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)))
 			{
 			{
 				_STARPU_DEBUG("Loading PAPI Event:%s\n", papi_event_name);
 				_STARPU_DEBUG("Loading PAPI Event:%s\n", papi_event_name);
 				retval = PAPI_event_name_to_code ((char*)papi_event_name, &papi_events[papi_nevents]);
 				retval = PAPI_event_name_to_code ((char*)papi_event_name, &papi_events[papi_nevents]);
@@ -188,7 +189,12 @@ void _starpu_profiling_papi_task_start_counters(struct starpu_task *task)
 		PAPI_create_eventset(&profiling_info->papi_event_set);
 		PAPI_create_eventset(&profiling_info->papi_event_set);
 		for(int i=0; i<papi_nevents; i++)
 		for(int i=0; i<papi_nevents; i++)
 		{
 		{
-			PAPI_add_event(profiling_info->papi_event_set, papi_events[i]);
+			int ret = PAPI_add_event(profiling_info->papi_event_set, papi_events[i]);
+			if (ret == PAPI_ECMP_DISABLED && !warned_component_unavailable)
+			{
+				_STARPU_MSG("Error while registering Papi event: Component containing event is disabled. Try running `papi_component_avail` to get more information.\n");
+				warned_component_unavailable = 1;
+			}
 			profiling_info->papi_values[i]=0;
 			profiling_info->papi_values[i]=0;
 		}
 		}
 		PAPI_reset(profiling_info->papi_event_set);
 		PAPI_reset(profiling_info->papi_event_set);