[Myrinet] (No Subject)

"TOUCHE Julien" <[email protected]>
Newsgroups gmane.network.myrinet.general
Organization Lycos Mail (http://www.mail.lycos.com:80)
Message-ID <[email protected]>
with your help, i solve the problem with gm_dma_alloc(), but there is 
always a problem of "incompatibles types assignement" with 
gm_register_memory()
when i use __GM_DMA__ (see end), it compiles but i have the following 
error:
"gm_open: send dropped as requested by the client"

i have also a mpi test which doesn't execute correctly, i don't know 
why ? i send a message to another nodes, and it returns but not 
modified ...

i put part of my code at the end.

---

Thanks
bye

           Julien Touche

compile with : mpicc -Wall -O -g -D__DEBUG__-static 
        + -D__GM__  or -D__GM_REGISTER__ or -D__GM_DMA__
 
int test_mpi(int argc,int param[2])
{
  MPI_Status stat;
  int myid,numnodes,next;
  i64 tps_deb, tps_fin, tps_exec;
  int i, j, nb_envoi, size_mem;
  char** argv = NULL;
  char* message;
  int namelen;
  char processor_name[MPI_MAX_PROCESSOR_NAME];

PINFO()

  size_mem = param[0];
  nb_envoi = param[1];

PINFO()
  if (size_mem>0)
  {
  	message = (char *) calloc(size_mem,sizeof(char));
		message = "123";
  }
  else
  	message = NULL; size_mem = 0;
PINFO()

  MPI_Init( &argc, &argv );
  MPI_Comm_rank( MPI_COMM_WORLD, &myid);
  MPI_Comm_size( MPI_COMM_WORLD, &numnodes);
  MPI_Get_processor_name(processor_name,&namelen);

    fprintf(stderr,"Process %d on %s\n",
	    myid, processor_name);

PINFO()
  next = myid + 1;
  if (next == numnodes) next = 0;
  PINFO()

  // serveur
  if (myid == 0) 
    {

      for (i=0;i<ECHANTILLON;i++)
        {
  PINFO()

	  tps_deb = GetTick();
	  
	  	for (j=0; j<nb_envoi; j++)
		  {
  PINFO()
		  MPI_Send(message, size_mem , MPI_INT, next, TAG, MPI_COMM_WORLD );
		  printf("Message envoyé (id %d): %s\n",myid,message);
		  MPI_Recv(message, size_mem, MPI_INT, MPI_ANY_SOURCE, TAG, MPI_COMM_WORLD,&stat);
		  printf("Message recu (id %d): %s\n",myid,message);
		  }

	  tps_fin = GetTick();
//	  printf("nb_envoi %d\n", nb_envoi);


	  tps_exec = tps_fin - tps_deb;
	  tab_result_tps[i] = tps_exec;

       } 
    
  PINFO()

      ////  Moyennage, tri et formatage des donnees 
    ptr_extrema = min_max_moy (&tab_result_tps[1], (ECHANTILLON - 1),nb_envoi*2);
  PINFO()
    printf("Latence  min : %.2f  moy : %.2f  max : %.2f ns\n",
       ptr_extrema->min*1000/CPU_CLOCK, ptr_extrema->moy*1000/CPU_CLOCK,
	   ptr_extrema->max*1000/CPU_CLOCK);

  PINFO()
    } 
  else 
    {

	  // client
      for (i=0;i<ECHANTILLON;i++)
        {
  PINFO()
	  	for (j=0; j<nb_envoi; j++)
		  {
		  MPI_Recv(message, size_mem, MPI_INT, MPI_ANY_SOURCE, TAG, MPI_COMM_WORLD,&stat);
		  printf("Message recu (id %d):%s\n",myid,message);
		  message = "456";
		  MPI_Send(message, size_mem, MPI_INT, next, TAG, MPI_COMM_WORLD );
		  printf("Message envoyé (id %d):%s\n",myid,message);
		  }
       }
    }
PINFO()
   free(message);
PINFO()

  MPI_Barrier( MPI_COMM_WORLD );
PINFO()
  MPI_Finalize();
PINFO()
  return 0;

}

#if defined(__GM__) || defined(__GM_REGISTER__) || defined(__GM_DMA__)
void allocate_gm_buffer(void** buffer, struct gm_port* port, int size_mem)
{
#ifdef __GM_REGISTER__
	*buffer = gm_register_memory(port, 
				buffer,
				(unsigned int)(size_mem*sizeof(char))
				);		// DMA transfer register
#elif defined(__GM_DMA__)
	*buffer = gm_dma_malloc(port, size_mem*sizeof(char));
#else // base alloc 
	*buffer = gm_malloc(size_mem*sizeof(char));
#endif
	if (*buffer == 0 && size_mem>0)
	{
		printf("Can't allocate memory\n");
		exit(-1);
	}

}

void unallocate_gm_buffer(void** buffer, struct gm_port* port)
{
#ifdef __GM_REGISTER__
		gm_deregister_memory(port, 
				buffer,
				sizeof(*buffer)
                           //   ^^^^^^^^^^^^^^^^ problem in compilation
				);
#elif defined(__GM_DMA__)
		gm_dma_free(port, buffer);
#else
		gm_free(buffer);
#endif
}
int test_gm(int argc,int param[3])
{
  i64 tps_deb, tps_fin, tps_exec;
  int i, j, nb_envoi, size_mem, ret;

  //// Rappel: seul les ports 2,4,5,6,7 sont disponibles pr utilisation courante 
  static void *out_buffer = 0, *in_buffer = 0, *directed_send_buffer = 0;
#if defined(__GM_REGISTER__) || defined(__GM_DMA__)
  void* remote_address;
#endif
  struct gm_port* port = NULL;
  unsigned int unit = GM_EXAMPLE_BOARD_RECEIVER, 
  		port_id = GM_EXAMPLE_PEER_PORT;
  char* port_name = "gm_myport";
  enum gm_api_version version = GM_API_VERSION;
  enum gm_priority prio = GM_HIGH_PRIORITY;
  unsigned int target_mode_id, target_port_id, local_node_id;

  gm_size_t mask;
  char dest_node_name[128];
  int  dest_node_id;

  int action = param[2];
  size_mem = param[0];
  nb_envoi = param[1];
  strncpy(dest_node_name,"node-104.alinka_raisin",128);;

PINFO()    
  if (size_mem<0)
  	size_mem = 0;
PINFO()

	gm_init();
	ret = gm_open(&port, unit, port_id, port_name, version);
	if (ret != GM_SUCCESS)
	{
		gm_perror("gm_open",errno);
		exit(-1);
	}

	dest_node_id = gm_host_name_to_node_id(port,dest_node_name);
	printf("[send] Destination node name %s, node id %d\n",
		   dest_node_name, dest_node_id);
	gm_get_node_id(port,&local_node_id);
	
	// recommended (but optionnal)
	gm_set_acceptable_sizes( port,GM_HIGH_PRIORITY, mask );
	gm_set_acceptable_sizes( port,GM_LOW_PRIORITY, mask );


	//// init memory
	allocate_gm_buffer(&in_buffer,port,size_mem);
	allocate_gm_buffer(&out_buffer,port,size_mem);
	allocate_gm_buffer(&directed_send_buffer,port,size_mem);

	gm_provide_receive_buffer(port, in_buffer, size_mem, prio);
PINFO()
	// allow DMA transfert
	gm_allow_remote_memory_access(port);
	
	if (action==0)
	{
		// message = sending buffer
		out_buffer = "toto";
		
      for (i=0;i<ECHANTILLON;i++)
        {
	  PINFO()
	  tps_deb = GetTick();

	  	for (j=0; j<nb_envoi; j++)
		  {
			/// send 
#if defined(__GM_REGISTER__) || defined(__GM_DMA__)
			// before sending, we must recover target_buffer
			gm_provide_receive_buffer_with_tag( port, 
					remote_address, 
					size_mem*sizeof(char), 
					prio, 0);
			

			// send in memory
			/// only if gm_allow_remote_memory_access(port);
			gm_directed_send_with_callback( port, out_buffer,
					(gm_remote_ptr_t)(remote_address),	// remote target buffer
					size_mem*sizeof(char),				// number of bytes to send
					prio,
					target_mode_id, target_port_id,
					NULL, NULL							// callback, context
					);			

			// OU
#else
			gm_send( port, out_buffer,
					size_mem*sizeof(char),			// size of remote buffer
					size_mem*sizeof(char),			// number of bytes to send
					prio,
					target_mode_id, target_port_id
					);
			// OU si target_port_id = sending port id
//			gm_send_to_peer_with_callback();
#endif
PINFO()
		  }
 
	  tps_fin = GetTick();
	  tps_exec = tps_fin - tps_deb;
	  tab_result_tps[i] = tps_exec;
       } 
	
		ptr_extrema = min_max_moy (&tab_result_tps[1], (ECHANTILLON - 1),nb_envoi);

		printf("Latence  min : %.2f  moy : %.2f  max : %.2f ns\n",
			ptr_extrema->min*1000/CPU_CLOCK, ptr_extrema->moy*1000/CPU_CLOCK,
			ptr_extrema->max*1000/CPU_CLOCK);

	}
	else
	{
		// message : receiving buffer

#if defined(__GM_REGISTER__) || defined(__GM_DMA__)
		// must send our buffer address
			gm_send( port, &in_buffer,
					sizeof(&in_buffer),			// size of remote buffer
					sizeof(&in_buffer),			// number of bytes to send
					prio,
					target_mode_id, target_port_id
					);
#endif /* defined(__GM_REGISTER__) || defined(__GM_DMA__) */
		// receive 
		// gm_receive(...)
		// OU
		// gm_blocking_receive (...)
		// OU
		gm_provide_receive_buffer_with_tag( port, 
				in_buffer, 
				size_mem*sizeof(char), 
				prio, 0);
		// ou
		// ...
	
	}
	PINFO()
	// Fin
	unallocate_gm_buffer(in_buffer,port);
	unallocate_gm_buffer(out_buffer,port);
	unallocate_gm_buffer(directed_send_buffer,port);

	gm_close(port);
	gm_finalize();

  return 0;

}
#endif /* __GM__ || __GM_REGISTER__ || __GM_DMA__ */




_______________________________________________________
WIN a first class trip to Hawaii.  Live like the King of Rock and Roll
on the big Island. Enter Now!
http://r.lycos.com/r/sagel_mail/http://www.elvis.lycos.com/sweepstakes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.