Skip to content

Commit

Permalink
feature partition-pack: pack patches in allocate_before_partition
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesbrandt committed Apr 11, 2024
1 parent bc79ed6 commit 38008db
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/fclaw_partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ void fclaw_partition_domain(fclaw_global_t* glob,
&patch_data, cb_patch_pack, glob,
cb_patch_unpack, glob);

/* For all (patch i) { pack its numerical data into patch_data[i] }
Does all the data in every patch need to be copied? */
fclaw_global_iterate_patches(glob,
cb_partition_pack,
(void *) patch_data);
fclaw_timer_stop (&glob->timers[FCLAW_TIMER_PARTITION_BUILD]);


Expand Down
40 changes: 40 additions & 0 deletions src/forestclaw2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,42 @@ fclaw2d_domain_assign_for_partition (fclaw2d_domain_t * domain,
FCLAW_ASSERT (zz == (size_t) domain->local_num_patches);
}

static void
fclaw2d_domain_pack_patches (fclaw2d_domain_t * domain)
{
int blockno, patchno;
size_t zz;
fclaw2d_block_t *block;
fclaw2d_patch_t *patch;
p4est_tree_t *tree;
p4est_quadrant_t *q;

p4est_wrap_t *wrap = (p4est_wrap_t *) domain->pp;
FCLAW_ASSERT (domain->partition_context != NULL);
fclaw2d_domain_partition_t *p = domain->partition_context;
FCLAW_ASSERT (p->patch_pack != NULL);
for (zz = 0, blockno = 0; blockno < domain->num_blocks; ++blockno)
{
block = domain->blocks + blockno;
tree =
p4est_tree_array_index (wrap->p4est->trees,
(p4est_topidx_t) blockno);

for (patchno = 0; patchno < block->num_patches; ++zz, ++patchno)
{
FCLAW_ASSERT (zz ==
(size_t) (block->num_patches_before + patchno));

patch = block->patches + patchno;
q = p4est_quadrant_array_index (&tree->quadrants,
(p4est_locidx_t) patchno);
p->patch_pack (domain, patch, blockno, patchno,
q->p.user_data, p->user_pack);
}
}
FCLAW_ASSERT (zz == (size_t) domain->local_num_patches);
}

void
fclaw2d_domain_allocate_before_partition (fclaw2d_domain_t * domain,
size_t data_size,
Expand Down Expand Up @@ -1575,6 +1611,10 @@ fclaw2d_domain_allocate_before_partition (fclaw2d_domain_t * domain,

*patch_data = FCLAW_ALLOC (void *, domain->local_num_patches);
fclaw2d_domain_assign_for_partition (domain, *patch_data);

/* iterate over all patches and pack them in corresponding p4est quadrants
* user data */
fclaw2d_domain_pack_patches (domain);
}

void
Expand Down

0 comments on commit 38008db

Please sign in to comment.