コード例 #1
0
static unsigned int Get_GlobalOP_RecvSize (event_t *current, int is_root)
{
	unsigned int res = 0;
	switch (Get_EvEvent(current))
	{
		case MPI_BARRIER_EV:
		case MPI_IBARRIER_EV:
			res = 0;
		break;
		case MPI_REDUCE_EV:
		case MPI_IREDUCE_EV:
			res = (!is_root)?0:Get_EvSize(current);
		break;
		case MPI_BCAST_EV:
		case MPI_IBCAST_EV:
			res = (is_root)?0:Get_EvSize(current);
		break;
		case MPI_REDUCESCAT_EV:
		case MPI_IREDUCESCAT_EV:
			res = (is_root)?Get_EvSize(current):Get_EvAux(current);
		break;
		case MPI_SCAN_EV:
		case MPI_ISCAN_EV:
		case MPI_ALLREDUCE_EV:
		case MPI_IALLREDUCE_EV:
			res = Get_EvSize(current);
		break;
		default:
			res = Get_EvAux(current);
		break;
	}
	return res;
}
コード例 #2
0
static unsigned int Get_GlobalOP_isRoot (event_t *current, int task)
{
	unsigned int res = FALSE;
	switch (Get_EvEvent(current))
	{
		case MPI_REDUCE_EV:
		case MPI_IREDUCE_EV:
			res = Get_EvAux(current) == Get_EvTag(current);
		break;
		case MPI_BCAST_EV:
		case MPI_IBCAST_EV:
			res = Get_EvTarget(current) == Get_EvTag(current);
		break;
		case MPI_GATHER_EV:
		case MPI_IGATHER_EV:
		case MPI_GATHERV_EV:
		case MPI_IGATHERV_EV:
		case MPI_SCATTER_EV:
		case MPI_ISCATTER_EV:
		case MPI_SCATTERV_EV:
		case MPI_ISCATTERV_EV:
			res = Get_EvTarget(current) == task-1;
		break;
		case MPI_REDUCESCAT_EV:
		case MPI_IREDUCESCAT_EV:
			res = Get_EvTarget(current) == 0;
		break;
	}
	return res;
}
コード例 #3
0
static int Get_GlobalOP_RootRank (event_t *current)
{
	int res;

	switch (Get_EvEvent(current))
	{
		case MPI_REDUCE_EV:
		case MPI_REDUCESCAT_EV:
		case MPI_SCAN_EV:
			res = Get_EvAux(current);
		break;

		case MPI_BARRIER_EV:
		case MPI_BCAST_EV:
		case MPI_ALLGATHER_EV:
		case MPI_ALLGATHERV_EV:
		case MPI_GATHER_EV:
		case MPI_GATHERV_EV:
		case MPI_SCATTER_EV:
		case MPI_SCATTERV_EV:
			res = Get_EvTarget(current);
		break;

		case MPI_ALLREDUCE_EV:
		case MPI_ALLTOALL_EV:
		case MPI_ALLTOALLV_EV:
		default:
			res = 0;
		break;
	}
	return res;
}
コード例 #4
0
static UINT64 Get_GlobalOP_RecvSize (event_t *current)
{
	UINT64 res;

	switch (Get_EvEvent(current))
	{
		case MPI_REDUCE_EV:
			if (Get_EvTag(current) == Get_EvAux(current))
				res = Get_EvSize(current);
			else
				res = 0;
		break;

		case MPI_BCAST_EV:
			if (Get_EvTag(current) != Get_EvTarget(current))
				res = Get_EvSize(current);
			else
				res = 0;
		break;

		case MPI_REDUCESCAT_EV:
		case MPI_SCAN_EV:
		case MPI_ALLREDUCE_EV:
			res = Get_EvSize(current);
		break;

		case MPI_ALLGATHER_EV:
		case MPI_ALLGATHERV_EV:
		case MPI_GATHER_EV:
		case MPI_GATHERV_EV:
		case MPI_SCATTER_EV:
		case MPI_SCATTERV_EV:
			res = Get_EvAux(current);
		break;

		case MPI_ALLTOALL_EV:
		case MPI_ALLTOALLV_EV:
			res = Get_EvTarget(current);
		break;

		case MPI_BARRIER_EV:
		default:
			res = 0;
		break;
	}
	return res;
}
コード例 #5
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;
}
コード例 #6
0
static int IRecv_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)
{
	event_t *send_begin, *send_end;
	off_t send_position;
	unsigned EvType, EvValue, send_thread, send_vthread;
	thread_t *thread_info;
	task_t *task_info, *task_info_partner;
	int EvComm;

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

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

	Switch_State (STATE_IWAITMESS, (EvValue == EVT_BEGIN), ptask, task, thread);

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

					if (isTaskInMyGroup (fset, target_ptask-1, Get_EvTarget(receive)))
					{
#if defined(DEBUG)
						fprintf (stderr, "IRECV_CMD: TIME/TIMESTAMP %lld/%lld IAM %d PARTNER %d tag %d\n", current_time, Get_EvTime(current_event), task-1, Get_EvTarget(receive), Get_EvTag(receive));
#endif
						task_info_partner = GET_TASK_INFO(target_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, "IRECV_CMD DID NOT find COMM\n");
#endif
							CommunicationQueues_QueueRecv (task_info->recv_queue, current_event, receive, thread, thread_info->virtual_thread, Get_EvTarget(receive), Get_EvTag(receive), 0);
						}
						else if (NULL != send_begin && NULL != send_end)
						{
#if defined(DEBUG)
							fprintf (stderr, "IRECV_CMD find COMM (partner times = %lld/%lld)\n", Get_EvTime(send_begin), Get_EvTime(send_end));
#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
				}
			}
		}
	}

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

	return 0;
}
コード例 #7
0
ファイル: communicators.c プロジェクト: mogeb/extrae-paraver
/******************************************************************************
 ***  GenerateAliesComunicator
 ******************************************************************************/
