int trace_paraver_pending_communication (unsigned int cpu_s, 
	unsigned int ptask_s, unsigned int task_s, unsigned int thread_s, unsigned vthread_s,
	unsigned long long log_s, unsigned long long phy_s, unsigned int cpu_r, 
	unsigned int ptask_r, unsigned int task_r, unsigned int thread_r, unsigned vthread_r,
	unsigned long long log_r, unsigned long long phy_r, unsigned int size,
	unsigned int tag)
{
	thread_t * thread_info_s = GET_THREAD_INFO (ptask_s, task_s, thread_s);
	off_t where;
	paraver_rec_t record;
	WriteFileBuffer_t *wfb = thread_info_s->file->wfb;

	UNREFERENCED_PARAMETER(thread_r);
	UNREFERENCED_PARAMETER(log_r);
	UNREFERENCED_PARAMETER(phy_r);

	if (!(EnabledTasks[ptask_s-1][task_s-1] || EnabledTasks[ptask_r-1][task_r-1]))
		return 0;

	record.type = PENDING_COMMUNICATION;
	record.cpu = cpu_s;
	record.ptask = ptask_s;
	record.task = task_s;
	record.thread = vthread_s;
	record.time = log_s;
	record.end_time = phy_s;
	record.event = size;
	record.value = tag;
	record.cpu_r = cpu_r;
	record.ptask_r = ptask_r;
	record.task_r = task_r;
	record.thread_r = vthread_r; /* may need fixing? thread_r instead? */

	/* record.receive[LOGICAL_COMMUNICATION] stores the matching zone (see FixPendingCommunication) */
	record.receive[LOGICAL_COMMUNICATION] = MatchComms_GetZone(ptask_s, task_s);
	record.receive[PHYSICAL_COMMUNICATION] = MatchComms_GetZone(ptask_s, task_s);

	where = WriteFileBuffer_getPosition (wfb);
	AddPendingCommunication (WriteFileBuffer_getFD(wfb), where, tag, task_r-1, task_s-1, MatchComms_GetZone(ptask_s, task_s));
	trace_paraver_record (wfb, &record);

	return 0;
}
예제 #2
0
int MPI_PersistentRequest_Event (event_t * current_event,
	unsigned long long current_time, unsigned int cpu, unsigned int ptask,
	unsigned int task, unsigned int thread, FileSet_t *fset)
{
	thread_t *thread_info;
	task_t *task_info, *task_info_partner;
	event_t *recv_begin, *recv_end;
	event_t *send_begin, *send_end;
	off_t send_position;
	unsigned recv_thread, send_thread, recv_vthread, send_vthread;
	int EvComm; 

	EvComm = Get_EvComm( current_event );

	thread_info = GET_THREAD_INFO(ptask, task, thread);
	task_info = GET_TASK_INFO(ptask, task);
	trace_paraver_state (cpu, ptask, task, thread, current_time);

	/* If this is a send, look for the receive */
	if (Get_EvValue (current_event) == MPI_ISEND_EV)
	{
		thread_info->Send_Rec = current_event;

		if (MatchComms_Enabled(ptask, task))
		{
			if (MPI_PROC_NULL != Get_EvTarget (current_event))
			{
				int target_ptask = intercommunicators_get_target_ptask( ptask, task, EvComm );

				if (isTaskInMyGroup (fset, target_ptask-1, Get_EvTarget(current_event)))
				{
#if defined(DEBUG)
					fprintf (stderr, "PERS_REQ_ISEND_CMD(%u): TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d\n", Get_EvValue (current_event), current_time, Get_EvTime(current_event), task-1, Get_EvTarget(current_event), Get_EvTag(current_event));
#endif

					task_info_partner = GET_TASK_INFO(target_ptask, Get_EvTarget(current_event)+1);

					CommunicationQueues_ExtractRecv (task_info_partner->recv_queue, task-1, Get_EvTag (current_event), &recv_begin, &recv_end, &recv_thread, &recv_vthread, 0);

					if (recv_begin == NULL || recv_end == NULL)
					{
						off_t position;
#if defined(DEBUG)
						fprintf (stderr, "PER_REQ_ISEND_CMD DID NOT find a partner\n");
#endif
						position = WriteFileBuffer_getPosition (thread_info->file->wfb);
						CommunicationQueues_QueueSend (task_info->send_queue, current_event, current_event, position, thread, thread_info->virtual_thread, Get_EvTarget(current_event), Get_EvTag(current_event), 0);
						trace_paraver_unmatched_communication (1, ptask, task, thread, thread_info->virtual_thread, current_time, Get_EvTime(current_event), 1, target_ptask, Get_EvTarget(current_event)+1, 1, Get_EvSize(current_event), Get_EvTag(current_event));
					}
					else
					{
#if defined(DEBUG)
						fprintf (stderr, "PER_REQ_ISEND_CMD DID NOT find a partner\n");
#endif
						trace_communicationAt (ptask, task, thread, thread_info->virtual_thread, target_ptask, 1+Get_EvTarget(current_event), recv_thread, recv_vthread, current_event, current_event, recv_begin, recv_end, FALSE, 0);
					}

				}
#if defined(PARALLEL_MERGE)
				else
				{
#if defined(DEBUG)
					fprintf (stdout, "SEND_CMD(%u): TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d >> PENDING\n", Get_EvEvent(current_event), current_time, Get_EvTime(current_event), task-1, Get_EvTarget(current_event), Get_EvTag(current_event));
#endif
					trace_pending_communication (ptask, task, thread, thread_info->virtual_thread, thread_info->Send_Rec, current_event, target_ptask, Get_EvTarget (current_event));
				}
#endif
			}
		}
	}

	/* If this is a receive, look for the send */
	if (Get_EvValue(current_event) == MPI_IRECV_EV)
	{
		thread_info->Recv_Rec = current_event;

		if (MatchComms_Enabled(ptask, task))
		{
			event_t *receive = Search_MPI_IRECVED (current_event, Get_EvAux (current_event), thread_info->file);
			if (NULL != receive)
			{
				int target_ptask = intercommunicators_get_target_ptask( ptask, task, EvComm );

				if (MPI_PROC_NULL != Get_EvTarget(receive))
				{
					if (isTaskInMyGroup (fset, target_ptask-1, Get_EvTarget(receive)))
					{
#if defined(DEBUG)
						fprintf (stderr, "PERS_REQ_IRECV_CMD(%u): TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d\n", Get_EvValue (current_event), current_time, Get_EvTime(current_event), task-1, Get_EvTarget(receive), Get_EvTag(receive));
#endif

						task_info_partner = GET_TASK_INFO(ptask, Get_EvTarget(receive)+1);

						CommunicationQueues_ExtractSend (task_info_partner->send_queue, task-1, Get_EvTag (receive), &send_begin, &send_end, &send_position, &send_thread, &send_vthread, 0);

						if (NULL == send_begin || NULL == send_end)
						{
#if defined(DEBUG)
							fprintf (stderr, "PER_REQ_IRECV_CMD DID NOT find a partner\n");
#endif
							CommunicationQueues_QueueRecv (task_info->recv_queue, current_event, receive, thread, thread_info->virtual_thread, Get_EvTarget(current_event), Get_EvTag(current_event), 0);
						}
						else if (NULL != send_begin && NULL != send_end)
						{
#if defined(DEBUG)
							fprintf (stderr, "PERS_REQ_IRECV_CMD find partner (send position = %llu)\n", (unsigned long long) send_position);
#endif
							trace_communicationAt (target_ptask, 1+Get_EvTarget(receive), send_thread, send_vthread, ptask, task, thread, thread_info->virtual_thread, send_begin, send_end, current_event, receive, TRUE, send_position);
						}
						else
							fprintf (stderr, "mpi2prv: Attention CommunicationQueues_ExtractSend returned send_begin = %p and send_end = %p\n", send_begin, send_end);
					}
#if defined(PARALLEL_MERGE)
					else
					{
						UINT64 log_r, phy_r;

						log_r = TIMESYNC (ptask-1, task-1, Get_EvTime(current_event));
						phy_r = TIMESYNC (ptask-1, task-1, Get_EvTime(receive));
						AddForeignRecv (phy_r, log_r, Get_EvTag(receive), ptask-1, task-1, thread-1,
							thread_info->virtual_thread-1, target_ptask-1, Get_EvTarget(receive), fset, MatchComms_GetZone(ptask, task));
					}
#endif
				}
			}
		}
	}

	return 0;
}
예제 #3
0
static int SendRecv_Event (event_t * current_event, 
	unsigned long long current_time, unsigned int cpu, unsigned int ptask, 
	unsigned int task, unsigned int thread, FileSet_t *fset)
{
	thread_t *thread_info;
	task_t *task_info, *task_info_partner;
#if !defined(AVOID_SENDRECV)
	unsigned recv_thread, send_thread, recv_vthread, send_vthread;
	event_t *recv_begin, *recv_end, *send_begin, *send_end;
	off_t send_position;
#endif
	int EvComm = Get_EvComm (current_event);

	Switch_State (STATE_SENDRECVOP, (Get_EvValue(current_event) == EVT_BEGIN), ptask, task, thread);

	trace_paraver_state (cpu, ptask, task, thread, current_time);
	trace_paraver_event (cpu, ptask, task, thread, current_time, Get_EvEvent(current_event), Get_EvValue(current_event));

	thread_info = GET_THREAD_INFO(ptask, task, thread);
	task_info = GET_TASK_INFO(ptask, task);

	if (!get_option_merge_SkipSendRecvComms())
	{
		if (Get_EvValue (current_event) == EVT_BEGIN)
		{
			thread_info->Send_Rec = current_event;

			/* Treat the send part */
			if (MatchComms_Enabled(ptask, task))
				if (MPI_PROC_NULL != Get_EvTarget (thread_info->Send_Rec))
				{
					int target_ptask = intercommunicators_get_target_ptask( ptask, task, EvComm );

					if (isTaskInMyGroup (fset, target_ptask-1, Get_EvTarget(thread_info->Send_Rec)))
					{
#if defined(DEBUG)
						fprintf (stderr, "SENDRECV/SEND: TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d\n", current_time, Get_EvTime(thread_info->Send_Rec), task-1, Get_EvTarget(thread_info->Send_Rec), Get_EvTag(thread_info->Send_Rec));
#endif
						task_info_partner = GET_TASK_INFO(target_ptask, Get_EvTarget(thread_info->Send_Rec)+1);

						CommunicationQueues_ExtractRecv (task_info_partner->recv_queue, task-1, Get_EvTag (thread_info->Send_Rec), &recv_begin, &recv_end, &recv_thread, &recv_vthread, 0);

						if (recv_begin == NULL || recv_end == NULL)
						{
							off_t position;

#if defined(DEBUG)
							fprintf (stderr, "SENDRECV/SEND DID NOT find partner\n");
#endif
							position = WriteFileBuffer_getPosition (thread_info->file->wfb);
							CommunicationQueues_QueueSend (task_info->send_queue, thread_info->Send_Rec, current_event, position, thread, thread_info->virtual_thread, Get_EvTarget(thread_info->Send_Rec), Get_EvTag(thread_info->Send_Rec), 0);
							trace_paraver_unmatched_communication (1, ptask, task, thread, thread_info->virtual_thread, current_time, Get_EvTime(current_event), 1, target_ptask, Get_EvTarget(current_event)+1, 1, Get_EvSize(current_event), Get_EvTag(current_event));
						}
						else if (recv_begin != NULL && recv_end != NULL)
						{
#if defined(DEBUG)
							fprintf (stderr, "SENDRECV/SEND found partner\n");
#endif
							trace_communicationAt (ptask, task, thread, thread_info->virtual_thread, target_ptask, 1+Get_EvTarget(thread_info->Send_Rec), recv_thread, recv_vthread, thread_info->Send_Rec, current_event, recv_begin, recv_end, FALSE, 0);
						}
						else
							fprintf (stderr, "mpi2prv: Attention CommunicationQueues_ExtractRecv returned recv_begin = %p and recv_end = %p\n", recv_begin, recv_end);
					}
#if defined(PARALLEL_MERGE)
					else
					{
#if defined(DEBUG)
						fprintf (stdout, "SEND_CMD(%u): TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d >> PENDING\n", Get_EvEvent(current_event), current_time, Get_EvTime(current_event), task-1, Get_EvTarget(current_event), Get_EvTag(current_event));
#endif
						trace_pending_communication (ptask, task, thread, thread_info->virtual_thread, thread_info->Send_Rec, current_event, target_ptask, Get_EvTarget (thread_info->Send_Rec));
					}
#endif /* PARALLEL_MERGE */
					}

		}
		else if (Get_EvValue (current_event) == EVT_END)
		{
			thread_info->Recv_Rec = current_event;

			/* Treat the receive part */
			if (MatchComms_Enabled(ptask, task))
				if (MPI_PROC_NULL != Get_EvTarget (thread_info->Recv_Rec))
				{
					int target_ptask = intercommunicators_get_target_ptask( ptask, task, EvComm );

					if (isTaskInMyGroup (fset, target_ptask-1, Get_EvTarget(thread_info->Recv_Rec)))
					{
#if defined(DEBUG)
						fprintf (stderr, "SENDRECV/RECV: TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d\n", current_time, Get_EvTime(thread_info->Recv_Rec), task-1, Get_EvTarget(thread_info->Recv_Rec), Get_EvTag(thread_info->Recv_Rec));
#endif

						task_info_partner = GET_TASK_INFO(target_ptask, Get_EvTarget(thread_info->Recv_Rec)+1);

						CommunicationQueues_ExtractSend (task_info_partner->send_queue, task-1, Get_EvTag (thread_info->Recv_Rec), &send_begin, &send_end, &send_position, &send_thread, &send_vthread, 0);

						if (NULL == send_begin && NULL == send_end)
						{
#if defined(DEBUG)
							fprintf (stderr, "SENDRECV/RECV DID NOT find partner\n");
#endif
							CommunicationQueues_QueueRecv (task_info->recv_queue, thread_info->Send_Rec, current_event, thread, thread_info->virtual_thread, Get_EvTarget(thread_info->Recv_Rec), Get_EvTag(thread_info->Recv_Rec), 0);
						}
						else if (NULL != send_begin && NULL != send_end)
						{
#if defined(DEBUG)
							fprintf (stderr, "SENDRECV/RECV found partner\n");
#endif
							trace_communicationAt (target_ptask, 1+Get_EvTarget(thread_info->Recv_Rec), send_thread, send_vthread, ptask, task, thread, thread_info->virtual_thread, send_begin, send_end, thread_info->Send_Rec, thread_info->Recv_Rec, TRUE, send_position);
						}
						else
							fprintf (stderr, "mpi2prv: Attention CommunicationQueues_ExtractSend returned send_begin = %p and send_end = %p\n", send_begin, send_end);
					}
#if defined(PARALLEL_MERGE)
					else
					{
						UINT64 log_r, phy_r;

						log_r = TIMESYNC (ptask-1, task-1, Get_EvTime(thread_info->Send_Rec));
						phy_r = TIMESYNC (ptask-1, task-1, Get_EvTime(current_event));
						AddForeignRecv (phy_r, log_r, Get_EvTag(current_event), ptask-1, task-1, thread-1,
							thread_info->virtual_thread-1, target_ptask-1, Get_EvTarget(current_event), fset, MatchComms_GetZone(ptask, task));
					}
#endif /* PARALLEL_MERGE */
				}
		}
	}

	return 0;
}
예제 #4
0
static int Any_Send_Event (event_t * current_event,
	unsigned long long current_time, unsigned int cpu, unsigned int ptask,
	unsigned int task, unsigned int thread, FileSet_t *fset)
{
	unsigned recv_thread, recv_vthread, EvType, EvValue;
	thread_t *thread_info;
	task_t *task_info, *task_info_partner;
	event_t * recv_begin, * recv_end;
	int EvComm;

	EvType  = Get_EvEvent(current_event);
	EvValue = Get_EvValue(current_event);
	EvComm  = Get_EvComm (current_event);

	Switch_State (Get_State(EvType), (EvValue == EVT_BEGIN), ptask, task, thread);

	trace_paraver_state (cpu, ptask, task, thread, current_time);
	trace_paraver_event (cpu, ptask, task, thread, current_time, EvType, EvValue);

	thread_info = GET_THREAD_INFO(ptask, task, thread);
	task_info = GET_TASK_INFO(ptask, task);

	switch (EvValue)
	{
		case EVT_BEGIN:
			thread_info->Send_Rec = current_event;
		break;
		case EVT_END:
			if (MatchComms_Enabled(ptask, task))
			{
				if (MPI_PROC_NULL != Get_EvTarget (current_event))
				{
					int target_ptask = intercommunicators_get_target_ptask( ptask, task, EvComm );

					if (isTaskInMyGroup (fset, target_ptask-1, Get_EvTarget(current_event)))
					{
#if defined(DEBUG)
						fprintf (stderr, "SEND_CMD(%u): TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d\n", EvType, current_time, Get_EvTime(current_event), task-1, Get_EvTarget(current_event), Get_EvTag(current_event));
#endif
						task_info_partner = GET_TASK_INFO(target_ptask, Get_EvTarget(current_event)+1);
						CommunicationQueues_ExtractRecv (task_info_partner->recv_queue, task-1, Get_EvTag (current_event), &recv_begin, &recv_end, &recv_thread, &recv_vthread, 0);

						if (recv_begin == NULL || recv_end == NULL)
						{
							off_t position;

#if defined(DEBUG)
							fprintf (stderr, "SEND_CMD(%u) DID NOT find receiver\n", EvType);
#endif
							position = WriteFileBuffer_getPosition (thread_info->file->wfb);
							CommunicationQueues_QueueSend (task_info->send_queue, thread_info->Send_Rec, current_event, position, thread, thread_info->virtual_thread, Get_EvTarget(current_event), Get_EvTag(current_event), 0);
							trace_paraver_unmatched_communication (1, ptask, task, thread, thread_info->virtual_thread, current_time, Get_EvTime(current_event), 1, target_ptask, Get_EvTarget(current_event)+1, 1, Get_EvSize(current_event), Get_EvTag(current_event));
						}
						else
						{
#if defined(DEBUG)
							fprintf (stderr, "SEND_CMD(%u) find receiver\n", EvType);
#endif
							trace_communicationAt (ptask, task, thread, thread_info->virtual_thread, target_ptask, 1+Get_EvTarget(current_event), recv_thread, recv_vthread, thread_info->Send_Rec, current_event, recv_begin, recv_end, FALSE, 0);
						}
					}
#if defined(PARALLEL_MERGE)
					else
					{
#if defined(DEBUG)
						fprintf (stdout, "SEND_CMD(%u): TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d >> PENDING\n", Get_EvEvent(current_event), current_time, Get_EvTime(current_event), task-1, Get_EvTarget(current_event), Get_EvTag(current_event));
#endif
						trace_pending_communication (ptask, task, thread, thread_info->virtual_thread, thread_info->Send_Rec, current_event, target_ptask, Get_EvTarget (current_event));
					}
#endif
				}
			}
		break;
	}
	return 0;
}
/******************************************************************************
 ***  trace_paraver_state
 ******************************************************************************/
