// Description: returns the number of items of the given type
entier Domain::nb_items(const LataField_base::Elem_som loc) const
{
  entier n = -1;
  switch (loc) {
  case LataField_base::SOM: n = nb_nodes(); break;
  case LataField_base::ELEM: n = nb_elements(); break;
  case LataField_base::FACES: n = nb_faces(); break;
  default:
    Journal() << "Invalid localisation " << (int) loc << " in Domain::nb_items" << endl;
    throw;
  }
  return n;
}
Ejemplo n.º 2
0
int  main(int argc, char**argv){;
  tm_topology_t *topology;
  int nb_cores;
  double **arch;
  if(argc<2){
    fprintf(stderr,"Usage: %s <Architecture tgt>\n",argv[0]);
    return -1;
  }

  topology=tgt_to_tm(argv[1],&arch);
  nb_cores=nb_nodes(topology);

  display_tab(arch,nb_cores);

  FREE_topology(topology);
  FREE(arch);



  return 0;
}
Ejemplo n.º 3
0
void deletemin(tree *root,void *key,int (*cmp)(const void *,const void *)){
     if(key == NULL || root == NULL) {
          PERROR;
          exit(1);
     }
     if(*root == NULL) {
          return ;
     }
     tree * found = search(root,key,cmp); 
     if(found == NULL || *found == NULL ) {
          fprintf(stderr,"ERROR : not found key !! \n");
          return ;
     }
     
     else {
          if(((*found)->count) > 1) {
               ((*found)->count)--;
               return ;
          }
          if(isLeaf(*found)) { // if leaf
               free((*found)->element); // free key
               free((*found)); // free node
               (*found) = NULL;
               return ;
          }
          else {
               if((*found)->left == NULL || (*found)->right == NULL) {
                    if((*found)->left == NULL) {
                         tree del = (*found);
                         (*found) = (*found)->right;
                         free(del->element);
                         free(del);
                    } 
                    if((*found)->right == NULL) {
                         tree del = (*found);
                         (*found) = (*found)->left;
                         free(del->element);
                         free(del);
                    }        
               } else {
                    tree *min = findmin(&((*found)->right)); // find min
                    
                    if(!isLeaf(*min)) {
                         
                         tree *max = findmax(&((*found)->left));
                         if(!isLeaf(*max)){
                              if(nb_nodes((*found)->right) > nb_nodes((*found)->left)) {
                                   SWAP((*found)->element,(*min)->element);
                                   tree del = *min;
                                   (*min) = (*min)->right;
                                   free((del)->element);
                                   free((del));
                                   (del) = NULL;
                              } else {
                                   SWAP((*found)->element,(*max)->element);
                                   tree del = *max;
                                   (*max) = (*max)->left;
                                   free((del)->element);
                                   free((del));
                                   (del) = NULL;
                              }
                         } else {
                              SWAP((*max)->element,(*found)->element);                 
                              free((*max)->element);
                              free((*max));
                              (*max) = NULL;
                         }
                    }
                    else {
                         SWAP((*min)->element,(*found)->element);                 
                         free((*min)->element);
                         free((*min));
                         (*min) = NULL;
                    }
               }
          }  
     }
}
Ejemplo n.º 4
0
/*Map topology to cores: 
 sigma_i is such that  process i is mapped on core sigma_i
 k_i is such that core i exectutes process k_i

 size of sigma is the number of process
 size of k is the number of cores/nodes

 We must have numbe of process<=number of cores

 k_i =-1 if no process is mapped on core i
*/
void map_topology(tm_topology_t *topology,tree_t *comm_tree,int nb_proc,int level,
		  int *sigma, int *k){
  int *nodes_id;
  int N;
  int *proc_list,i,l;
  int M;
  int block_size;

 
  M=nb_leaves(comm_tree);
  printf("nb_leaves=%d\n",M);



  nodes_id=topology->node_id[level];
  N=topology->nb_nodes[level];
  //printf("level=%d, nodes_id=%p, N=%d\n",level,nodes_id,N);


  //printf("N=%d,nb_proc=%d\n",N,nb_proc);
  /* The number of node at level "level" in the tree should be equal to the number of processors*/
  assert(N==nb_proc);


  proc_list=(int*)malloc(sizeof(int)*M);
  i=0;
  depth_first(comm_tree,proc_list,&i);

  l=0;
  for(i=0;i<M;i++){
    //printf ("%d\n",proc_list[i]);
  }


  block_size=M/N;


  if(k){/*if we need the k vector*/
    printf("M=%d, N=%d, BS=%d\n",M,N,block_size);
    for(i=0;i<nb_nodes(topology);i++){
      k[i]=-1;
    }
    for(i=0;i<M;i++){
      if(proc_list[i]!=-1){
#ifdef DEBUG
	printf ("%d->%d\n",proc_list[i],nodes_id[i/block_size]);
#endif
	sigma[proc_list[i]]=nodes_id[i/block_size];
	k[nodes_id[i/block_size]]=proc_list[i];
      }
    }
  }else{
    printf("M=%d, N=%d, BS=%d\n",M,N,block_size);
    for(i=0;i<M;i++){
      if(proc_list[i]!=-1){
#ifdef DEBUG
	printf ("%d->%d\n",proc_list[i],nodes_id[i/block_size]);
#endif
	sigma[proc_list[i]]=nodes_id[i/block_size];
      }
    }

  }
  free(proc_list);

}