Exemplo n.º 1
0
void _starpu_worker_stop_sleeping(int workerid)
{
	if (starpu_profiling_status_get())
	{
		struct timespec *sleeping_start, sleep_end_time;

		_starpu_clock_gettime(&sleep_end_time);

		STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);

		sleeping_start = &sleeping_start_date[workerid];

                /* Perhaps that profiling was enabled while the worker was
                 * already blocked, so we don't measure (end - start), but
                 * (end - max(start,worker_start)) where worker_start is the
                 * date of the previous profiling info reset on the worker */
		struct timespec *worker_start = &worker_info[workerid].start_time;
		if (starpu_timespec_cmp(sleeping_start, worker_start, <))
		{
			/* sleeping_start < worker_start */
			sleeping_start = worker_start;
		}

		struct timespec sleeping_time;
		starpu_timespec_sub(&sleep_end_time, sleeping_start, &sleeping_time);

		starpu_timespec_accumulate(&worker_info[workerid].sleeping_time, &sleeping_time);

		worker_registered_sleeping_start[workerid] = 0;

		STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);

	}
}
Exemplo n.º 2
0
void _starpu_driver_update_job_feedback(starpu_job_t j, struct starpu_worker_s *worker_args,
      unsigned calibrate_model,
      struct timespec *codelet_start, struct timespec *codelet_end)
{
   struct timespec measured_ts;
   double measured;

   int event_prof = starpu_event_profiling_enabled(j->event);

   if (event_prof || calibrate_model)
   {
      starpu_timespec_sub(codelet_end, codelet_start, &measured_ts);
      measured = starpu_timing_timespec_to_us(&measured_ts);

      if (event_prof)
      {
         _starpu_event_profiling_start_time_set(j->event, codelet_start);
         _starpu_event_profiling_end_time_set(j->event, codelet_end);

         int workerid = worker_args->workerid;

         _starpu_event_profiling_worker_id_set(j->event, workerid);

         _starpu_worker_update_profiling_info_executing(workerid, &measured_ts, 1);
      }

      if (calibrate_model)
         _starpu_update_perfmodel_history(j, worker_args->perf_arch, worker_args->devid, measured);
   }
}
Exemplo n.º 3
0
int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *info)
{
	if (!starpu_profiling_status_get())
	{
		/* Not thread safe, shouldn't be too much a problem */
		info->executed_tasks = worker_info[workerid].executed_tasks;
	}

	STARPU_PTHREAD_MUTEX_LOCK(&worker_info_mutex[workerid]);

	if (info)
	{
		/* The total time is computed in a lazy fashion */
		struct timespec now;
		_starpu_clock_gettime(&now);

		/* In case some worker is currently sleeping, we take into
		 * account the time spent since it registered. */
		if (worker_registered_sleeping_start[workerid])
		{
			struct timespec sleeping_time;
			starpu_timespec_sub(&now, &sleeping_start_date[workerid], &sleeping_time);
			starpu_timespec_accumulate(&worker_info[workerid].sleeping_time, &sleeping_time);
		}

		if (worker_registered_executing_start[workerid])
		{
			struct timespec executing_time;
			starpu_timespec_sub(&now, &executing_start_date[workerid], &executing_time);
			starpu_timespec_accumulate(&worker_info[workerid].executing_time, &executing_time);
		}

		/* total_time = now - start_time */
		starpu_timespec_sub(&now, &worker_info[workerid].start_time,
					&worker_info[workerid].total_time);

		memcpy(info, &worker_info[workerid], sizeof(struct starpu_profiling_worker_info));
	}

	_starpu_worker_reset_profiling_info_with_lock(workerid);

	STARPU_PTHREAD_MUTEX_UNLOCK(&worker_info_mutex[workerid]);

	return 0;
}
Exemplo n.º 4
0
void starpu_clock_gettime(struct timespec *ts)
{
	struct timespec absolute_ts;

	/* Read the current time */
	__starpu_clock_gettime(&absolute_ts);

	/* Compute the relative time since initialization */
	starpu_timespec_sub(&absolute_ts, &reference_start_time_ts, ts);
}
Exemplo n.º 5
0
/* Returns the time elapsed between start and end in microseconds */
double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end)
{
	struct timespec diff;
	
	starpu_timespec_sub(end, start, &diff);

	double us = (diff.tv_sec*1e6) + (diff.tv_nsec*1e-3);

	return us;
}
Exemplo n.º 6
0
int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info)
{
	int src_node = busid_to_node_pair[busid].src;
	int dst_node = busid_to_node_pair[busid].dst;

	/* XXX protect all this  method with a mutex */
	if (bus_info)
	{
		struct timespec now;
		_starpu_clock_gettime(&now);

		/* total_time = now - start_time */
		starpu_timespec_sub(&now, &bus_profiling_info[src_node][dst_node].start_time,
					  &bus_profiling_info[src_node][dst_node].total_time);

		memcpy(bus_info, &bus_profiling_info[src_node][dst_node], sizeof(struct starpu_profiling_bus_info));
	}

	_starpu_bus_reset_profiling_info(&bus_profiling_info[src_node][dst_node]);

	return 0;
}
Exemplo n.º 7
0
/* Workers may block when there is no work to do at all. We assume that the
 * mutex is hold when that function is called. */
void _starpu_block_worker(int workerid, pthread_cond_t *cond, pthread_mutex_t *mutex)
{
   struct timespec start_time, end_time;

   STARPU_TRACE_WORKER_SLEEP_START
      _starpu_worker_set_status(workerid, STATUS_SLEEPING);

   starpu_clock_gettime(&start_time);
   _starpu_worker_register_sleeping_start_date(workerid, &start_time);

   PTHREAD_COND_WAIT(cond, mutex);

   _starpu_worker_set_status(workerid, STATUS_UNKNOWN);
   STARPU_TRACE_WORKER_SLEEP_END
      starpu_clock_gettime(&end_time);

   int profiling = starpu_profiling_status_get();
   if (profiling)
   {
      struct timespec sleeping_time;
      starpu_timespec_sub(&end_time, &start_time, &sleeping_time);
      _starpu_worker_update_profiling_info_sleeping(workerid, &start_time, &end_time);
   }
}