void trace_paraver_state (
   unsigned int cpu, unsigned int ptask, unsigned int task, unsigned int thread,
   unsigned long long current_time)
{
	thread_t * thread_info = GET_THREAD_INFO (ptask, task, thread);
	WriteFileBuffer_t *wfb = thread_info->file->wfb;
	unsigned current_state = Top_State(ptask, task, thread);

#if 0
	fprintf (stderr, "trace_paraver_state (..)\n");
	fprintf (stderr, "thread_info->incomplete_state_offset = %u\n", thread_info->incomplete_state_offset);
#endif

	/* Complete the previous state */
	if (thread_info->incomplete_state_offset != (off_t)-1) /* This isn't the first state */
	{
#if 0
		fprintf (stderr, "get_option_merge_JointStates() = %d Get_Last_State() = %d\n", get_option_merge_JointStates(), Get_Last_State());
		fprintf (stderr, "thread_info->incomplete_state_record.value = %d == current_state = %d\n", thread_info->incomplete_state_record.value, current_state);
#endif

		/* Do not split states whether appropriate */
		if (get_option_merge_JointStates() && !Get_Last_State())
			if (thread_info->incomplete_state_record.value == current_state)
				return;

		/* Write the record into the *.tmp file if the state isn't excluded */
#if defined(DEBUG_STATES)
		fprintf(stderr, "mpi2prv: DEBUG [T:%d] Closing state %u at %llu\n", task,  
		(unsigned int)thread_info->incomplete_state_record.value, current_time);
		fprintf (stderr, "Excluded? %d\n", State_Excluded(thread_info->incomplete_state_record.value));
#endif

		if (!State_Excluded(thread_info->incomplete_state_record.value))
		{
			thread_info->incomplete_state_record.end_time = current_time;
			WriteFileBuffer_writeAt (wfb, &(thread_info->incomplete_state_record), thread_info->incomplete_state_offset);
		}
	}

	/* Start the next state */
	thread_info->incomplete_state_record.type   = STATE;
	thread_info->incomplete_state_record.cpu    = cpu;
	thread_info->incomplete_state_record.ptask  = ptask;
	thread_info->incomplete_state_record.task   = task;
	thread_info->incomplete_state_record.thread = thread_info->virtual_thread;
	thread_info->incomplete_state_record.time   = current_time;
	thread_info->incomplete_state_record.value  = current_state;
	/* Save a slot in the *.tmp file for this record if this state isn't excluded */
#if defined(DEBUG_STATES)
	fprintf(stderr, "mpi2prv: DEBUG [T:%d] Starting state %u (excluded? %d) at %llu\n", task, current_state, State_Excluded(current_state), current_time);
#endif
	if (!State_Excluded(current_state))
	{
		paraver_rec_t fake_record;
		fake_record.type   = UNFINISHED_STATE;
		fake_record.ptask  = ptask;
		fake_record.task   = task;
		fake_record.thread = thread;
		fake_record.time   = current_time;
		thread_info->incomplete_state_offset = WriteFileBuffer_getPosition (wfb);
		trace_paraver_record (wfb, &fake_record);
	}
}