19 #include "../gravtree/gravtree.h"
20 #include "../ngbtree/ngbtree.h"
21 #include "../time_integration/driftfac.h"
23 #include "../mpi_utils/shared_mem_handler.h"
30 ptrdiff_t off = ((
char *)p -
Mem.
Base);
32 offset_tab = (ptrdiff_t *)
Mem.mymalloc(
"offset_tab",
Island_NTask *
sizeof(ptrdiff_t));
39 ptrdiff_t off = ((
char *)p -
Mem.
Base);
58 MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
60 int source = status.MPI_SOURCE;
61 int tag = status.MPI_TAG;
64 MPI_Get_count(&status, MPI_BYTE, &length);
67 char *message = (
char *)
Mem.mymalloc(
"message", length);
68 MPI_Recv(message, length, MPI_BYTE, source, tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
72 int handle = *((
int *)message);
93 int handle = *((
int *)message);
131 H5Eset_auto(H5E_DEFAULT, NULL, NULL);
137 size_t tab_len = *((
size_t *)message);
141 MPI_Recv(
TableData, tab_len, MPI_BYTE, source,
TAG_DMOM, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
152 size_t tab_len = *((
size_t *)message);
156 MPI_Recv(
EwaldData, tab_len, MPI_BYTE, source,
TAG_DMOM, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
164 Terminate(
"num_tree_info > MAX_TREE_INFOS");
166 size_t *sizep = ((
size_t *)message);
167 size_t sizes[4] = {sizep[0], sizep[1], sizep[2], sizep[3]};
179 MPI_Send(off, 4 *
sizeof(ptrdiff_t), MPI_BYTE, source,
TAG_TOPNODE_OFFSET, MPI_COMM_WORLD);
181 MPI_Send(&handle, 1, MPI_INT, source,
TAG_N, MPI_COMM_WORLD);
185 int handle = *((
int *)message);
217 ntree::node_req *node_req_recv = (ntree::node_req *)message;
218 int nrecv = length /
sizeof(ntree::node_req);
228 ntree::node_count_info *node_info_recv =
229 (ntree::node_count_info *)
Mem.mymalloc(
"node_info_recv", nrecv *
sizeof(ntree::node_count_info));
232 int n_recvpoints = 0;
235 for(
int i = 0; i < nrecv; i++)
237 node_info_recv[i].count_nodes = 0;
238 node_info_recv[i].count_parts = 0;
240 int no = node_req_recv[i].foreignnode;
241 int task = node_req_recv[i].foreigntask;
258 node_info_recv[i].count_parts++;
263 node_info_recv[i].count_nodes++;
268 node_info_recv[i].count_parts++;
275 if(node_info_recv[i].count_parts == 0 && node_info_recv[i].count_nodes == 0)
276 Terminate(
"strange: we have we requested an empty node?\n");
278 n_recvpoints += node_info_recv[i].count_parts;
279 n_recvnodes += node_info_recv[i].count_nodes;
284 ngbnode *exportbuf_nodes = (
ngbnode *)
Mem.mymalloc_movable(&exportbuf_nodes,
"exportbuf_nodes", n_recvnodes *
sizeof(
ngbnode));
289 for(
int i = 0; i < nrecv; i++)
291 int no = node_req_recv[i].foreignnode;
292 int task = node_req_recv[i].foreigntask;
303 int off = n_recvpoints++;
320 while(ptr->
access.test_and_set(std::memory_order_acquire))
324 sphp_copy = *sph_ptr;
327 ptr->
access.clear(std::memory_order_release);
329 p_copy.
access.clear(std::memory_order_release);
334 sph_ptr = &sphp_copy;
353 int off = n_recvnodes++;
356 ngbnode *exnodes = &exportbuf_nodes[off];
380 MPI_Send(node_info_recv, nrecv *
sizeof(ntree::node_count_info), MPI_BYTE, source,
TAG_N, MPI_COMM_WORLD);
387 MPI_Send(exportbuf_nodes, n_recvnodes *
sizeof(
ngbnode), MPI_BYTE, source,
TAG_SPHDATA, MPI_COMM_WORLD);
389 Mem.myfree(exportbuf_nodes);
390 Mem.myfree(exportbuf_points);
391 Mem.myfree(node_info_recv);
400 gtree::node_req *node_req_recv = (gtree::node_req *)message;
401 int nrecv = length /
sizeof(gtree::node_req);
411 gtree::node_count_info *node_info_recv =
412 (gtree::node_count_info *)
Mem.mymalloc(
"node_info_recv", nrecv *
sizeof(gtree::node_count_info));
415 int n_recvpoints = 0;
418 for(
int i = 0; i < nrecv; i++)
420 node_info_recv[i].count_nodes = 0;
421 node_info_recv[i].count_parts = 0;
423 int no = node_req_recv[i].foreignnode;
424 int task = node_req_recv[i].foreigntask;
441 node_info_recv[i].count_parts++;
446 node_info_recv[i].count_nodes++;
451 node_info_recv[i].count_parts++;
458 if(node_info_recv[i].count_parts == 0 && node_info_recv[i].count_nodes == 0)
459 Terminate(
"strange: we have we requested an empty node?\n");
461 n_recvpoints += node_info_recv[i].count_parts;
462 n_recvnodes += node_info_recv[i].count_nodes;
472 for(
int i = 0; i < nrecv; i++)
474 int no = node_req_recv[i].foreignnode;
475 int task = node_req_recv[i].foreigntask;
486 int off = n_recvpoints++;
501 #if defined(PMGRID) && defined(PLACEHIGHRESREGION)
502 expoints->InsideOutsideFlag = ptr->InsideOutsideFlag;
510 int off = n_recvnodes++;
512 gravnode *exnodes = &exportbuf_nodes[off];
515 memcpy(
static_cast<void *
>(exnodes),
static_cast<void *
>(sourcep),
529 int off = n_recvpoints++;
544 #if defined(PMGRID) && defined(PLACEHIGHRESREGION)
545 expoints->InsideOutsideFlag = pointsp->InsideOutsideFlag;
556 MPI_Send(node_info_recv, nrecv *
sizeof(gtree::node_count_info), MPI_BYTE, source,
TAG_N, MPI_COMM_WORLD);
563 MPI_Send(exportbuf_nodes, n_recvnodes *
sizeof(
gravnode), MPI_BYTE, source,
TAG_SPHDATA, MPI_COMM_WORLD);
565 Mem.myfree(exportbuf_nodes);
566 Mem.myfree(exportbuf_points);
567 Mem.myfree(node_info_recv);
global_data_all_processes All
void init_drift_table(void)
void mymalloc_init(int maxmemsize, enum restart_options restartflag)
Initialize memory manager.
char * get_basenodep(int no, unsigned char shmrank, int handle)
char * get_SphPp(unsigned char shmrank, int handle)
void prepare_offset_table(void *p, ptrdiff_t *&offset_tab)
void deal_with_gravity_node_request(char *message, int length, int source, int handle)
int * get_nextnodep(unsigned char shmrank, int handle)
void deal_with_sph_node_request(char *message, int length, int source, int handle, simparticles *Sp)
void shared_memory_handler(void)
char * get_pointsp(unsigned char shmrank, int handle)
void inform_offset_table(void *p)
int * GetShmRankForSimulCommRank
tree_storage_info tree_info[MAX_TREE_INFOS]
char * get_Pp(unsigned char shmrank, int handle)
void free_offset_table(ptrdiff_t *&offset_tab)
int drift_particle(particle_data *P, sph_particle_data *SphP, integertime time1, bool ignore_light_cone=false)
This function drifts a particle i to time1.
#define TAG_FETCH_SPH_DENSITY
#define TAG_FETCH_SPH_TREETIMESTEP
#define TAG_FETCH_GRAVTREE
#define TAG_TOPNODE_ALLOC
#define TAG_FETCH_SPH_HYDRO
#define TAG_TOPNODE_OFFSET
gravtree< simparticles > gtree
std::atomic< unsigned char > cannot_be_opened_locally
unsigned char SofteningClass
sph_particle_data_hydrocore SphCore
char * get_data_ptr(void)
size_t get_data_size(void)
unsigned char SofteningClass
std::atomic< integertime > Ti_Current
void drift_node(integertime time1, simparticles *Sp)
integertime get_Ti_Current(void)
unsigned char getSofteningClass(void)
unsigned char getType(void)
char * NodeSibling_storage