int GenerateAliesComunicator (
   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 long long *num_events, int traceformat)
{
	unsigned int i = 0;
	unsigned int EvValue = Get_EvValue (current_event);
	unsigned int EvCommType = Get_EvTarget (current_event);
	unsigned int EvType = Get_EvEvent (current_event);

	if (EvValue == EVT_BEGIN)
	{
#if defined(DEBUG_COMMUNICATORS)
		fprintf (stderr, "DEBUG: new communicator definition (commtype = %d)\n",
			EvCommType);
#endif

		if (PRV_SEMANTICS == traceformat)
			if (Get_EvAux (current_event)) /* Shall we emit this into tracefile? */ 
			{
				trace_paraver_state (cpu, ptask, task, thread, current_time);
				trace_paraver_event (cpu, ptask, task, thread, current_time, EvType, EVT_BEGIN);
			}

		/* Build COMM WORLD communicator */
		if (MPI_COMM_WORLD_ALIAS == EvCommType)
		{
			TipusComunicador new_comm;
			unsigned int i;

#if defined(DEBUG_COMMUNICATORS)
			fprintf (stderr, "DEBUG: defining MPI_COMM_WORLD (%d members)\n", Get_EvSize (current_event));
#endif

			new_comm.id = Get_EvComm (current_event);
			new_comm.num_tasks = Get_EvSize (current_event);
			new_comm.tasks = (int*) malloc(sizeof(int)*new_comm.num_tasks);
			if (NULL == new_comm.tasks)
			{
				fprintf (stderr, "mpi2prv: Can't allocate memory for a COMM WORLD alias\n");
				fflush (stderr);
				exit (-1);
			}
			for (i = 0; i < new_comm.num_tasks; i++)
				new_comm.tasks[i] = i;
#if defined(PARALLEL_MERGE)
			ParallelMerge_AddIntraCommunicator (ptask, task, MPI_COMM_WORLD_ALIAS, new_comm.id, new_comm.num_tasks, new_comm.tasks);
#else
			afegir_comunicador (&new_comm, ptask, task);
#endif
			free (new_comm.tasks);
		}
		/* Build COMM SELF communicator */
		else if (MPI_COMM_SELF_ALIAS == EvCommType)
		{
			TipusComunicador new_comm;

#if defined(DEBUG_COMMUNICATORS)
			fprintf (stderr, "DEBUG: defining MPI_COMM_SELF (%d members)\n", Get_EvSize (current_event));
#endif

			new_comm.id = Get_EvComm (current_event);
			new_comm.num_tasks = 1;
			new_comm.tasks = (int*) malloc(sizeof(int)*new_comm.num_tasks);
			if (NULL == new_comm.tasks)
			{
				fprintf (stderr, "mpi2prv: Can't allocate memory for a COMM SELF alias\n");
				fflush (stderr);
				exit (-1);
			}
			new_comm.tasks[0] = task-1;
#if defined(PARALLEL_MERGE)
			ParallelMerge_AddIntraCommunicator (ptask, task, MPI_COMM_SELF_ALIAS, new_comm.id, new_comm.num_tasks, new_comm.tasks);
#else
			afegir_comunicador (&new_comm, ptask, task);
#endif
			free (new_comm.tasks);
		}
		else if (MPI_NEW_INTERCOMM_ALIAS == EvCommType)
		{
#if defined(DEBUG_COMMUNICATORS)
			fprintf (stderr, "DEBUG: defining new INTERCOMM\n");
#endif
			i = BuildInterCommunicatorFromFile (current_event, current_time, cpu, ptask, task, thread, fset);
		}
		else
		{
#if defined(DEBUG_COMMUNICATORS)
			fprintf (stderr, "DEBUG: defining new COMM (%d members id = %d)\n", Get_EvSize(current_event), Get_EvComm (current_event));
#endif

			i = BuildCommunicatorFromFile (current_event, current_time, cpu, ptask, task,
				thread, fset);
		}
	}
	else if (EvValue == EVT_END)
	{
		if (PRV_SEMANTICS == traceformat)
			if (Get_EvAux (current_event)) /* Shall we emit this into tracefile? */
				trace_paraver_event (cpu, ptask, task, thread, current_time, EvType, EVT_END);
	}

	*num_events = i+1;
	/* Count how many records have we processed
		(i communicator members + begin of communicator event) */
	return 0;
}