Beispiel #1
0
void MessageHeader::remove(const char* key)
{
    if( ! *key)
        throw std::invalid_argument("header key is NULL");

    char* p = eptr();

    ConstIterator it = begin();
    while (it != end())
    {
        if (compareIgnoreCase(key, it->name()) == 0)
        {
            std::size_t slen = it->value() - it->name() + std::strlen(it->value()) + 1;

            std::memcpy(
                const_cast<char*>(it->name()),
                it->name() + slen,
                p - it->name() + slen);

            p -= slen;

            it.fixup();
        }
        else
            ++it;
    }

    _endOffset = p - _rawdata;
}
Beispiel #2
0
void MessageHeader::add(const char* key, const char* value)
{ 
    log_debug("MessageHeader::add(\"" << key << "\", \"" << value << "\", " << replace << ')');

    if( ! *key)
        throw std::invalid_argument("header key is NULL");

    char* p = eptr();

    std::size_t lk = std::strlen(key);     // length of key
    std::size_t lv = std::strlen(value);   // length of value

    if (p - _rawdata + lk + lv + 2 > MaxHeaderSize)
        throw HttpError("message header too big");

    std::strcpy(p, key);   // copy key
    p += lk + 1;
    std::strcpy(p, value); // copy value
    p[lv + 1] = '\0';      // put new message end marker in place

    _endOffset = (p + lv + 1) - _rawdata;
}
Beispiel #3
0
int FEM_master_parallel_part(int fem_mesh,int masterRank,FEM_Comm_t comm_context){
  const char *caller="FEM_Create_connmsa"; 
  FEMAPI(caller);
  FEMchunk *c=FEMchunk::get(caller);
  FEM_Mesh *m=c->lookup(fem_mesh,caller);
  m->setAbsoluteGlobalno();
  int nelem = m->nElems();
  int numChunks;
  MPI_Comm_size((MPI_Comm)comm_context,&numChunks);
  printf("master -> number of elements %d \n",nelem);
  DEBUG(m->print(0));


  /*load the connectivity information into the eptr and
    eind datastructure. It will be read by the other slave 
    elements and used to call parmetis*/
  MSA1DINT eptr(nelem,numChunks);
  MSA1DINT eind(nelem*10,numChunks);
  /*
    after the msa array has been created and loaded with connectivity data
    tell the slaves about the msa array 
  */
  struct conndata data;
  data.nelem = nelem;
  data.nnode = m->node.size();
  data.arr1 = eptr;
  data.arr2 = eind;
  MPI_Bcast_pup(data,masterRank,(MPI_Comm)comm_context);

  eptr.enroll(numChunks);
  eind.enroll(numChunks);
  int indcount=0,ptrcount=0;
  for(int t=0;t<m->elem.size();t++){
    if(m->elem.has(t)){
      FEM_Elem &k=m->elem[t];
      for(int e=0;e<k.size();e++){
	eptr.set(ptrcount)=indcount;
	ptrcount++;
	for(int n=0;n<k.getNodesPer();n++){
	  eind.set(indcount)=k.getConn(e,n);
	  indcount++;
	}
      }
    }
  }
  eptr.set(ptrcount) = indcount;
  printf("master -> ptrcount %d indcount %d \n",ptrcount,indcount);
  /*
    break up the mesh such that each chunk gets the same number of elements
    and the nodes corresponding to those elements. However this is not the partition.
    This is just distributing the data, so that when partition is done using parmetis
    all the requests for data do not go to chunk 0. Instead after partition each chunk
    can send the element and node data to the chunks that will need it
  */
  FEM_Mesh *mesh_array=FEM_break_mesh(m,ptrcount,numChunks);
  /*
    Send the broken up meshes to the different chunks. 
  */
  sendBrokenMeshes(mesh_array,comm_context);
  delete [] mesh_array;
  FEM_Mesh mypiece;
  MPI_Recv_pup(mypiece,masterRank,MESH_CHUNK_TAG,(MPI_Comm)comm_context);
	
  /*
    call parmetis
  */
  struct partconndata *partdata = FEM_call_parmetis(data,comm_context);

  printf("done with parmetis \n");
	
  /*
    Set up a msa to store the partitions to which a node belongs.
    A node can belong to multiple partitions.
  */
  int totalNodes = m->node.size();
  MSA1DINTLIST nodepart(totalNodes,numChunks);
  MPI_Bcast_pup(nodepart,masterRank,(MPI_Comm)comm_context);
  nodepart.enroll(numChunks);
	
  FEM_write_nodepart(nodepart,partdata);
	
  /*
    Set up a msa to store the nodes that belong to a partition
  */
  MSA1DNODELIST part2node(numChunks,numChunks);
  MPI_Bcast_pup(part2node,masterRank,(MPI_Comm)comm_context);
  part2node.enroll(numChunks);

  FEM_write_part2node(nodepart,part2node,partdata,(MPI_Comm)comm_context);

  /*
    Set up a msa to store the elements that belong to a partition
  */
  MSA1DINTLIST part2elem(numChunks,numChunks);
  MPI_Bcast_pup(part2elem,masterRank,(MPI_Comm)comm_context);
  part2elem.enroll(numChunks);
	
  FEM_write_part2elem(part2elem,partdata,(MPI_Comm)comm_context);
	
  /*
    Get the list of elements and nodes that belong to this partition
  */
  NodeList lnodes = part2node.get(masterRank);
  IntList lelems = part2elem.get(masterRank);
	

  /*
    Build an MSA of FEM_Mesh, with each index containing the mesh for that  chunk
  */
  MSA1DFEMMESH part2mesh(numChunks,numChunks);
  MPI_Bcast_pup(part2mesh,masterRank,(MPI_Comm)comm_context);
  part2mesh.enroll(numChunks);
  FEM_write_part2mesh(part2mesh,partdata, &data,nodepart,numChunks,masterRank,&mypiece);
  /*
    Get your mesh consisting of elements and nodes out of the mesh MSA
  */
  MeshElem me = part2mesh.get(masterRank);
  printf("[%d] Number of elements in my partitioned mesh %d number of nodes %d \n",masterRank,me.m->nElems(),me.m->node.size());
	
  addIDXLists(me.m,lnodes,masterRank);
	
  /*
    Broadcast  the user data to all the meshes
  */
  DEBUG(printf("[%d] Length of udata vector in master %d \n",masterRank,m->udata.size()));
  MPI_Bcast_pup(m->udata,masterRank,(MPI_Comm)comm_context);
  me.m->udata = m->udata;
	
	
  delete partdata;
  /*
    collect the ghost data and send it to all the chunks.
  */
  struct ghostdata *gdata = gatherGhosts();
  printf("[%d] number of ghost layers %d \n",masterRank,gdata->numLayers);
  MPI_Bcast_pup(*gdata,masterRank,(MPI_Comm)comm_context);

  /*
    make ghosts for this mesh
  */
  makeGhosts(me.m,(MPI_Comm)comm_context,masterRank,gdata->numLayers,gdata->layers);
  delete gdata;
	
  me.m->becomeGetting();
  FEMchunk *chunk = FEMchunk::get("FEM_Mesh_Parallel_broadcast");
  int tempMeshNo = chunk->meshes.put(me.m);
  int new_mesh = FEM_Mesh_copy(tempMeshNo);
	
  FEM_Mesh *nmesh = c->lookup(new_mesh,"master_parallel_broadcast");
  DEBUG(printf("[%d] Length of udata vector in master new_mesh %d \n",masterRank,nmesh->udata.size()));
		
  return new_mesh;
};